1 // File: GLViewer_Object.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 #ifndef GLVIEWER_OBJECT_H
7 #define GLVIEWER_OBJECT_H
14 #include "GLViewer_Defs.h"
15 #include "GLViewer_Geom.h"
17 #include <SUIT_DataOwner.h>
26 #pragma warning( disable:4251 )
29 // Class: GLViewer_Object
30 // Descr: OpenGL Object
32 class GLViewer_Drawer;
33 class GLViewer_AspectLine;
35 class GLViewer_CoordSystem;
39 class GLVIEWER_API GLViewer_Object
43 virtual ~GLViewer_Object();
45 virtual void compute() = 0;
46 virtual GLViewer_Drawer* createDrawer() = 0;
48 virtual void setDrawer( GLViewer_Drawer* theDrawer ) { myDrawer = theDrawer; }
49 GLViewer_Drawer* getDrawer() const { return myDrawer; }
51 virtual GLboolean highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle = GL_FALSE ) = 0;
52 virtual GLboolean unhighlight() = 0;
53 virtual GLboolean select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect,
54 GLboolean isFull = GL_FALSE, GLboolean isCircle = GL_FALSE, GLboolean isShift = GL_FALSE ) = 0;
55 virtual GLboolean unselect() = 0;
57 virtual GLboolean isInside( GLViewer_Rect );
59 virtual bool portContains( GLViewer_Pnt ) { return false; }
60 virtual bool startPulling( GLViewer_Pnt ) { return false; }
61 virtual void pull( GLViewer_Pnt, GLViewer_Object* ) {}
62 virtual void finishPulling() {}
63 virtual bool isPulling() { return false; }
64 virtual GLViewer_Rect getPullingRect() const { return GLViewer_Rect(
65 myRect->left(), myRect->right(), myRect->top(), myRect->bottom() ); }
67 virtual void setRect( GLViewer_Rect* rect) { myRect = rect; }
68 virtual GLViewer_Rect* getRect() const { return myRect; }
69 virtual GLViewer_Rect* getUpdateRect() = 0;
71 virtual void setScale( GLfloat xScale, GLfloat yScale ) { myXScale = xScale; myYScale = yScale; }
72 virtual void getScale( GLfloat& xScale, GLfloat& yScale ) const { xScale = myXScale; yScale = myYScale;}
74 virtual GLboolean setZoom( GLfloat zoom, bool recompute, bool fromGroup = false );
75 virtual GLfloat getZoom() const { return myZoom; }
76 virtual GLboolean updateZoom( bool zoomIn );
78 virtual GLboolean isHighlighted() const { return myIsHigh; }
79 virtual GLboolean isSelected() const { return myIsSel; }
80 virtual void setSelected( GLboolean state ) { myIsSel = state; }
82 void setGLText( GLViewer_Text* glText ) { myGLText = glText; }
83 GLViewer_Text* getGLText() const { return myGLText; }
85 virtual void setAspectLine ( GLViewer_AspectLine* aspect ) { myAspectLine = aspect; }
86 virtual GLViewer_AspectLine* getAspectLine() const { return myAspectLine; }
88 QString getObjectType() const { return myType; }
90 void setName( QString name ) { myName = name; }
91 QString getName() const { return myName; }
93 virtual int getPriority() const;
95 virtual void moveObject( float, float, bool fromGroup = false ) = 0;
96 virtual bool finishMove() { return true; }
98 bool getVisible() const { return myIsVisible; }
99 virtual void setVisible( bool theStatus ) { myIsVisible = theStatus; }
101 void setToolTipText( QString str ){ myToolTipText = str; }
102 virtual QString getToolTipText(){ return myToolTipText; }
104 bool isTooTipHTML() const { return isToolTipHTML; }
105 void setToolTipFormat( bool isHTML ) { isToolTipHTML = isHTML; }
107 virtual QByteArray getByteCopy();
108 virtual bool initializeFromByteCopy( QByteArray );
110 virtual bool translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS ) = 0;
111 virtual bool translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS ) = 0;
114 virtual bool translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS ) = 0;
117 GLViewer_Owner* owner() const { return myOwner; }
118 void setOwner( GLViewer_Owner* owner ) { myOwner = owner; }
120 void setGroup( GLViewer_Group* );
121 GLViewer_Group* getGroup() const;
123 virtual GLViewer_Object* getOwner() { return this; }
125 virtual bool isSelectable() { return true; }
126 virtual bool isScalable() { return true; }
132 GLViewer_Rect* myRect;
133 GLViewer_Rect* myUpdateRect;
134 GLViewer_Text* myGLText;
146 GLViewer_Drawer* myDrawer;
147 GLViewer_AspectLine* myAspectLine;
149 QString myToolTipText;
154 GLViewer_Owner* myOwner;
155 GLViewer_Group* myGroup;
158 // Class: GLViewer_Object
159 // Descr: OpenGL Object
161 class GLVIEWER_API GLViewer_Owner : public SUIT_DataOwner
164 GLViewer_Owner() : SUIT_DataOwner() {}
172 #pragma warning ( default:4251 )