Version: 9.12.0
GLViewer_Viewer2d.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // Author : OPEN CASCADE
24 // File: GLViewer_Viewer2d.h
25 // Created: November, 2004
26 //
27 #ifndef GLVIEWER_VIEWER2D_H
28 #define GLVIEWER_VIEWER2D_H
29 
30 #ifdef WIN32
31 #include <windows.h>
32 #endif
33 
34 class QRect;
35 class QFile;
36 
37 #include "GLViewer_Viewer.h"
38 
39 #include <TColStd_SequenceOfInteger.hxx>
40 
41 #ifdef __APPLE__
42 #include <OpenGL/gl.h>
43 #else
44 #include <GL/gl.h>
45 #endif
46 
47 class GLViewer_Object;
48 class GLViewer_ViewFrame;
49 class GLViewer_Drawer;
50 class GLViewer_Context;
51 class GLViewer_Rect;
52 //class GLViewer_Sketcher;
53 
54 class SUIT_Desktop;
55 class SUIT_ViewWindow;
56 
58 const double Sizes[2*5] = {
59  /* A1 */ 594.0, 840.0,
60  /* A2 */ 420.0, 594.0,
61  /* A3 */ 297.0, 420.0,
62  /* A4 */ 210.0, 297.0,
63  /* A5 */ 148.5, 210.0
64 };
65 
66 #ifdef WIN32
67 #pragma warning( disable:4251 )
68 #endif
69 
76 {
77  Q_OBJECT
78 
79 public:
82  {
85  Arc,
89  Rectangle
90  };
93  {
95  HPGL
96 #ifdef WIN32
97  , ENH_METAFILE
98 #endif
99  };
100 
103  {
104  A1=0,
105  A2,
106  A3,
107  A4,
108  A5
109  };
110 
111 public:
113  GLViewer_Viewer2d( const QString& title );
116 
117 public:
119  /*Returns GLViewer_ViewFrame*/
121 
123  void addPopupItems( QMenu* );
124 
125  //void activateGLSketching( int );
126 
128  const QList<GLViewer_Drawer*>& getDrawers() const { return myDrawers; }
129 
131  GLViewer_Context* getGLContext() const { return myGLContext; }
133  void updateColors( QColor colorH, QColor colorS );
134 
136  void updateBorders( GLViewer_Rect* theRect );
138  void updateBorders();
139 
141  void updateAll();
143  /* \param onlyUpdate is passed to method activateAllDrawersdrawers*/
144  void updateDrawers( GLboolean onlyUpdate, GLfloat scX = 0.0, GLfloat scY = 0.0 );
146  void activateDrawers( QList<GLViewer_Object*>& theObjects, bool onlyUpdate, GLboolean swap = GL_FALSE );
148  void activateDrawer( GLViewer_Object* theObject, bool onlyUpdate, GLboolean swap = GL_FALSE );
150  /* \param onlyUpdate is passed to drawers*/
151  void activateAllDrawers( bool onlyUpdate, GLboolean swap = GL_FALSE );
152 
154  void transPoint( GLfloat& x, GLfloat& y );
156  QRect* getWinObjectRect( GLViewer_Object* theObject);
157 
159  GLViewer_Rect getGLVRect( const QRect& ) const;
161  QRect getQRect( const GLViewer_Rect& ) const;
162 
164  virtual void insertHeader( VectorFileType aType, QFile& hFile );
166  virtual void insertEnding( VectorFileType aType, QFile& hFile );
168  /* Translates current view content to vector file with type \param aType, name \param FileName,
169  * output paper size \param aPType, with margins in mm
170  */
171  virtual bool translateTo( VectorFileType aType, QString FileName, PaperType aPType,
172  double mmLeft, double mmRight, double mmTop, double mmBottom );
173 
174  //bool isSketchingActive();
175  //int getSketchingType();
176 
177  //virtual void startSketching();
178  //virtual void finishSketching();
179 
181  void repaintView( GLViewer_ViewFrame* theView = NULL, bool makeCurrent = false );
182 
183 signals:
186  void wheelZoomChange( bool );
187 
188 public slots:
189  //void onSketchDelObject();
190  //void onSketchUndoLast();
191  //void onSketchFinish();
192 
194  void onChangeBgColor();
196  void onCreateGLMarkers( int number = 1000, int size = 5 );
198  void onCreateGLPolyline( int number = 100, int angles = 10, int size = 100 );
200  void onCreateGLText( QString text = "Text", int number = 1 );
201 
202 protected:
207 
209  void transformCoordsToPS( double& x, double& y );
211  void transformCoordsToHPGL( double& x, double& y );
212 
214  virtual void startOperations( QMouseEvent* );
216  virtual bool updateOperations( QMouseEvent* );
218  virtual void finishOperations( QMouseEvent* );
220  virtual void startOperations( QWheelEvent* );
221 
222 protected slots:
223  void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* );
224 
225 private:
227  bool testRotation( QMouseEvent* );
228 protected:
233 
234  //GLViewer_Sketcher* myGLSketcher;
235 };
236 
238 {
239 public:
242 
243  virtual void exec();
244 
246  static int rotateButton() { return rotateBtn; }
247  static void setRotateButton( int b ) { rotateBtn = b; }
248 
249 protected:
250  void onTransform( TransformState );
251 
252  static int rotateBtn;
253 };
254 
255 #ifdef WIN32
256 #pragma warning ( default:4251 )
257 #endif
258 
259 #endif
#define GLVIEWER_API
Macro for exports.
Definition: GLViewer.h:37
const double Sizes[2 *5]
Paper sizes array.
Definition: GLViewer_Viewer2d.h:58
Definition: GLViewer_Context.h:58
Definition: GLViewer_Drawer.h:193
Definition: GLViewer_Object.h:65
Definition: GLViewer_Geom.h:69
Definition: GLViewer_Selector.h:47
Definition: GLViewer_Viewer2d.h:238
static int rotateBtn
Definition: GLViewer_Viewer2d.h:252
static int rotateButton()
Definition: GLViewer_Viewer2d.h:246
static void setRotateButton(int b)
Definition: GLViewer_Viewer2d.h:247
Definition: GLViewer_ViewFrame.h:52
Definition: GLViewer_Viewer.h:139
Definition: GLViewer_Viewer2d.h:76
const QList< GLViewer_Drawer * > & getDrawers() const
Returns all drawers.
Definition: GLViewer_Viewer2d.h:128
QList< GLViewer_Drawer * > myDrawers
Map of active drawers.
Definition: GLViewer_Viewer2d.h:232
GLViewer_Context * getGLContext() const
Returns context.
Definition: GLViewer_Viewer2d.h:131
GLViewer_Context * myGLContext
Current context.
Definition: GLViewer_Viewer2d.h:230
void transformCoordsToPS(double &x, double &y)
Transforms point (x,y) in Viewer CS to Post Script CS.
void transformCoordsToHPGL(double &x, double &y)
Transforms point (x,y) in Viewer CS to HPGL CS.
GLSketchingType
Type of sketcher operation
Definition: GLViewer_Viewer2d.h:82
@ Scribble
Definition: GLViewer_Viewer2d.h:87
@ Curve
Definition: GLViewer_Viewer2d.h:86
@ None
Definition: GLViewer_Viewer2d.h:83
@ Polyline
Definition: GLViewer_Viewer2d.h:84
@ Arc
Definition: GLViewer_Viewer2d.h:85
@ Oval
Definition: GLViewer_Viewer2d.h:88
PaperType
Type of paper for export to vector format.
Definition: GLViewer_Viewer2d.h:103
@ A3
Definition: GLViewer_Viewer2d.h:106
@ A2
Definition: GLViewer_Viewer2d.h:105
@ A4
Definition: GLViewer_Viewer2d.h:107
void wheelZoomChange(bool)
Signal needs for optimum recompute of zoom depending objects Warning: use recompute without update vi...
VectorFileType
Type of export vector file.
Definition: GLViewer_Viewer2d.h:93
@ POST_SCRIPT
Definition: GLViewer_Viewer2d.h:94
Definition: GLViewer_Viewer.h:60
virtual void onChangeBgColor()
Definition: GLViewer_Viewer.cxx:105
virtual bool updateOperations(QMouseEvent *)
Definition: GLViewer_Viewer.h:111
virtual GLViewer_ViewTransformer * createTransformer(int)
Definition: GLViewer_Viewer.cxx:228
virtual void onMouseEvent(SUIT_ViewWindow *, QMouseEvent *)
Definition: GLViewer_Viewer.cxx:359
virtual void startOperations(QMouseEvent *)
Definition: GLViewer_Viewer.h:110
virtual GLViewer_Selector * createSelector()
Definition: GLViewer_Viewer.cxx:244
virtual void finishOperations(QMouseEvent *)
Definition: GLViewer_Viewer.h:112
Definition: SUIT_Desktop.h:47
virtual SUIT_ViewWindow * createView(SUIT_Desktop *theDesktop)
Definition: SUIT_ViewModel.cxx:77
Definition: SUIT_ViewWindow.h:42
@ Rectangle
Definition: Plot2d.h:76