QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "RExportListener.h"
28 #include "RImportListener.h"
30 #include "RTransactionListener.h"
31 #include "RPropertyEvent.h"
32 #include "RMessageHandler.h"
33 #include "RProgressHandler.h"
34 #include "RS.h"
35 
36 class RBlockListener;
38 class RDocument;
39 class RDocumentInterface;
40 class REntity;
41 class RFocusListener;
42 class RGraphicsView;
43 class RLayerListener;
45 class RPenListener;
46 class RPropertyListener;
47 class RSelectionListener;
48 class RSnapListener;
49 class RTransaction;
50 class RUcsListener;
51 class RVector;
52 class RViewFocusListener;
53 class RViewListener;
54 
55 #ifndef RDEFAULT_MINUS_ONE
56 #define RDEFAULT_MINUS_ONE -1
57 #endif
58 
66 
67 public:
68  RMainWindow();
69  virtual ~RMainWindow();
70 
71  static RMainWindow* getMainWindow();
72 
73  static bool hasMainWindow();
74 
75  static void installMessageHandler();
76 
81  virtual RDocument* getDocument() = 0;
82 
87  virtual RDocumentInterface* getDocumentInterface() = 0;
88  static RDocumentInterface* getDocumentInterfaceStatic();
89 
90  void notifyListeners(bool withNull = false);
91 
92  void addCoordinateListener(RCoordinateListener* l);
93  void removeCoordinateListener(RCoordinateListener* l);
94  void notifyCoordinateListeners(RDocumentInterface* documentInterface);
95 
96  void addSelectionListener(RSelectionListener* l);
97  void removeSelectionListener(RSelectionListener* l);
98  void notifySelectionListeners(RDocumentInterface* documentInterface);
99 
100  virtual void postSelectionChangedEvent() = 0;
101  virtual void postTransactionEvent(
102  RTransaction& t,
103  bool onlyChanges=false,
104  RS::EntityType entityTypeFilter = RS::EntityAll
105  ) = 0;
106  virtual void postCloseEvent() = 0;
107  //virtual void postPropertyEvent() = 0;
108 // virtual void postPropertyEvent(RPropertyTypeId propertyTypeId,
109 // const QVariant& value,
110 // RS::EntityType entityTypeFilter = RS::EntityAll
111 // ) = 0;
112 
113  void addPropertyListener(RPropertyListener* l);
114  void removePropertyListener(RPropertyListener* l);
115  void notifyPropertyListeners(
116  RDocument* document,
117  bool onlyChanges=false,
118  RS::EntityType entityTypeFilter = RS::EntityAll
119  );
120  void notifyPropertyListeners(RDocument& document, REntity& entity);
121  void notifyPropertyListeners();
122 
123  void addExportListener(RExportListener* l);
124  void removeExportListener(RExportListener* l);
125  void notifyExportListenersPre(RDocumentInterface* documentInterface);
126  void notifyExportListenersPost(RDocumentInterface* documentInterface);
127 
128  void addImportListener(RImportListener* l);
129  void removeImportListener(RImportListener* l);
130  void notifyImportListenersPre(RDocumentInterface* documentInterface);
131  void notifyImportListenersPost(RDocumentInterface* documentInterface);
132 
133  void addTransactionListener(RTransactionListener* l);
134  void removeTransactionListener(RTransactionListener* l);
135  void notifyTransactionListeners(RDocument* document, RTransaction* transaction = NULL);
136 
137  void addInterTransactionListener(RInterTransactionListener* l);
138  void removeInterTransactionListener(RInterTransactionListener* l);
139  void notifyInterTransactionListeners(RDocument* document, RTransaction* transaction = NULL);
140 
141  void addNewDocumentListener(RNewDocumentListener* l);
142  void removeNewDocumentListener(RNewDocumentListener* l);
143  void notifyNewDocumentListeners(RDocument* document, RTransaction* transaction);
144 
145  void addSnapListener(RSnapListener* l);
146  void removeSnapListener(RSnapListener* l);
147  void notifySnapListeners(RDocumentInterface* documentInterface);
148 
149  void addFocusListener(RFocusListener* l);
150  void removeFocusListener(RFocusListener* l);
151  void notifyFocusListeners(RDocumentInterface* documentInterface);
152 
153  void addViewFocusListener(RViewFocusListener* l);
154  void removeViewFocusListener(RViewFocusListener* l);
155  void notifyViewFocusListeners(RGraphicsView* view);
156 
157  void propertyChangeEvent(RPropertyEvent& event);
158 
159  void addUcsListener(RUcsListener* l);
160  void removeUcsListener(RUcsListener* l);
161  void notifyUcsListeners(RDocumentInterface* documentInterface);
162 
163  void addLayerListener(RLayerListener* l);
164  void removeLayerListener(RLayerListener* l);
165  void notifyLayerListeners(RDocumentInterface* documentInterface);
166 
167  void addBlockListener(RBlockListener* l);
168  void removeBlockListener(RBlockListener* l);
169  void notifyBlockListeners(RDocumentInterface* documentInterface);
170 
171  void addViewListener(RViewListener* l);
172  void removeViewListener(RViewListener* l);
173  void notifyViewListeners(RDocumentInterface* documentInterface);
174 
175  void addPenListener(RPenListener* l);
176  void removePenListener(RPenListener* l);
177  void notifyPenListeners(RDocumentInterface* documentInterface);
178 
179  void ucsSetEvent(const QString& ucsName);
180 
181  //void commandEvent(const QString& command);
182 
183  virtual void escapeEvent() = 0;
184 
190  virtual void setGraphicsViewCursor(const QCursor& cursor) = 0;
191 
195  virtual int getWidth() = 0;
199  virtual int getHeight() = 0;
204  virtual int getPositionX() = 0;
209  virtual int getPositionY() = 0;
210 
214  virtual void resize(int width, int height) = 0;
218  virtual void move(int x, int y) = 0;
222  virtual void quit() = 0;
223 
224  virtual void handleUserMessage(const QString& message) {
225  qDebug() << message;
226  }
227 
228  virtual void handleUserInfo(const QString& message) {
229  qDebug() << message;
230  }
231 
232  virtual void handleUserWarning(const QString& message, bool messageBox = false) {
233  Q_UNUSED(messageBox);
234  qWarning() << message;
235  }
236 
237  virtual void handleUserCommand(const QString& message) {
238  qDebug() << "Command: " << message;
239  }
240 
241 #if QT_VERSION >= 0x050000
242 
245  static void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message);
246 #else
247 
250  static void messageHandler(QtMsgType type, const char* msg);
251 #endif
252 
253  virtual void setCommandPrompt(const QString& text = "") = 0;
254  virtual void setLeftMouseTip(const QString& text = "") = 0;
255  virtual void setRightMouseTip(const QString& text = "") = 0;
256 
257 protected:
258  virtual bool readSettings();
259  virtual void writeSettings();
260 
261 protected:
263 
264  QList<RCoordinateListener*> coordinateListeners;
265  QList<RSelectionListener*> selectionListeners;
266  QList<RPropertyListener*> propertyListeners;
267  QList<RUcsListener*> ucsListeners;
268  QList<RLayerListener*> layerListeners;
269  QList<RBlockListener*> blockListeners;
270  QList<RViewListener*> viewListeners;
271  QList<RPenListener*> penListeners;
272  QList<RExportListener*> exportListeners;
273  QList<RImportListener*> importListeners;
274  QList<RTransactionListener*> transactionListeners;
275  QList<RInterTransactionListener*> interTransactionListeners;
276  QList<RNewDocumentListener*> newDocumentListeners;
277  QList<RSnapListener*> snapListeners;
278  QList<RFocusListener*> focusListeners;
279  QList<RViewFocusListener*> viewFocusListeners;
280 
281  QMutex mutex;
282 };
283 
285 
286 #endif