00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef GLVIEWER_VIEWER2D_H
00028 #define GLVIEWER_VIEWER2D_H
00029
00030 #ifdef WIN32
00031 #include <windows.h>
00032 #endif
00033
00034 class QRect;
00035 class QFile;
00036
00037 #include "GLViewer_Viewer.h"
00038
00039 #include <TColStd_SequenceOfInteger.hxx>
00040
00041 #include <GL/gl.h>
00042
00043 class GLViewer_Object;
00044 class GLViewer_ViewFrame;
00045 class GLViewer_Drawer;
00046 class GLViewer_Context;
00047 class GLViewer_Rect;
00048
00049
00050 class SUIT_Desktop;
00051 class SUIT_ViewWindow;
00052
00054 const double Sizes[2*5] = {
00055 594.0, 840.0,
00056 420.0, 594.0,
00057 297.0, 420.0,
00058 210.0, 297.0,
00059 148.5, 210.0
00060 };
00061
00062 #ifdef WIN32
00063 #pragma warning( disable:4251 )
00064 #endif
00065
00071 class GLVIEWER_API GLViewer_Viewer2d : public GLViewer_Viewer
00072 {
00073 Q_OBJECT
00074
00075 public:
00077 enum GLSketchingType
00078 {
00079 None,
00080 Polyline,
00081 Arc,
00082 Curve,
00083 Scribble,
00084 Oval,
00085 Rectangle
00086 };
00088 enum VectorFileType
00089 {
00090 POST_SCRIPT,
00091 HPGL
00092 #ifdef WIN32
00093 , ENH_METAFILE
00094 #endif
00095 };
00096
00098 enum PaperType
00099 {
00100 A1=0,
00101 A2,
00102 A3,
00103 A4,
00104 A5
00105 };
00106
00107 public:
00109 GLViewer_Viewer2d( const QString& title );
00111 ~GLViewer_Viewer2d();
00112
00113 public:
00115
00116 virtual SUIT_ViewWindow* createView( SUIT_Desktop* );
00117
00119 void addPopupItems( QMenu* );
00120
00121
00122
00124 const QList<GLViewer_Drawer*>& getDrawers() const { return myDrawers; }
00125
00127 GLViewer_Context* getGLContext() const { return myGLContext; }
00129 void updateColors( QColor colorH, QColor colorS );
00130
00132 void updateBorders( GLViewer_Rect* theRect );
00134 void updateBorders();
00135
00137 void updateAll();
00139
00140 void updateDrawers( GLboolean onlyUpdate, GLfloat scX = 0.0, GLfloat scY = 0.0 );
00142 void activateDrawers( QList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap = GL_FALSE );
00144 void activateDrawer( GLViewer_Object* theObject, bool onlyUpdate, GLboolean swap = GL_FALSE );
00146
00147 void activateAllDrawers( bool onlyUpdate, GLboolean swap = GL_FALSE );
00148
00150 void transPoint( GLfloat& x, GLfloat& y );
00152 QRect* getWinObjectRect( GLViewer_Object* theObject);
00153
00155 GLViewer_Rect getGLVRect( const QRect& ) const;
00157 QRect getQRect( const GLViewer_Rect& ) const;
00158
00160 virtual void insertHeader( VectorFileType aType, QFile& hFile );
00162 virtual void insertEnding( VectorFileType aType, QFile& hFile );
00164
00165
00166
00167 virtual bool translateTo( VectorFileType aType, QString FileName, PaperType aPType,
00168 double mmLeft, double mmRight, double mmTop, double mmBottom );
00169
00170
00171
00172
00173
00174
00175
00177 void repaintView( GLViewer_ViewFrame* theView = NULL, bool makeCurrent = false );
00178
00179 signals:
00182 void wheelZoomChange( bool );
00183
00184 public slots:
00185
00186
00187
00188
00190 void onChangeBgColor();
00192 void onCreateGLMarkers( int number = 1000, int size = 5 );
00194 void onCreateGLPolyline( int number = 100, int angles = 10, int size = 100 );
00196 void onCreateGLText( QString text = "Text", int number = 1 );
00197
00198 protected:
00200 GLViewer_Selector* createSelector();
00202 GLViewer_ViewTransformer* createTransformer( int type);
00203
00205 void transformCoordsToPS( double& x, double& y );
00207 void transformCoordsToHPGL( double& x, double& y );
00208
00210 virtual void startOperations( QMouseEvent* );
00212 virtual bool updateOperations( QMouseEvent* );
00214 virtual void finishOperations( QMouseEvent* );
00216 virtual void startOperations( QWheelEvent* );
00217
00218 protected slots:
00219 void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* );
00220
00221 private:
00223 bool testRotation( QMouseEvent* );
00224 protected:
00226 GLViewer_Context* myGLContext;
00228 QList<GLViewer_Drawer*> myDrawers;
00229
00230
00231 };
00232
00233 class GLVIEWER_API GLViewer_View2dTransformer : public GLViewer_ViewTransformer
00234 {
00235 public:
00236 GLViewer_View2dTransformer( GLViewer_Viewer*, int );
00237 ~GLViewer_View2dTransformer();
00238
00239 virtual void exec();
00240
00242 static int rotateButton() { return rotateBtn; }
00243 static void setRotateButton( int b ) { rotateBtn = b; }
00244
00245 protected:
00246 void onTransform( TransformState );
00247
00248 static int rotateBtn;
00249 };
00250
00251 #ifdef WIN32
00252 #pragma warning ( default:4251 )
00253 #endif
00254
00255 #endif