本文整理汇总了C++中GLWidget类的典型用法代码示例。如果您正苦于以下问题:C++ GLWidget类的具体用法?C++ GLWidget怎么用?C++ GLWidget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GLWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMainWindow
/* \x41\x41\x41\x41\x41\x41\x41 */
TempleWin::TempleWin(QWidget *parent)
: QMainWindow(parent) {
lang = new TempleLang();
std::cout << "==========" << std::endl;
//menu
QAction *quit = new QAction("&Quit", this);
QMenu *file;
file = menuBar()->addMenu("&File");
file->addAction(quit);
connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
//toolbar
QToolBar *tb = new QToolBar("TOOLBAR");
TBar *tbw = new TBar(this, lang);
tb->addWidget(tbw);
tb->setMovable(false);
addToolBar(Qt::RightToolBarArea, tb);
GLWidget *widGl = new GLWidget(this, lang);
widGl->show();
widGl->resize(200,200);
setCentralWidget(widGl);
}
示例2: function
void TVertex::function(Action action, QMouseEvent *event)
{
using namespace Model;
if(action == DRAW) return;
GLWidget *widget = Workspace::activeWidget();
widget->countFinalInverseMatrix();
if(action == START || action == FINAL)
{
Journal::newRecord(CREATE);
QVector3D newVertex;
if(action == START)
{
_busy = true;
widget->fromScreenToWorld(&newVertex, event);
}
else for(int i = 0; i < 3; i++) newVertex[i] = spinBox[i]->value();
ver.clear();
ver.push_back(vertex().push(newVertex));
vertex()[ver[0]].setNewSelected(true);
if(action == FINAL) action = STOP;
}
if(action == EXECUTE) widget->fromScreenToWorld(&vertex()[ver[0]].position(), event);
if(action == STOP)
{
_busy = false;
vertex()[ver[0]].setSelected(true, false);
Journal::submit();
}
}
示例3: main
int main( int argc, char **argv ) {
QApplication a( argc, argv );
OctreeNode n1;
GLWidget *w = new GLWidget();
GLData* g = w->addObject();
GLData* rnd = w->addObject();
RandomSource src( rnd );
QObject::connect( w->timer, SIGNAL(timeout()), &src, SLOT(timeOutSlot()) );
std::cout << " genVBO()\n";
/*
g->setTriangles();
g->setPosition(1,0,-6);
g->setUsageStaticDraw();
g->addVertex(-1.0f,-1.0f, 0.0f, 1.0f,0.0f,0.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
g->addVertex( 1.0f,-1.0f, 0.0f, 0.0f,1.0f,0.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
g->addVertex( 0.0f, 1.0f, 0.0f, 0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
g->addVertex( 1.0f, 1.0f, 0.0f, 1.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
g->addVertex( -1.0f, 1.0f, 0.0f, 1.0f,1.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
g->addVertex( -2.0f, 0.0f, 0.0f, 1.0f,1.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
std::vector<GLuint> poly(3);
//poly.resize(3);
poly[0]=0; poly[1]=1; poly[2]=2;
g->addPolygon( poly );
poly[0]=2; poly[1]=1; poly[2]=3;
g->addPolygon( poly );
poly[0]=0; poly[1]=2; poly[2]=4;
g->addPolygon( poly );
poly[0]=0; poly[1]=5; poly[2]=4;
g->addPolygon( poly );
g->print();
//std::cout << "removePolygon()\n";
//g.removePolygon(0);
std::cout << "removeVertex(4)\n";
g->removeVertex(4);
g->print();
*/
// now try a quad.
OctreeNode n2;
GLData* q = w->addObject();
q->setQuads();
q->setPosition(2,0,-6);
q->setUsageStaticDraw();
q->addVertex(-3.0f,0.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
q->addVertex(-3.0f,1.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
q->addVertex(-4.0f,1.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
q->addVertex(-4.0f,0.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
std::vector<GLuint> quad(4);
quad[0]=0; quad[1]=1; quad[2]=2; quad[3]=3;
q->addPolygon(quad);
q->print();
std::cout << "Q removeVertex(3)\n";
//q->removeVertex(0);
q->print();
w->show();
return a.exec();
}
示例4: setAtoms
void VdWSurface::setAtoms(Molecule* mol)
{
// check if there is a selection in the current glwidget
GLWidget *glwidget = GLWidget::current();
if (glwidget) {
QList<Primitive*> atoms = glwidget->selectedPrimitives().subList(Primitive::AtomType);
if (!atoms.isEmpty()) {
qDebug() << "VdWSurface: Number of atoms" << atoms.size();
m_atomPos.resize(atoms.size());
m_atomRadius.resize(atoms.size());
for (unsigned int i = 0; i < m_atomPos.size(); ++i) {
Atom *atom = static_cast<Atom*>(atoms.at(i));
m_atomPos[i] = *atom->pos();
m_atomRadius[i] = OpenBabel::etab.GetVdwRad(atom->atomicNumber());
}
return;
}
}
qDebug() << "VdWSurface: Number of atoms" << mol->numAtoms();
m_atomPos.resize(mol->numAtoms());
m_atomRadius.resize(mol->numAtoms());
for (unsigned int i = 0; i < m_atomPos.size(); ++i) {
m_atomPos[i] = *mol->atom(i)->pos();
m_atomRadius[i] = OpenBabel::etab.GetVdwRad(mol->atom(i)->atomicNumber());
}
}
示例5: QMainWindow
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle("3D cloud crop");
GLWidget *glWidget = new GLWidget();
setCentralWidget(glWidget);
scaleSelectionWidget = new ScaleSelectionWidget();
scaleSelectionDockWidget = new QDockWidget("Color map", this);
scaleSelectionDockWidget->setWidget(scaleSelectionWidget);
scaleSelectionDockWidget->setAllowedAreas(Qt::RightDockWidgetArea | Qt::LeftDockWidgetArea);
scaleSelectionDockWidget->setVisible(true);
addDockWidget(Qt::RightDockWidgetArea, scaleSelectionDockWidget, Qt::Horizontal);
createActions();
createMenu();
connect(this, SIGNAL(gotFileNameToLoad(QString)),glWidget->getGLOperationThread(),SLOT(loadMesh(QString)));
connect(scaleSelectionWidget, SIGNAL(scaleChanged(Scale*)),
glWidget->getGLOperationThread(),SLOT(setScale(Scale*)));
}
示例6: QWidget
//! [0]
Window::Window()
: QWidget()
{
Widget *native = new Widget(&helper, this);
GLWidget *openGL = new GLWidget(&helper, this);
QLabel *nativeLabel = new QLabel(tr("Native"));
nativeLabel->setAlignment(Qt::AlignHCenter);
QLabel *openGLLabel = new QLabel(tr("OpenGL"));
openGLLabel->setAlignment(Qt::AlignHCenter);
qWarning() << (openGL->doubleBuffer() ? "true" : "false");
QGridLayout *layout = new QGridLayout;
layout->addWidget(native, 0, 0);
layout->addWidget(openGL, 0, 1);
layout->addWidget(nativeLabel, 1, 0);
layout->addWidget(openGLLabel, 1, 1);
setLayout(layout);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), native, SLOT(animate()));
connect(timer, SIGNAL(timeout()), openGL, SLOT(animate()));
timer->start(50);
setWindowTitle(tr("2D Painting on Native and OpenGL Widgets"));
}
示例7: closeEvent
void closeEvent(QCloseEvent *evt){
QWidgetList windows = ws->windowList();
for (int i = 0; i < int(windows.count()); ++i) {
GLWidget *window = (GLWidget *)windows.at(i);
window->stopRendering();
}
QMainWindow::closeEvent(evt);
}
示例8: centralWidget
void MainWindow::on_actionSave_view_triggered()
{
QString filename = QFileDialog::getSaveFileName(this);
if (filename!=""){
GLWidget* glw = centralWidget()->findChild<GLWidget*>("widget");
glw->saveView(filename);
}
}
示例9: main
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
GLWidget w;
w.show();
return a.exec();
}
示例10: on_frame_show
// MLT consumer-frame-show event handler
void GLWidget::on_frame_show(mlt_consumer, void* self, mlt_frame frame_ptr)
{
GLWidget* widget = static_cast<GLWidget*>(self);
if (widget->showFrameSemaphore.tryAcquire()) {
Frame frame(frame_ptr);
emit widget->frameReceived(Mlt::QFrame(frame));
}
}
示例11: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
GLWidget widget;
widget.show();
//widget.showFullScreen();
return a.exec();
}
示例12: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
GLWidget mainwin;
mainwin.resize(500,500);
mainwin.show();
return app.exec();
}
示例13: main
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
GLWidget window;
window.resize(800,600);
window.show();
return app.exec();
}
示例14: GLWidget_openGLVersion
/** LuaStackSize GLWidget::openGLVersion(lua_State *L)
* include/mimas/GLWidget.h:99
*/
static int GLWidget_openGLVersion(lua_State *L) {
try {
GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget"));
return self->openGLVersion(L);
} catch (std::exception &e) {
lua_pushfstring(L, "openGLVersion: %s", e.what());
} catch (...) {
lua_pushfstring(L, "openGLVersion: Unknown exception");
}
return dub_error(L);
}
示例15: QMainWindow
/*---------------------------------------------------------------------------*/
MainWindow::MainWindow( QWidget* pParent ):
QMainWindow( pParent )
{
CreateMenu( );
GLWidget* pGLWidget = new GLWidget( this );
connect( pGLWidget, SIGNAL( ToggleFullScreen( ) ),
this, SLOT( ToggleFullScreen( ) ) );
setCentralWidget( pGLWidget );
resize( pGLWidget->width( ), pGLWidget->height( ) + menuBar( )->height( ) );
setWindowTitle( tr( "Color cube example" ) ); // 设置窗口标题
}