Salome HOME
Updated copyright comment
[modules/gui.git] / src / GLViewer / GLViewer_BaseObjects.cxx
index 79c32e3f86a7a34049404260146f9191d13d9193..013270f4d55a9872b88a4b57e9ed013439975cd5 100644 (file)
@@ -1,51 +1,38 @@
-//  Copyright (C) 2005 OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
-//  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.
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  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.
+// 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.
 //
-//  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
+// 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.
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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
 //
-//  Author : OPEN CASCADE
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-/***************************************************************************
-**  Class:   GLViewer_BaseObjects
-**  Descr:   Internal OpenGL Objects
-**  Module:  GLViewer
-**  Created: UI team, 02.09.02
-****************************************************************************/
-
-//#include <GLViewerAfx.h>
 #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 ),
@@ -67,6 +54,9 @@ GLViewer_MarkerSet::GLViewer_MarkerSet( int number, float size, const QString& t
     setNumMarkers( number );    
 }
 
+/*!
+  Destructor
+*/
 GLViewer_MarkerSet::~GLViewer_MarkerSet()
 {
     if ( myXCoord )
@@ -75,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 )
 {
@@ -87,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 )
 {
@@ -99,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 )
 {
@@ -129,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 )
 {
@@ -150,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;
@@ -182,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.toLatin1() );
 
     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 )
 {
@@ -214,13 +250,19 @@ bool GLViewer_MarkerSet::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aV
         }
         aBuffer+="PU;\n";
 
-        hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+        hFile.write( aBuffer.toLatin1() );
     }
 
     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;
@@ -256,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;
@@ -267,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;
@@ -282,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 )
@@ -296,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;
@@ -313,15 +367,15 @@ 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;
+      isFound = false;
       count++;
       for ( it = myCurSelNumbers.begin(); it != myCurSelNumbers.end(); ++it )
         if( i == *it )
         {
-          isFound = TRUE;
+          isFound = true;
           curHNumbers.append( i );
         }
       
@@ -342,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() )
@@ -356,7 +413,16 @@ GLboolean GLViewer_MarkerSet::unhighlight()
   return GL_FALSE;
 }
 
-GLboolean GLViewer_MarkerSet::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull,
+/*!
+  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 )
 {
     if( !myIsVisible )
@@ -364,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.;
 
@@ -390,19 +456,19 @@ 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 )
       {
-        bool isFound = FALSE;
+        bool isFound = false;
           for( it = mySelNumbers.begin(); it != mySelNumbers.end(); ++it )
             if ( *it == i )
             {
               myUSelNumbers.append( *it );
             remIt = it;
-              isFound = TRUE;
+              isFound = true;
               break;
             }
 
@@ -413,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;
         }
         }
@@ -453,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;
       }        
       }     
@@ -470,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--;
       }
   
@@ -480,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() )
@@ -493,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();
@@ -510,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 ];
@@ -518,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 ];
@@ -525,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 )
@@ -540,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;
@@ -570,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;
+    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;
+  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 );
 
@@ -608,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)
@@ -623,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;
@@ -631,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++ )
@@ -649,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;
@@ -683,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];
         
@@ -701,21 +800,25 @@ 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
 
-GLViewer_Polyline::GLViewer_Polyline( int number, float size, const QString& toolTip ):
+/*!
+  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 ),
   myXCoord( 0 ),
-  myYCoord( 0 )       
+  myYCoord( 0 ),
+  myNumber( 0 )
 {
   myHighFlag = GL_TRUE;
 
@@ -732,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 )
@@ -740,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";
@@ -757,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.toLatin1() );
 
     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 = "";
@@ -777,12 +895,18 @@ bool GLViewer_Polyline::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* aVi
 
     aBuffer+="PU;\n";
     
-    hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+    hFile.write( aBuffer.toLatin1() );
 
     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 )
@@ -819,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;
@@ -829,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;
@@ -844,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();
@@ -856,13 +987,24 @@ 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();
 }
 
-GLboolean GLViewer_Polyline::highlight( GLfloat x, GLfloat y, GLfloat tol, GLboolean isCircle )
+/*!
+  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 )
         return false;
@@ -916,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() )
@@ -934,15 +1079,24 @@ GLboolean GLViewer_Polyline::unhighlight()
   return GL_FALSE;
 }
 
-GLboolean GLViewer_Polyline::select( GLfloat x, GLfloat y, GLfloat tol, GLViewer_Rect rect, GLboolean isFull,
-                                     GLboolean isCircle, GLboolean isShift )
+/*!
+  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*/ )
 {
     if( !myIsVisible )
         return false;
     GLfloat xa, xb, ya, yb, l;
     GLfloat rsin, rcos, r, ra, rb;
-    GLboolean update;
-    GLboolean selected = myIsSel;
+    // GLboolean update;
+    // GLboolean selected = myIsSel;
 
     myIsSel = GL_FALSE;
 
@@ -986,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;
 
@@ -994,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() )
@@ -1013,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 ];
@@ -1020,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 ];
@@ -1027,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 )
@@ -1042,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;
@@ -1067,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)
@@ -1082,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;
@@ -1091,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++ )
@@ -1111,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;
@@ -1150,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];
 
@@ -1167,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()
@@ -1186,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();    
@@ -1204,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.toLatin1() );
 
     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();    
@@ -1220,12 +1416,18 @@ bool GLViewer_TextObject::translateToHPGL( QFile& hFile, GLViewer_CoordSystem* a
     
     aBuffer = "LB" + aText + "#;";
     
-    hFile.writeBlock( aBuffer.ascii(), aBuffer.length() );
+    hFile.write( aBuffer.toLatin1() );
 
     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();    
@@ -1236,16 +1438,15 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC
            y = double( yPos );
 
     aViewerCS->transform( *aEMFCS, x, y );
-    const char* str = aText.ascii();
 
     int nHeight = 35*14;       // height of font
     int nWidth = 35*12;        // average character width
     int nEscapement = 0;       // angle of escapement
     int nOrientation = 0;      // base-line orientation angle
     int fnWeight = FW_NORMAL;  // font weight
-    DWORD fdwItalic = FALSE;    // italic attribute option
-    DWORD fdwUnderline = FALSE; // underline attribute option
-    DWORD fdwStrikeOut = FALSE; // strikeout attribute option
+    DWORD fdwItalic = false;    // italic attribute option
+    DWORD fdwUnderline = false; // underline attribute option
+    DWORD fdwStrikeOut = false; // strikeout attribute option
     DWORD fdwCharSet = ANSI_CHARSET; // character set identifier
     DWORD fdwOutputPrecision = OUT_DEFAULT_PRECIS;  // output precision
     DWORD fdwClipPrecision = CLIP_DEFAULT_PRECIS;    // clipping precision
@@ -1264,8 +1465,17 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC
 
     HGDIOBJ old1 = SelectObject( dc, aFont );
     HGDIOBJ old2 = SelectObject( dc, aBrush );
-
+#ifdef UNICODE
+       LPTSTR str = new TCHAR[aText.length() + 1];
+       str[aText.toWCharArray(str)] = '\0';
+#else  
+       QByteArray arr = FileName.toLatin1();
+       LPTSTR str = arr.constData();
+#endif
     TextOut( dc, x, y, str, aText.length() );
+#ifdef UNICODE
+        delete str;
+#endif
 
     SelectObject ( dc, old1 );
     SelectObject ( dc, old2 );
@@ -1276,6 +1486,9 @@ bool GLViewer_TextObject::translateToEMF( HDC dc, GLViewer_CoordSystem* aViewerC
 }
 #endif
 
+/*!
+  Creates corresponding drawer
+*/
 GLViewer_Drawer* GLViewer_TextObject::createDrawer()
 {
     myDrawer = new GLViewer_TextDrawer();
@@ -1283,6 +1496,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;
@@ -1297,12 +1513,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();
@@ -1319,6 +1543,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 )
@@ -1349,9 +1581,9 @@ GLboolean GLViewer_TextObject::highlight( GLfloat theX, GLfloat theY, GLfloat th
     QRegion circle( (int)(theX - theTol), (int)(theY - theTol),
                       (int)(2 * theTol), (int)(2 * theTol), QRegion::Ellipse );
     if( isCircle )
-        intersection = obj.intersect( circle );
+        intersection = obj.intersected( circle );
     else
-        intersection = obj.intersect( region );
+        intersection = obj.intersected( region );
     
     if( intersection.isEmpty() )
         myIsHigh = false;
@@ -1366,6 +1598,9 @@ GLboolean GLViewer_TextObject::highlight( GLfloat theX, GLfloat theY, GLfloat th
     return myIsHigh;
 }
 
+/*!
+  Unhilights object
+*/
 GLboolean GLViewer_TextObject::unhighlight()
 {
     if( myIsHigh )
@@ -1377,8 +1612,17 @@ GLboolean GLViewer_TextObject::unhighlight()
     return GL_FALSE;
 }
 
-GLboolean GLViewer_TextObject::select( GLfloat theX, GLfloat theY, GLfloat theTol, GLViewer_Rect rect,
-                                       GLboolean isFull, GLboolean isCircle, GLboolean isShift )
+/*!
+  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*/ )
 { 
     if( !myIsVisible )
         return false;
@@ -1395,9 +1639,9 @@ GLboolean GLViewer_TextObject::select( GLfloat theX, GLfloat theY, GLfloat theTo
     QRegion circle( (int)(theX - theTol), (int)(theY - theTol),
                       (int)(2 * theTol), (int)(2 * theTol), QRegion::Ellipse );
     if( isCircle )
-        intersection = obj.intersect( circle );
+        intersection = obj.intersected( circle );
     else
-        intersection = obj.intersect( region );
+        intersection = obj.intersected( region );
     
     if( intersection.isEmpty() )
         myIsSel = false;
@@ -1415,6 +1659,9 @@ GLboolean GLViewer_TextObject::select( GLfloat theX, GLfloat theY, GLfloat theTo
     return myIsSel;
 }
 
+/*!
+  Unselects text object
+*/
 GLboolean GLViewer_TextObject::unselect()
 {
     if( myIsSel )
@@ -1426,6 +1673,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)
@@ -1441,6 +1694,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();
@@ -1448,6 +1705,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" )