Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GLViewer_Context.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, 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_Context.h
25 // Created: November, 2004
26 //
27 #ifndef GLVIEWER_CONTEXT_H
28 #define GLVIEWER_CONTEXT_H
29 
30 #ifdef WIN32
31 #include "windows.h"
32 #endif
33 
34 #include "GLViewer_Defs.h"
35 #include "GLViewer_Object.h"
36 
37 class QRect;
38 
39 #include <Quantity_NameOfColor.hxx>
40 #include <Quantity_Color.hxx>
41 
42 #ifdef __APPLE__
43 #include <OpenGL/gl.h>
44 #else
45 #include <GL/gl.h>
46 #endif
47 
48 class GLViewer_Viewer2d;
49 
50 #ifdef WIN32
51 #pragma warning( disable:4251 )
52 #endif
53 
58 {
59 public:
64 
66  void setUpdateAll( bool on ) { myUpdateAll = on; }
68  bool isUpdateAll() const { return myUpdateAll; }
69 
71 
77  int MoveTo( int x, int y, bool byCircle = false );
82  int Select( bool Append = false, bool byCircle = false );
88  int SelectByRect( const QRect& theRect, bool Append = false );
89 
91  void SetHighlightColor( Quantity_NameOfColor aCol );
93  void SetSelectionColor( Quantity_NameOfColor aCol );
95  Quantity_NameOfColor HighlightColor() { return myHighlightColor; }
97  Quantity_NameOfColor SelectionColor() { return mySelectionColor; }
98 
100  int NbSelected();
102  void InitSelected();
104  bool MoreSelected();
106  bool NextSelected();
108  GLViewer_Object* SelectedObject();
109 
111  bool isSelected( GLViewer_Object* theObject );
112 
114 
119  int insertObject( GLViewer_Object* theObject, bool display = false, bool isActive = true );
121 
124  bool replaceObject( GLViewer_Object* oldObject, GLViewer_Object* newObject );
126  void updateScales( GLfloat theX, GLfloat theY );
128  void setTolerance( int tol ) { myTolerance = tol; }
129 
131 
134  const ObjList& getObjects( bool isActive = true )
135  { return isActive ? myActiveObjects : myInactiveObjects; }
136 
138  GLViewer_Object* getFirstObject() { return *( myActiveObjects.begin() ); }
139 
141  void clearHighlighted( bool updateViewer );
143  void clearSelected( bool updateViewer );
145  void setSelected( GLViewer_Object* theObject, bool updateViewer );
147  void remSelected( GLViewer_Object* theObject, bool updateViewer );
148 
150  GLViewer_Object* getCurrentObject() { return myLastPicked; }
152  bool currentObjectIsChanged() { return myLastPickedChanged; }
153 
155  void eraseObject( GLViewer_Object* theObject, bool updateViewer = true );
157  void deleteObject( GLViewer_Object* theObject, bool updateViewer = true );
158 
160  bool setActive( GLViewer_Object* theObject );
162  bool setInactive( GLViewer_Object* theObject );
163 
164 protected:
166 
171 
177 
179 
182 
184 
189 
191  GLfloat myXhigh;
193  GLfloat myYhigh;
194 
196  Quantity_NameOfColor myHighlightColor;
198  Quantity_NameOfColor mySelectionColor;
200  GLboolean myHFlag;
202  GLboolean mySFlag;
205 };
206 
207 #ifdef WIN32
208 #pragma warning ( default:4251 )
209 #endif
210 
211 #endif