blob: e16f5b457b9f76dea2f5151b0b536ccd4cac5bb7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_
#include <QMainWindow>
#include "ui_MainWindow.h"
#include "openscad.h"
#include "modcontext.h"
#include "module.h"
#include "Tree.h"
#include "memory.h"
#include <vector>
#include <QMutex>
class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
static void requestOpenFile(const QString &filename);
QString fileName;
class Highlighter *highlighter;
class Preferences *prefs;
QTimer *animate_timer;
double tval, fps, fsteps;
QTimer *autoReloadTimer;
std::string autoReloadId;
QTimer *waitAfterReloadTimer;
ModuleContext top_ctx;
FileModule *root_module; // Result of parsing
ModuleInstantiation root_inst; // Top level instance
AbstractNode *absolute_root_node; // Result of tree evaluation
AbstractNode *root_node; // Root if the root modifier (!) is used
Tree tree;
shared_ptr<class CSGTerm> root_raw_term; // Result of CSG term rendering
shared_ptr<CSGTerm> root_norm_term; // Normalized CSG products
class CSGChain *root_chain;
#ifdef ENABLE_CGAL
class CGAL_Nef_polyhedron *root_N;
class CGALRenderer *cgalRenderer;
#endif
#ifdef ENABLE_OPENCSG
class OpenCSGRenderer *opencsgRenderer;
#endif
class ThrownTogetherRenderer *thrownTogetherRenderer;
std::vector<shared_ptr<CSGTerm> > highlight_terms;
CSGChain *highlights_chain;
std::vector<shared_ptr<CSGTerm> > background_terms;
CSGChain *background_chain;
QString last_compiled_doc;
static QString qexamplesdir;
static const int maxRecentFiles = 10;
QAction *actionRecentFile[maxRecentFiles];
MainWindow(const QString &filename);
~MainWindow();
protected:
void closeEvent(QCloseEvent *event);
private slots:
void updatedFps();
void updateTVal();
void setFileName(const QString &filename);
void setFont(const QString &family, uint size);
void setSyntaxHighlight(const QString &s);
void showProgress();
void openCSGSettingsChanged();
private:
void openFile(const QString &filename);
void refreshDocument();
void updateTemporalVariables();
bool fileChangedOnDisk();
void compileTopLevelDocument();
void compile(bool reload, bool forcedone = false);
void compileCSG(bool procevents);
bool maybeSave();
bool checkEditorModified();
QString dumpCSGTree(AbstractNode *root);
static void consoleOutput(const std::string &msg, void *userdata);
void loadViewSettings();
void loadDesignSettings();
class QMessageBox *openglbox;
private slots:
void actionUpdateCheck();
void actionNew();
void actionOpen();
void actionOpenRecent();
void actionOpenExample();
void updateRecentFiles();
void clearRecentFiles();
void updateRecentFileActions();
void actionSave();
void actionSaveAs();
void actionReload();
void actionShowLibraryFolder();
void instantiateRoot();
void compileDone(bool didchange);
void compileEnded();
private slots:
void pasteViewportTranslation();
void pasteViewportRotation();
void hideEditor();
void preferences();
private slots:
void actionRenderCSG();
void selectFindType(int);
void find();
void findAndReplace();
void findNext();
void findPrev();
void useSelectionForFind();
void replace();
void replaceAll();
protected:
bool findOperation(QTextDocument::FindFlags options = 0);
virtual bool eventFilter(QObject* obj, QEvent *event);
private slots:
void csgRender();
void csgReloadRender();
#ifdef ENABLE_CGAL
void actionRenderCGAL();
void actionRenderCGALDone(class CGAL_Nef_polyhedron *);
void cgalRender();
#endif
void actionDisplayAST();
void actionDisplayCSGTree();
void actionDisplayCSGProducts();
void actionExportSTLorOFF(bool stl_mode);
void actionExportSTL();
void actionExportOFF();
void actionExportDXF();
void actionExportCSG();
void actionExportImage();
void actionFlushCaches();
public:
static void setExamplesDir(const QString &dir) { MainWindow::qexamplesdir = dir; }
void viewModeActionsUncheck();
void setCurrentOutput();
void clearCurrentOutput();
public slots:
void actionReloadRenderCSG();
#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();
void viewResetView();
void hideConsole();
void animateUpdateDocChanged();
void animateUpdate();
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void helpAbout();
void helpHomepage();
void helpManual();
void helpLibrary();
void quit();
void checkAutoReload();
void waitAfterReload();
void autoReloadSet(bool);
private:
static void report_func(const class AbstractNode*, void *vp, int mark);
char const * afterCompileSlot;
bool procevents;
class ProgressWidget *progresswidget;
class CGALWorker *cgalworker;
QMutex consolemutex;
};
class GuiLocker
{
public:
GuiLocker() {
gui_locked++;
}
~GuiLocker() {
gui_locked--;
}
static bool isLocked() { return gui_locked > 0; }
static void lock() { gui_locked++; }
static void unlock() { gui_locked--; }
private:
static unsigned int gui_locked;
};
#endif
|