Back to index

salome-gui  6.5.0
GLViewer_Context.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  Author : OPEN CASCADE
00024 // File:      GLViewer_Context.h
00025 // Created:   November, 2004
00026 //
00027 #ifndef GLVIEWER_CONTEXT_H
00028 #define GLVIEWER_CONTEXT_H
00029 
00030 #ifdef WIN32
00031 #include "windows.h"
00032 #endif
00033 
00034 #include "GLViewer_Defs.h"
00035 #include "GLViewer_Object.h"
00036 
00037 class QRect;
00038 
00039 #include <Quantity_NameOfColor.hxx>
00040 #include <Quantity_Color.hxx>
00041 
00042 #include <GL/gl.h>
00043 
00044 class GLViewer_Viewer2d;
00045 
00046 #ifdef WIN32
00047 #pragma warning( disable:4251 )
00048 #endif
00049 
00053 class GLVIEWER_API GLViewer_Context
00054 {
00055 public:
00057   GLViewer_Context( GLViewer_Viewer2d* );
00059   ~GLViewer_Context();
00060 
00062   void                  setUpdateAll( bool on ) { myUpdateAll = on; }
00064   bool                  isUpdateAll() const { return myUpdateAll; }
00065 
00067 
00073   int                   MoveTo( int x, int y, bool byCircle = FALSE );
00078   int                   Select( bool Append = FALSE, bool byCircle = FALSE );
00084   int                   SelectByRect( const QRect& theRect, bool Append = FALSE );
00085 
00087   void                  SetHighlightColor( Quantity_NameOfColor aCol );
00089   void                  SetSelectionColor( Quantity_NameOfColor aCol );
00091   Quantity_NameOfColor  HighlightColor() { return myHighlightColor; }
00093   Quantity_NameOfColor  SelectionColor() { return mySelectionColor; } 
00094 
00096   int                   NbSelected();
00098   void                  InitSelected();
00100   bool                  MoreSelected();
00102   bool                  NextSelected();
00104   GLViewer_Object*      SelectedObject();
00105 
00107   bool                  isSelected( GLViewer_Object* theObject );
00108 
00110 
00115   int                   insertObject( GLViewer_Object* theObject, bool display = false, bool isActive = true );
00117 
00120   bool                  replaceObject( GLViewer_Object* oldObject, GLViewer_Object* newObject );
00122   void                  updateScales( GLfloat theX, GLfloat theY );
00124   void                  setTolerance( int tol ) { myTolerance = tol; }
00125 
00127 
00130   const ObjList&        getObjects( bool isActive = true )
00131                         { return isActive ? myActiveObjects : myInactiveObjects; }
00132 
00134   GLViewer_Object*      getFirstObject() { return *( myActiveObjects.begin() ); }
00135 
00137   void                  clearHighlighted( bool updateViewer );
00139   void                  clearSelected( bool updateViewer );
00141   void                  setSelected( GLViewer_Object* theObject, bool updateViewer );
00143   void                  remSelected( GLViewer_Object* theObject, bool updateViewer );
00144 
00146   GLViewer_Object*      getCurrentObject() { return myLastPicked; }
00148   bool                  currentObjectIsChanged() { return myLastPickedChanged; }
00149 
00151   void                  eraseObject( GLViewer_Object* theObject, bool updateViewer = true );
00153   void                  deleteObject( GLViewer_Object* theObject, bool updateViewer = true );
00154 
00156   bool                  setActive( GLViewer_Object* theObject );
00158   bool                  setInactive( GLViewer_Object* theObject );
00159 
00160 protected:
00162 
00166   bool                  myUpdateAll;
00167 
00168   GLViewer_Viewer2d*    myGLViewer2d;
00170   GLViewer_Object*      myLastPicked;
00172   bool                  myLastPickedChanged;
00173 
00175 
00176   ObjList               myActiveObjects;
00178 
00179   ObjList               myInactiveObjects;
00180 
00182   ObjList               mySelectedObjects;
00184   int                   mySelCurIndex;
00185 
00187   GLfloat               myXhigh;
00189   GLfloat               myYhigh;
00190 
00192   Quantity_NameOfColor  myHighlightColor;
00194   Quantity_NameOfColor  mySelectionColor;
00196   GLboolean             myHFlag;
00198   GLboolean             mySFlag;
00200   int                   myTolerance;
00201 };
00202 
00203 #ifdef WIN32
00204 #pragma warning ( default:4251 )
00205 #endif
00206 
00207 #endif