2009-12-09 17:25:09 +03:00
|
|
|
#ifndef MAINWINDOW_H_
|
|
|
|
#define MAINWINDOW_H_
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include "ui_MainWindow.h"
|
|
|
|
#include "openscad.h"
|
2013-04-09 08:28:16 +04:00
|
|
|
#include "modcontext.h"
|
2010-01-30 07:26:05 +03:00
|
|
|
#include "module.h"
|
2010-07-12 01:29:01 +04:00
|
|
|
#include "Tree.h"
|
2011-12-06 04:16:54 +04:00
|
|
|
#include "memory.h"
|
2010-09-07 04:02:22 +04:00
|
|
|
#include <vector>
|
2011-12-26 02:00:30 +04:00
|
|
|
#include <QMutex>
|
2009-12-09 17:25:09 +03:00
|
|
|
|
|
|
|
class MainWindow : public QMainWindow, public Ui::MainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2009-12-13 00:27:54 +03:00
|
|
|
static void requestOpenFile(const QString &filename);
|
2009-12-09 17:25:09 +03:00
|
|
|
|
2009-12-13 23:24:15 +03:00
|
|
|
QString fileName;
|
2009-12-09 17:25:09 +03:00
|
|
|
class Highlighter *highlighter;
|
|
|
|
|
2010-01-15 04:02:28 +03:00
|
|
|
class Preferences *prefs;
|
|
|
|
|
2009-12-09 17:25:09 +03:00
|
|
|
QTimer *animate_timer;
|
|
|
|
double tval, fps, fsteps;
|
|
|
|
|
2010-05-09 17:27:05 +04:00
|
|
|
QTimer *autoReloadTimer;
|
2012-02-14 04:30:39 +04:00
|
|
|
std::string autoReloadId;
|
2013-05-28 09:25:03 +04:00
|
|
|
QTimer *waitAfterReloadTimer;
|
2010-05-09 17:27:05 +04:00
|
|
|
|
2013-04-24 17:17:25 +04:00
|
|
|
ModuleContext top_ctx;
|
2013-04-20 01:52:01 +04:00
|
|
|
FileModule *root_module; // Result of parsing
|
2010-01-10 01:43:33 +03:00
|
|
|
ModuleInstantiation root_inst; // Top level instance
|
2010-01-07 00:35:01 +03:00
|
|
|
AbstractNode *absolute_root_node; // Result of tree evaluation
|
|
|
|
AbstractNode *root_node; // Root if the root modifier (!) is used
|
2010-07-12 01:29:01 +04:00
|
|
|
Tree tree;
|
2010-01-07 00:35:01 +03:00
|
|
|
|
2011-12-06 04:16:54 +04:00
|
|
|
shared_ptr<class CSGTerm> root_raw_term; // Result of CSG term rendering
|
|
|
|
shared_ptr<CSGTerm> root_norm_term; // Normalized CSG products
|
2010-01-30 07:26:05 +03:00
|
|
|
class CSGChain *root_chain;
|
2009-12-09 17:25:09 +03:00
|
|
|
#ifdef ENABLE_CGAL
|
2010-01-30 07:26:05 +03:00
|
|
|
class CGAL_Nef_polyhedron *root_N;
|
2011-07-30 23:29:40 +04:00
|
|
|
class CGALRenderer *cgalRenderer;
|
2009-12-09 17:25:09 +03:00
|
|
|
#endif
|
2011-07-30 23:29:40 +04:00
|
|
|
#ifdef ENABLE_OPENCSG
|
|
|
|
class OpenCSGRenderer *opencsgRenderer;
|
|
|
|
#endif
|
|
|
|
class ThrownTogetherRenderer *thrownTogetherRenderer;
|
2009-12-09 17:25:09 +03:00
|
|
|
|
2011-12-06 04:16:54 +04:00
|
|
|
std::vector<shared_ptr<CSGTerm> > highlight_terms;
|
2009-12-09 17:25:09 +03:00
|
|
|
CSGChain *highlights_chain;
|
2011-12-06 04:16:54 +04:00
|
|
|
std::vector<shared_ptr<CSGTerm> > background_terms;
|
2009-12-09 17:25:09 +03:00
|
|
|
CSGChain *background_chain;
|
|
|
|
QString last_compiled_doc;
|
2013-10-04 07:21:26 +04:00
|
|
|
static QString qexamplesdir;
|
2009-12-09 17:25:09 +03:00
|
|
|
|
2009-12-13 23:24:15 +03:00
|
|
|
static const int maxRecentFiles = 10;
|
|
|
|
QAction *actionRecentFile[maxRecentFiles];
|
|
|
|
|
2013-10-04 07:21:26 +04:00
|
|
|
MainWindow(const QString &filename);
|
2009-12-09 17:25:09 +03:00
|
|
|
~MainWindow();
|
|
|
|
|
2009-12-14 07:24:51 +03:00
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *event);
|
|
|
|
|
2009-12-09 17:25:09 +03:00
|
|
|
private slots:
|
|
|
|
void updatedFps();
|
|
|
|
void updateTVal();
|
2009-12-13 23:24:15 +03:00
|
|
|
void setFileName(const QString &filename);
|
2010-01-22 15:28:30 +03:00
|
|
|
void setFont(const QString &family, uint size);
|
2010-02-12 18:43:56 +03:00
|
|
|
void showProgress();
|
2012-01-14 04:22:46 +04:00
|
|
|
void openCSGSettingsChanged();
|
2009-12-09 17:25:09 +03:00
|
|
|
|
|
|
|
private:
|
2009-12-13 00:27:54 +03:00
|
|
|
void openFile(const QString &filename);
|
2012-02-14 04:30:39 +04:00
|
|
|
void refreshDocument();
|
|
|
|
void updateTemporalVariables();
|
|
|
|
bool fileChangedOnDisk();
|
2013-05-28 09:25:03 +04:00
|
|
|
void compileTopLevelDocument();
|
|
|
|
void compile(bool reload, bool forcedone = false);
|
2010-02-09 16:48:09 +03:00
|
|
|
void compileCSG(bool procevents);
|
2009-12-14 07:24:51 +03:00
|
|
|
bool maybeSave();
|
2012-02-22 16:50:38 +04:00
|
|
|
bool checkEditorModified();
|
2010-04-12 04:16:36 +04:00
|
|
|
QString dumpCSGTree(AbstractNode *root);
|
2011-12-26 02:00:30 +04:00
|
|
|
static void consoleOutput(const std::string &msg, void *userdata);
|
2011-07-04 00:57:07 +04:00
|
|
|
void loadViewSettings();
|
2011-07-06 03:07:26 +04:00
|
|
|
void loadDesignSettings();
|
2009-12-09 17:25:09 +03:00
|
|
|
|
2013-02-21 15:49:19 +04:00
|
|
|
class QMessageBox *openglbox;
|
2011-12-09 06:43:06 +04:00
|
|
|
|
2009-12-09 17:25:09 +03:00
|
|
|
private slots:
|
2013-02-05 09:36:25 +04:00
|
|
|
void actionUpdateCheck();
|
2009-12-09 17:25:09 +03:00
|
|
|
void actionNew();
|
|
|
|
void actionOpen();
|
2009-12-13 23:24:15 +03:00
|
|
|
void actionOpenRecent();
|
2010-01-22 18:20:52 +03:00
|
|
|
void actionOpenExample();
|
2011-09-08 11:52:02 +04:00
|
|
|
void updateRecentFiles();
|
2009-12-13 23:24:15 +03:00
|
|
|
void clearRecentFiles();
|
|
|
|
void updateRecentFileActions();
|
2009-12-09 17:25:09 +03:00
|
|
|
void actionSave();
|
|
|
|
void actionSaveAs();
|
|
|
|
void actionReload();
|
2013-05-22 02:02:16 +04:00
|
|
|
void actionShowLibraryFolder();
|
2009-12-09 17:25:09 +03:00
|
|
|
|
2013-05-28 09:25:03 +04:00
|
|
|
void instantiateRoot();
|
|
|
|
void compileDone(bool didchange);
|
|
|
|
void compileEnded();
|
|
|
|
|
2009-12-09 17:25:09 +03:00
|
|
|
private slots:
|
|
|
|
void pasteViewportTranslation();
|
|
|
|
void pasteViewportRotation();
|
2009-12-20 15:48:32 +03:00
|
|
|
void hideEditor();
|
2010-01-15 04:02:28 +03:00
|
|
|
void preferences();
|
2009-12-09 17:25:09 +03:00
|
|
|
|
|
|
|
private slots:
|
2013-05-28 09:25:03 +04:00
|
|
|
void actionRenderCSG();
|
|
|
|
void csgRender();
|
|
|
|
void csgReloadRender();
|
2009-12-09 17:25:09 +03:00
|
|
|
#ifdef ENABLE_CGAL
|
|
|
|
void actionRenderCGAL();
|
2011-12-26 02:00:30 +04:00
|
|
|
void actionRenderCGALDone(class CGAL_Nef_polyhedron *);
|
2013-05-28 09:25:03 +04:00
|
|
|
void cgalRender();
|
2009-12-09 17:25:09 +03:00
|
|
|
#endif
|
|
|
|
void actionDisplayAST();
|
|
|
|
void actionDisplayCSGTree();
|
|
|
|
void actionDisplayCSGProducts();
|
|
|
|
void actionExportSTLorOFF(bool stl_mode);
|
|
|
|
void actionExportSTL();
|
|
|
|
void actionExportOFF();
|
2010-01-06 05:04:49 +03:00
|
|
|
void actionExportDXF();
|
2011-10-19 19:35:14 +04:00
|
|
|
void actionExportCSG();
|
2011-06-05 22:05:55 +04:00
|
|
|
void actionExportImage();
|
2010-01-08 00:08:47 +03:00
|
|
|
void actionFlushCaches();
|
2009-12-09 17:25:09 +03:00
|
|
|
|
|
|
|
public:
|
2013-10-04 07:21:26 +04:00
|
|
|
static void setExamplesDir(const QString &dir) { MainWindow::qexamplesdir = dir; }
|
2009-12-09 17:25:09 +03:00
|
|
|
void viewModeActionsUncheck();
|
2010-02-28 23:54:55 +03:00
|
|
|
void setCurrentOutput();
|
|
|
|
void clearCurrentOutput();
|
2009-12-09 17:25:09 +03:00
|
|
|
|
|
|
|
public slots:
|
2013-05-28 09:25:03 +04:00
|
|
|
void actionReloadRenderCSG();
|
2009-12-09 17:25:09 +03:00
|
|
|
#ifdef ENABLE_OPENCSG
|
|
|
|
void viewModeOpenCSG();
|
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_CGAL
|
|
|
|
void viewModeCGALSurface();
|
|
|
|
void viewModeCGALGrid();
|
|
|
|
#endif
|
|
|
|
void viewModeThrownTogether();
|
|
|
|
void viewModeShowEdges();
|
|
|
|
void viewModeShowAxes();
|
|
|
|
void viewModeShowCrosshairs();
|
|
|
|
void viewModeAnimate();
|
|
|
|
void viewAngleTop();
|
|
|
|
void viewAngleBottom();
|
|
|
|
void viewAngleLeft();
|
|
|
|
void viewAngleRight();
|
|
|
|
void viewAngleFront();
|
|
|
|
void viewAngleBack();
|
|
|
|
void viewAngleDiagonal();
|
|
|
|
void viewCenter();
|
|
|
|
void viewPerspective();
|
|
|
|
void viewOrthogonal();
|
2013-11-01 01:54:05 +04:00
|
|
|
void viewResetView();
|
2009-12-20 15:48:32 +03:00
|
|
|
void hideConsole();
|
2009-12-09 17:25:09 +03:00
|
|
|
void animateUpdateDocChanged();
|
|
|
|
void animateUpdate();
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
void dropEvent(QDropEvent *event);
|
2009-12-13 01:04:32 +03:00
|
|
|
void helpAbout();
|
2010-02-20 13:20:18 +03:00
|
|
|
void helpHomepage();
|
2009-12-13 01:19:53 +03:00
|
|
|
void helpManual();
|
2012-02-15 04:26:38 +04:00
|
|
|
void helpLibrary();
|
2010-01-26 00:39:34 +03:00
|
|
|
void quit();
|
2010-05-09 17:27:05 +04:00
|
|
|
void checkAutoReload();
|
2013-05-28 09:25:03 +04:00
|
|
|
void waitAfterReload();
|
2010-05-09 17:27:05 +04:00
|
|
|
void autoReloadSet(bool);
|
2011-12-26 02:00:30 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
static void report_func(const class AbstractNode*, void *vp, int mark);
|
|
|
|
|
2013-05-28 09:25:03 +04:00
|
|
|
char const * afterCompileSlot;
|
|
|
|
bool procevents;
|
|
|
|
|
2011-12-26 02:00:30 +04:00
|
|
|
class ProgressWidget *progresswidget;
|
|
|
|
class CGALWorker *cgalworker;
|
|
|
|
QMutex consolemutex;
|
2009-12-09 17:25:09 +03:00
|
|
|
};
|
|
|
|
|
2010-11-06 18:03:01 +03:00
|
|
|
class GuiLocker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GuiLocker() {
|
|
|
|
gui_locked++;
|
|
|
|
}
|
|
|
|
~GuiLocker() {
|
|
|
|
gui_locked--;
|
|
|
|
}
|
|
|
|
static bool isLocked() { return gui_locked > 0; }
|
2011-12-26 02:00:30 +04:00
|
|
|
static void lock() { gui_locked++; }
|
|
|
|
static void unlock() { gui_locked--; }
|
2010-11-06 18:03:01 +03:00
|
|
|
|
|
|
|
private:
|
2013-10-04 07:21:26 +04:00
|
|
|
static unsigned int gui_locked;
|
2010-11-06 18:03:01 +03:00
|
|
|
};
|
|
|
|
|
2009-12-09 17:25:09 +03:00
|
|
|
#endif
|