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