Window::Window() { m_shouldDisplayFeather = true; std::cout<<"Initializing Mallard main window "; glWidget = new GLWidget; m_tools = new ToolBox; m_barbEdit = new BarbEdit(this); m_renderEdit = new RenderEdit(this); glWidget->setInteractContext(m_tools); m_brushControl = new BrushControl(glWidget->brush(), this); m_featherEdit = new FeatherEdit(this); FeatherExample::FeatherLibrary = glWidget; m_timeControl = new TimeControl(this); glWidget->setPlayback(m_timeControl); m_sceneEdit = new SceneEdit(glWidget, this); addToolBar(m_tools); setCentralWidget(glWidget); setWorkTitle(tr("untitled")); createActions(); createMenus(); connect(m_tools, SIGNAL(contextChanged(int)), this, SLOT(receiveToolContext(int))); connect(m_tools, SIGNAL(contextChanged(int)), m_brushControl, SLOT(receiveToolContext(int))); connect(m_tools, SIGNAL(actionTriggered(int)), this, SLOT(receiveToolAction(int))); connect(m_tools, SIGNAL(stateChanged(int)), this, SLOT(receiveToolState(int))); connect(m_brushControl, SIGNAL(brushChanged()), glWidget, SLOT(receiveBrushChanged())); connect(m_brushControl, SIGNAL(paintModeChanged(int)), glWidget, SLOT(receivePaintMode(int))); connect(glWidget, SIGNAL(sceneNameChanged(QString)), this, SLOT(setWorkTitle(QString))); connect(glWidget, SIGNAL(sendMessage(QString)), this, SLOT(showMessage(QString))); connect(m_featherEdit, SIGNAL(textureLoaded(QString)), glWidget, SLOT(receiveFeatherEditBackground(QString))); connect(m_featherEdit, SIGNAL(featherAdded()), glWidget, SLOT(receiveFeatherAdded())); connect(glWidget, SIGNAL(sendFeatherEditBackground(QString)), m_featherEdit, SLOT(receiveTexture(QString))); connect(m_timeControl, SIGNAL(currentFrameChanged(int)), glWidget, SLOT(updateOnFrame(int))); connect(m_featherEdit->uvView(), SIGNAL(selectionChanged()), m_barbEdit->barbControl(), SLOT(receiveSelectionChanged())); connect(glWidget, SIGNAL(featherSelectionChanged()), m_barbEdit->barbControl(), SLOT(receiveSelectionChanged())); connect(m_featherEdit->uvView(), SIGNAL(shapeChanged()), m_barbEdit->barbView(), SLOT(receiveShapeChanged())); connect(glWidget, SIGNAL(renderResChanged(QSize)), m_renderEdit, SLOT(resizeRenderView(QSize))); connect(glWidget, SIGNAL(renderEngineChanged(QString)), m_renderEdit, SLOT(setRenderEngine(QString))); connect(glWidget, SIGNAL(renderStarted(QString)), m_renderEdit, SLOT(startRender(QString))); connect(m_renderEdit, SIGNAL(cancelRender()), glWidget, SLOT(receiveCancelRender())); connect(m_barbEdit->barbControl(), SIGNAL(shapeChanged()), glWidget, SLOT(receiveBarbChanged())); connect(glWidget, SIGNAL(sceneOpened()), m_sceneEdit, SLOT(reloadScene())); connect(m_sceneEdit->model(), SIGNAL(cameraChanged()), glWidget, SLOT(receiveCameraChanged())); std::cout<<"Ready\n"; statusBar()->showMessage(tr("Ready")); }
bool AppDelegate::applicationDidFinishLaunching() { std::vector<std::string> searchPaths; searchPaths.push_back("assets"); // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) glview = GLViewImpl::createWithRect("Evil", Rect(0, 0, mediumResolutionSize.width, mediumResolutionSize.height)); #else glview = GLViewImpl::create("Evil"); #endif director->setOpenGLView(glview); } // turn on display FPS //director->setDisplayStats(true); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) Size visibleSize = Director::getInstance()->getVisibleSize(); float height; if (getTargetPlatform() == Platform::OS_IPAD) height = 700; else height = 640; if (visibleSize.height > height) { float s = height / visibleSize.height; glview->setDesignResolutionSize(visibleSize.width*s, height, ResolutionPolicy::NO_BORDER); } #endif // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); FileUtils::getInstance()->setSearchPaths(searchPaths); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("assets.plist"); reloadScene(NULL); return true; }
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())); }
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 ); }
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(); }