QCAD
Open Source 2D CAD
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>
26 
27 #include "REntityExportListener.h"
28 #include "RExportListener.h"
29 #include "RImportListener.h"
31 #include "RTransactionListener.h"
32 #include "RPropertyEvent.h"
33 #include "RMessageHandler.h"
34 #include "RProgressHandler.h"
35 #include "RS.h"
36 
37 class RBlockListener;
39 class RDocument;
40 class RDocumentInterface;
41 class REntity;
42 class RFocusListener;
43 class RGraphicsView;
44 class RLayerListener;
46 class RPenListener;
47 class RPropertyListener;
49 class RSelectionListener;
50 class RSnapListener;
51 class RTransaction;
52 class RUcsListener;
53 class RVector;
54 class RViewFocusListener;
55 class RViewListener;
56 
57 #ifndef RDEFAULT_MINUS_ONE
58 #define RDEFAULT_MINUS_ONE -1
59 #endif
60 
68 
69 public:
70  RMainWindow();
71  virtual ~RMainWindow();
72 
73  static RMainWindow* getMainWindow();
74 
75  static bool hasMainWindow();
76 
77  static void installMessageHandler();
78 
83  virtual RDocument* getDocument() = 0;
84 
85  virtual void disable() {}
86  virtual void enable() {}
87 
93  static RDocumentInterface* getDocumentInterfaceStatic();
94 
95  void notifyListeners(bool withNull = false);
96 
97  void addCoordinateListener(RCoordinateListener* l);
98  void removeCoordinateListener(RCoordinateListener* l);
99  void notifyCoordinateListeners(RDocumentInterface* documentInterface);
100 
101  void addSelectionListener(RSelectionListener* l);
102  void removeSelectionListener(RSelectionListener* l);
103  void notifySelectionListeners(RDocumentInterface* documentInterface);
104 
105  virtual void postSelectionChangedEvent() = 0;
106  virtual void postTransactionEvent(
107  RTransaction& t,
108  bool onlyChanges=false,
109  RS::EntityType entityTypeFilter = RS::EntityAll
110  ) = 0;
111  virtual void postCloseEvent() = 0;
112  //virtual void postPropertyEvent() = 0;
113 // virtual void postPropertyEvent(RPropertyTypeId propertyTypeId,
114 // const QVariant& value,
115 // RS::EntityType entityTypeFilter = RS::EntityAll
116 // ) = 0;
117 
118  void addPropertyListener(RPropertyListener* l);
119  void removePropertyListener(RPropertyListener* l);
120  void notifyPropertyListeners(
121  RDocument* document,
122  bool onlyChanges=false,
123  RS::EntityType entityTypeFilter = RS::EntityUnknown
124  );
125  void notifyPropertyListeners(RDocument& document, REntity& entity);
126  void notifyPropertyListeners();
127 
128  void addExportListener(RExportListener* l);
129  void removeExportListener(RExportListener* l);
130  void notifyExportListenersPre(RDocumentInterface* documentInterface);
131  void notifyExportListenersPost(RDocumentInterface* documentInterface);
132  void notifyExportListenersEnd(RExporter* exporter);
133 
134  void addEntityExportListener(REntityExportListener* l);
135  void removeEntityExportListener(REntityExportListener* l);
136  void notifyEntityExportListeners(RExporter* exporter, REntity* entity);
137 
138  void addImportListener(RImportListener* l);
139  void removeImportListener(RImportListener* l);
140  void notifyImportListenersPre(RDocumentInterface* documentInterface);
141  void notifyImportListenersPost(RDocumentInterface* documentInterface);
142 
143  void addTransactionListener(RTransactionListener* l);
144  void removeTransactionListener(RTransactionListener* l);
145  void notifyTransactionListeners(RDocument* document, RTransaction* transaction = NULL);
146 
147  void addInterTransactionListener(RInterTransactionListener* l);
148  void removeInterTransactionListener(RInterTransactionListener* l);
149  void notifyInterTransactionListeners(RDocument* document, RTransaction* transaction = NULL);
150 
151  void addNewDocumentListener(RNewDocumentListener* l);
152  void removeNewDocumentListener(RNewDocumentListener* l);
153  void notifyNewDocumentListeners(RDocument* document, RTransaction* transaction);
154 
155  void addSnapListener(RSnapListener* l);
156  void removeSnapListener(RSnapListener* l);
157  void notifySnapListeners(RDocumentInterface* documentInterface);
158 
159  void addFocusListener(RFocusListener* l);
160  void removeFocusListener(RFocusListener* l);
161  void notifyFocusListeners(RDocumentInterface* documentInterface);
162 
163  void addViewFocusListener(RViewFocusListener* l);
164  void removeViewFocusListener(RViewFocusListener* l);
165  void notifyViewFocusListeners(RGraphicsView* view);
166 
167  void addPreferencesListener(RPreferencesListener* l);
168  void removePreferencesListener(RPreferencesListener* l);
169  void notifyPreferencesListeners(RDocumentInterface* documentInterface);
170 
171  void propertyChangeEvent(RPropertyEvent& event);
172 
173  void addUcsListener(RUcsListener* l);
174  void removeUcsListener(RUcsListener* l);
175  void notifyUcsListeners(RDocumentInterface* documentInterface);
176 
177  void addLayerListener(RLayerListener* l);
178  void removeLayerListener(RLayerListener* l);
179  void notifyLayerListeners(RDocumentInterface* documentInterface);
180  void notifyLayerListenersCurrentLayer(RDocumentInterface* documentInterface);
181 
182  void addBlockListener(RBlockListener* l);
183  void removeBlockListener(RBlockListener* l);
184  void notifyBlockListeners(RDocumentInterface* documentInterface);
185 
186  void addViewListener(RViewListener* l);
187  void removeViewListener(RViewListener* l);
188  void notifyViewListeners(RDocumentInterface* documentInterface);
189 
190  void addPenListener(RPenListener* l);
191  void removePenListener(RPenListener* l);
192  void notifyPenListeners(RDocumentInterface* documentInterface);
193 
194  void ucsSetEvent(const QString& ucsName);
195 
196  //void commandEvent(const QString& command);
197 
198  virtual void escapeEvent() = 0;
199 
205  virtual void setGraphicsViewCursor(const QCursor& cursor) = 0;
206 
210  virtual int getWidth() = 0;
214  virtual int getHeight() = 0;
219  virtual int getPositionX() = 0;
224  virtual int getPositionY() = 0;
225 
229  virtual void resize(int width, int height) = 0;
233  virtual void move(int x, int y) = 0;
237  virtual void quit() = 0;
238 
239  virtual QWidget* getChildWidget(const QString& name) = 0;
240 
241  virtual void handleUserMessage(const QString& message, bool escape = true) {
242  Q_UNUSED(escape);
243 
244  qDebug() << message;
245  }
246 
247  virtual void handleUserInfo(const QString& message, bool escape = true) {
248  Q_UNUSED(escape);
249 
250  qDebug() << message;
251  }
252 
253  virtual void handleUserWarning(const QString& message, bool messageBox = false, bool escape = true) {
254  Q_UNUSED(messageBox);
255  Q_UNUSED(escape);
256 
257  qWarning() << message;
258  }
259 
260  virtual void handleUserCommand(const QString& message, bool escape = true) {
261  Q_UNUSED(escape);
262 
263  qDebug() << "Command: " << message;
264  }
265 
266 #if QT_VERSION >= 0x050000
267 
270  static void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message);
271 #else
272 
275  static void messageHandler(QtMsgType type, const char* msg);
276 #endif
277 
278  virtual void setCommandPrompt(const QString& text = "") = 0;
279  virtual void setLeftMouseTip(const QString& text = "") = 0;
280  virtual void setRightMouseTip(const QString& text = "") = 0;
281 
282  QVariant eval(const QString& ext, const QString& script);
283 
284 protected:
285  virtual bool readSettings();
286  virtual void writeSettings();
287 
288 protected:
290 
291  QList<RCoordinateListener*> coordinateListeners;
292  QList<RSelectionListener*> selectionListeners;
293  QList<RPropertyListener*> propertyListeners;
294  QList<RUcsListener*> ucsListeners;
295  QList<RLayerListener*> layerListeners;
296  QList<RBlockListener*> blockListeners;
297  QList<RViewListener*> viewListeners;
298  QList<RPenListener*> penListeners;
299  QList<REntityExportListener*> entityExportListeners;
300  QList<RExportListener*> exportListeners;
301  QList<RImportListener*> importListeners;
302  QList<RTransactionListener*> transactionListeners;
303  QList<RInterTransactionListener*> interTransactionListeners;
304  QList<RNewDocumentListener*> newDocumentListeners;
305  QList<RSnapListener*> snapListeners;
306  QList<RFocusListener*> focusListeners;
307  QList<RViewFocusListener*> viewFocusListeners;
308  QList<RPreferencesListener*> preferencesListeners;
309 
310  QMutex mutex;
311 };
312 
314 
315 #endif
Abstract base class for classes that want to be notified on every transaction (objects added...
Definition: RTransactionListener.h:38
Abstract base class for classes that are interested in being notified whenever a view has been added ...
Definition: RViewListener.h:37
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RMessageHandler.h:33
QList< RCoordinateListener * > coordinateListeners
Definition: RMainWindow.h:291
Abstract base class for classes that are interested in the current snap mode.
Definition: RSnapListener.h:39
Unknown entity.
Definition: RS.h:89
QList< RLayerListener * > layerListeners
Definition: RMainWindow.h:295
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
QMutex mutex
Definition: RMainWindow.h:310
Abstract base class for classes that are interested in being notified when a new document is created...
Definition: RNewDocumentListener.h:37
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
Abstract base class for classes that are interested in transactions in progress.
Definition: RInterTransactionListener.h:41
QList< RViewFocusListener * > viewFocusListeners
Definition: RMainWindow.h:307
virtual void handleUserCommand(const QString &message, bool escape=true)
Definition: RMainWindow.h:260
#define QCADCORE_EXPORT
Definition: core_global.h:10
void move(void e, void offset)
Moves the given entity or shape by the given offset.
Definition: simple_modify.js:76
QList< RFocusListener * > focusListeners
Definition: RMainWindow.h:306
Base class for an MDI main application window.
Definition: RMainWindow.h:67
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPropertyEvent.h:40
virtual void handleUserMessage(const QString &message, bool escape=true)
Definition: RMainWindow.h:241
void getDocument()
Definition: simple.js:44
virtual void handleUserInfo(const QString &message, bool escape=true)
Definition: RMainWindow.h:247
Transaction implementation.
Definition: RTransaction.h:74
Abstract base class for classes that are interested in being notified whenever a layer has been added...
Definition: RLayerListener.h:37
Abstract base class for classes that are interested in changes in drawing or application preferences...
Definition: RPreferencesListener.h:36
virtual void enable()
Definition: RMainWindow.h:86
Abstract base class for classes that are interested in being notified whenever a UCS has been added o...
Definition: RUcsListener.h:36
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 wish to be notified when an entity is exported.
Definition: REntityExportListener.h:40
Abstract base class for classes that are interested in file export events.
Definition: RExportListener.h:37
Abstract base class for classes that are interested in being notified whenever the current pen change...
Definition: RPenListener.h:37
QList< RTransactionListener * > transactionListeners
Definition: RMainWindow.h:302
QList< RBlockListener * > blockListeners
Definition: RMainWindow.h:296
Abstract base class for classes that are interested in the current selection and want to be notified ...
Definition: RSelectionListener.h:36
static RMainWindow * mainWindow
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RMainWindow.h:289
Abstract base class for classes that are interested in properties of the current selection or the cur...
Definition: RPropertyListener.h:43
Base class for all entity classes.
Definition: REntity.h:64
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
QList< RInterTransactionListener * > interTransactionListeners
Definition: RMainWindow.h:303
Q_DECLARE_METATYPE(RMath *)
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 file import events.
Definition: RImportListener.h:38
QList< RPropertyListener * > propertyListeners
Definition: RMainWindow.h:293
QList< RPenListener * > penListeners
Definition: RMainWindow.h:298
QList< RPreferencesListener * > preferencesListeners
Definition: RMainWindow.h:308
QList< RSelectionListener * > selectionListeners
Definition: RMainWindow.h:292
QList< RSnapListener * > snapListeners
Definition: RMainWindow.h:305
Abstract base class for classes that are interested in the current focus.
Definition: RFocusListener.h:36
All entities (for filters)
Definition: RS.h:88
Abstract base class for classes that are interested in the current coordinate of the mouse cursor...
Definition: RCoordinateListener.h:38
QList< RImportListener * > importListeners
Definition: RMainWindow.h:301
virtual void disable()
Definition: RMainWindow.h:85
QList< RUcsListener * > ucsListeners
Definition: RMainWindow.h:294
Abstract base class for exporters.
Definition: RExporter.h:71
void getMainWindow()
Definition: library.js:549
void getDocumentInterface()
Returns the current RDocumentInterface or undefined.
Definition: simple.js:76
QList< RViewListener * > viewListeners
Definition: RMainWindow.h:297
Interface for interaction between a graphics document and a user.
Definition: RDocumentInterface.h:82
virtual void handleUserWarning(const QString &message, bool messageBox=false, bool escape=true)
Definition: RMainWindow.h:253
QList< REntityExportListener * > entityExportListeners
Definition: RMainWindow.h:299
QList< RExportListener * > exportListeners
Definition: RMainWindow.h:300
QList< RNewDocumentListener * > newDocumentListeners
Definition: RMainWindow.h:304
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RProgressHandler.h:33
Graphics view.
Definition: RGraphicsView.h:58