Version: 9.16.0
GLViewer_Context.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 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_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
37class 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
49
50#ifdef WIN32
51#pragma warning( disable:4251 )
52#endif
53
58{
59public:
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
164protected:
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
#define GLVIEWER_API
Macro for exports.
Definition: GLViewer.h:37
QList< GLViewer_Object * > ObjList
Definition: GLViewer_Defs.h:62
Definition: GLViewer_Context.h:58
GLfloat myXhigh
X coordinate of mouse cursor.
Definition: GLViewer_Context.h:191
bool isUpdateAll() const
Returns update flag in highlighting technology.
Definition: GLViewer_Context.h:68
int mySelCurIndex
Selected object iterator.
Definition: GLViewer_Context.h:188
ObjList myActiveObjects
List of active object.
Definition: GLViewer_Context.h:180
GLfloat myYhigh
Y coordinate of mouse cursor.
Definition: GLViewer_Context.h:193
Quantity_NameOfColor myHighlightColor
Color for highlight.
Definition: GLViewer_Context.h:196
bool myUpdateAll
Flag of updating viewer after highlight.
Definition: GLViewer_Context.h:170
GLboolean mySFlag
If = false - select method is not any select.
Definition: GLViewer_Context.h:202
GLViewer_Object * getCurrentObject()
Returns highlighted object.
Definition: GLViewer_Context.h:150
Quantity_NameOfColor mySelectionColor
Color for selection.
Definition: GLViewer_Context.h:198
ObjList mySelectedObjects
List of selected objects.
Definition: GLViewer_Context.h:186
GLboolean myHFlag
If = false - moveTo method is not any highlighting.
Definition: GLViewer_Context.h:200
GLViewer_Object * myLastPicked
Highlighted object.
Definition: GLViewer_Context.h:174
int myTolerance
Tolerance in window pixels for highlghting and selection methods.
Definition: GLViewer_Context.h:204
Quantity_NameOfColor SelectionColor()
Returns select color.
Definition: GLViewer_Context.h:97
const ObjList & getObjects(bool isActive=true)
Returns list of context objects.
Definition: GLViewer_Context.h:134
GLViewer_Viewer2d * myGLViewer2d
Definition: GLViewer_Context.h:172
GLViewer_Object * getFirstObject()
Returns first active object.
Definition: GLViewer_Context.h:138
void setTolerance(int tol)
A function installing tolerance in window pixels for highlghting and selection methods.
Definition: GLViewer_Context.h:128
bool currentObjectIsChanged()
Returns true if after last MoveTo method calling highlight object is changed.
Definition: GLViewer_Context.h:152
void setUpdateAll(bool on)
A function installing update flag in highlighting technology.
Definition: GLViewer_Context.h:66
ObjList myInactiveObjects
List of inactive object.
Definition: GLViewer_Context.h:183
bool myLastPickedChanged
= true if after last MoveTo method calling highlight object is changed
Definition: GLViewer_Context.h:176
Quantity_NameOfColor HighlightColor()
Returns highlight color.
Definition: GLViewer_Context.h:95
Definition: GLViewer_Object.h:65
Definition: GLViewer_Viewer2d.h:76