Esempio n. 1
0
int CPreviews::openNextScene()
{
	// Here we set the function pointer for the cycle and load stuff for it...
	m_scene_number++;
	std::string filename = "preview";
	filename += itoa(m_scene_number);
	filename += ".ck";
	filename += itoa(m_episode);

	// If the we have scene to load, load it, else open the text which ends the preview
	if(openScene(filename))
	{
        this->ponder_ptr = &CPreviews::processPreviewScene;
        this->render_ptr = &CPreviews::drawPreviewScene;
	}
	else
	{
		std::string filename = JoinPaths(g_pBehaviorEngine->m_ExeFile.getDataDirectory(), "previews.ck");
		filename += itoa(g_pBehaviorEngine->getEpisode());

		mp_TextViewer.reset( new CTextViewer(0, 8, 320, 160) );

		if(!mp_TextViewer->loadTextfromFile(filename))
			m_destroy_me = true;

        this->render_ptr = &CPreviews::showText;
        this->ponder_ptr = &CPreviews::processShowText;
	}

	return 0;
}
Esempio n. 2
0
void MainWindow::openScene()
{
    Path dir = (!_scene || _scene->path().empty()) ?
            FileUtils::getCurrentDir() :
            _scene->path();
    QString file = QFileDialog::getOpenFileName(
        nullptr,
        "Open file...",
        QString::fromStdString(dir.absolute().asString()),
        "Scene files (*.json)"
    );

    if (!file.isEmpty())
        openScene(file);
}
Esempio n. 3
0
bool WorldEditor::OnInit( WORLDid wID  )
{
	if ( !TGame::OnInit( wID ) )
		return false;

	btDynamicsWorld* phyWorld = TPhySystem::instance().getDynamicsWorld();

	TRoleManager::instance().loadData( ROLE_DATA_PATH );
	getWorldEditor()->init( this );

	openScene("BT_LOWER_TEST");


	g_isEditMode = true;

	return true;
}
Esempio n. 4
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. 5
0
Window::Window( const QString& scene_name, QWidget* parent )
: QMainWindow( parent )
, m_content_widget( nullptr )
{
  m_content_widget = new ContentWidget{ scene_name, this };

  QMenu* file{ menuBar()->addMenu( tr( "File" ) ) };

  QMenu* view{ menuBar()->addMenu( tr( "View" ) ) };
  
  QAction* separator{ new QAction{ this } };
  separator->setSeparator( true );

  // File menu actions

  // Load the input xml file
  QAction* open_scene{ new QAction{ tr( "Open..." ), this } };
  open_scene->setShortcut( tr( "Ctrl+o" ) );
  file->addAction( open_scene );
  connect( open_scene, SIGNAL( triggered() ), m_content_widget, SLOT( openScene() ) );

  // Reload the current xml file
  QAction* reload_scene{ new QAction{ tr( "Reload" ), this } };
  reload_scene->setShortcut( tr( "Ctrl+r" ) );
  file->addAction( reload_scene );
  connect( reload_scene, SIGNAL( triggered() ), m_content_widget, SLOT( reloadScene() ) );

  // Add a separator
  file->addAction( separator );

  // Export an image of the scene
  QAction* export_image{ new QAction{ tr( "Export Image..." ), this } };
  export_image->setShortcut( tr( "Ctrl+i" ) );
  file->addAction( export_image );
  connect( export_image, SIGNAL( triggered() ), m_content_widget, SLOT( exportImage() ) );

  // Export a movie of the scene
  QAction* export_movie{ new QAction{ tr( "Export Movie..." ), this } };
  export_movie->setShortcut( tr( "Ctrl+m" ) );
  file->addAction( export_movie );
  connect( export_movie, SIGNAL( triggered() ), m_content_widget, SLOT( exportMovie() ) );

  // Add a separator
  QAction* separator2{ new QAction{ this } };
  separator2->setSeparator( true );
  file->addAction( separator2 );
  
  // Export the current camera settings
  QAction* export_camera_settings{ new QAction{ tr( "Export Camera..." ), this } };
  file->addAction( export_camera_settings );
  connect( export_camera_settings, SIGNAL( triggered() ), m_content_widget, SLOT( exportCameraSettings() ) );

  // View menu actions

  // Toggle the heads up display
  QAction* toggle_hud{ new QAction{ tr( "Togge HUD" ), this } };
  toggle_hud->setShortcut( tr( "h" ) );
  view->addAction( toggle_hud );
  connect( toggle_hud, SIGNAL( triggered() ), m_content_widget, SLOT( toggleHUD() ) );

  // Add a separator
  view->addAction( separator );

  // Center the camera
  QAction* center_camera{ new QAction( tr( "Center Camera" ), this ) };
  center_camera->setShortcut( tr( "c" ) );
  view->addAction( center_camera );
  connect( center_camera, SIGNAL( triggered() ), m_content_widget, SLOT( centerCamera() ) );

  setCentralWidget( m_content_widget );  
}
Esempio n. 6
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. 7
0
void MainWindow::reloadScene()
{
    if (_scene)
        openScene(QString::fromStdString(_scene->path().absolute().asString()));
}