/* \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); }
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(); } }
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(); }
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()); } }
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*))); }
//! [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")); }
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); }
/** * @brief keyPressEvent * @param e */ void keyPressEvent( QKeyEvent* e ){ if(e->type() == QEvent::KeyPress) { if(e->key() == Qt::Key_Space) { window_gl->update(); window_gl->updateGL(); } } }
void MainWindow::on_actionSave_view_triggered() { QString filename = QFileDialog::getSaveFileName(this); if (filename!=""){ GLWidget* glw = centralWidget()->findChild<GLWidget*>("widget"); glw->saveView(filename); } }
int main(int argc, char* argv[]) { QApplication a(argc, argv); GLWidget w; w.show(); return a.exec(); }
// 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)); } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); GLWidget widget; widget.show(); //widget.showFullScreen(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); GLWidget mainwin; mainwin.resize(500,500); mainwin.show(); return app.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); GLWidget window; window.resize(800,600); window.show(); return app.exec(); }
/** 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); }
/*---------------------------------------------------------------------------*/ 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" ) ); // 设置窗口标题 }
/** void GLWidget::update() * include/mimas/GLWidget.h:95 */ static int GLWidget_update(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); self->update(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "update: %s", e.what()); } catch (...) { lua_pushfstring(L, "update: Unknown exception"); } return dub_error(L); }
/** QString QWidget::windowTitle() * bind/QWidget.h:40 */ static int GLWidget_windowTitle(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); lua_pushstring(L, self->windowTitle().toUtf8()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "windowTitle: %s", e.what()); } catch (...) { lua_pushfstring(L, "windowTitle: Unknown exception"); } return dub_error(L); }
/** QVariant QObject::property(const char *name) * bind/QObject.h:9 */ static int GLWidget_property(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); const char *name = dub_checkstring(L, 2); return pushVariantInLua(L, self->property(name)); } catch (std::exception &e) { lua_pushfstring(L, "property: %s", e.what()); } catch (...) { lua_pushfstring(L, "property: Unknown exception"); } return dub_error(L); }
/** int QWidget::height() * bind/QWidget.h:15 */ static int GLWidget_height(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); lua_pushnumber(L, self->height()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "height: %s", e.what()); } catch (...) { lua_pushfstring(L, "height: Unknown exception"); } return dub_error(L); }
/** bool QWidget::isFullScreen() * bind/QWidget.h:36 */ static int GLWidget_isFullScreen(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); lua_pushboolean(L, self->isFullScreen()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "isFullScreen: %s", e.what()); } catch (...) { lua_pushfstring(L, "isFullScreen: Unknown exception"); } return dub_error(L); }
void Window::SetTestImage() { QImage input_image(QString(":/my-test-image.jpg")); if (input_image.isNull()) { qWarning() << "Картинка не загрузилась, это фатально."; QApplication::closeAllWindows(); QApplication::exit(1); } GLWidget *glw = qobject_cast<GLWidget *>(myGLWidget); glw->SetImage(input_image); }
/** void QWidget::setFocus() * bind/QWidget.h:20 */ static int GLWidget_setFocus(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); self->setFocus(Qt::OtherFocusReason); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setFocus: %s", e.what()); } catch (...) { lua_pushfstring(L, "setFocus: Unknown exception"); } return dub_error(L); }
/** void QWidget::setStyle(const char *text) * bind/QWidget.h:51 */ static int GLWidget_setStyle(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); const char *text = dub_checkstring(L, 2); self->setStyleSheet(QString("%1 { %2 }").arg(self->metaObject()->className()).arg(text)); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setStyle: %s", e.what()); } catch (...) { lua_pushfstring(L, "setStyle: Unknown exception"); } return dub_error(L); }
/** void QWidget::setStyleSheet(const char *text) * bind/QWidget.h:52 */ static int GLWidget_setStyleSheet(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); const char *text = dub_checkstring(L, 2); self->setStyleSheet(text); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setStyleSheet: %s", e.what()); } catch (...) { lua_pushfstring(L, "setStyleSheet: Unknown exception"); } return dub_error(L); }
/** QString QObject::objectName() const * bind/QObject.h:7 */ static int GLWidget_objectName(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); QByteArray str_(self->objectName().toUtf8()); lua_pushlstring(L, str_.constData(), str_.size()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "objectName: %s", e.what()); } catch (...) { lua_pushfstring(L, "objectName: Unknown exception"); } return dub_error(L); }
/** void QWidget::setParent(QWidget *parent) * bind/QWidget.h:16 */ static int GLWidget_setParent(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); QWidget *parent = *((QWidget **)dub_checksdata(L, 2, "mimas.QWidget")); self->setParent(parent); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setParent: %s", e.what()); } catch (...) { lua_pushfstring(L, "setParent: Unknown exception"); } return dub_error(L); }
/** void QWidget::setMouseTracking(bool enable) * bind/QWidget.h:28 */ static int GLWidget_setMouseTracking(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); bool enable = dub_checkboolean(L, 2); self->setMouseTracking(enable); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setMouseTracking: %s", e.what()); } catch (...) { lua_pushfstring(L, "setMouseTracking: Unknown exception"); } return dub_error(L); }
/** void QWidget::setFocusPolicy(int policy) * bind/QWidget.h:21 */ static int GLWidget_setFocusPolicy(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); int policy = dub_checkint(L, 2); self->setFocusPolicy((Qt::FocusPolicy)policy); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setFocusPolicy: %s", e.what()); } catch (...) { lua_pushfstring(L, "setFocusPolicy: Unknown exception"); } return dub_error(L); }
/** void QWidget::addAction(Action *action) * bind/QWidget.h:37 */ static int GLWidget_addAction(lua_State *L) { try { GLWidget *self = *((GLWidget **)dub_checksdata(L, 1, "mimas.GLWidget")); Action *action = *((Action **)dub_checksdata(L, 2, "mimas.Action")); self->addAction(action); return 0; } catch (std::exception &e) { lua_pushfstring(L, "addAction: %s", e.what()); } catch (...) { lua_pushfstring(L, "addAction: Unknown exception"); } return dub_error(L); }