1 // File: GLViewer_Viewer2d.h
2 // Created: November, 2004
4 // Copyright (C) CEA 2004
6 /***************************************************************************
7 ** Class: GLViewer_Viewer2d
8 ** Descr: OpenGL Viewer 2D
10 ** Created: UI team, 04.09.02
11 ****************************************************************************/
12 #ifndef GLVIEWER_VIEWER2D_H
13 #define GLVIEWER_VIEWER2D_H
22 #include "GLViewer_Viewer.h"
23 #include "GLViewer_ViewFrame.h"
24 #include "GLViewer_Drawer.h"
26 #include <TColStd_SequenceOfInteger.hxx>
30 class GLViewer_Object;
32 class GLViewer_Context;
33 class GLViewer_Selector2d;
34 //class GLViewer_Sketcher;
37 class SUIT_ViewWindow;
39 const double Sizes[2*5] = {
40 /* A1 */ 594.0, 840.0,
41 /* A2 */ 420.0, 594.0,
42 /* A3 */ 297.0, 420.0,
43 /* A4 */ 210.0, 297.0,
48 #pragma warning( disable:4251 )
51 class GLVIEWER_EXPORT GLViewer_Viewer2d : public GLViewer_Viewer
56 enum GLSketchingType { None, Polyline, Arc, Curve, Scribble, Oval, Rectangle };
57 enum VectorFileType { POST_SCRIPT, HPGL
63 enum PaperType { A1=0, A2, A3, A4, A5 };
66 GLViewer_Viewer2d( const QString& title );
70 SUIT_ViewWindow* createView( SUIT_Desktop* );
72 virtual void contextMenuPopup( QPopupMenu* );
74 //void activateGLSketching( int );
76 GLViewer_Context* getGLContext() const { return myGLContext; }
77 void updateColors( QColor colorH, QColor colorS );
78 void updateBorders( const QRect& rect );
82 void updateDrawers( GLboolean update, GLfloat scX = 0.0, GLfloat scY = 0.0 );
83 void activateDrawers( TColStd_SequenceOfInteger& list, bool onlyUpdate,
84 GLboolean swap = GL_TRUE );
85 void activateDrawers( QValueList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap = GL_FALSE );
86 void activateDrawer( int index, bool onlyUpdate, GLboolean swap = GL_FALSE );
87 void activateDrawer( GLViewer_Object*, bool onlyUpdate, GLboolean swap = GL_FALSE );
88 void activateAllDrawers( bool onlyUpdate, GLboolean swap = GL_FALSE );
90 void transPoint( GLfloat& x, GLfloat& y );
91 QRect* getWinObjectRect( GLViewer_Object* theObject );
93 GLViewer_Rect getGLVRect( const QRect& ) const;
94 QRect getQRect( const GLViewer_Rect& ) const;
96 virtual void insertHeader( VectorFileType aType, QFile& hFile );
97 virtual void insertEnding( VectorFileType aType, QFile& hFile );
98 virtual bool translateTo( VectorFileType aType, QString FileName, PaperType aPType,
99 double mmLeft, double mmRight, double mmTop, double mmBottom );
101 //bool isSketchingActive();
102 //int getSketchingType();
104 //virtual void startSketching();
105 //virtual void finishSketching();
107 void repaintView( GLViewer_ViewFrame* theView = NULL, bool makeCurrent = false );
110 //void onSketchDelObject();
111 //void onSketchUndoLast();
112 //void onSketchFinish();
113 void onChangeBgColor();
114 void onCreateGLMarkers( int = 1000, int = 5 );
115 void onCreateGLPolyline( int = 100, int = 10, int = 100 );
116 void onCreateGLText( QString = "Text", int = 1 );
119 GLViewer_Selector* createSelector();
120 GLViewer_ViewTransformer* createTransformer( int );
122 void transformCoordsToPS( double& x, double& y );
123 void transformCoordsToHPGL( double& x, double& y );
125 virtual void startOperations( QMouseEvent* );
126 virtual bool updateOperations( QMouseEvent* );
127 virtual void finishOperations( QMouseEvent* );
128 virtual void startOperations( QWheelEvent* );
131 void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* );
135 bool testRotation( QMouseEvent* );
138 GLViewer_Context* myGLContext;
139 QValueList<GLViewer_Drawer*> myDrawers;
141 //GLViewer_Sketcher* myGLSketcher;
144 /****************************************************************
145 ** Class: GLViewer_View2dTransformer
147 *****************************************************************/
148 class GLVIEWER_EXPORT GLViewer_View2dTransformer : public GLViewer_ViewTransformer
151 GLViewer_View2dTransformer( GLViewer_Viewer*, int );
152 ~GLViewer_View2dTransformer();
157 /*! Sets/returns mouse butto which will be used for rotation ( MB1 by default ) */
158 static int rotateButton() { return rotateBtn; }
159 static void setRotateButton( int b ) { rotateBtn = b; }
162 void onTransform( TransformState );
165 static int rotateBtn;
169 #pragma warning ( default:4251 )