src/GLViewer/GLViewer_Context.h

Go to the documentation of this file.
00001 //  Copyright (C) 2005 OPEN CASCADE
00002 //
00003 //  This library is free software; you can redistribute it and/or
00004 //  modify it under the terms of the GNU Lesser General Public
00005 //  License as published by the Free Software Foundation; either
00006 //  version 2.1 of the License.
00007 //
00008 //  This library is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 //  Lesser General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU Lesser General Public
00014 //  License along with this library; if not, write to the Free Software
00015 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 //  Author : OPEN CASCADE
00020 //
00021 
00022 // File:      GLViewer_Context.h
00023 // Created:   November, 2004
00024 
00025 
00026 #ifndef GLVIEWER_CONTEXT_H
00027 #define GLVIEWER_CONTEXT_H
00028 
00029 #ifdef WNT
00030 #include "windows.h"
00031 #endif
00032 
00033 #include "GLViewer_Defs.h"
00034 #include "GLViewer_Object.h"
00035 
00036 #include <qrect.h>
00037 #include <qobject.h>
00038 #include <qregion.h>
00039 
00040 #include <Quantity_NameOfColor.hxx>
00041 #include <Quantity_Color.hxx>
00042 
00043 #include <GL/gl.h>
00044 
00045 class GLViewer_Viewer2d;
00046 
00047 #ifdef WNT
00048 #pragma warning( disable:4251 )
00049 #endif
00050 
00054 class GLVIEWER_API GLViewer_Context
00055 {
00056 public:
00058   GLViewer_Context( GLViewer_Viewer2d* );
00060   ~GLViewer_Context();
00061 
00063   void                  setUpdateAll( bool on ) { myUpdateAll = on; }
00065   bool                  isUpdateAll() const { return myUpdateAll; }
00066 
00068 
00074   int                   MoveTo( int x, int y, bool byCircle = FALSE );
00079   int                   Select( bool Append = FALSE, bool byCircle = FALSE );
00085   int                   SelectByRect( const QRect& theRect, bool Append = FALSE );
00086 
00088   void                  SetHighlightColor( Quantity_NameOfColor aCol );
00090   void                  SetSelectionColor( Quantity_NameOfColor aCol );
00092   Quantity_NameOfColor  HighlightColor() { return myHighlightColor; }
00094   Quantity_NameOfColor  SelectionColor() { return mySelectionColor; } 
00095 
00097   int                   NbSelected();
00099   void                  InitSelected();
00101   bool                  MoreSelected();
00103   bool                  NextSelected();
00105   GLViewer_Object*      SelectedObject();
00106 
00108   bool                  isSelected( GLViewer_Object* theObject );
00109 
00111 
00116   int                   insertObject( GLViewer_Object* theObject, bool display = false, bool isActive = true );
00118 
00121   bool                  replaceObject( GLViewer_Object* oldObject, GLViewer_Object* newObject );
00123   void                  updateScales( GLfloat theX, GLfloat theY );
00125   void                  setTolerance( int tol ) { myTolerance = tol; }
00126 
00128 
00131   const ObjList&        getObjects( bool isActive = true )
00132                         { return isActive ? myActiveObjects : myInactiveObjects; }
00133 
00135   GLViewer_Object*      getFirstObject() { return *( myActiveObjects.begin() ); }
00136 
00138   void                  clearHighlighted( bool updateViewer );
00140   void                  clearSelected( bool updateViewer );
00142   void                  setSelected( GLViewer_Object* theObject, bool updateViewer );
00144   void                  remSelected( GLViewer_Object* theObject, bool updateViewer );
00145 
00147   GLViewer_Object*      getCurrentObject() { return myLastPicked; }
00149   bool                  currentObjectIsChanged() { return myLastPickedChanged; }
00150 
00152   void                  eraseObject( GLViewer_Object* theObject, bool updateViewer = true );
00154   void                  deleteObject( GLViewer_Object* theObject, bool updateViewer = true );
00155 
00157   bool                  setActive( GLViewer_Object* theObject );
00159   bool                  setInactive( GLViewer_Object* theObject );
00160 
00161 protected:
00163 
00167   bool                  myUpdateAll;
00168 
00169   GLViewer_Viewer2d*    myGLViewer2d;
00171   GLViewer_Object*      myLastPicked;
00173   bool                  myLastPickedChanged;
00174 
00176 
00177   ObjList               myActiveObjects;
00179 
00180   ObjList               myInactiveObjects;
00181 
00183   ObjList               mySelectedObjects;
00185   int                   mySelCurIndex;
00186 
00188   GLfloat               myXhigh;
00190   GLfloat               myYhigh;
00191 
00193   Quantity_NameOfColor  myHighlightColor;
00195   Quantity_NameOfColor  mySelectionColor;
00197   GLboolean             myHFlag;
00199   GLboolean             mySFlag;
00201   int                   myTolerance;
00202 };
00203 
00204 #ifdef WNT
00205 #pragma warning ( default:4251 )
00206 #endif
00207 
00208 #endif