diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 805f71468e3..c79c8046eda 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef QT_SCRIPT_LIB # include # ifdef QT_SCRIPTTOOLS_LIB @@ -2303,3 +2304,75 @@ void MainWindow::propagate_action() } } } + +void MainWindow::on_actionSa_ve_Scene_as_Script_triggered() +{ + QString filename = + QFileDialog::getSaveFileName(this, + "Save the Scene as a Script File", + last_saved_dir, + "*.js"); + std::ofstream os(filename.toUtf8()); + if(!os) + return; + std::vector names; + std::vector loaders; + std::vector colors; + std::vector rendering_modes; + for(int i = 0; i < scene->numberOfEntries(); ++i) + { + Scene_item* item = scene->item(i); + QString loader = item->property("loader_name").toString(); + QString source = item->property("source filename").toString(); + if(loader.isEmpty()) + continue; + names.push_back(source); + loaders.push_back(loader); + colors.push_back(item->color()); + rendering_modes.push_back(item->renderingMode()); + } + //path + os << "var camera = \""<dumpCameraCoordinates().toStdString()<<"\";\n"; + os << "var items = ["; + for(std::size_t i = 0; i< names.size() -1; ++i) + { + os << "\'" << names[i].toStdString() << "\', "; + } + os<<"\'"< + @@ -551,6 +552,11 @@ Set Transparency &Pass Number + + + Sa&ve the Scene as a Script File... + + diff --git a/Three/include/CGAL/Three/Scene_item.h b/Three/include/CGAL/Three/Scene_item.h index 1b00fea5fc4..3d668298688 100644 --- a/Three/include/CGAL/Three/Scene_item.h +++ b/Three/include/CGAL/Three/Scene_item.h @@ -316,7 +316,7 @@ public Q_SLOTS: virtual void setColor(QColor c) { color_ = c;} //!Setter for the RGB color of the item. Calls setColor(QColor). //!@see setColor(QColor c) - void setRbgColor(int r, int g, int b) { setColor(QColor(r, g, b)); } + virtual void setRgbColor(int r, int g, int b) { setColor(QColor(r, g, b)); } //!Sets the name of the item. virtual void setName(QString n) { name_ = n; } //!Sets the visibility of the item. @@ -325,6 +325,7 @@ public Q_SLOTS: //!This function is called by `Scene::changeGroup` and should not be //!called manually. virtual void moveToGroup(Scene_group_item* group); + void setRenderingMode(int m) { setRenderingMode((RenderingMode)m);} //!Sets the rendering mode of the item. //!@see RenderingMode virtual void setRenderingMode(RenderingMode m) {