Ejemplo n.º 1
0
RenderController::RenderController(MainWindow *mainWindow,
                                   QObject *parent):
    QObject(parent)
{
    this->mainWindow = mainWindow;

    light = new DirectionalLight;
    arcBall = new ArcBall(500);
    wireframe = false;
    lightRotation = false;

    this->display = new GLDisplay();
    mainWindow->setGLDisplay(display);
    {  // esta ordem deve ser mantida
        display->updateGL();

        scene = new Scene3D(mainWindow);

        connect(display, SIGNAL(drawModel()), this, SLOT(drawModel()));
        connect(display, SIGNAL(lightSetup()), this, SLOT(lightSetup()));
    }

    connect(display, SIGNAL(mouseLefthFinish(QPoint,QPoint)), this, SLOT(mouseLefthFinish(QPoint,QPoint)));
    connect(display, SIGNAL(mouseLeftMove(QPoint,QPoint)), this, SLOT(mouseLeftMove(QPoint,QPoint)));
    connect(display, SIGNAL(mouseCancel()),
            this, SLOT(mouseCancel()));

    connect(mainWindow, SIGNAL(loadWave(QString)), this, SLOT(loadWave(QString)));
    connect(mainWindow, SIGNAL(saveWave(QString)), this, SLOT(saveWave(QString)));
    connect(mainWindow->actionClose, SIGNAL(triggered()), this, SLOT(closeScene()));
    connect(mainWindow->actionWireFrame, SIGNAL(triggered()), this, SLOT(wireFrameToggle()));

    connect(&timer, SIGNAL(timeout()), this, SLOT(timeOut()));
    timer.start(30);

    mainWindow->showMaximized();
}
Ejemplo n.º 2
0
int stopOGLRendererSandbox()
{
  closeScene();
  return 1;
}
Ejemplo n.º 3
0
MainWindow::MainWindow()
: QMainWindow()
{
    _scene.reset();

    if (!QGLFormat::hasOpenGL()) {
        QMessageBox::critical(this,
                "No OpenGL Support",
                "This system does not appear to support OpenGL.\n\n"
                "The Tungsten scene editor requires OpenGL "
                "to work properly. The editor will now terminate.\n\n"
                "Please install any available updates for your graphics card driver and try again");
        std::exit(0);
    }

    QGLFormat qglFormat;
    qglFormat.setVersion(3, 2);
    qglFormat.setProfile(QGLFormat::CoreProfile);
    qglFormat.setAlpha(true);
    qglFormat.setSampleBuffers(true);
    qglFormat.setSamples(16);

    _windowSplit = new QSplitter(this);
    _stackWidget = new QStackedWidget(_windowSplit);

      _renderWindow = new   RenderWindow(_stackWidget, this);
     _previewWindow = new  PreviewWindow(_stackWidget, this, qglFormat);
    _propertyWindow = new PropertyWindow(_windowSplit, this);

    _stackWidget->addWidget(_renderWindow);
    _stackWidget->addWidget(_previewWindow);

    _windowSplit->addWidget(_stackWidget);
    _windowSplit->addWidget(_propertyWindow);
    _windowSplit->setStretchFactor(0, 1);
    _windowSplit->setStretchFactor(1, 0);

    setCentralWidget(_windowSplit);

    _previewWindow->addStatusWidgets(statusBar());
     _renderWindow->addStatusWidgets(statusBar());

    connect(this, SIGNAL(sceneChanged()),  _previewWindow, SLOT(sceneChanged()));
    connect(this, SIGNAL(sceneChanged()),   _renderWindow, SLOT(sceneChanged()));
    connect(this, SIGNAL(sceneChanged()), _propertyWindow, SLOT(sceneChanged()));

    connect( _previewWindow, SIGNAL(primitiveListChanged()), _propertyWindow, SLOT(primitiveListChanged()));
    connect( _previewWindow, SIGNAL(selectionChanged()), _propertyWindow, SLOT(changeSelection()));
    connect(_propertyWindow, SIGNAL(selectionChanged()),  _previewWindow, SLOT(changeSelection()));

    showPreview(true);

    QMenu *fileMenu = new QMenu("&File");
    fileMenu->addAction("New",          this, SLOT(newScene()),  QKeySequence("Ctrl+N"));
    fileMenu->addAction("Open File...", this, SLOT(openScene()), QKeySequence("Ctrl+O"));
    fileMenu->addAction("Reload File...", this, SLOT(reloadScene()), QKeySequence("Shift+R"));
    fileMenu->addSeparator();
    fileMenu->addAction("Close", this, SLOT(closeScene()), QKeySequence("Ctrl+W"));
    fileMenu->addSeparator();
    fileMenu->addAction("Save",       this, SLOT(saveScene()),   QKeySequence("Ctrl+S"));
    fileMenu->addAction("Save as...", this, SLOT(saveSceneAs()), QKeySequence("Ctrl+Shift+S"));
    fileMenu->addSeparator();
    fileMenu->addAction("Exit", this, SLOT(close()));

    QMenuBar *menuBar = new QMenuBar();
    menuBar->addMenu(fileMenu);

    setMenuBar(menuBar);

    newScene();
}