00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef CONTEXTPOINTER_H
00024 #define CONTEXTPOINTER_H
00025
00026 #include <QObject>
00027 #include <QTimer>
00028
00029 #include "ViewPort.h"
00030
00031 class ContextItem;
00032
00033 class ContextPointer : public QObject
00034 {
00035 Q_OBJECT
00036
00037 public:
00043 inline int x() const {return m_x;}
00044
00050 inline int y() const {return m_y;}
00051
00058 inline QPoint pos() {return QPoint(m_x, m_y);}
00059
00066 inline int scene_x() const {
00067 Q_ASSERT(currentViewPort);
00068 return (int) currentViewPort->mapToScene(m_x, m_y).x();
00069 }
00070
00077 inline int scene_y() const {
00078 Q_ASSERT(currentViewPort);
00079 return (int) currentViewPort->mapToScene(m_x, m_y).y();
00080 }
00081
00086 inline QPointF scene_pos() const {
00087 Q_ASSERT(currentViewPort);
00088 return currentViewPort->mapToScene(m_x, m_y);
00089 }
00090
00091
00098 inline void set_point(int x, int y)
00099 {
00100 m_x = x;
00101 m_y = y;
00102 m_jogEvent = true;
00103 }
00104
00109 inline int on_first_input_event_x() const {return m_onFirstInputEventX; }
00110
00115 inline int on_first_input_event_y() const {return m_onFirstInputEventY; }
00116
00121 inline int on_first_input_event_scene_x() const {
00122 return (int) currentViewPort->mapToScene(m_onFirstInputEventX, m_onFirstInputEventY).x();
00123 }
00124
00129 inline int on_first_input_event_scene_y() const {
00130 return (int) currentViewPort->mapToScene(m_onFirstInputEventX, m_onFirstInputEventY).y();
00131 }
00132
00136 inline void inputengine_first_input_event( )
00137 {
00138 m_onFirstInputEventX = m_x;
00139 m_onFirstInputEventY = m_y;
00140 }
00141
00142 inline int get_current_mode() const {
00143 if (currentViewPort) {
00144 return currentViewPort->get_current_mode();
00145 }
00146 return -1;
00147 }
00148
00149 void jog_start();
00150 void jog_finished();
00151 void reset_cursor();
00152
00153 ViewPort* get_viewport();
00154
00155 void set_current_viewport(ViewPort* vp) {
00156 currentViewPort = vp;
00157 }
00158 QList<QObject* > get_context_items();
00159
00160 void add_contextitem(QObject* item);
00161
00162 void remove_contextitem(QObject* item);
00163
00164 QList<QObject* > get_contextmenu_items() const;
00165 void set_contextmenu_items(QList<QObject* > list);
00166
00167
00168 private:
00169 ContextPointer();
00170 ContextPointer(const ContextPointer&);
00171
00172
00173 friend ContextPointer& cpointer();
00174
00175 int m_x;
00176 int m_y;
00177
00178 bool m_jogEvent;
00179
00180 QTimer m_jogTimer;
00181
00182 int m_onFirstInputEventX;
00183 int m_onFirstInputEventY;
00184
00185 ViewPort* currentViewPort;
00186 QList<QObject* > contextItemsList;
00187 QList<QObject* > m_contextMenuItems;
00188
00189
00190 private slots:
00191 void update_jog();
00192 };
00193
00194 #endif
00195
00196
00197 ContextPointer& cpointer();
00198
00199
00200
00201