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 "RTransactionListener.h"
28 #include "RPropertyEvent.h"
29 #include "RMessageHandler.h"
30 #include "RProgressHandler.h"
31 #include "RS.h"
32 
33 class RBlockListener;
35 class RDocument;
36 class RDocumentInterface;
37 class REntity;
38 class RFocusListener;
39 class RGraphicsView;
40 class RLayerListener;
41 class RPenListener;
42 class RPropertyListener;
43 class RSelectionListener;
44 class RSnapListener;
45 class RTransaction;
46 class RUcsListener;
47 class RVector;
48 class RViewFocusListener;
49 class RViewListener;
50 
51 #ifndef RDEFAULT_MINUS_ONE
52 #define RDEFAULT_MINUS_ONE -1
53 #endif
54 
62 
63 public:
64  RMainWindow();
65  virtual ~RMainWindow();
66 
67  static RMainWindow* getMainWindow();
68 
69  static bool hasMainWindow();
70 
71  static void installMessageHandler();
72 
77  virtual RDocument* getDocument() = 0;
78 
83  virtual RDocumentInterface* getDocumentInterface() = 0;
84  static RDocumentInterface* getDocumentInterfaceStatic();
85 
86  void notifyListeners(bool withNull = false);
87 
88  void addCoordinateListener(RCoordinateListener* l);
89  void removeCoordinateListener(RCoordinateListener* l);
90  void notifyCoordinateListeners(RDocumentInterface* documentInterface);
91 
92  void addSelectionListener(RSelectionListener* l);
93  void removeSelectionListener(RSelectionListener* l);
94  void notifySelectionListeners(RDocumentInterface* documentInterface);
95 
96  virtual void postSelectionChangedEvent() = 0;
97  virtual void postTransactionEvent(
98  RTransaction& t,
99  bool onlyChanges=false,
100  RS::EntityType entityTypeFilter = RS::EntityAll
101  ) = 0;
102  virtual void postCloseEvent() = 0;
103  //virtual void postPropertyEvent() = 0;
104 // virtual void postPropertyEvent(RPropertyTypeId propertyTypeId,
105 // const QVariant& value,
106 // RS::EntityType entityTypeFilter = RS::EntityAll
107 // ) = 0;
108 
109  void addPropertyListener(RPropertyListener* l);
110  void removePropertyListener(RPropertyListener* l);
111  void notifyPropertyListeners(
112  RDocument* document,
113  bool onlyChanges=false,
114  RS::EntityType entityTypeFilter = RS::EntityAll
115  );
116  void notifyPropertyListeners(RDocument& document, REntity& entity);
117  void notifyPropertyListeners();
118 
119  void addTransactionListener(RTransactionListener* l);
120  void removeTransactionListener(RTransactionListener* l);
121  void notifyTransactionListeners(RDocument* document, RTransaction* transaction = NULL);
122 
123  void addSnapListener(RSnapListener* l);
124  void removeSnapListener(RSnapListener* l);
125  void notifySnapListeners(RDocumentInterface* documentInterface);
126 
127  void addFocusListener(RFocusListener* l);
128  void removeFocusListener(RFocusListener* l);
129  void notifyFocusListeners(RDocumentInterface* documentInterface);
130 
131  void addViewFocusListener(RViewFocusListener* l);
132  void removeViewFocusListener(RViewFocusListener* l);
133  void notifyViewFocusListeners(RGraphicsView* view);
134 
135  void propertyChangeEvent(RPropertyEvent& event);
136 
137  void addUcsListener(RUcsListener* l);
138  void removeUcsListener(RUcsListener* l);
139  void notifyUcsListeners(RDocumentInterface* documentInterface);
140 
141  void addLayerListener(RLayerListener* l);
142  void removeLayerListener(RLayerListener* l);
143  void notifyLayerListeners(RDocumentInterface* documentInterface);
144 
145  void addBlockListener(RBlockListener* l);
146  void removeBlockListener(RBlockListener* l);
147  void notifyBlockListeners(RDocumentInterface* documentInterface);
148 
149  void addViewListener(RViewListener* l);
150  void removeViewListener(RViewListener* l);
151  void notifyViewListeners(RDocumentInterface* documentInterface);
152 
153  void addPenListener(RPenListener* l);
154  void removePenListener(RPenListener* l);
155  void notifyPenListeners(RDocumentInterface* documentInterface);
156 
157  void ucsSetEvent(const QString& ucsName);
158 
159  //void commandEvent(const QString& command);
160 
161  virtual void escapeEvent() = 0;
162 
168  virtual void setGraphicsViewCursor(const QCursor& cursor) = 0;
169 
173  virtual int getWidth() = 0;
177  virtual int getHeight() = 0;
182  virtual int getPositionX() = 0;
187  virtual int getPositionY() = 0;
188 
192  virtual void resize(int width, int height) = 0;
196  virtual void move(int x, int y) = 0;
200  virtual void quit() = 0;
201 
202  virtual void handleUserMessage(const QString& message) {
203  qDebug() << message;
204  }
205 
206  virtual void handleUserInfo(const QString& message) {
207  qDebug() << message;
208  }
209 
210  virtual void handleUserWarning(const QString& message, bool messageBox = false) {
211  Q_UNUSED(messageBox);
212  qWarning() << message;
213  }
214 
215  virtual void handleUserCommand(const QString& message) {
216  qDebug() << "Command: " << message;
217  }
218 
219 #if QT_VERSION >= 0x050000
220 
223  static void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message);
224 #else
225 
228  static void messageHandler(QtMsgType type, const char* msg);
229 #endif
230 
231  virtual void setCommandPrompt(const QString& text = "") = 0;
232  virtual void setLeftMouseTip(const QString& text = "") = 0;
233  virtual void setRightMouseTip(const QString& text = "") = 0;
234 
235 protected:
236  virtual bool readSettings();
237  virtual void writeSettings();
238 
239 protected:
241 
242  QList<RCoordinateListener*> coordinateListeners;
243  QList<RSelectionListener*> selectionListeners;
244  QList<RPropertyListener*> propertyListeners;
245  QList<RUcsListener*> ucsListeners;
246  QList<RLayerListener*> layerListeners;
247  QList<RBlockListener*> blockListeners;
248  QList<RViewListener*> viewListeners;
249  QList<RPenListener*> penListeners;
250  QList<RTransactionListener*> transactionListeners;
251  QList<RSnapListener*> snapListeners;
252  QList<RFocusListener*> focusListeners;
253  QList<RViewFocusListener*> viewFocusListeners;
254 
255  QMutex mutex;
256 };
257 
259 
260 #endif