Salome HOME
refs #416: to store the open state of object browser items in the binary array
[modules/gui.git] / src / GLViewer / GLViewer_BaseObjects.cxx
index 759736136aba37a82e21f1c0abd8b0c402582b8e..86112cb7814b3cb8f11fde5c7f35d983de7cbc6c 100644 (file)
@@ -1,30 +1,38 @@
-/***************************************************************************
-**  Class:   GLViewer_BaseObjects
-**  Descr:   Internal OpenGL Objects
-**  Module:  GLViewer
-**  Created: UI team, 02.09.02
-****************************************************************************/
-
-//#include <GLViewerAfx.h>
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 #include "GLViewer_BaseObjects.h"
 #include "GLViewer_BaseDrawers.h"
 #include "GLViewer_AspectLine.h"
 #include "GLViewer_CoordSystem.h"
 #include "GLViewer_Text.h"
 #include "GLViewer_Group.h"
-
 #include "GLViewer_Drawer.h"
 
-//#include <cmath>
-//using namespace std;
-
-/***************************************************************************
-**  Class:   GLViewer_MarkerSet
-**  Descr:   OpenGL MarkerSet
-**  Module:  GLViewer
-**  Created: UI team, 03.09.02
-****************************************************************************/
+#include <QFile>
 
+/*!
+  Constructor
+*/
 GLViewer_MarkerSet::GLViewer_MarkerSet( int number, float size, const QString& toolTip ) :
   GLViewer_Object(),
   myNumber( 0 ),
@@ -46,6 +54,9 @@ GLViewer_MarkerSet::GLViewer_MarkerSet( int number, float size, const QString& t
     setNumMarkers( number );    
 }
 
+/*!
+  Destructor
+*/
 GLViewer_MarkerSet::~GLViewer_MarkerSet()
 {
     if ( myXCoord )
@@ -54,6 +65,16 @@ GLViewer_MarkerSet::~GLViewer_MarkerSet()
         delete[] myYCoord;
 }
 
+/*!
+  Adds coords to text buffer in HPGL format
+  \param buffer - text buffer
+  \param command - command to be added with coords
+  \param aViewerCS - viewer co-ordinates system
+  \param aPaperCS - paper co-ordinates system
+  \param x - x co-ordinate
+  \param y - y co-ordinate
+  \param NewLine - adds new line to buffer
+*/
 void AddCoordsToHPGL( QString& buffer, QString command, GLViewer_CoordSystem* aViewerCS, 
                       GLViewer_CoordSystem* aPaperCS, double x, double y, bool NewLine = true )
 {
@@ -66,6 +87,16 @@ void AddCoordsToHPGL( QString& buffer, QString command, GLViewer_CoordSystem* aV
         buffer += ";\n";
 }
 
+/*!
+  Adds coords to text buffer in PostScript format
+  \param buffer - text buffer
+  \param command - command to be added with coords
+  \param aViewerCS - viewer co-ordinates system
+  \param aPaperCS - paper co-ordinates system
+  \param x - x co-ordinate
+  \param y - y co-ordinate
+  \param NewLine - adds new line to buffer
+*/
 void AddCoordsToPS( QString& buffer, QString command, GLViewer_CoordSystem* aViewerCS, 
                     GLViewer_CoordSystem* aPaperCS, double x, double y, bool NewLine = true )
 {
@@ -78,6 +109,13 @@ void AddCoordsToPS( QString& buffer, QString command, GLViewer_CoordSystem* aVie
         buffer += "\n";
 }
 
+/*!
+  Adds line aspect description to text buffer in PostScript format
+  \param buffer - text buffer
+  \param anAspect - line aspect
+  \param aViewerCS - viewer co-ordinates system
+  \param aPaperCS - paper co-ordinates system
+*/
 void AddLineAspectToPS( QString& buffer, GLViewer_AspectLine* anAspect, 
                         GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPaperCS )
 {
@@ -108,6 +146,13 @@ void AddLineAspectToPS( QString& buffer, GLViewer_AspectLine* anAspect,
 }
 
 #ifdef WIN32
+/*!
+  Adds line aspect description EMF image
+  \param hDC - descriptor of EMF
+  \param anAspect - line aspect
+  \param aViewerCS - viewer co-ordinates system
+  \param aPaperCS - paper co-ordinates system
+*/
 HPEN AddLineAspectToEMF( HDC hDC, GLViewer_AspectLine* anAspect, 
                          GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPaperCS )
 {
@@ -129,6 +174,12 @@ HPEN AddLineAspectToEMF( HDC hDC, GLViewer_AspectLine* anAspect,
 }
 #endif
 
+/*!
+  Saves to file PostScript set of markers
+  \param hFile - file instance
+  \param aViewerCS - viewer co-ordinates system
+  \param aPSCS - paper co-ordinates system
+*/
 bool GLViewer_MarkerSet::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
 {   
     int noPoints = 20;
@@ -161,11 +212,17 @@ bool GLViewer_MarkerSet::translateToPS( QFile& hFile, GLViewer_CoordSystem* aVie
     }
     aBuffer+="closepath\nstroke\n";
 
-    hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+    hFile.write( aBuffer.toAscii() );
 
     return true;
 }
 
+/*!
+  Saves to file HPGL set of markers
+  \param hFile - file instance
+  \param aViewerCS - viewer co-ordinates system
+  \param aHPGLCS - paper co-ordinates system
+*/
 bool GLViewer_MarkerSet::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS,
                                        GLViewer_CoordSystem* aHPGLCS )
 {
@@ -193,13 +250,19 @@ bool GLViewer_MarkerSet::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aV
         }
         aBuffer+="PU;\n";
 
-        hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+        hFile.write( aBuffer.toAscii() );
     }
 
     return true;
 }
 
 #ifdef WIN32
+/*!
+  Saves to EMF image set of markers
+  \param dc - EMF image descriptor
+  \param aViewerCS - viewer co-ordinates system
+  \param aEMFCS - paper co-ordinates system
+*/
 bool GLViewer_MarkerSet::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
 {
     int noPoints = 20;
@@ -235,7 +298,9 @@ bool GLViewer_MarkerSet::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS
 }
 #endif
 
-
+/*! 
+  Computes all necessary information about object for presentation in drawer
+*/
 void GLViewer_MarkerSet::compute()
 {
 //  cout << "GLViewer_MarkerSet::compute" << endl;
@@ -246,10 +311,10 @@ void GLViewer_MarkerSet::compute()
 
   for ( int i = 0; i < myNumber; i++ )  
   {
-    xa = QMIN( xa, myXCoord[i] );
-    xb = QMAX( xb, myXCoord[i] );
-    ya = QMIN( ya, myYCoord[i] );
-    yb = QMAX( yb, myYCoord[i] );
+    xa = qMin( xa, myXCoord[i] );
+    xb = qMax( xb, myXCoord[i] );
+    ya = qMin( ya, myYCoord[i] );
+    yb = qMax( yb, myYCoord[i] );
   }
   
   myXGap = ( xb - xa ) / 10;
@@ -261,13 +326,23 @@ void GLViewer_MarkerSet::compute()
   myRect->setBottom( ya - myYGap );
 }
 
+/*!
+  Creates corresponding drawer
+*/
 GLViewer_Drawer* GLViewer_MarkerSet::createDrawer()
 {
 //  cout << "GLViewer_MarkerSet::createDrawer" << endl;
   return myDrawer = new GLViewer_MarkerDrawer();
 }
 
-
+/*!
+  Computes highlight presentation
+  \param x        - x coord
+  \param y        - y coord
+  \param tol      - tolerance of detecting
+  \param isCircle - true if sensitive area of detection is round
+  \return true if highlight status is changed
+*/
 GLboolean GLViewer_MarkerSet::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle )
 {
     if( !myIsVisible )
@@ -275,8 +350,8 @@ GLboolean GLViewer_MarkerSet::highlight( GLfloat x, GLfloat y, GLfloat tol, GLbo
 //  cout << "GLViewer_MarkerSet::highlight " << x <<" " << y << " " << tol << endl;
   int count = 0;
   GLfloat xdist, ydist, radius;
-  QValueList<int>::Iterator it;
-  QValueList<int> curHNumbers;
+  QList<int>::Iterator it;
+  QList<int> curHNumbers;
   bool isFound;
   GLboolean update;
   int cnt = 0;
@@ -292,8 +367,8 @@ GLboolean GLViewer_MarkerSet::highlight( GLfloat x, GLfloat y, GLfloat tol, GLbo
     ydist = ( myYCoord[i] - y ) * myYScale;
 
 //    if ( isCircle && ( xdist * xdist + ydist * ydist <= radius * radius ) ||
-    if ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) ||
-    !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) )
+    if ( ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) ) ||
+         ( !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) ) )
     {
       isFound = FALSE;
       count++;
@@ -321,6 +396,9 @@ GLboolean GLViewer_MarkerSet::highlight( GLfloat x, GLfloat y, GLfloat tol, GLbo
   return update;
 }
 
+/*!
+  Unhilights object
+*/
 GLboolean GLViewer_MarkerSet::unhighlight()
 {
   if( !myHNumbers.isEmpty() )
@@ -335,6 +413,15 @@ GLboolean GLViewer_MarkerSet::unhighlight()
   return GL_FALSE;
 }
 
+/*!
+  Selects marker set
+  /param x, y - co-ordinates of mouse
+  /param tol - tolerance
+  /param rect - rectangle (in case of rectangular selection)
+  /param isFull - if it is true, then object may selected only if it lays whole in selection zone
+  \param isCircle - true if sensitive area of detection is round
+  \param isShift  - true if selection exec with append option
+*/
 GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull,
                                       GLboolean isCircle, GLboolean isShift )
 {
@@ -343,10 +430,10 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe
 //  cout << "GLViewer_MarkerSet::select " << x << " " << y << endl;
   int count = 0;
   GLfloat xdist, ydist, radius;
-  QValueList<int>::Iterator it;
-  QValueList<int>::Iterator it1;
-  QValueList<int>::Iterator remIt;
-  QValueList<int>::Iterator curIt;
+  QList<int>::Iterator it;
+  QList<int>::Iterator it1;
+  QList<int>::Iterator remIt;
+  QList<int>::Iterator curIt;
 
   radius = tol - myMarkerSize / 2.;
 
@@ -369,8 +456,8 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe
     ydist = ( myYCoord[i] - y ) * myYScale;
 
     //if ( isCircle && ( xdist * xdist + ydist * ydist <= radius * radius ) ||
-    if ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) ||
-          !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) )
+    if ( ( isCircle && ( xdist * xdist + ydist * ydist <= myMarkerSize * myMarkerSize ) ) ||
+         ( !isCircle && ( fabs( xdist ) <= radius && fabs( ydist ) <= radius ) ) )
     {
       count++;
       if ( isShift )
@@ -392,35 +479,35 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe
             for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 )
               if( i == *it1 )
               {
-                myHNumbers.remove( it1 );
+                myHNumbers.erase( it1 );
                 break;
               }
       for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 )
         if( i == *it1 )
         {
-          myUHNumbers.remove( it1 );
+          myUHNumbers.erase( it1 );
           break;
         }
         }
     else
         {
-      mySelNumbers.remove( remIt );
+      mySelNumbers.erase( remIt );
       for ( curIt = myCurSelNumbers.begin(); curIt != myCurSelNumbers.end(); ++curIt )
         if( *curIt == *remIt)
         {
-          myCurSelNumbers.remove( curIt );
+          myCurSelNumbers.erase( curIt );
           break;
         }
       for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 )
         if( i == *it1 )
         {
-          myHNumbers.remove( it1 );
+          myHNumbers.erase( it1 );
           break;
         }
       for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 )
         if( i == *it1 )
         {
-          myUHNumbers.remove( it1 );
+          myUHNumbers.erase( it1 );
           break;
         }
         }
@@ -432,13 +519,13 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe
     for ( it1 = myHNumbers.begin(); it1 != myHNumbers.end(); ++it1 )
       if( i == *it1 )
       {
-        myHNumbers.remove( it1 );
+        myHNumbers.erase( it1 );
         break;
       }
     for ( it1 = myUHNumbers.begin(); it1 != myUHNumbers.end(); ++it1 )
       if( i == *it1 )
           {
-        myUHNumbers.remove( it1 );
+        myUHNumbers.erase( it1 );
         break;
       }        
       }     
@@ -449,7 +536,7 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe
     for( it1 = myUSelNumbers.begin(); it1 != myUSelNumbers.end(); ++it1 )
       if( *it == *it1 )
       {
-        it1 = myUSelNumbers.remove( it1 );
+        it1 = myUSelNumbers.erase( it1 );
         it1--;
       }
   
@@ -459,6 +546,9 @@ GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewe
   return myIsSel;
 }
 
+/*!
+  Unselects marker set
+*/
 GLboolean GLViewer_MarkerSet::unselect()
 {
   if( !mySelNumbers.isEmpty() )
@@ -472,6 +562,10 @@ GLboolean GLViewer_MarkerSet::unselect()
   return GL_FALSE;
 }
 
+/*!
+  \return update object rectangle
+  Does not equal getRect() if object have a persistence to some viewer transformations
+*/
 GLViewer_Rect* GLViewer_MarkerSet::getUpdateRect()
 {
   GLViewer_Rect* rect = new GLViewer_Rect();
@@ -489,7 +583,11 @@ GLViewer_Rect* GLViewer_MarkerSet::getUpdateRect()
   return rect;
 }
 
-
+/*!
+  Sets array of x coords of points
+  \param xCoord - array of co-ordinates
+  \param size - array size
+*/
 void GLViewer_MarkerSet::setXCoord( GLfloat* xCoord, int size )
 {
   myXCoord = new GLfloat[ size ];
@@ -497,6 +595,11 @@ void GLViewer_MarkerSet::setXCoord( GLfloat* xCoord, int size )
      myXCoord[i] = xCoord[i];
 }
 
+/*!
+  Sets array of y coords of points
+  \param yCoord - array of co-ordinates
+  \param size - array size
+*/
 void GLViewer_MarkerSet::setYCoord( GLfloat* yCoord, int size )
 {
   myYCoord = new GLfloat[ size ];
@@ -504,6 +607,10 @@ void GLViewer_MarkerSet::setYCoord( GLfloat* yCoord, int size )
      myYCoord[i] = yCoord[i];
 }
 
+/*!
+  Sets number of markers
+  \param number - new number of markers
+*/
 void GLViewer_MarkerSet::setNumMarkers( GLint number )
 {
   if ( myNumber == number )
@@ -519,27 +626,15 @@ void GLViewer_MarkerSet::setNumMarkers( GLint number )
   myXCoord = new GLfloat[ myNumber ];
   myYCoord = new GLfloat[ myNumber ];
 }
-/*
-void GLViewer_MarkerSet::onSelectionDone( bool append)
-{
-  mySelectedIndexes.Clear();
-  QValueList<int>::Iterator it;
-  //for( it = myMarkers->mySelNumbers.begin(); it != myMarkers->mySelNumbers.end(); ++it )
-  //  mySelectedIndexes.Append( *it / 2 ); //!!!
 
-  emit dvMarkersSelected( mySelectedIndexes );
-}
 
-void GLViewer_MarkerSet::onSelectionCancel()
-{
-  mySelectedIndexes.Clear();
-  emit dvMarkersSelected( mySelectedIndexes );
-}
+/*!
+  Export numbers of highlighted/selected lines
 */
-void GLViewer_MarkerSet::exportNumbers( QValueList<int>& highlight,
-                     QValueList<int>& unhighlight,
-                     QValueList<int>& select,
-                     QValueList<int>& unselect )
+void GLViewer_MarkerSet::exportNumbers( QList<int>& highlight,
+                     QList<int>& unhighlight,
+                     QList<int>& select,
+                     QList<int>& unselect )
 {
     highlight = myHNumbers;
     unhighlight = myUHNumbers;
@@ -549,34 +644,44 @@ void GLViewer_MarkerSet::exportNumbers( QValueList<int>& highlight,
     myUHNumbers = myHNumbers;
 }
 
+/*!
+  Adds or remove selected number
+  \param index - selected index
+*/
 bool GLViewer_MarkerSet::addOrRemoveSelected( int index )
 {
   if( index < 0 || index > myNumber )
     return FALSE;
 
-  int n = mySelNumbers.findIndex( index );
+  int n = mySelNumbers.indexOf( index );
   if( n == -1 )
     mySelNumbers.append( index );
   else
   {
-    QValueList<int>::Iterator it;
-    it = mySelNumbers.at( n );
-    mySelNumbers.remove( it );
+    mySelNumbers.removeAt(n);
     myUSelNumbers.append( index );
   }
   return TRUE;
 }
 
+/*!
+  Adds some selected numbers
+  \param seq - sequence of indices
+*/
 void GLViewer_MarkerSet::addSelected( const TColStd_SequenceOfInteger& seq )
 {
   for ( int i = 1; i <= seq.Length(); i++ )
-    if( mySelNumbers.findIndex( seq.Value( i ) ) == -1 )
+    if( mySelNumbers.indexOf( seq.Value( i ) ) == -1 )
       mySelNumbers.append( seq.Value( i ) - 1 );
 }
 
+/*!
+  Sets some numbers as selected
+  \param seq - sequence of indices
+*/
 void GLViewer_MarkerSet::setSelected( const TColStd_SequenceOfInteger& seq )
 {
-//   for( QValueList<int>::Iterator it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it )
+//   for( QList<int>::Iterator it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it )
 //     if( myUSelNumbers.findIndex( *it ) == -1 )
 //       myUSelNumbers.append( *it );
 
@@ -587,6 +692,11 @@ void GLViewer_MarkerSet::setSelected( const TColStd_SequenceOfInteger& seq )
     mySelNumbers.append( seq.Value( i ) - 1 );
 }
 
+/*! Moves object by recomputing
+  \param dx        - moving along X coord
+  \param dy        - moving along Y coord
+  \param fromGroup - is true if this method called from group
+*/
 void GLViewer_MarkerSet::moveObject( float theX, float theY, bool fromGroup )
 {
     if( !fromGroup && myGroup)
@@ -602,6 +712,10 @@ void GLViewer_MarkerSet::moveObject( float theX, float theY, bool fromGroup )
     compute();    
 }
 
+/*!
+  Codes marker set as byte copy
+  \return byte array
+*/
 QByteArray GLViewer_MarkerSet::getByteCopy()
 {
     int i = 0;
@@ -610,7 +724,8 @@ QByteArray GLViewer_MarkerSet::getByteCopy()
     
     QByteArray aObject = GLViewer_Object::getByteCopy();
 
-    QByteArray aResult( anISize + 2*aFSize*myNumber + aFSize + aObject.size());
+    QByteArray aResult;
+    aResult.resize( anISize + 2*aFSize*myNumber + aFSize + aObject.size());
 
     char* aPointer = (char*)&myNumber;
     for( i = 0; i < anISize; i++, aPointer++ )
@@ -628,12 +743,16 @@ QByteArray GLViewer_MarkerSet::getByteCopy()
         aResult[i] = *aPointer;
         
     
-    for( ; i < aResult.size(); i++ )
+    for ( ; i < (int)aResult.size(); i++ )
         aResult[i] = aObject[i - anISize - 2*aFSize*myNumber - aFSize];
 
     return aResult;
 }
 
+/*!
+  Initialize marker set by byte array
+  \param theArray - byte array
+*/
 bool GLViewer_MarkerSet::initializeFromByteCopy( QByteArray theArray )
 {
     int i = 0;
@@ -662,7 +781,8 @@ bool GLViewer_MarkerSet::initializeFromByteCopy( QByteArray theArray )
          *aPointer = theArray[i];
          
     int aCurIndex = anISize + 2*aFSize*myNumber + aFSize;
-    QByteArray aObject( aSize - aCurIndex );
+    QByteArray aObject;
+    aObject.resize( aSize - aCurIndex );
     for( ; i < aSize; i++ )
         aObject[i - aCurIndex] = theArray[i];
         
@@ -680,16 +800,20 @@ bool GLViewer_MarkerSet::initializeFromByteCopy( QByteArray theArray )
     return true;        
 }
 
-/***************************************************************************
-**  Class:   GLViewer_Polyline
-**  Descr:   OpenGL Polyline
-**  Module:  GLViewer
-**  Created: UI team, 03.09.02
-****************************************************************************/
+/*!
+  \class GLViewer_Polyline
+  OpenGL Polyline
+*/
 
 #define SECTIONS 100
 #define DISTANTION 5
 
+/*!
+  Constructor
+  \param number - number of segments
+  \param size - size of polyline
+  \param toolTip - tool tip of polyline
+*/
 GLViewer_Polyline::GLViewer_Polyline( int number, float size, const QString& toolTip ):
   GLViewer_Object(),
   myNumber( 0 ),
@@ -711,6 +835,9 @@ GLViewer_Polyline::GLViewer_Polyline( int number, float size, const QString& too
   myToolTipText = toolTip;
 }
 
+/*!
+  Destructor, destroys internal arrays of co-ordinates
+*/
 GLViewer_Polyline::~GLViewer_Polyline()
 {
   if ( myXCoord )
@@ -719,6 +846,12 @@ GLViewer_Polyline::~GLViewer_Polyline()
     delete[] myYCoord;
 }
 
+/*!
+  Saves polyline to file PostScript
+  \param hFile - file instance
+  \param aViewerCS - viewer co-ordinates system
+  \param aPSCS - paper co-ordinates system
+*/
 bool GLViewer_Polyline::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
 {
     QString aBuffer = "newpath\n";
@@ -736,11 +869,17 @@ bool GLViewer_Polyline::translateToPS( QFile& hFile, GLViewer_CoordSystem* aView
 
     aBuffer+="closepath\nstroke\n";
     
-    hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+    hFile.write( aBuffer.toAscii() );
 
     return true;
 }
 
+/*!
+  Saves polyline to file HPGL
+  \param hFile - file instance
+  \param aViewerCS - viewer co-ordinates system
+  \param aHPGLCS - paper co-ordinates system
+*/
 bool GLViewer_Polyline::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS )
 {
     QString aBuffer = "";
@@ -756,12 +895,18 @@ bool GLViewer_Polyline::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aVi
 
     aBuffer+="PU;\n";
     
-    hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+    hFile.write( aBuffer.toAscii() );
 
     return true;
 }
 
 #ifdef WIN32
+/*!
+  Saves polyline to EMF image
+  \param dc - EMF image descriptor
+  \param aViewerCS - viewer co-ordinates system
+  \param aEMFCS - paper co-ordinates system
+*/
 bool GLViewer_Polyline::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
 {
     if( !aViewerCS || !aEMFCS )
@@ -798,6 +943,9 @@ bool GLViewer_Polyline::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS,
 }
 #endif
 
+/*! 
+  Computes all necessary information about object for presentation in drawer
+*/
 void GLViewer_Polyline::compute()
 {
 //  cout << "GLViewer_MarkerSet::compute" << endl;
@@ -808,10 +956,10 @@ void GLViewer_Polyline::compute()
 
   for ( int i = 0; i < myNumber; i++ )  
   {
-    xa = QMIN( xa, myXCoord[i] );
-    xb = QMAX( xb, myXCoord[i] );
-    ya = QMIN( ya, myYCoord[i] );
-    yb = QMAX( yb, myYCoord[i] );
+    xa = qMin( xa, myXCoord[i] );
+    xb = qMax( xb, myXCoord[i] );
+    ya = qMin( ya, myYCoord[i] );
+    yb = qMax( yb, myYCoord[i] );
   }
 
   GLfloat xGap = ( xb - xa ) / 10;
@@ -823,6 +971,10 @@ void GLViewer_Polyline::compute()
   myRect->setBottom( ya - yGap );
 }
 
+/*!
+  \return update object rectangle
+  Does not equal getRect() if object have a persistence to some viewer transformations
+*/
 GLViewer_Rect* GLViewer_Polyline::getUpdateRect()
 {
     GLViewer_Rect* rect = new GLViewer_Rect();
@@ -835,12 +987,23 @@ GLViewer_Rect* GLViewer_Polyline::getUpdateRect()
     return rect;
 }
 
+/*!
+  Creates corresponding drawer
+*/
 GLViewer_Drawer* GLViewer_Polyline::createDrawer()
 {
 //  cout << "GLViewer_MarkerSet::createDrawer" << endl;
     return myDrawer = new GLViewer_PolylineDrawer();
 }
 
+/*!
+  Computes highlight presentation
+  \param x        - x coord
+  \param y        - y coord
+  \param tol      - tolerance of detecting
+  \param isCircle - true if sensitive area of detection is round
+  \return true if highlight status is changed
+*/
 GLboolean GLViewer_Polyline::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle )
 {
     if( !myIsVisible )
@@ -895,6 +1058,9 @@ GLboolean GLViewer_Polyline::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboo
     return update;
 }
 
+/*!
+  Unhilights object
+*/
 GLboolean GLViewer_Polyline::unhighlight()
 {
 //   if( !myHNumbers.isEmpty() )
@@ -913,6 +1079,15 @@ GLboolean GLViewer_Polyline::unhighlight()
   return GL_FALSE;
 }
 
+/*!
+  Selects polyline
+  /param x, y - co-ordinates of mouse
+  /param tol - tolerance
+  /param rect - rectangle (in case of rectangular selection)
+  /param isFull - if it is true, then object may selected only if it lays whole in selection zone
+  \param isCircle - true if sensitive area of detection is round
+  \param isShift  - true if selection exec with append option
+*/
 GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull,
                                      GLboolean isCircle, GLboolean isShift )
 {
@@ -920,7 +1095,7 @@ GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer
         return false;
     GLfloat xa, xb, ya, yb, l;
     GLfloat rsin, rcos, r, ra, rb;
-    GLboolean update;
+    // GLboolean update;
     GLboolean selected = myIsSel;
 
     myIsSel = GL_FALSE;
@@ -965,7 +1140,7 @@ GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer
     else
         myHighFlag = GL_TRUE;
 
-    update = ( GLboolean )( myIsSel != selected );
+    // update = ( GLboolean )( myIsSel != selected );
 
     //  cout << "GLViewer_Polyline::select complete with " << (int)myIsSel << endl;
 
@@ -973,6 +1148,9 @@ GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer
     return myIsSel;
 }
 
+/*!
+  Unselects polyline
+*/
 GLboolean GLViewer_Polyline::unselect()
 {
 //   if( !mySelNumbers.isEmpty() )
@@ -992,6 +1170,11 @@ GLboolean GLViewer_Polyline::unselect()
   return GL_FALSE;
 }
 
+/*!
+  Sets array of abscisses for points of polyline
+  \param xCoord - array of of abscisses
+  \param size - size of array
+*/
 void GLViewer_Polyline::setXCoord( GLfloat* xCoord, int size )
 {
   myXCoord = new GLfloat[ size ];
@@ -999,6 +1182,11 @@ void GLViewer_Polyline::setXCoord( GLfloat* xCoord, int size )
      myXCoord[i] = xCoord[i];
 }
 
+/*!
+  Sets array of ordinates for points of polyline
+  \param xCoord - array of of ordinates
+  \param size - size of array
+*/
 void GLViewer_Polyline::setYCoord( GLfloat* yCoord, int size )
 {
   myYCoord = new GLfloat[ size ];
@@ -1006,6 +1194,10 @@ void GLViewer_Polyline::setYCoord( GLfloat* yCoord, int size )
      myYCoord[i] = yCoord[i];
 }
 
+/*!
+  Sets number of points
+  \param number - new number of points
+*/
 void GLViewer_Polyline::setNumber( GLint number )
 {
   if ( myNumber == number )
@@ -1021,24 +1213,14 @@ void GLViewer_Polyline::setNumber( GLint number )
   myXCoord = new GLfloat[ myNumber ];
   myYCoord = new GLfloat[ myNumber ];
 }
-/*
-void GLViewer_Polyline::onSelectionDone( bool append)
-{
-  mySelectedIndexes.Clear();
-  QValueList<int>::Iterator it;
-  //for( it = myMarkers->mySelNumbers.begin(); it != myMarkers->mySelNumbers.end(); ++it )
-  //  mySelectedIndexes.Append( *it / 2 ); //!!!
-}
 
-void GLViewer_Polyline::onSelectionCancel()
-{
-  mySelectedIndexes.Clear();
-}
+/*!
+  Export numbers of highlighted/selected lines
 */
-void GLViewer_Polyline::exportNumbers( QValueList<int>& highlight,
-                     QValueList<int>& unhighlight,
-                     QValueList<int>& select,
-                     QValueList<int>& unselect )
+void GLViewer_Polyline::exportNumbers( QList<int>& highlight,
+                     QList<int>& unhighlight,
+                     QList<int>& select,
+                     QList<int>& unselect )
 {
   highlight = myHNumbers;
   unhighlight = myUHNumbers;
@@ -1046,6 +1228,12 @@ void GLViewer_Polyline::exportNumbers( QValueList<int>& highlight,
   unselect = myUSelNumbers;
 }
 
+/*!
+  Moves object by recomputing
+  \param dx        - moving along X coord
+  \param dy        - moving along Y coord
+  \param fromGroup - is true if this method called from group
+*/
 void GLViewer_Polyline::moveObject( float theX, float theY, bool fromGroup )
 {
   if( !fromGroup && myGroup)
@@ -1061,6 +1249,10 @@ void GLViewer_Polyline::moveObject( float theX, float theY, bool fromGroup )
   compute();    
 }
 
+/*!
+  Codes polyline as byte copy
+  \return byte array
+*/
 QByteArray GLViewer_Polyline::getByteCopy()
 {
     int i = 0;
@@ -1070,7 +1262,8 @@ QByteArray GLViewer_Polyline::getByteCopy()
 
     QByteArray aObject = GLViewer_Object::getByteCopy();
 
-    QByteArray aResult( aFSize*myNumber*2 + anISize + 2*aBSize + aObject.size());
+    QByteArray aResult;
+    aResult.resize( aFSize*myNumber*2 + anISize + 2*aBSize + aObject.size());
 
     char* aPointer = (char*)&myNumber;
     for( i = 0; i < anISize; i++, aPointer++ )
@@ -1090,13 +1283,17 @@ QByteArray GLViewer_Polyline::getByteCopy()
     for( ; i < anISize + 2*aFSize*myNumber + 2*aBSize; i++, aPointer++ )
         aResult[i] = *aPointer;
 
-    for( ; i < aResult.size(); i++ )
+    for ( ; i < (int)aResult.size(); i++ )
         aResult[i] = aObject[i - anISize - 2*aFSize*myNumber - 2*aBSize];
 
     return aResult;
 }
 
 
+/*!
+  Initialize polyline by byte array
+  \param theArray - byte array
+*/
 bool GLViewer_Polyline::initializeFromByteCopy( QByteArray theArray )
 {
     int i = 0;
@@ -1129,7 +1326,8 @@ bool GLViewer_Polyline::initializeFromByteCopy( QByteArray theArray )
          *aPointer = theArray[i];
 
     int aCurIndex = anISize + 2*aFSize*myNumber + 2*aBSize;
-    QByteArray aObject( aSize - aCurIndex );
+    QByteArray aObject;
+    aObject.resize( aSize - aCurIndex );
     for( ; i < aSize; i++ )
         aObject[i - aCurIndex] = theArray[i];
 
@@ -1146,13 +1344,16 @@ bool GLViewer_Polyline::initializeFromByteCopy( QByteArray theArray )
     return true;        
 }
 
-/***************************************************************************
-**  Class:   GLViewer_TextObject
-**  Descr:   Text as Object for OpenGL
-**  Module:  GLViewer
-**  Created: UI team, 12.02.04
-****************************************************************************/
 
+
+/*!
+  Constructor
+  \param theStr - text string
+  \param xPos - x position
+  \param yPos - y position
+  \param color - color of text
+  \param toolTip - tooltip of text object
+*/
 GLViewer_TextObject::GLViewer_TextObject( const QString& theStr, float xPos, float yPos, 
                                     const QColor& color, const QString& toolTip )
                                     : GLViewer_Object()
@@ -1165,12 +1366,22 @@ GLViewer_TextObject::GLViewer_TextObject( const QString& theStr, float xPos, flo
 
     myToolTipText = toolTip;
 }
+
+/*!
+  Destructor
+*/
 GLViewer_TextObject::~GLViewer_TextObject()
 {
   if ( myGLText )
     delete myGLText;
 }
 
+/*!
+  Saves text object to file PostScript
+  \param hFile - file instance
+  \param aViewerCS - viewer co-ordinates system
+  \param aPSCS - paper co-ordinates system
+*/
 bool GLViewer_TextObject::translateToPS( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aPSCS )
 {
     QString aText = myGLText->getText();    
@@ -1183,11 +1394,17 @@ bool GLViewer_TextObject::translateToPS( QFile& hFile, GLViewer_CoordSystem* aVi
     AddCoordsToPS( aBuffer, "moveto", aViewerCS, aPSCS, double(xPos), double(yPos) );
     aBuffer += "(" + aText + ") show\n";
 
-    hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+    hFile.write( aBuffer.toAscii() );
 
     return true;
 }
 
+/*!
+  Saves text object to file HPGL
+  \param hFile - file instance
+  \param aViewerCS - viewer co-ordinates system
+  \param aHPGLCS - paper co-ordinates system
+*/
 bool GLViewer_TextObject::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aHPGLCS )
 {
     QString aText = myGLText->getText();    
@@ -1199,12 +1416,18 @@ bool GLViewer_TextObject::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* a
     
     aBuffer = "LB" + aText + "#;";
     
-    hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+    hFile.write( aBuffer.toAscii() );
 
     return true;
 }
 
 #ifdef WIN32
+/*!
+  Saves text object to EMF image
+  \param dc - EMF image descriptor
+  \param aViewerCS - viewer co-ordinates system
+  \param aEMFCS - paper co-ordinates system
+*/
 bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerCS, GLViewer_CoordSystem* aEMFCS )
 {
     QString aText = myGLText->getText();    
@@ -1215,7 +1438,7 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC
            y = double( yPos );
 
     aViewerCS->transform( *aEMFCS, x, y );
-    const char* str = aText.ascii();
+    const char* str = aText.toAscii();
 
     int nHeight = 35*14;       // height of font
     int nWidth = 35*12;        // average character width
@@ -1255,6 +1478,9 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC
 }
 #endif
 
+/*!
+  Creates corresponding drawer
+*/
 GLViewer_Drawer* GLViewer_TextObject::createDrawer()
 {
     myDrawer = new GLViewer_TextDrawer();
@@ -1262,6 +1488,9 @@ GLViewer_Drawer* GLViewer_TextObject::createDrawer()
     return myDrawer;
 }
 
+/*! 
+  Computes all necessary information about object for presentation in drawer
+*/
 void GLViewer_TextObject::compute()
 {
     float xPos, yPos;
@@ -1276,12 +1505,20 @@ void GLViewer_TextObject::compute()
     myRect->setBottom( yPos );
 }
 
+/*!
+  Installing already exist drawer with same type
+  \param theDrawer - new drawer
+*/
 void GLViewer_TextObject::setDrawer( GLViewer_Drawer* theDrawer )
 {
     myDrawer = theDrawer;
     //compute();
 }
 
+/*!
+  \return update object rectangle
+  Does not equal getRect() if object have a persistence to some viewer transformations
+*/
 GLViewer_Rect* GLViewer_TextObject::getUpdateRect()
 {    
     GLViewer_Rect* rect = new GLViewer_Rect();
@@ -1298,6 +1535,14 @@ GLViewer_Rect* GLViewer_TextObject::getUpdateRect()
     return rect;
 }
 
+/*!
+  Computes highlight presentation
+  \param x        - x coord
+  \param y        - y coord
+  \param tol      - tolerance of detecting
+  \param isCircle - true if sensitive area of detection is round
+  \return true if highlight status is changed
+*/
 GLboolean GLViewer_TextObject::highlight( GLfloat theX, GLfloat theY, GLfloat theTol, GLboolean isCircle )
 {
     if( !myIsVisible )
@@ -1345,6 +1590,9 @@ GLboolean GLViewer_TextObject::highlight( GLfloat theX, GLfloat theY, GLfloat th
     return myIsHigh;
 }
 
+/*!
+  Unhilights object
+*/
 GLboolean GLViewer_TextObject::unhighlight()
 {
     if( myIsHigh )
@@ -1356,6 +1604,15 @@ GLboolean GLViewer_TextObject::unhighlight()
     return GL_FALSE;
 }
 
+/*!
+  Selects text object
+  /param x, y - co-ordinates of mouse
+  /param tol - tolerance
+  /param rect - rectangle (in case of rectangular selection)
+  /param isFull - if it is true, then object may selected only if it lays whole in selection zone
+  \param isCircle - true if sensitive area of detection is round
+  \param isShift  - true if selection exec with append option
+*/
 GLboolean GLViewer_TextObject::select( GLfloat theX, GLfloat theY, GLfloat theTol, GLViewer_Rect rect,
                                        GLboolean isFull, GLboolean isCircle, GLboolean isShift )
 { 
@@ -1394,6 +1651,9 @@ GLboolean GLViewer_TextObject::select( GLfloat theX, GLfloat theY, GLfloat theTo
     return myIsSel;
 }
 
+/*!
+  Unselects text object
+*/
 GLboolean GLViewer_TextObject::unselect()
 {
     if( myIsSel )
@@ -1405,6 +1665,12 @@ GLboolean GLViewer_TextObject::unselect()
     return GL_FALSE;
 }
 
+/*!
+  Moves object by recomputing
+  \param dx        - moving along X coord
+  \param dy        - moving along Y coord
+  \param fromGroup - is true if this method called from group
+*/
 void GLViewer_TextObject::moveObject( float theX, float theY, bool fromGroup )
 {
   if( !fromGroup && myGroup)
@@ -1420,6 +1686,10 @@ void GLViewer_TextObject::moveObject( float theX, float theY, bool fromGroup )
   compute();
 }
 
+/*!
+  Codes text object as byte copy
+  \return byte array
+*/
 QByteArray GLViewer_TextObject::getByteCopy()
 {
     QByteArray aObject = GLViewer_Object::getByteCopy();
@@ -1427,6 +1697,10 @@ QByteArray GLViewer_TextObject::getByteCopy()
     return aObject;
 }
 
+/*!
+  Initialize text object by byte array
+  \param theArray - byte array
+*/
 bool GLViewer_TextObject::initializeFromByteCopy( QByteArray theArray )
 {
     if( !GLViewer_Object::initializeFromByteCopy( theArray ) || myType != "GLViewer_TextObject" )