Handle shared_ptr in signals/slots

customizer
Marius Kintel 2013-12-14 12:54:36 -05:00
parent 1ef92f55f2
commit f4ae95d9e5
3 changed files with 16 additions and 14 deletions

View File

@ -41,7 +41,7 @@ public:
shared_ptr<CSGTerm> root_norm_term; // Normalized CSG products shared_ptr<CSGTerm> root_norm_term; // Normalized CSG products
class CSGChain *root_chain; class CSGChain *root_chain;
#ifdef ENABLE_CGAL #ifdef ENABLE_CGAL
class CGAL_Nef_polyhedron *root_N; shared_ptr<const class CGAL_Nef_polyhedron> root_N;
class CGALRenderer *cgalRenderer; class CGALRenderer *cgalRenderer;
#endif #endif
#ifdef ENABLE_OPENCSG #ifdef ENABLE_OPENCSG
@ -121,7 +121,7 @@ private slots:
void csgReloadRender(); void csgReloadRender();
#ifdef ENABLE_CGAL #ifdef ENABLE_CGAL
void actionRenderCGAL(); void actionRenderCGAL();
void actionRenderCGALDone(class CGAL_Nef_polyhedron *); void actionRenderCGALDone(shared_ptr<const class CGAL_Nef_polyhedron>);
void cgalRender(); void cgalRender();
#endif #endif
void actionDisplayAST(); void actionDisplayAST();

View File

@ -160,8 +160,8 @@ MainWindow::MainWindow(const QString &filename)
#ifdef ENABLE_CGAL #ifdef ENABLE_CGAL
this->cgalworker = new CGALWorker(); this->cgalworker = new CGALWorker();
connect(this->cgalworker, SIGNAL(done(CGAL_Nef_polyhedron *)), connect(this->cgalworker, SIGNAL(done(shared_ptr<const CGAL_Nef_polyhedron>)),
this, SLOT(actionRenderCGALDone(CGAL_Nef_polyhedron *))); this, SLOT(actionRenderCGALDone(shared_ptr<const CGAL_Nef_polyhedron>)));
#endif #endif
top_ctx.registerBuiltin(); top_ctx.registerBuiltin();
@ -171,7 +171,6 @@ MainWindow::MainWindow(const QString &filename)
absolute_root_node = NULL; absolute_root_node = NULL;
this->root_chain = NULL; this->root_chain = NULL;
#ifdef ENABLE_CGAL #ifdef ENABLE_CGAL
this->root_N = NULL;
this->cgalRenderer = NULL; this->cgalRenderer = NULL;
#endif #endif
#ifdef ENABLE_OPENCSG #ifdef ENABLE_OPENCSG
@ -447,7 +446,7 @@ MainWindow::~MainWindow()
if (root_module) delete root_module; if (root_module) delete root_module;
if (root_node) delete root_node; if (root_node) delete root_node;
#ifdef ENABLE_CGAL #ifdef ENABLE_CGAL
if (this->root_N) delete this->root_N; this->root_N.reset();
delete this->cgalRenderer; delete this->cgalRenderer;
#endif #endif
#ifdef ENABLE_OPENCSG #ifdef ENABLE_OPENCSG
@ -1290,10 +1289,7 @@ void MainWindow::cgalRender()
this->qglview->setRenderer(NULL); this->qglview->setRenderer(NULL);
delete this->cgalRenderer; delete this->cgalRenderer;
this->cgalRenderer = NULL; this->cgalRenderer = NULL;
if (this->root_N) { this->root_N.reset();
delete this->root_N;
this->root_N = NULL;
}
PRINT("Rendering Polygon Mesh using CGAL..."); PRINT("Rendering Polygon Mesh using CGAL...");
@ -1305,7 +1301,7 @@ void MainWindow::cgalRender()
this->cgalworker->start(this->tree); this->cgalworker->start(this->tree);
} }
void MainWindow::actionRenderCGALDone(CGAL_Nef_polyhedron *root_N) void MainWindow::actionRenderCGALDone(shared_ptr<const CGAL_Nef_polyhedron> root_N)
{ {
progress_report_fin(); progress_report_fin();
@ -1469,8 +1465,8 @@ void MainWindow::actionExportSTLorOFF(bool)
PRINTB("Can't open file \"%s\" for export", stl_filename.toLocal8Bit().constData()); PRINTB("Can't open file \"%s\" for export", stl_filename.toLocal8Bit().constData());
} }
else { else {
if (stl_mode) export_stl(this->root_N, fstream); if (stl_mode) export_stl(this->root_N.get(), fstream);
else export_off(this->root_N, fstream); else export_off(this->root_N.get(), fstream);
fstream.close(); fstream.close();
PRINTB("%s export finished.", (stl_mode ? "STL" : "OFF")); PRINTB("%s export finished.", (stl_mode ? "STL" : "OFF"));
@ -1522,7 +1518,7 @@ void MainWindow::actionExportDXF()
PRINTB("Can't open file \"%s\" for export", dxf_filename.toLocal8Bit().constData()); PRINTB("Can't open file \"%s\" for export", dxf_filename.toLocal8Bit().constData());
} }
else { else {
export_dxf(this->root_N, fstream); export_dxf(this->root_N.get(), fstream);
fstream.close(); fstream.close();
PRINT("DXF export finished."); PRINT("DXF export finished.");
} }

View File

@ -450,6 +450,9 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
#include <QApplication> #include <QApplication>
#include <QString> #include <QString>
#include <QDir> #include <QDir>
#include <QMetaType>
Q_DECLARE_METATYPE(shared_ptr<const CGAL_Nef_polyhedron>);
// Only if "fileName" is not absolute, prepend the "absoluteBase". // Only if "fileName" is not absolute, prepend the "absoluteBase".
static QString assemblePath(const fs::path& absoluteBase, static QString assemblePath(const fs::path& absoluteBase,
@ -491,6 +494,9 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
QCoreApplication::setOrganizationDomain("openscad.org"); QCoreApplication::setOrganizationDomain("openscad.org");
QCoreApplication::setApplicationName("OpenSCAD"); QCoreApplication::setApplicationName("OpenSCAD");
QCoreApplication::setApplicationVersion(TOSTRING(OPENSCAD_VERSION)); QCoreApplication::setApplicationVersion(TOSTRING(OPENSCAD_VERSION));
// Other global settings
qRegisterMetaType<shared_ptr<const CGAL_Nef_polyhedron> >();
const QString &app_path = app.applicationDirPath(); const QString &app_path = app.applicationDirPath();