Esempio n. 1
0
void CppLayoutPreviewer::RefreshFromLayout()
{
    cout << "Scene Editor canvas reloading... (step 1/2)" << endl;
    isReloading = true;

    previewGame.GetSoundManager().ClearAllSoundsAndMusics();
    if ( editor.GetProject().GetImageManager() ) editor.GetProject().GetImageManager()->PreventImagesUnloading(); //Images are normally unloaded and loaded again when reloading the scene. We can prevent this to happen as it is time wasting.

    //Reset game
    RuntimeGame newGame;
    previewGame = newGame;
    previewGame.LoadFromProject(editor.GetProject());
    previewGame.SetImageManager(editor.GetProject().GetImageManager()); //Use same image manager.

    //Reset scene
    RuntimeScene newScene(&editor, &previewGame);
    previewScene = newScene;
    playing = false;

    if ( debugger ) previewScene.debugger = debugger.get();
    if ( profiler ) previewScene.SetProfiler(profiler.get());
    if ( profiler ) editor.GetLayout().SetProfiler(profiler.get());

    //Launch now events compilation if it has not been launched by another way (i.e: by the events editor).
    if ( editor.GetLayout().CompilationNeeded() && !CodeCompiler::Get()->HasTaskRelatedTo(editor.GetLayout()) )
    {
        CodeCompilationHelpers::CreateSceneEventsCompilationTask(editor.GetProject(), editor.GetLayout());
        mainFrameWrapper.GetInfoBar()->ShowMessage(_("Changes made to events will be taken into account when you switch to Edition mode"));
    }

    return; //RefreshFromLayoutSecondPart() will be called by OnUpdate() when appropriate
}
void GameView::setGameSetup(NewGameSetup *gameSetup)
{
    this->gameSetup = gameSetup;

    for (int i=0; i<2; ++i) {

    }

    if (game) delete game;
    game = new FourInARowGame(gameSetup->startPlayer, gameSetup->columns, gameSetup->rows );
    columnIndex = 0;

    if (scene()) delete scene();
    GameScene * scene = newScene();
    //PrimitivesGameScene * scene = new PrimitivesGameScene(ui->gameView);
    //SvgGameScene * scene = new SvgGameScene(ui->gameView);
    setScene(scene);
    scene->setBoard(game->getBoard());
    scene->toggleSound(false);
    for (int i=0; i<gameSetup->moveHistory.length(); ++i) {
        QString number(gameSetup->moveHistory.at(i));
        columnIndex = number.toInt();
        game->move(columnIndex);
        scene->addToken(i%2, columnIndex, game->getLatestTokenRow());
        qDebug() << "column: " << columnIndex;
        scene->setupNextToken(columnIndex);
        qDebug() << "move: " << columnIndex;
    }
    scene->toggleSound(true);
    printNextPlayer();
    if (gameSetup->isCpu[game->getPlayerToMoveNext()]) {
        move();
    }
}
Esempio n. 3
0
AS3_Val initializeScene( void* self, AS3_Val args )
{
	Scene * scene;

	scene =  newScene();

	return AS3_Array( "PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType", scene, & scene->nNodes, & scene->nVertices, & scene->nFaces, & scene->nRenderList, & scene->nCullList, & scene->nClippList, &scene->terrain );
}
Esempio n. 4
0
void TextLayer::nextCallback(Ref* sender)
{
    // update the action index
    actionIdx++;
    actionIdx = actionIdx % MAX_LAYER;

    newScene();
}
Esempio n. 5
0
void TextLayer::nextCallback(NSObject* pSender)
{
    // update the action index
    actionIdx++;
    actionIdx = actionIdx % MAX_LAYER;

	/*newOrientation();*/
	newScene();
}
Esempio n. 6
0
void TextLayer::backCallback(Ref* sender)
{
    // update the action index
    actionIdx--;
    int total = MAX_LAYER;
    if( actionIdx < 0 )
        actionIdx += total;    

    newScene();
} 
Esempio n. 7
0
void BrowserWidget::resetZoom() {
    float scale = webView->scale();
    freezeTilesFor(1000 * 1000);
    webView->setScale(1);
    horizontalScrollBar()->setValue(horizontalScrollBar()->value() / scale);
    verticalScrollBar()->setValue(verticalScrollBar()->value() / scale);
    freezeTilesFor(freezeForMsecsWhenZooming); // ... and unfreeze after that time
    emit zoomChanged(1);
    newScene();
}
Esempio n. 8
0
BrowserWidget::BrowserWidget(QWidget *parent, QSettings *settings, QObject *jsProxy):
    QGraphicsView(parent),
    scene(0),
    jsProxy(jsProxy),
    zoomStepFactor              (settings->value("browser/zoom_step_factor").toFloat()),
    homePageUrl                 (settings->value("browser/home_page_url").toString()),
    errorPageUrl                (settings->value("browser/error_url").toString()),
    unsupportedPageUrl          (settings->value("browser/unsupported_url").toString()),
    pagesInFastHistory          (settings->value("browser/pages_in_fast_history").toInt()),
    freezeForMsecsWhenZooming   (settings->value("browser/freeze_time_when_zoom_ms").toInt()),
    freezeForMsecsWhenDragging  (settings->value("browser/freeze_time_when_drag_ms").toInt()),
    maxDragDistanceToEmitClick  (settings->value("browser/click_if_drag_at_most_px").toInt()),
    dragDistance(maxDragDistanceToEmitClick)
{
    
    webView = new QGraphicsWebView();
    webPage = new BrowserWebPage();
    webView->setPage(webPage);
    
    newScene();
    
    // visual settings
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    setFrameShape(QFrame::NoFrame);
    setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
    webView->setResizesToContents(true);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    QPalette pal(palette());
    pal.setColor(QPalette::Base, Qt::white);
    setPalette(pal);

    // web settings
    QWebSettings *globalSettings = QWebSettings::globalSettings();
    globalSettings->setAttribute(QWebSettings::PluginsEnabled, true);
    globalSettings->setAttribute(QWebSettings::TiledBackingStoreEnabled, true);
    globalSettings->setMaximumPagesInCache(pagesInFastHistory);
    webView->page()->history()->setMaximumItemCount(pagesInFastHistory);
    webView->page()->setForwardUnsupportedContent(true);
    
    // connects
    connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanging(QUrl)));
    connect(webView, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
    connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(newScene()));
    connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
    connect(webView->page(), SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(unsupportedContent(QNetworkReply*)));
    connect(webView->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
                                                 this, SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&))
    );
    connect(&unfreezeTimer, SIGNAL(timeout()), this, SLOT(unfreezeTiles()));
    unfreezeTimer.setSingleShot(true);
    
    connect(webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJavaScriptBinding()));
    addJavaScriptBinding();
}
Esempio n. 9
0
void TextLayer::backCallback(NSObject* pSender)
{
    // update the action index
    actionIdx--;
    int total = MAX_LAYER;
    if( actionIdx < 0 )
        actionIdx += total;	

	/*newOrientation();*/
	newScene();
} 
Esempio n. 10
0
int main()
{
    int frameCnt = 0;
    struct timeval curTime;
    float dSecond = 0;
    float dSecondSum = 0; /* droped if more than 0.5 sec */

    timeval_diff_replace(&curTime);

    flags.pause = GL_FALSE;
    flags.vsync = GL_TRUE;

    scene = newScene(flags.vsync);

    setupGLFWCallbacks();
    glfwSetMousePos(scene->context->w / 2, scene->context->h / 2);

    while (running)
    {
        if (glfwGetWindowParam(GLFW_OPENED) == GL_FALSE)
        {
            running = GL_FALSE;
            break;
        }

        processKeyboardEvents(dSecond * BASE_FPS);
        processMouseEvents(dSecond * BASE_FPS);

        ++frameCnt;
        dSecond = timeval_diff_replace(&curTime);
        dSecondSum += dSecond;

        if (dSecondSum > 0.5f)
        {
            viewFps(frameCnt, dSecondSum);
            frameCnt = 0;
            dSecondSum = 0.0f;
        }

        if (!flags.pause)
        {
            modifyWaterMesh(scene->water, dSecond);
        }

        draw();
        glfwSwapBuffers();
    }

    freeScene(scene);

    return EXIT_SUCCESS;
}
Esempio n. 11
0
int main(int argc, char **argv)
{
    if (argc != 2 && argc != 3) {
        printUsage();
        return EXIT_FAILURE;
    }

    Scene scene;
    StlSerializer serializer;
    std::ifstream stream(argv[1], std::ifstream::in);
    if (stream.fail()) {
        printCantOpenFile(argv[1]);
        return EXIT_FAILURE;
    }

    try {
        serializer.serializeFrom(stream, scene);
    }
    catch (const BadFormatException &e) {
        printParseException(argv[1], e.what());
        return EXIT_FAILURE;
    }
    catch (const UnexpectedEofException &) {
        printParseException(argv[1], "Unexpected EOF.");
        return EXIT_FAILURE;
    }
    catch (const CantReadException &) {
        printParseException(argv[1], "Some strange has happened. Can't read data from stream.");
        return EXIT_FAILURE;
    }

    int i = 0;
    for (const Scene::Surface &surface : scene.surfaces()) {
        const std::string outputFolder = argc == 3 ? argv[2] : "./";
        const std::string outputFilePath = buildOutputFilePath(outputFolder, i);
        ++i;

        std::ofstream ostream(outputFilePath, std::ofstream::out);
        if (ostream.fail()) {
            printCantOpenFile(outputFilePath);
            return EXIT_FAILURE;
        }

        Scene newScene(surface);
        newScene.centralize();
        serializer.serializeTo(ostream, newScene);
    }

    return EXIT_SUCCESS;
}
Esempio n. 12
0
int FileWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: newScene(); break;
        case 1: addChunk(); break;
        case 2: addTile(); break;
        case 3: saveChunk(); break;
        case 4: saveTile(); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Esempio n. 13
0
FileWidget::FileWidget() 
	: QWidget(0)
{
	newSceneBtn = new QPushButton("New Scene");

	chunkCmb = new QComboBox();
	addChunkToSceneBtn = new QPushButton("Add Scene");

	tileCmb = new QComboBox();
	addTileToSceneBtn = new QPushButton("Add Tile");

	saveAsChunkBtn = new QPushButton("Save as Scene");
	saveAsTileBtn = new QPushButton("Save as Tile");

	QVBoxLayout *mainLayout = new QVBoxLayout;
		QHBoxLayout *chunkLayout = new QHBoxLayout;
		QHBoxLayout *tileLayout = new QHBoxLayout;
		QHBoxLayout *saveLayout = new QHBoxLayout;

	chunkLayout->addWidget(chunkCmb);
	chunkLayout->addWidget(addChunkToSceneBtn);

	saveLayout->addWidget(saveAsChunkBtn);

	mainLayout->addWidget(newSceneBtn);
	mainLayout->addLayout(chunkLayout);
	mainLayout->addLayout(saveLayout);
	mainLayout->setContentsMargins(0,0,0,0);

	setLayout(mainLayout);

	connect(newSceneBtn, SIGNAL(clicked()),this, SLOT(newScene()));
	connect(addChunkToSceneBtn, SIGNAL(clicked()),this, SLOT(addChunk()));
	connect(addTileToSceneBtn, SIGNAL(clicked()),this, SLOT(addTile()));
	connect(saveAsChunkBtn, SIGNAL(clicked()),this, SLOT(saveChunk()));
	connect(saveAsTileBtn, SIGNAL(clicked()),this, SLOT(saveTile()));

	setFixedHeight(sizeHint().height());
	setFixedWidth(400);
}
Esempio n. 14
0
/**
 * Go in edition mode
 */
void CppLayoutPreviewer::StopPreview()
{
    std::cout << "Stopping GD C++ preview..." << std::endl;

    CodeCompiler::Get()->EnableTaskRelatedTo(editor.GetLayout());
    playing = false;

    if ( externalPreviewWindow ) externalPreviewWindow->Show(false);
    previewScene.ChangeRenderWindow(&editor);
    previewScene.GetCodeExecutionEngine()->Unload();

    //Parse now the results of profiling
    if ( profiler ) profiler->ParseProfileEvents();

    //Reset the scene.
    RuntimeScene newScene(&editor, &previewGame);
    previewScene = newScene;
    if ( debugger ) previewScene.debugger = debugger.get();
    if ( profiler ) previewScene.SetProfiler(profiler.get());
    if ( profiler ) editor.GetLayout().SetProfiler(profiler.get());
    if ( debugger ) debugger->Pause();
    previewGame.GetSoundManager().ClearAllSoundsAndMusics();
}
Esempio n. 15
0
  MainWindow::MainWindow(QWidget* parent)
    : QMainWindow(parent), m_ui(new Ui::MainWindow), m_context(0), m_sync(0),
      m_loadedScenes(0)
  {
    if (!s_instance)
      s_instance = this;

    m_ui->setupUi(this);
    //m_ui->filelist->init();
    m_ui->renderpass_properties->init();
    m_ui->material_properties->init();

    createViewport();

    /*  QDockWidget *dw = new QDockWidget;
    dw->setObjectName("Foo");
    dw->setWindowTitle("Bar");
    dw->setWidget(new QTextEdit);

               addDockWidget(Qt::LeftDockWidgetArea, dw);*/
    //m_ui->properties

    connect(m_ui->action_textures, SIGNAL(triggered()), this, SLOT(openTextureBrowser()));

    connect(m_ui->error_list, SIGNAL(itemActivated(QTableWidgetItem*)),
            this, SLOT(errorItemActivated(QTableWidgetItem*)));
    connect(m_ui->action_savematerial, SIGNAL(triggered()), this, SLOT(saveMaterial()));
    connect(m_ui->action_open, SIGNAL(triggered()), this, SLOT(load()));
    connect(m_ui->action_savescene, SIGNAL(triggered()), this, SLOT(saveScene()));
    connect(m_ui->action_newscene, SIGNAL(triggered()), this, SLOT(newScene()));
    connect(m_ui->action_savescene_as, SIGNAL(triggered()), this, SLOT(saveSceneAs()));
    /*connect(m_ui->action_new, SIGNAL(triggered()), this, SLOT(open()));
    connect(m_ui->action_saveas, SIGNAL(triggered()), this, SLOT(open()));
    connect(m_ui->action_open, SIGNAL(triggered()), this, SLOT(open()));*/

    connect(m_ui->action_autosave_scene, SIGNAL(triggered(bool)), this, SLOT(setAutosaveScene(bool)));

    connect(m_ui->action_import, SIGNAL(triggered()), this, SLOT(import()));

    connect(m_ui->action_reload, SIGNAL(triggered()), this, SLOT(reload()));

    QAction* actions[] = {m_ui->action_toggle_materials,
                          m_ui->action_toggle_render_passes, m_ui->action_toggle_error_log
                         };
    QDockWidget* widgets[] = {m_ui->materials_dock, m_ui->render_passes_dock, m_ui->error_dock};
    for (size_t i = 0; i < sizeof(actions)/sizeof(*actions); ++i) {
      connect(actions[i], SIGNAL(triggered(bool)), widgets[i], SLOT(setVisible(bool)));
      connect(widgets[i], SIGNAL(visibilityChanged(bool)), actions[i], SLOT(setChecked(bool)));
    }

    connect(m_ui->action_reset_layout, SIGNAL(triggered()),
            this, SLOT(resetLayout()));

    connect(m_ui->action_about, SIGNAL(triggered()),
            this, SLOT(about()));
    connect(m_ui->editor_tabs, SIGNAL(tabCloseRequested(int)),
            this, SLOT(closeEditor(int)));

    connect(m_ui->action_sandbox_compiler, SIGNAL(toggled(bool)),
            this, SLOT(setSandboxCompiler(bool)));

    QSettings settings("Shaderkit", "Shaderkit");
    m_ui->action_autosave_scene->setChecked(settings.value("gui/autosave_scene", true).toBool());
    m_ui->action_sandbox_compiler->setChecked(settings.value("core/use_sandbox_compiler", true).toBool());

    {
      m_ui->editor_menu->layout()->setMargin(0);

      QIcon icon(":/btns/nosync.png");
      icon.addFile(":/btns/sync.png", QSize(), QIcon::Normal, QIcon::On);
      m_sync = m_ui->editor_menu->addAction(icon, "Auto-compile");
      m_sync->setCheckable(true);
      m_sync->setChecked(true);

      icon.addFile(":/btns/sync.png", QSize(), QIcon::Normal, QIcon::On);
      m_ui->editor_menu->addAction(QIcon(":/btns/compile.png"), "Compile all",
                                   this, SLOT(compileAll()));
    }
  }
Esempio n. 16
0
void TextLayer::restartCallback(NSObject* pSender)
{
	/*newOrientation();*/
	newScene();
}
Esempio n. 17
0
MainWindow::MainWindow()
{
    fullScreen_ = false;

    // Set Title and window properties
    setWindowTitle(tr("Examinationroom"));
    QMainWindow::setDockOptions(AnimatedDocks | AllowNestedDocks | AllowTabbedDocks);

    // Add Dock Widgets
    dockDesign_ = new DesignWidget("Design", this);
    dockCode_ = new CodeWidget("Code", this);
    dockConsole_ = new ConsoleWidget("Console", this);
    dockDesign_->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    dockCode_->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    dockConsole_->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    addDockWidget(Qt::RightDockWidgetArea, dockDesign_);
    addDockWidget(Qt::RightDockWidgetArea, dockCode_);
    addDockWidget(Qt::RightDockWidgetArea, dockConsole_);
    tabifyDockWidget(dockDesign_, dockCode_);
    tabifyDockWidget(dockDesign_, dockConsole_);

    // Set up logging early
    LogTool::initLogFile();
    LogTool::setConsoleWidget(dockConsole_);

    // File dialogs
#ifdef Q_WS_MACX
    Qt::WindowFlags dialogFlags = Qt::Sheet;
    QString defaultPath = QString("res/");
#else
    Qt::WindowFlags dialogFlags = Qt::Dialog;
    QString defaultPath = QString("res/");
#endif
    loadDialog_ = new QFileDialog(this, dialogFlags);
    loadDialog_->setFilter("Lua Scene File (*.lua)");
    loadDialog_->setWindowTitle("Open Lua Scene...");
    loadDialog_->setDirectory(defaultPath);
    storeDialog_ = new QFileDialog(this, dialogFlags);
    storeDialog_->setAcceptMode(QFileDialog::AcceptSave);
    storeDialog_->setFilter("Lua Scene File (*.lua)");
    storeDialog_->setWindowTitle("Save Lua Scene...");
    storeDialog_->setDirectory(defaultPath);
    storeDialog_->setDefaultSuffix("lua");
    connect(loadDialog_, SIGNAL(fileSelected(const QString &)), this, SLOT(loadLuaFile(const QString &)));
    connect(storeDialog_, SIGNAL(fileSelected(const QString &)), this, SLOT(storeLuaFile(const QString &)));

    // Create GL Widgets
    QGLFormat glFormat = QGLFormat::defaultFormat();
    // Stereo Buffering seems to work in SnowLeopard...
    // but is incompatible with other renderers and might cause problems.
    // enable at your own risk
    glFormat.setStereo(false);
    glFormat.setSwapInterval(1); // Enable VSync on platforms that support it
    QGLFormat::setDefaultFormat(glFormat);

    // Checking for errors here leads to a crash on OS X
    // Probably because OpenGL was not initialized yet?
    //ErrorTool::getErrors("MainWindow::MainWindow:1");
    mainGlWidget_ = new GLWidget(this);
    fsGlWidget_ = new GLWidget(0, mainGlWidget_);
    fsGlWidget_->setCursor(Qt::BlankCursor);
    mainGlWidget_->setStyle(GLWidget::single);
    fsGlWidget_->setStyle(GLWidget::single);
    mainGlWidget_->makeCurrent();
    GlErrorTool::getErrors("MainWindow::MainWindow:2");
    GlErrorTool::logVersionStrings();

    aboutWindow_ = 0;

    // Add menu
    QMenu *menu = menuBar()->addMenu(tr("&File"));
    menu->addAction(tr("&About Examinationroom..."),
                    this, SLOT(showAbout()));
    menu->addAction(tr("&Open Scene..."),
                    loadDialog_, SLOT(open()),
                    QKeySequence(QKeySequence::Open));
    menu->addAction(tr("Close Scene"),
                    this, SLOT(newScene()),
                    QKeySequence(QKeySequence::Close));
    menu->addAction(tr("&Save Copy As..."),
                    storeDialog_, SLOT(open()),
                    QKeySequence(QKeySequence::Save));
    menu->addAction(tr("&Revert Scene"),
                    this, SLOT(revert()));
    menu->addSeparator();
    menu->addAction(tr("&Quit"), this, SLOT(close()),
                    QKeySequence(tr("ctrl-Q")));

    // Signal mapper for display types
    signalMapper_ = new QSignalMapper(this);

    // Add display menu
    QAction * action;
    menu = menuBar()->addMenu(tr("&Output Mode"));

    action = menu->addAction(tr("&Fullscreen"),
                             this, SLOT(toggleFullscreen()),
                             QKeySequence(Qt::Key_F | Qt::CTRL));
    fsGlWidget_->addAction(action);

    menu->addSeparator();

    action = menu->addAction(tr("&Anaglyph"));
    action->setShortcut(QKeySequence(Qt::Key_1 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::anaglyph);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("&Side by Side"));
    action->setShortcut(QKeySequence(Qt::Key_2 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::sidebyside);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("&Line interlacing (Experimental)"));
    action->setShortcut(QKeySequence(Qt::Key_3 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::line);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("Quad Buffering (Experimental)"));
    action->setShortcut(QKeySequence(Qt::Key_4 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::quad);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("Matrix Anaglyph (Experimental)"));
    action->setShortcut(QKeySequence(Qt::Key_5 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::matrix);
    fsGlWidget_->addAction(action);

    menu->addSeparator();

    action = menu->addAction(tr("&Shader (Line interlacing)"));
    action->setShortcut(QKeySequence(Qt::Key_6 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::shaderLine);
    fsGlWidget_->addAction(action);

    action = menu->addAction(tr("&Shader (Mayan)"));
    action->setShortcut(QKeySequence(Qt::Key_7 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::shaderMayan);
    fsGlWidget_->addAction(action);

    menu->addSeparator();

    action = menu->addAction(tr("Si&ngle"));
    action->setShortcut(QKeySequence(Qt::Key_0 | Qt::CTRL));
    connect(action, SIGNAL(triggered()), signalMapper_, SLOT(map()));
    signalMapper_->setMapping(action, GLWidget::single);
    fsGlWidget_->addAction(action);

    connect(signalMapper_, SIGNAL(mapped(int)), this, SLOT(setDrawStyle(int)));

    // Object Creation Menu and signal mapper
    objectMenu_ = menuBar()->addMenu(tr("&Create Object"));
    objectMapper_ = new QSignalMapper(this);
    connect(objectMapper_, SIGNAL(mapped(int)), this, SLOT(onObjectCreate(int)));

#ifdef Q_WS_MACX
    // Make menu bar the default menu bar
    menuBar()->setParent(0);
#endif

    // Set up layout
    setFocusPolicy(Qt::StrongFocus);
    setCentralWidget(mainGlWidget_);

    // Create Scene
    setProgram(Program::create());

    // Set up redraw timer
    timer_ = new QTimer(this);
    connect(timer_, SIGNAL(timeout()), this, SLOT(onTimeout()));
    timer_->start(15); // ~60 fps
}
Esempio n. 18
0
void BrowserWidget::resizeEvent(QResizeEvent *event) {
    wideEmulationMode(wideEmulation);
    newScene();
}
Esempio n. 19
0
void TextLayer::restartCallback(Ref* sender)
{
    newScene();
}
Esempio n. 20
0
void BrowserWidget::zoomOut() {
    changeZoom(1 / zoomStepFactor);
    newScene();
}
Esempio n. 21
0
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags)
    , Ui::MainWindow()
{
    setupUi(this);

    // instantiate singleton
    new RobotManager(this);

    QWidget* toolsWidget = new QWidget();
    m_toolsUi = new Ui::ToolWidget();
    m_toolsUi->setupUi(toolsWidget);
    m_toolsUi->cmbTool->addItem("Place Vehicle");        // 0
    m_toolsUi->cmbTool->insertSeparator(1);              // 1
    m_toolsUi->cmbTool->addItem("Modify Obstacles");     // 2
    m_toolsUi->cmbTool->addItem("Modify Explored Area"); // 3
    m_toolsUi->cmbTool->insertSeparator(4);              // 4
    m_toolsUi->cmbTool->addItem("DisCoverage (Orientation-based)"); // 5
    m_toolsUi->cmbTool->addItem("MinDist");              // 6
    m_toolsUi->cmbTool->addItem("DisCoverage (Frontier Weights)"); // 7
	m_toolsUi->cmbTool->addItem("Random"); // 8
	m_toolsUi->cmbTool->addItem("MaxArea"); // 9
	m_toolsUi->cmbTool->addItem("Ruffins"); // 10
    toolBar->insertWidget(actionDummy, toolsWidget);
    toolBar->removeAction(actionDummy);

    m_stats = new Statistics(this);
    dwStatistics->setWidget(m_stats);
    dwStatistics->setVisible(false);

    m_statusProgress = new QLabel("Explored: 0.00%", statusBar());
    statusBar()->addPermanentWidget(m_statusProgress);

    m_statusResolution = new QLabel(statusBar());
    statusBar()->addPermanentWidget(m_statusResolution);
    setStatusResolution(0.2);

    m_statusPosition = new QLabel(statusBar());
    statusBar()->addPermanentWidget(m_statusPosition);
    setStatusPosition(QPoint(0, 0));

    m_scene = new Scene(this, this);
    scrollArea->setWidget(m_scene);
    scrollArea->installEventFilter(this);

    m_robotListView = new RobotListView(this);
    dwRobotManager->setWidget(m_robotListView);


    connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect(actionZoomIn, SIGNAL(triggered()), m_scene, SLOT(zoomIn()));
    connect(actionZoomOut, SIGNAL(triggered()), m_scene, SLOT(zoomOut()));
    connect(actionNew, SIGNAL(triggered()), this, SLOT(newScene()));
    connect(actionOpen, SIGNAL(triggered()), this, SLOT(openScene()));
    connect(actionSave, SIGNAL(triggered()), this, SLOT(saveScene()));
    connect(actionSaveAs, SIGNAL(triggered()), this, SLOT(saveSceneAs()));
    connect(actionPartition, SIGNAL(triggered(bool)), Config::self(), SLOT(setShowPartition(bool)));
    connect(actionDensity, SIGNAL(triggered(bool)), Config::self(), SLOT(setShowDensity(bool)));
    connect(actionVectorField, SIGNAL(triggered(bool)), Config::self(), SLOT(setShowVectorField(bool)));
    connect(actionPreview, SIGNAL(triggered(bool)), Config::self(), SLOT(setShowPreviewTrajectory(bool)));
    connect(actionStatistics, SIGNAL(triggered(bool)), dwStatistics, SLOT(setVisible(bool)));
    connect(actionExport, SIGNAL(triggered()), this, SLOT(exportToTikz()));
    connect(actionReload, SIGNAL(triggered()), this, SLOT(reloadScene()));
	connect(actionStep, SIGNAL(triggered()), this, SLOT(tick()));
    connect(m_toolsUi->cmbTool, SIGNAL(currentIndexChanged(int)), m_scene, SLOT(selectTool(int)));
    connect(m_toolsUi->sbRadius, SIGNAL(valueChanged(double)), m_scene, SLOT(setOperationRadius(double)));

    connect(actionAbout, SIGNAL(triggered()), this, SLOT(helpAbout()));
    connect(actionAboutQt, SIGNAL(triggered()), this, SLOT(helpAboutQt()));
}
Esempio n. 22
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();
}
Esempio n. 23
0
void TextLayer::restartCallback(CCObject* pSender)
{
    newScene();
}
Esempio n. 24
0
void TextLayer::restartCallback(Object* sender)
{
    newScene();
}
Esempio n. 25
0
S3DScene* Scenery3d::loadSceneBackground(const SceneInfo& scene) const
{
	//the scoped pointer ensures this scene is deleted when errors occur
	QScopedPointer<S3DScene> newScene(new S3DScene(scene));

	if(loadCancel)
		return Q_NULLPTR;

	updateProgress(q_("Loading model..."),1,0,6);

	//load model
	StelOBJ modelOBJ;
	QString modelFile = StelFileMgr::findFile( scene.fullPath+ "/" + scene.modelScenery);
	qCDebug(scenery3d)<<"Loading scene from "<<modelFile;
	if(!modelOBJ.load(modelFile, scene.vertexOrderEnum))
	{
	    qCCritical(scenery3d)<<"Failed to load OBJ file"<<modelFile;
	    return Q_NULLPTR;
	}

	if(loadCancel)
		return Q_NULLPTR;

	updateProgress(q_("Transforming model..."),2,0,6);
	newScene->setModel(modelOBJ);

	if(loadCancel)
		return Q_NULLPTR;

	if(scene.modelGround.isEmpty())
	{
		updateProgress(q_("Calculating collision map..."),5,0,6);
		newScene->setGround(modelOBJ);
	}
	else if (scene.modelGround != "NULL")
	{
		updateProgress(q_("Loading ground..."),3,0,6);

		StelOBJ groundOBJ;
		modelFile = StelFileMgr::findFile(scene.fullPath + "/" + scene.modelGround);
		qCDebug(scenery3d)<<"Loading ground from"<<modelFile;
		if(!groundOBJ.load(modelFile, scene.vertexOrderEnum))
		{
			qCCritical(scenery3d)<<"Failed to load ground model"<<modelFile;
			return Q_NULLPTR;
		}

		updateProgress(q_("Transforming ground..."),4,0,6);
		if(loadCancel)
			return Q_NULLPTR;

		updateProgress(q_("Calculating collision map..."),5,0,6);
		newScene->setGround(groundOBJ);
	}

	if(loadCancel)
		return Q_NULLPTR;

	updateProgress(q_("Finalizing load..."),6,0,6);

	return newScene.take();
}
Esempio n. 26
0
void Opeke::setupActions()
{
    KStandardAction::openNew ( this, SLOT ( fileNew() ), actionCollection() );
    KStandardAction::quit ( qApp, SLOT ( quit() ), actionCollection() );
    KStandardAction::save ( this, SLOT ( saveFile() ), actionCollection() );
    KStandardAction::open ( this, SLOT ( openFile() ), actionCollection() );
    KStandardAction::saveAs ( this, SLOT ( saveFileAs() ), actionCollection() );

    KStandardAction::preferences ( this, SLOT ( optionsPreferences() ), actionCollection() );
    undoAct = KStandardAction::undo (m_view, SLOT(undo()), actionCollection() );
    redoAct = KStandardAction::redo (m_view, SLOT(redo()), actionCollection() );

    removeAct = KStandardAction::cut (m_view, SLOT(delBrick()), actionCollection());
    removeAct->setShortcut(QKeySequence(Qt::Key_Delete));
    removeAct->setText( i18n ("Delete"));
    removeAct->setEnabled(false);

    // The action to start building Bricks in OGRE
    KAction *build = new KAction ( KIcon ( "build" ), i18n ( "Build" ), this );
    build->setShortcut(QKeySequence(Qt::Key_B));
    actionCollection()->addAction ( QLatin1String ( "build_action" ), build );
    connect ( build, SIGNAL ( triggered ( bool ) ), m_view, SLOT ( setBuildMode() ) );

    // Start select mode
    KAction *select = new KAction ( KIcon ( "select" ), i18n ( "S&elect" ), this );
    select->setShortcut(QKeySequence(Qt::Key_E));
    actionCollection()->addAction ( QLatin1String ( "select_action" ), select );
    connect ( select, SIGNAL ( triggered ( bool ) ), m_view, SLOT ( setSelectMode() ) );

    // Enable or disable grid
    KAction *grid = new KAction (KIcon ( "grid" ), i18n ("Toggle &Grid"), this);
    grid->setShortcut(QKeySequence(Qt::Key_G));
    actionCollection()->addAction(QLatin1String("grid_action"), grid);
    connect (grid, SIGNAL (triggered (bool)), m_view, SLOT (flipGridEnabled() ));

    // Actions to choose what kind of Brick to build
    KAction *block = new KAction (KIcon ( "block" ), i18n ("Build B&lock"), this);
    block->setShortcut(QKeySequence(Qt::Key_L));
    actionCollection()->addAction(QLatin1String("block_action"), block);
    connect (block, SIGNAL (triggered (bool)), m_view, SLOT (changeTypeBlock() ));
    connect (block, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));

    KAction *roof = new KAction (KIcon ( "roof" ), i18n ("Build &Roof"), this);
    roof->setShortcut(QKeySequence(Qt::Key_R));
    actionCollection()->addAction(QLatin1String("roof_action"), roof);
    connect (roof, SIGNAL (triggered (bool)), m_view, SLOT (changeTypeRoof()));
    connect (roof, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));


    KAction *cylinder = new KAction (KIcon ( "cylinder" ), i18n ("Build &Cylinder"), this);
    cylinder->setShortcut(QKeySequence(Qt::Key_C));
    actionCollection()->addAction(QLatin1String("cylinder_action"), cylinder);
    connect (cylinder, SIGNAL (triggered (bool)), m_view, SLOT (changeTypeCylinder() ));
    connect (cylinder, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));

    KAction *invCyl = new KAction (KIcon ("invCyl"), i18n ("Build &Inverted Cylinder"), this);
    invCyl->setShortcut(QKeySequence(Qt::Key_I));
    actionCollection()->addAction(QLatin1String("invCyl_action"), invCyl);
    connect (invCyl, SIGNAL (triggered (bool)), m_view, SLOT (changeTypeInvCyl() ));
    connect (invCyl, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));

    KAction *sphere = new KAction (KIcon ("sphere"), i18n ("Build &Sphere"), this);
    sphere->setShortcut(QKeySequence(Qt::Key_S));
    actionCollection()->addAction(QLatin1String("sphere_action"), sphere);
    connect (sphere, SIGNAL (triggered (bool)), m_view, SLOT (changeTypeSphere() ));
    connect (sphere, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));

    KAction *cone = new KAction (KIcon ( "cone" ), i18n ("Build Co&ne"), this);
    cone->setShortcut(QKeySequence(Qt::Key_N));
    actionCollection()->addAction(QLatin1String("cone_action"), cone);
    connect (cone, SIGNAL (triggered (bool)), m_view, SLOT (changeTypeCone() ));
    connect (cone, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));

    KAction *corner = new KAction (KIcon ( "corner" ), i18n ("Build Roof C&orner"), this);
    corner->setShortcut(QKeySequence(Qt::Key_O));
    actionCollection()->addAction(QLatin1String("corner_action"), corner);
    connect (corner, SIGNAL (triggered (bool)), m_view, SLOT (changeTypeCorner() ));
    connect (corner, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));

    KAction *invrcor = new KAction (KIcon ( "invrcor" ), i18n ("Build In&verted Roof Corner"), this);
    invrcor->setShortcut(QKeySequence(Qt::Key_V));
    actionCollection()->addAction(QLatin1String("invrcor_action"), invrcor);
    connect (invrcor, SIGNAL (triggered (bool)), m_view, SLOT (changeTypeInvCorner() ));
    connect (invrcor, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));

    KAction *pyramid = new KAction (KIcon ( "pyramid" ), i18n ("Build &Pyramid"), this);
    pyramid->setShortcut(QKeySequence(Qt::Key_P));
    actionCollection()->addAction(QLatin1String("pyramid_action"), pyramid);
    connect (pyramid, SIGNAL (triggered (bool)), m_view, SLOT (changeTypePyramid() ));
    connect (pyramid, SIGNAL (triggered (bool)), m_view, SLOT (setBuildMode() ));

    KAction *snapshot = new KAction (KIcon ("ksnapshot"), i18n ("&Take Screenshot"), this);
    snapshot->setShortcut(QKeySequence("Ctrl+T"));
    actionCollection()->addAction(QLatin1String("snapshot_action"), snapshot);
    connect (snapshot, SIGNAL(triggered(bool)), this, SLOT (saveScreen()));

    // Reload the field after loading a new file
    connect ( this, SIGNAL ( reload() ), m_view, SLOT ( update() ) );
    connect ( this, SIGNAL ( clear() ), m_view, SLOT ( newScene() ) );

    connect ( m_tool, SIGNAL ( colorViewed ( QColor ) ), m_view, SLOT ( viewColor ( QColor ) ) );
    connect ( m_tool, SIGNAL ( colorChanged ( QColor ) ), m_view, SLOT ( setColor ( QColor ) ) );

    connect ( m_tool, SIGNAL ( planeChanged ( int ) ), m_view, SLOT ( setPlaneZ ( int ) ) );

    connect ( m_tool, SIGNAL ( sizeXChanged ( int ) ), m_view, SLOT ( setSizeX ( int ) ) );
    connect ( m_tool, SIGNAL ( sizeYChanged ( int ) ), m_view, SLOT ( setSizeY ( int ) ) );
    connect ( m_tool, SIGNAL ( sizeZChanged ( int ) ), m_view, SLOT ( setSizeZ ( int ) ) );
    connect ( m_view, SIGNAL(planeChanged(int)), m_tool, SLOT(changePlaneZ(int)));

    connect ( m_view, SIGNAL(undoEmpty(bool)), this, SLOT(undoEnable(bool)));
    connect ( m_view, SIGNAL(redoEmpty(bool)), this, SLOT(redoEnable(bool)));
    connect ( m_view, SIGNAL(delEnable(bool)), this, SLOT(removeEnable(bool)));
    connect ( m_view, SIGNAL(modified()), this, SLOT(fileModified()));

    connect (m_tool, SIGNAL(rotX()), m_view, SLOT(rotateX()));
    connect (m_tool, SIGNAL(rotY()), m_view, SLOT(rotateY()));
    connect (m_tool, SIGNAL(rotZ()), m_view, SLOT(rotateZ()));
}