QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RMainWindow.h
Go to the documentation of this file.
1
20#ifndef RMAINWINDOW_H
21#define RMAINWINDOW_H
22
23#include "core_global.h"
24
25#include <QMutex>
26class QKeyEvent;
27
28#include "RMainWindowProxy.h"
29#include "RMessageHandler.h"
30#include "RObject.h"
31#include "RProgressHandler.h"
32#include "RS.h"
33
34class RBlockListener;
36class RDocument;
38class REntity;
40class RExporter;
41class RExportListener;
42class RFocusListener;
43class RGraphicsView;
44class RImportListener;
46class RKeyListener;
47class RLayerListener;
50class RPenListener;
51class RPropertyEvent;
53class RPropertyTypeId;
56class RSnapListener;
57class RTransaction;
59class RUcsListener;
60class RVector;
62class RViewListener;
63
64#ifndef RDEFAULT_MINUS_ONE
65#define RDEFAULT_MINUS_ONE -1
66#endif
67
75
76public:
78 virtual ~RMainWindow();
79
80 static RMainWindow* getMainWindow();
81
82 static bool hasMainWindow();
83
84 static void installMessageHandler();
85
90 virtual RDocument* getDocument() = 0;
91
92 virtual void disable() {}
93 virtual void enable() {}
94
100 static RDocumentInterface* getDocumentInterfaceStatic();
101
102 void notifyListeners(bool withNull = false);
103
104 void addCoordinateListener(RCoordinateListener* l);
105 void removeCoordinateListener(RCoordinateListener* l);
106 void notifyCoordinateListeners(RDocumentInterface* documentInterface);
107
108 void addSelectionListener(RSelectionListener* l);
109 void removeSelectionListener(RSelectionListener* l);
110 void notifySelectionListeners(RDocumentInterface* documentInterface);
111
112 virtual void postSelectionChangedEvent() = 0;
114 RTransaction& t,
115 bool onlyChanges=false,
116 RS::EntityType entityTypeFilter = RS::EntityAll
117 ) = 0;
118 virtual void postCloseEvent() = 0;
119 //virtual void postPropertyEvent() = 0;
120 virtual void postPropertyEvent(RPropertyTypeId propertyTypeId,
121 const QVariant& value,
122 RS::EntityType entityTypeFilter = RS::EntityAll
123 ) = 0;
124
125 void addPropertyListener(RPropertyListener* l);
126 void removePropertyListener(RPropertyListener* l);
127 void notifyPropertyListeners(
128 RDocument* document,
129 bool onlyChanges=false,
130 RS::EntityType entityTypeFilter = RS::EntityUnknown
131 );
132 void notifyPropertyListeners(RDocument& document, REntity& entity);
133 void notifyPropertyListeners();
134
135 void addExportListener(RExportListener* l);
136 void removeExportListener(RExportListener* l);
137 void notifyExportListenersPre(RDocumentInterface* documentInterface);
138 void notifyExportListenersPost(RDocumentInterface* documentInterface);
139 void notifyExportListenersEnd(RExporter* exporter);
140
141 void addEntityExportListener(REntityExportListener* l);
142 void removeEntityExportListener(REntityExportListener* l);
143 void notifyEntityExportListeners(RExporter* exporter, REntity* entity);
144
145 void addImportListener(RImportListener* l);
146 void removeImportListener(RImportListener* l);
147 void notifyImportListenersPre(RDocumentInterface* documentInterface);
148 void notifyImportListenersPost(RDocumentInterface* documentInterface);
149
150 void addTransactionListener(RTransactionListener* l);
151 void removeTransactionListener(RTransactionListener* l);
152 void notifyTransactionListeners(RDocument* document, RTransaction* transaction = NULL);
153
154 void addInterTransactionListener(RInterTransactionListener* l);
155 void removeInterTransactionListener(RInterTransactionListener* l);
156 void notifyInterTransactionListeners(RDocument* document, RTransaction* transaction = NULL);
157
158 void addNewDocumentListener(RNewDocumentListener* l);
159 void removeNewDocumentListener(RNewDocumentListener* l);
160 void notifyNewDocumentListeners(RDocument* document, RTransaction* transaction, bool beforeLoad);
161
162 void addSnapListener(RSnapListener* l);
163 void removeSnapListener(RSnapListener* l);
164 void notifySnapListeners(RDocumentInterface* documentInterface);
165
166 void addFocusListener(RFocusListener* l);
167 void removeFocusListener(RFocusListener* l);
168 void notifyFocusListeners(RDocumentInterface* documentInterface);
169
170 void addKeyListener(RKeyListener* l);
171 void removeKeyListener(RKeyListener* l);
172 void notifyKeyListeners(QKeyEvent* event);
173
174 void addViewFocusListener(RViewFocusListener* l);
175 void removeViewFocusListener(RViewFocusListener* l);
176 void notifyViewFocusListeners(RGraphicsView* view);
177
178 void addPreferencesListener(RPreferencesListener* l);
179 void removePreferencesListener(RPreferencesListener* l);
180 void notifyPreferencesListeners(RDocumentInterface* documentInterface);
181
182 void propertyChangeEvent(RPropertyEvent& event);
183
184 void addUcsListener(RUcsListener* l);
185 void removeUcsListener(RUcsListener* l);
186 void notifyUcsListeners(RDocumentInterface* documentInterface);
187
188 void addLayerListener(RLayerListener* l);
189 void removeLayerListener(RLayerListener* l);
190 void notifyLayerListeners(RDocumentInterface* documentInterface, QList<RObject::Id>& layerIds);
191 void notifyLayerListenersCurrentLayer(RDocumentInterface* documentInterface, RObject::Id previousLayerId);
192
193 void addBlockListener(RBlockListener* l);
194 void removeBlockListener(RBlockListener* l);
195 void notifyBlockListeners(RDocumentInterface* documentInterface);
196 void notifyBlockListenersCurrentBlock(RDocumentInterface* documentInterface);
197
198 void addViewListener(RViewListener* l);
199 void removeViewListener(RViewListener* l);
200 void notifyViewListeners(RDocumentInterface* documentInterface);
201
202 void addPenListener(RPenListener* l);
203 void removePenListener(RPenListener* l);
204 void notifyPenListeners(RDocumentInterface* documentInterface);
205
206 void addPaletteListener(RPaletteListener* l);
207 void removePaletteListener(RPaletteListener* l);
208 void notifyPaletteListeners();
209
210 void ucsSetEvent(const QString& ucsName);
211
212 //void commandEvent(const QString& command);
213
214 virtual void escapeEvent() = 0;
215
221 virtual void setGraphicsViewCursor(const QCursor& cursor) = 0;
222
226 virtual int getWidth() = 0;
230 virtual int getHeight() = 0;
235 virtual int getPositionX() = 0;
240 virtual int getPositionY() = 0;
241
245 virtual void resize(int width, int height) = 0;
249 virtual void move(int x, int y) = 0;
253 virtual void quit() = 0;
254
255 virtual QWidget* getChildWidget(const QString& name) = 0;
256
257 virtual void handleUserMessage(const QString& message, bool escape = true) {
258 Q_UNUSED(escape);
259
260 qDebug() << message;
261 }
262
263 virtual void handleUserInfo(const QString& message, bool escape = true) {
264 Q_UNUSED(escape);
265
266 qDebug() << message;
267 }
268
269 virtual void handleUserWarning(const QString& message, bool messageBox = false, bool escape = true) {
270 Q_UNUSED(messageBox);
271 Q_UNUSED(escape);
272
273 qWarning() << message;
274 }
275
276 virtual void handleUserCommand(const QString& message, bool escape = true) {
277 Q_UNUSED(escape);
278
279 qDebug() << "Command: " << message;
280 }
281
282#if QT_VERSION >= 0x050000
286 static void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message);
287#else
291 static void messageHandler(QtMsgType type, const char* msg);
292#endif
293
294 virtual void setCommandPrompt(const QString& text = "") = 0;
295 virtual void setLeftMouseTip(const QString& text = "") = 0;
296 virtual void setRightMouseTip(const QString& text = "") = 0;
297
298 QVariant eval(const QString& ext, const QString& script);
299
300 static bool hasProxy() {
301 return mainWindowProxy!=NULL;
302 }
303
308 if (mainWindowProxy!=NULL) {
309 delete mainWindowProxy;
310 }
311 mainWindowProxy = p;
312 }
313
318 return mainWindowProxy;
319 }
320
321protected:
322 virtual bool readSettings();
323 virtual void writeSettings();
324
325protected:
327
328 QList<RCoordinateListener*> coordinateListeners;
329 QList<RSelectionListener*> selectionListeners;
330 QList<RPropertyListener*> propertyListeners;
331 QList<RUcsListener*> ucsListeners;
332 QList<RLayerListener*> layerListeners;
333 QList<RBlockListener*> blockListeners;
334 QList<RViewListener*> viewListeners;
335 QList<RPenListener*> penListeners;
336 QList<RPaletteListener*> paletteListeners;
337 QList<REntityExportListener*> entityExportListeners;
338 QList<RExportListener*> exportListeners;
339 QList<RImportListener*> importListeners;
340 QList<RTransactionListener*> transactionListeners;
341 QList<RInterTransactionListener*> interTransactionListeners;
342 QList<RNewDocumentListener*> newDocumentListeners;
343 QList<RSnapListener*> snapListeners;
344 QList<RKeyListener*> keyListeners;
345 QList<RFocusListener*> focusListeners;
346 QList<RViewFocusListener*> viewFocusListeners;
347 QList<RPreferencesListener*> preferencesListeners;
348
349 QMutex mutex;
350
352};
353
355
356#endif
Q_DECLARE_METATYPE(RMath *)
Abstract base class for classes that are interested in being notified whenever a block has been added...
Definition RBlockListener.h:37
Abstract base class for classes that are interested in the current coordinate of the mouse cursor.
Definition RCoordinateListener.h:38
A graphics document contains and owns entities, layers, user coordinate systems, variables,...
Definition RDocument.h:78
Interface for interaction between a graphics document and a user.
Definition RDocumentInterface.h:97
Abstract base class for classes that wish to be notified when an entity is exported.
Definition REntityExportListener.h:40
Base class for all entity classes.
Definition REntity.h:63
Abstract base class for classes that are interested in file export events.
Definition RExportListener.h:37
Abstract base class for exporters.
Definition RExporter.h:78
Abstract base class for classes that are interested in the current focus.
Definition RFocusListener.h:36
Graphics view.
Definition RGraphicsView.h:67
Abstract base class for classes that are interested in file import events.
Definition RImportListener.h:38
Abstract base class for classes that are interested in transactions in progress.
Definition RInterTransactionListener.h:41
Abstract base class for classes that are interested in key events.
Definition RKeyListener.h:33
Abstract base class for classes that are interested in being notified whenever a layer has been added...
Definition RLayerListener.h:39
Base class for an MDI main application window.
Definition RMainWindow.h:74
QList< RViewFocusListener * > viewFocusListeners
Definition RMainWindow.h:346
static RMainWindowProxy * getMainWindowProxy()
Definition RMainWindow.h:317
QList< RFocusListener * > focusListeners
Definition RMainWindow.h:345
virtual void postCloseEvent()=0
QList< RTransactionListener * > transactionListeners
Definition RMainWindow.h:340
virtual int getPositionY()=0
virtual void handleUserCommand(const QString &message, bool escape=true)
Definition RMainWindow.h:276
QList< RViewListener * > viewListeners
Definition RMainWindow.h:334
virtual int getWidth()=0
virtual void resize(int width, int height)=0
Resizes the application window to the given width and height.
QList< RSelectionListener * > selectionListeners
Definition RMainWindow.h:329
QMutex mutex
Definition RMainWindow.h:349
QList< RPropertyListener * > propertyListeners
Definition RMainWindow.h:330
virtual void move(int x, int y)=0
Moves the application window to the given x / y position.
virtual void disable()
Definition RMainWindow.h:92
QList< RBlockListener * > blockListeners
Definition RMainWindow.h:333
virtual void postSelectionChangedEvent()=0
static RMainWindowProxy * mainWindowProxy
Definition RMainWindow.h:351
virtual RDocument * getDocument()=0
virtual void handleUserWarning(const QString &message, bool messageBox=false, bool escape=true)
Definition RMainWindow.h:269
QList< RInterTransactionListener * > interTransactionListeners
Definition RMainWindow.h:341
QList< RPreferencesListener * > preferencesListeners
Definition RMainWindow.h:347
virtual QWidget * getChildWidget(const QString &name)=0
virtual void setCommandPrompt(const QString &text="")=0
static RMainWindow * mainWindow
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RMainWindow.h:326
static void setMainWindowProxy(RMainWindowProxy *p)
Definition RMainWindow.h:307
virtual void setGraphicsViewCursor(const QCursor &cursor)=0
Sets the cursor of all graphics views in all MDI children.
QList< RImportListener * > importListeners
Definition RMainWindow.h:339
QList< RNewDocumentListener * > newDocumentListeners
Definition RMainWindow.h:342
static bool hasProxy()
Definition RMainWindow.h:300
QList< RSnapListener * > snapListeners
Definition RMainWindow.h:343
virtual RDocumentInterface * getDocumentInterface()=0
virtual void handleUserInfo(const QString &message, bool escape=true)
Definition RMainWindow.h:263
virtual void quit()=0
Closes the application window.
QList< RCoordinateListener * > coordinateListeners
Definition RMainWindow.h:328
QList< RPenListener * > penListeners
Definition RMainWindow.h:335
virtual int getPositionX()=0
virtual void postTransactionEvent(RTransaction &t, bool onlyChanges=false, RS::EntityType entityTypeFilter=RS::EntityAll)=0
virtual void postPropertyEvent(RPropertyTypeId propertyTypeId, const QVariant &value, RS::EntityType entityTypeFilter=RS::EntityAll)=0
virtual void escapeEvent()=0
QList< RKeyListener * > keyListeners
Definition RMainWindow.h:344
virtual void setRightMouseTip(const QString &text="")=0
QList< REntityExportListener * > entityExportListeners
Definition RMainWindow.h:337
QList< RUcsListener * > ucsListeners
Definition RMainWindow.h:331
QList< RPaletteListener * > paletteListeners
Definition RMainWindow.h:336
virtual void handleUserMessage(const QString &message, bool escape=true)
Definition RMainWindow.h:257
QList< RLayerListener * > layerListeners
Definition RMainWindow.h:332
virtual void enable()
Definition RMainWindow.h:93
virtual int getHeight()=0
QList< RExportListener * > exportListeners
Definition RMainWindow.h:338
virtual void setLeftMouseTip(const QString &text="")=0
Definition RMainWindowProxy.h:8
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RMessageHandler.h:33
Abstract base class for classes that are interested in being notified when a new document is created.
Definition RNewDocumentListener.h:37
int Id
Definition RObject.h:69
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RPaletteListener.h:33
Abstract base class for classes that are interested in being notified whenever the current pen change...
Definition RPenListener.h:37
Abstract base class for classes that are interested in changes in drawing or application preferences.
Definition RPreferencesListener.h:36
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RProgressHandler.h:33
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RPropertyEvent.h:40
Abstract base class for classes that are interested in properties of the current selection or the cur...
Definition RPropertyListener.h:43
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RPropertyTypeId.h:54
EntityType
Entity types used for property handling / filtering.
Definition RS.h:227
@ EntityAll
All entities (for filters)
Definition RS.h:241
@ EntityUnknown
Unknown entity.
Definition RS.h:242
Abstract base class for classes that are interested in the current selection and want to be notified ...
Definition RSelectionListener.h:36
Abstract base class for classes that are interested in the current snap mode.
Definition RSnapListener.h:39
Transaction implementation.
Definition RTransaction.h:73
Abstract base class for classes that want to be notified on every transaction (objects added,...
Definition RTransactionListener.h:40
Abstract base class for classes that are interested in being notified whenever a UCS has been added o...
Definition RUcsListener.h:36
Represents a 3d vector (x/y/z).
Definition RVector.h:47
Abstract base class for classes that are interested in the current view focus.
Definition RViewFocusListener.h:36
Abstract base class for classes that are interested in being notified whenever a view has been added ...
Definition RViewListener.h:37
#define QCADCORE_EXPORT
Definition core_global.h:10
void getMainWindow()
Definition library.js:357
#define NULL
Definition opennurbs_system.h:256