void bankManager::saveScenes(ofxXmlSettings & XML){ XML.addTag("SCENE_SETTINGS"); if(XML.pushTag("SCENE_SETTINGS")){ vector<ofPtr<scene> >::iterator it; int counter = 0; for(it = allScenes.begin(); it != allScenes.end(); it++){ XML.addTag("SCENE"); ofPtr<scene> sn = (*it); if(XML.pushTag("SCENE", counter)){ saveScene(XML, sn); counter++; //scene tag XML.popTag(); } } //scene settings tag XML.popTag(); } }
void MainWindow::saveSceneAs() { const QString fileName = QFileDialog::getSaveFileName(this, "Save Scene As", QString(), "Scenes (*.scene)"); if (!fileName.isEmpty()) { m_sceneFile = fileName; saveScene(); } }
void MainWindow::init() { this->configurationDockWidget->toggleViewAction()->setShortcut(QKeySequence("F5")); this->addAction(this->configurationDockWidget->toggleViewAction()); this->saveImageWithoutAlphaAction->setShortcut(QKeySequence("Return")); QObject::connect(this->saveImageWithoutAlphaAction, SIGNAL(triggered()), this, SLOT(saveImageWithoutAlpha())); this->addAction(this->saveImageWithoutAlphaAction); this->saveImageWithAlphaAction->setShortcut(QKeySequence("Shift+Return")); QObject::connect(this->saveImageWithAlphaAction, SIGNAL(triggered()), this, SLOT(saveImageWithAlpha())); this->addAction(this->saveImageWithAlphaAction); this->saveSceneAction->setShortcut(QKeySequence("Ctrl+Return")); QObject::connect(this->saveSceneAction, SIGNAL(triggered()), this, SLOT(saveScene())); this->addAction(this->saveSceneAction); }
void MainWindow::saveSceneAs() { if (_scene) { Path dir = _scene->path().empty() ? FileUtils::getCurrentDir() : _scene->path(); QString file = QFileDialog::getSaveFileName( nullptr, "Save file as...", QString::fromStdString(dir.absolute().asString()), "Scene files (*.json)" ); if (!file.isEmpty()) { _scene->setPath(Path(file.toStdString())); saveScene(); } } }
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())); }
/* FbxMesh pMesh : the original mesh load from fbx file FbxScene pScene : the FbxScene load from fbx file float threshold : */ void GenerateLOD::Reduction_EdgesCollapse_UV(FbxNode *node, FbxMesh *pMesh, FbxManager *pManager, FbxScene *pScene) { // Clear the ralated data structure (*ControlP).clear(); (*Triangles).clear(); (*Edges).clear(); (*CostToEdge).clear(); // Clear the HeapCost while (!HeapCost->empty()) HeapCost->pop(); FbxVector4 *pControlPoints = pMesh->GetControlPoints(); int AddTriangleIndex = pMesh->GetPolygonCount(); int AddEdgeIndex = pMesh->GetMeshEdgeCount(); int threshold_1 = static_cast<int>(AddTriangleIndex * model_1.GetReductionRate()); int threshold_2 = static_cast<int>(AddTriangleIndex * model_2.GetReductionRate()); int threshold_3 = static_cast<int>(AddTriangleIndex * model_3.GetReductionRate()); double start = GetTickCount(); //# Init the ditc of (*Triangles) and the dict of (*ControlP) Init_Triangles_And_ControlP_EdgeCollapse(pMesh, pControlPoints);///////////////////////////// //Before Reduction, Now Init the Original VertexBuffer Init_Buffer(pMesh, model_0); //# Init the ditc of (*Edges) InitEdges(pMesh); ////////////////////////////////// // Now, Simplify Iterator int Ring = 0; bool flag1 = true; bool flag2 = true; while (true) { int idx; if (0 == HeapCost->size()) idx = -1; else { //First Get the top element, namely the minmum cost //Second pop the minmum cost from HeapCost FbxDouble PopCost = HeapCost->top(); HeapCost->pop(); if (0 == (*CostToEdge)[PopCost].size()) continue; idx = (*CostToEdge)[PopCost][0]; } //int idx = GetMinEdgeCost(); if (-1 == idx) { MessageBox(NULL, "When execute Simplification, there has No any edges should be collapse.", "The title", 0); break; } // Execute the current Edge Collapse and Update the (*ControlP), (*Triangles), (*Edges). CollapseEdge_And_UpdateCost(idx, pControlPoints, AddTriangleIndex, AddEdgeIndex); Ring += 1; if (flag1 && (int)(*Triangles).size() < threshold_1) { // After Reduction, Now Init Reduction VertexBuffer Init_Buffer(pMesh, model_1); model = model_1; FbxMesh *newMesh = CreateNewMesh(pControlPoints, pMesh, pScene); // Update the Node Atrribute node->RemoveNodeAttribute(pMesh); node->SetNodeAttribute(newMesh); // Export new Mesh std::string tmp = std::string(".\\LODs\\") + std::string("Save") + srcFbxName.substr(0, srcFbxName.size() - 4) + "_(" + std::to_string(int(model_1.GetReductionRate() * 100)) + "%)" + ".FBX"; saveScene(tmp.c_str(), pManager, pScene, true); node->RemoveNodeAttribute(newMesh); node->SetNodeAttribute(pMesh); flag1 = false; } if (flag2 && (int)(*Triangles).size() < threshold_2) { // After Reduction, Now Init Reduction VertexBuffer Init_Buffer(pMesh, model_2); FbxMesh *newMesh = CreateNewMesh(pControlPoints, pMesh, pScene); // Update the Node Atrribute node->RemoveNodeAttribute(pMesh); node->SetNodeAttribute(newMesh); // Export new Mesh std::string tmp = std::string(".\\LODs\\") + std::string("Save") + srcFbxName.substr(0, srcFbxName.size() - 4) + "_(" + std::to_string(int(model_2.GetReductionRate() * 100)) + "%)" + ".FBX"; saveScene(tmp.c_str(), pManager, pScene, true); node->RemoveNodeAttribute(newMesh); node->SetNodeAttribute(pMesh); flag2 = false; } if ((int)(*Triangles).size() < threshold_3) { // After Reduction, Now Init Reduction VertexBuffer Init_Buffer(pMesh, model_3); FbxMesh *newMesh = CreateNewMesh(pControlPoints, pMesh, pScene); // Update the Node Atrribute node->RemoveNodeAttribute(pMesh); node->SetNodeAttribute(newMesh); // Export new Mesh std::string tmp = std::string(".\\LODs\\") + std::string("Save") + srcFbxName.substr(0, srcFbxName.size() - 4) + "_(" + std::to_string(int(model_3.GetReductionRate() * 100)) + "%)" + ".FBX"; saveScene(tmp.c_str(), pManager, pScene, true); node->RemoveNodeAttribute(newMesh); node->SetNodeAttribute(pMesh); break; } } }
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())); } }
void MainWindow::createActions() { //loadAct loadSceneAct = new QAction(tr("&Load Scene"), this); loadSceneAct->setShortcut(Qt::CTRL + Qt::Key_O); loadSceneAct->setStatusTip(tr("Load scene")); connect(loadSceneAct, SIGNAL(triggered()), this, SLOT(loadScene())); //quickLoadAct quickLoadAct = new QAction(tr("&Quick Load"), this); quickLoadAct->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_Q); quickLoadAct->setStatusTip(tr("Load last scene")); connect(quickLoadAct, SIGNAL(triggered()), this, SLOT(quickLoad())); //saveSceneAct saveSceneAct = new QAction(tr("&Save Scene"), this); saveSceneAct->setShortcut(Qt::CTRL + Qt::Key_S); saveSceneAct->setStatusTip(tr("Save Scene")); connect(saveSceneAct, SIGNAL(triggered()), this, SLOT(saveScene())); loadPluginFileAct = new QAction(tr("&Load Plugin"), this); loadPluginFileAct->setShortcut(Qt::CTRL + Qt::Key_L); loadPluginFileAct->setStatusTip(tr("Load plugin file")); connect(loadPluginFileAct, SIGNAL(triggered()), this, SLOT(loadPluginFileWithDialog())); loadPluginDirAct = new QAction(tr("&Load Plugin Directory"), this); loadPluginDirAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_L); loadPluginDirAct->setStatusTip(tr("Load all plugins in directory")); connect(loadPluginDirAct, SIGNAL(triggered()), this, SLOT(loadPluginDirWithDialog())); /// save workspace configuration action saveWorkspaceConfigurationAct = new QAction(tr("Save Workspace"), this); saveWorkspaceConfigurationAct->setStatusTip(tr("Save the configuration of the workspace")); connect(saveWorkspaceConfigurationAct, SIGNAL(triggered()), this, SLOT(saveWorkspace())); /// save new workspace configuration action saveNewWorkspaceConfigurationAct = new QAction(tr("Save Workspace As..."), this); saveNewWorkspaceConfigurationAct->setStatusTip(tr("Save a new workspace configuration")); connect(saveNewWorkspaceConfigurationAct, SIGNAL(triggered()), this, SLOT(saveNewWorkspace())); /// load workspace configuration action loadWorkspaceConfigurationAct = new QAction(tr("Load Workspace"), this); loadWorkspaceConfigurationAct->setStatusTip(tr("Load a workspace configuration")); connect(loadWorkspaceConfigurationAct, SIGNAL(triggered()), this, SLOT(loadWorkspace())); //closeAct closeSceneAct = new QAction(tr("&Close"), this); closeSceneAct->setShortcut(Qt::CTRL + Qt::Key_W); closeSceneAct->setStatusTip(tr("Close Scene")); connect(closeSceneAct, SIGNAL(triggered()), this, SLOT(close())); //exitAct exitAct = new QAction(tr("&Exit"), this); exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(exit())); //frontAct frontAct = new QAction(tr("Front"), this); frontAct->setStatusTip(tr("Camera Front View")); connect(frontAct, SIGNAL(triggered()), this, SLOT(front())); //topAct topAct = new QAction(tr("Top"), this); topAct->setStatusTip(tr("Camera Top View")); connect(topAct, SIGNAL(triggered()), this, SLOT(top())); //sideAct sideAct = new QAction(tr("Side"), this); sideAct->setStatusTip(tr("Camera Side View")); connect(sideAct, SIGNAL(triggered()), this, SLOT(side())); //startSimulationAct startSimulationAct = new QAction(tr("Start Simulation"), this); startSimulationAct->setShortcut(Qt::CTRL + Qt::Key_R); connect(startSimulationAct, SIGNAL(triggered()), this, SLOT(startSimulation())); //stopSimulationAct stopSimulationAct = new QAction(tr("Stop Simulation"), this); stopSimulationAct->setShortcut(Qt::CTRL + Qt::Key_C); connect(stopSimulationAct, SIGNAL(triggered()), this, SLOT(stopSimulation())); //simulateSingleStepAct simulateSingleStepAct = new QAction(tr("Simulate Single Step"), this); simulateSingleStepAct->setStatusTip(tr("Simulates one step at a time")); simulateSingleStepAct->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_R); connect(simulateSingleStepAct, SIGNAL(triggered()), this, SLOT(simulateSingleStep())); //renderDuringSimulationAct renderDuringSimulationAct = new QAction(tr("Render during Simulation"), this); connect(renderDuringSimulationAct, SIGNAL(triggered()), this, SLOT(renderDuringSimulation())); //whiteAct whiteAct = new QAction(tr("White"), this); connect(whiteAct, SIGNAL(triggered()), this, SLOT(white())); //grayAct grayAct = new QAction(tr("Gray"), this); connect(grayAct, SIGNAL(triggered()), this, SLOT(gray())); //BlackAct blackAct = new QAction(tr("Black"), this); connect(blackAct, SIGNAL(triggered()), this, SLOT(black())); //resetCameraAct resetCameraAct = new QAction(tr("Reset Camera"), this); resetCameraAct->setStatusTip(tr("Reset Camera Angle")); connect(resetCameraAct, SIGNAL(triggered()), this, SLOT(resetCamera())); //xga1024x768Act xga1024x768Act = new QAction(tr("XGA 1024 x 768"), this); xga1024x768Act->setCheckable(true); xga1024x768Act->setChecked(true); connect(xga1024x768Act, SIGNAL(triggered()), this, SLOT(xga1024x768())); //vga640x480Act vga640x480Act = new QAction(tr("VGA 640 x 768"), this); vga640x480Act->setCheckable(true); connect(vga640x480Act, SIGNAL(triggered()), this, SLOT(vga640x480())); //hd1280x720Act hd1280x720Act = new QAction(tr("HD 1280 x 720"), this); hd1280x720Act->setCheckable(true); connect(hd1280x720Act, SIGNAL(triggered()), this, SLOT(hd1280x720())); //aboutAct aboutAct = new QAction(tr("About"), this); aboutAct->setShortcut(Qt::Key_F1); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); }
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(); }