00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __mitkWidgetModel_h
00012 #define __mitkWidgetModel_h
00013
00014 #include "mitkModel.h"
00015 #include "mitkDataModel.h"
00016 #include "mitkRenderer.h"
00017 #include "mitkGeometryTypes.h"
00018
00019 #include <GL/glu.h>
00020 #include <GL/gl.h>
00021 #include <math.h>
00022
00023 typedef Point3f PointType;
00024
00025 class mitkWidgetModel;
00026 typedef struct _widget_names
00027 {
00028 mitkWidgetModel *owner;
00029 GLuint name1;
00030 GLuint name2;
00031 GLuint name3;
00032
00033
00034 } WidgetNames;
00035
00036 class mitkScene;
00037 class mitkView;
00038
00044 class MITK_VISUALIZATION_API mitkWidgetModel : public mitkModel
00045 {
00046 public:
00047 MITK_TYPE(mitkWidgetModel, mitkModel)
00048
00049
00050 virtual void PrintSelf(ostream &os);
00051
00057 virtual void Pick(const WidgetNames &names) = 0;
00058
00062 virtual void Release() = 0;
00063
00068 virtual void Select(mitkScene *scene);
00069
00078 void OnMouseDown(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00079
00088 void OnMouseUp(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos);
00089
00099 void OnMouseMove(bool ctrlDown, bool shiftDown, int xPos, int yPos, int deltaX, int deltaY);
00100
00105 virtual void SetSourceModel(mitkDataModel *model);
00106
00111 mitkDataModel* GetSourceModel() { return m_SourceModel; }
00112
00121 virtual void SetScene(mitkScene *scene) = 0;
00122
00127 virtual void SetView(mitkView *view);
00128
00133 virtual bool IsOpaque() { return m_IsOpaque; }
00134
00139 virtual bool IsActive() { return m_IsActive; }
00140
00145 bool IsMouseLeftButtonDown() { return m_LButtonDown; }
00146
00151 bool IsMouseRightButtonDown() { return m_RButtonDown; }
00152
00157 bool IsMouseMiddleButtonDown() { return m_MButtonDown; }
00158
00162 void UpdateObservers() { this->_updateObservers(); }
00163
00167 virtual void Update() = 0;
00168
00169 GLuint GetIndex() {return m_Index;}
00170 static mitkWidgetModel* GetInstance(GLuint index);
00171
00172 protected:
00173 mitkWidgetModel();
00174 virtual ~mitkWidgetModel();
00175
00184 virtual void _onMouseDown(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos) = 0;
00185
00194 virtual void _onMouseUp(int mouseButton, bool ctrlDown, bool shiftDown, int xPos, int yPos) = 0;
00195
00205 virtual void _onMouseMove(bool ctrlDown, bool shiftDown, int xPos, int yPos, int deltaX, int deltaY) = 0;
00206
00207 void _pushName();
00208 void _popNames();
00209
00210 mitkDataModel *m_SourceModel;
00211 GLuint m_PickedObj;
00212 bool m_LButtonDown;
00213 bool m_MButtonDown;
00214 bool m_RButtonDown;
00215 bool m_IsOpaque;
00216 bool m_IsSelectMode;
00217 bool m_IsActive;
00218
00219 GLuint m_Index;
00220
00221 private:
00222 mitkWidgetModel(const mitkWidgetModel&);
00223 void operator = (const mitkWidgetModel&);
00224
00225 static int RegisterInstance(mitkWidgetModel* instance);
00226 static void UnregisterInstance(GLuint index);
00227 };
00228
00229 inline void mitkWidgetModel::_pushName()
00230 {
00231 glPushName(m_Index);
00232 }
00233
00234 inline void mitkWidgetModel::_popNames()
00235 {
00236
00237 glPopName();
00238
00239
00240 glPopName();
00241 glPopName();
00242 glPopName();
00243 }
00244
00245
00246
00247
00248
00249
00250 #endif
00251