From: abd Date: Mon, 4 Jul 2005 03:30:39 +0000 (+0000) Subject: Update comments X-Git-Tag: V3_0_1~95 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=17f067976939532047d730120d5d30b03ab73ff8;p=modules%2Fgui.git Update comments --- diff --git a/src/GLViewer/GLViewer_Context.cxx b/src/GLViewer/GLViewer_Context.cxx index 8a51e5daf..699df866d 100644 --- a/src/GLViewer/GLViewer_Context.cxx +++ b/src/GLViewer/GLViewer_Context.cxx @@ -3,14 +3,10 @@ // Author: OCC team // Copyright (C) CEA 2004 -/**************************************************************************** -** Class: GLViewer_Context -** Descr: OpenGL Context -** Module: GLViewer -** Created: UI team, 20.09.02 -*****************************************************************************/ - -//#include +//================================================================ +// Class : GLViewer_AspectLine +// Description : Class for manage of presentations in GLViewer +//================================================================ #include "GLViewer_Context.h" @@ -23,6 +19,10 @@ #define TOLERANCE 12 +//======================================================================= +// Function: GLViewer_Context +// Purpose : +//======================================================================= GLViewer_Context::GLViewer_Context( GLViewer_Viewer2d* v ) : myGLViewer2d( v ), myHighlightColor( Quantity_NOC_CYAN1 ), @@ -40,6 +40,10 @@ GLViewer_Context::GLViewer_Context( GLViewer_Viewer2d* v ) : mySelCurIndex = 0; } +//======================================================================= +// Function: ~GLViewer_Context +// Purpose : +//======================================================================= GLViewer_Context::~GLViewer_Context() { myActiveObjects.clear(); @@ -47,6 +51,10 @@ GLViewer_Context::~GLViewer_Context() mySelectedObjects.clear(); } +//======================================================================= +// Function: MoveTo +// Purpose : +//======================================================================= int GLViewer_Context::MoveTo( int xi, int yi, bool byCircle ) { GLfloat x = (GLfloat)xi; @@ -155,6 +163,10 @@ int GLViewer_Context::MoveTo( int xi, int yi, bool byCircle ) return 0; } +//======================================================================= +// Function: GLViewer_Select +// Purpose : +//======================================================================= int GLViewer_Context::Select( bool Append, bool byCircle ) { ObjList::Iterator it, itEnd, oit, oitEnd; @@ -200,7 +212,7 @@ int GLViewer_Context::Select( bool Append, bool byCircle ) if( status == SS_Invalid ) status = SS_GlobalChanged; } - else if( status = SS_LocalChanged ) + else if( status == SS_LocalChanged ) status = SS_GlobalChanged; return status; @@ -282,6 +294,10 @@ int GLViewer_Context::Select( bool Append, bool byCircle ) return SS_NoChanged; } +//======================================================================= +// Function: GLViewer_SelectByRect +// Purpose : +//======================================================================= int GLViewer_Context::SelectByRect( const QRect& theRect, bool Append ) { GLfloat aXScale; @@ -340,6 +356,10 @@ int GLViewer_Context::SelectByRect( const QRect& theRect, bool Append ) return status; } +//======================================================================= +// Function: GLViewer_SetHighlightColor +// Purpose : +//======================================================================= void GLViewer_Context::SetHighlightColor( Quantity_NameOfColor aCol ) { myHighlightColor = aCol; @@ -359,6 +379,10 @@ void GLViewer_Context::SetHighlightColor( Quantity_NameOfColor aCol ) myGLViewer2d->updateColors( colH, colS); } +//======================================================================= +// Function: GLViewer_SetSelectionColor +// Purpose : +//======================================================================= void GLViewer_Context::SetSelectionColor( Quantity_NameOfColor aCol ) { mySelectionColor = aCol; @@ -378,21 +402,37 @@ void GLViewer_Context::SetSelectionColor( Quantity_NameOfColor aCol ) myGLViewer2d->updateColors( colH, colS); } +//======================================================================= +// Function: GLViewer_NbSelected +// Purpose : +//======================================================================= int GLViewer_Context::NbSelected() { return mySelectedObjects.count(); } +//======================================================================= +// Function: GLViewer_InitSelected +// Purpose : +//======================================================================= void GLViewer_Context::InitSelected() { mySelCurIndex = 0; } +//======================================================================= +// Function: GLViewer_MoreSelected +// Purpose : +//======================================================================= bool GLViewer_Context::MoreSelected() { return ( mySelCurIndex < NbSelected() ); } +//======================================================================= +// Function: GLViewer_NextSelected +// Purpose : +//======================================================================= bool GLViewer_Context::NextSelected() { if ( mySelCurIndex >= 0 && mySelCurIndex < NbSelected() ) @@ -404,16 +444,28 @@ bool GLViewer_Context::NextSelected() return FALSE; } +//======================================================================= +// Function: GLViewer_SelectedObject +// Purpose : +//======================================================================= GLViewer_Object* GLViewer_Context::SelectedObject() { return mySelectedObjects[ mySelCurIndex ]; } +//======================================================================= +// Function: GLViewer_isSelected +// Purpose : +//======================================================================= bool GLViewer_Context::isSelected( GLViewer_Object* theObj ) { return mySelectedObjects.contains( theObj ); } +//======================================================================= +// Function: GLViewer_insertObject +// Purpose : +//======================================================================= int GLViewer_Context::insertObject( GLViewer_Object* object, bool display, bool isActive ) { // cout << "GLViewer_Context::insertObject" << endl; @@ -437,6 +489,10 @@ int GLViewer_Context::insertObject( GLViewer_Object* object, bool display, bool return myActiveObjects.count() + myInactiveObjects.count(); } +//======================================================================= +// Function: GLViewer_replaceObject +// Purpose : +//======================================================================= bool GLViewer_Context::replaceObject( GLViewer_Object* oldObject, GLViewer_Object* newObject ) { if( !oldObject || !newObject ) @@ -459,6 +515,10 @@ bool GLViewer_Context::replaceObject( GLViewer_Object* oldObject, GLViewer_Objec return false; } +//======================================================================= +// Function: GLViewer_updateScales +// Purpose : +//======================================================================= void GLViewer_Context::updateScales( GLfloat scX, GLfloat scY ) { if( scX <= 0 || scY <= 0 ) @@ -473,6 +533,10 @@ void GLViewer_Context::updateScales( GLfloat scX, GLfloat scY ) (*it)->setScale( scX, scY ); } +//======================================================================= +// Function: GLViewer_clearHighlighted +// Purpose : +//======================================================================= void GLViewer_Context::clearHighlighted() { if( myHFlag && myLastPicked ) @@ -484,6 +548,10 @@ void GLViewer_Context::clearHighlighted() } } +//======================================================================= +// Function: GLViewer_clearSelected +// Purpose : +//======================================================================= void GLViewer_Context::clearSelected( bool updateViewer ) { if( !mySFlag ) @@ -503,6 +571,10 @@ void GLViewer_Context::clearSelected( bool updateViewer ) mySelectedObjects.clear(); } +//======================================================================= +// Function: GLViewer_setSelected +// Purpose : +//======================================================================= void GLViewer_Context::setSelected( GLViewer_Object* object, bool updateViewer ) { if( !object ) @@ -518,6 +590,10 @@ void GLViewer_Context::setSelected( GLViewer_Object* object, bool updateViewer ) myGLViewer2d->activateDrawer( object, TRUE, TRUE ); } +//======================================================================= +// Function: GLViewer_remSelected +// Purpose : +//======================================================================= void GLViewer_Context::remSelected( GLViewer_Object* object, bool updateViewer ) { if( !object || !mySelectedObjects.contains( object ) ) @@ -530,6 +606,10 @@ void GLViewer_Context::remSelected( GLViewer_Object* object, bool updateViewer ) myGLViewer2d->activateDrawer( object, TRUE, TRUE ); } +//======================================================================= +// Function: GLViewer_eraseObject +// Purpose : +//======================================================================= void GLViewer_Context::eraseObject( GLViewer_Object* theObject, bool theUpdateViewer ) { if( !theObject || !myActiveObjects.contains( theObject ) ) @@ -543,6 +623,10 @@ void GLViewer_Context::eraseObject( GLViewer_Object* theObject, bool theUpdateVi myGLViewer2d->updateAll(); } +//======================================================================= +// Function: GLViewer_deleteObject +// Purpose : +//======================================================================= void GLViewer_Context::deleteObject( GLViewer_Object* theObject, bool updateViewer ) { if( !theObject || @@ -569,6 +653,10 @@ void GLViewer_Context::deleteObject( GLViewer_Object* theObject, bool updateView myGLViewer2d->updateAll(); } +//======================================================================= +// Function: GLViewer_setActive +// Purpose : +//======================================================================= bool GLViewer_Context::setActive( GLViewer_Object* theObject ) { if( !theObject || !myInactiveObjects.contains( theObject ) ) @@ -579,6 +667,10 @@ bool GLViewer_Context::setActive( GLViewer_Object* theObject ) return true; } +//======================================================================= +// Function: GLViewer_setInactive +// Purpose : +//======================================================================= bool GLViewer_Context::setInactive( GLViewer_Object* theObject ) { if( !theObject || !myActiveObjects.contains( theObject ) ) diff --git a/src/GLViewer/GLViewer_Context.h b/src/GLViewer/GLViewer_Context.h index 8ce09f7be..603e183cf 100644 --- a/src/GLViewer/GLViewer_Context.h +++ b/src/GLViewer/GLViewer_Context.h @@ -3,12 +3,11 @@ // Author: OCC team // Copyright (C) CEA 2004 -/*************************************************************************** -** Class: GLViewer_Context -** Descr: OpenGL Context -** Module: GLViewer -** Created: UI team, 04.09.02 -****************************************************************************/ + +/*! Class GLViewer_Context + * Class for manage of presentations in GLViewer + */ + #ifndef GLVIEWER_CONTEXT_H #define GLVIEWER_CONTEXT_H @@ -16,10 +15,9 @@ #include "windows.h" #endif +#include "GLViewer_Defs.h" #include "GLViewer_Object.h" -#include -#include #include #include #include @@ -29,92 +27,161 @@ #include -typedef QMap ObjectMap; -typedef QValueList ObjList; - class GLViewer_Viewer2d; #ifdef WNT #pragma warning( disable:4251 ) #endif -enum SelectionStatus -{ - SS_Invalid, - SS_LocalChanged, - SS_GlobalChanged, - SS_NoChanged -}; - class GLVIEWER_API GLViewer_Context { public: + //! A constructor GLViewer_Context( GLViewer_Viewer2d* ); + //! A desructor ~GLViewer_Context(); + //! A function installing update flag in highlighting technology void setUpdateAll( bool on ) { myUpdateAll = on; } + //! Returns update flag in highlighting technology bool isUpdateAll() const { return myUpdateAll; } + //! Main interactive method. Trace mouse in viewer window + /*! + *\param x - X coord of mouse cursor + *\param y - Y coord of mouse cursor + *\paran byCircle - true if needs round sensitive area around mouse cursor, else rectangle + *function search object rectangle which intersect with sensitive area and call object highlight method + */ int MoveTo( int x, int y, bool byCircle = FALSE ); + //! A function selecting already highlighting object by calling object method select + /*! + *\param Append - true if new selection will be append to existing selection, false - another + *\param byCircle - true if needs round selection area in complex object + */ int Select( bool Append = FALSE, bool byCircle = FALSE ); - int SelectByRect( const QRect&, bool Append = FALSE ); - + //! A function selecting objects on scene by rectangle + /*! + *\param theRect - rectangle of selection + *\param Append - true if new selection will be append to existing selection, false - another + *function search object rectangle which intersect with theRect and call object select method + */ + int SelectByRect( const QRect& theRect, bool Append = FALSE ); + + //! A function installing highlight color for all presentation (does not work) void SetHighlightColor( Quantity_NameOfColor aCol ); + //! A function installing select color for all presentation (does not work) void SetSelectionColor( Quantity_NameOfColor aCol ); + //! Returns highlight color Quantity_NameOfColor HighlightColor() { return myHighlightColor; } + //! Returns select color Quantity_NameOfColor SelectionColor() { return mySelectionColor; } + //! Returns number of objects in current selection int NbSelected(); + //! A function set iterator of selected objects on first object void InitSelected(); + //! Retuns true if iterator of selected objects is not set on last object bool MoreSelected(); + //! Increment of iterator of selected objects bool NextSelected(); + //! Returns object corresponding the current iterator of selected objects GLViewer_Object* SelectedObject(); - bool isSelected( GLViewer_Object* ); - - int insertObject( GLViewer_Object*, bool display = false, bool isActive = true ); - bool replaceObject( GLViewer_Object*, GLViewer_Object* ); - void updateScales( GLfloat, GLfloat ); + //! Returns true if theObject is selected + bool isSelected( GLViewer_Object* theObject ); + + //! Insert new object in context + /*! + *\param theObject - inserting object + *\param display - true if needs display object immediatly after inserting, else false + *\param isActive - true if needs inserting object in active list + */ + int insertObject( GLViewer_Object* theObject, bool display = false, bool isActive = true ); + //! Replacing objects in context + /*! + * Function search activ and incative objects + */ + bool replaceObject( GLViewer_Object* oldObject, GLViewer_Object* newObject ); + //! A function updating scales of all objects in context + void updateScales( GLfloat theX, GLfloat theY ); + //! A function installing tolerance in window pixels for highlghting and selection methods void setTolerance( int tol ) { myTolerance = tol; } - //const ObjectMap& getObjects() { return myObjects; } + //! Returns list of context objects + /*! + * Returns active objects if isActive = true, else inactive objects + */ const ObjList& getObjects( bool isActive = true ) { return isActive ? myActiveObjects : myInactiveObjects; } + + //! Returns first active object GLViewer_Object* getFirstObject() { return *( myActiveObjects.begin() ); } + //! A function clear highlighted object information void clearHighlighted(); + //! A function clear selection object information void clearSelected( bool updateViewer ); - void setSelected( GLViewer_Object*, bool updateViewer ); - void remSelected( GLViewer_Object*, bool updateViewer ); + //! A function make theObject as selected object and update viewer if updateViewer = true + void setSelected( GLViewer_Object* theObject, bool updateViewer ); + //! A function make theObject as unselected object and update viewer if updateViewer = true + void remSelected( GLViewer_Object* theObject, bool updateViewer ); + //! Returns highlighted object GLViewer_Object* getCurrentObject() { return myLastPicked; } + //! Returns true if after last MoveTo method calling highlight object is changed bool currentObjectIsChanged() { return myLastPickedChanged; } - void eraseObject( GLViewer_Object*, bool updateViewer = true ); - void deleteObject( GLViewer_Object*, bool updateViewer = true ); + //! A function installing to theObject invisible status and update viewer if updateViewer = true + void eraseObject( GLViewer_Object* theObject, bool updateViewer = true ); + //! A function remove theObject from context and update viewer if updateViewer = true + void deleteObject( GLViewer_Object* theObject, bool updateViewer = true ); - bool setActive( GLViewer_Object* ); - bool setInactive( GLViewer_Object* ); + //! A function installing to theObject active status + bool setActive( GLViewer_Object* theObject ); + //! A function installing to theObject inactive status + bool setInactive( GLViewer_Object* theObject ); protected: + //! Flag of updating viewer after highlight + /*! + * if = true, the viewer update all objects after change of highlight object, + * else - only highlight object + */ bool myUpdateAll; GLViewer_Viewer2d* myGLViewer2d; + //! Highlighted object GLViewer_Object* myLastPicked; + //! = true if after last MoveTo method calling highlight object is changed bool myLastPickedChanged; + //! List of active object + /*!Active objects if consider in highlight and select methods*/ ObjList myActiveObjects; + //! List of inactive object + /*!Active objects isn't consider in highlight and select methods*/ ObjList myInactiveObjects; + //! List of selected objects ObjList mySelectedObjects; + //! Selected object iterator int mySelCurIndex; + //! X coordinate of mouse cursor GLfloat myXhigh; + //! Y coordinate of mouse cursor GLfloat myYhigh; + + //! Color for highlight Quantity_NameOfColor myHighlightColor; + //! Color for selection Quantity_NameOfColor mySelectionColor; + //! If = false - moveTo method is not any highlighting GLboolean myHFlag; + //! If = false - select method is not any select GLboolean mySFlag; + //! Tolerance in window pixels for highlghting and selection methods int myTolerance; }; diff --git a/src/GLViewer/GLViewer_Defs.h b/src/GLViewer/GLViewer_Defs.h index 694e678c3..0ef2cb4d1 100644 --- a/src/GLViewer/GLViewer_Defs.h +++ b/src/GLViewer/GLViewer_Defs.h @@ -6,6 +6,10 @@ #ifndef GLVIEWER_DEFS_H #define GLVIEWER_DEFS_H +#include +#include + +class GLViewer_Object; //Selection staus enum SelectionChangeStatus { @@ -14,16 +18,27 @@ enum SelectionChangeStatus SCS_Global }; -//Fit Selection Rectangle +//! Fit Selection Rectangle static const int SELECTION_RECT_GAP = 50; -//Display Text Format of Objects +//! Display Text Format of Objects enum DisplayTextFormat { DTF_TEXTURE = 0, DTF_BITMAP = 1 }; +enum SelectionStatus +{ + SS_Invalid, + SS_LocalChanged, + SS_GlobalChanged, + SS_NoChanged +}; + +typedef QMap ObjectMap; +typedef QValueList ObjList; + #define SEGMENTS 32 #define PI 3.14159265359 #define STEP ( float )( 2 * PI / SEGMENTS )