]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/GLViewer/GLViewer_ViewPort2d.cxx
Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / GLViewer / GLViewer_ViewPort2d.cxx
index cd505e7bad223991b0fbb81900a9530bb1fccea8..a81bc07633b46d285209cb2f161fc1b80890ee4c 100644 (file)
@@ -1,7 +1,26 @@
+//  Copyright (C) 2005 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.
+//
+//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//  Author : OPEN CASCADE
+//
+
 // File:      GLViewer_ViewPort2d.cxx
 // Created:   November, 2004
-// Author:    OCC team
-// Copyright (C) CEA 2004
 
 /* GLViewer_ViewPort2d Source File */
 
@@ -44,11 +63,15 @@ void rotate_point( float& theX, float& theY, float theAngle )
     theY = aTempY;
 }
 
+/*!
+  Constructor
+*/
 GLViewer_ViewPort2d::GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame ) :
        GLViewer_ViewPort( parent ),
        myMargin( MARGIN ), myWidth( WIDTH ), myHeight( HEIGHT ),
        myXScale( 1.0 ), myYScale( 1.0 ), myXOldScale( 1.0 ), myYOldScale( 1.0 ),
-       myXPan( 0.0 ), myYPan( 0.0 )
+       myXPan( 0.0 ), myYPan( 0.0 ),
+       myIsMouseReleaseBlock( false )
 {
     if( theViewFrame == NULL )
         myViewFrame = ( GLViewer_ViewFrame* )parent;
@@ -85,6 +108,9 @@ GLViewer_ViewPort2d::GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* t
 //    myGLWidget->installEventFilter( myObjectTip );
 }
 
+/*!
+  Destructor
+*/
 GLViewer_ViewPort2d::~GLViewer_ViewPort2d()
 {
     if( myCompass )
@@ -97,6 +123,9 @@ GLViewer_ViewPort2d::~GLViewer_ViewPort2d()
     delete myGLWidget;
 }
 
+/*!
+  SLOT: initializes drag process
+*/
 void GLViewer_ViewPort2d::onStartDragObject( )
 {
     if( myIsDragProcess == noDrag )
@@ -112,6 +141,9 @@ void GLViewer_ViewPort2d::onStartDragObject( )
     } 
 }
 
+/*!
+  SLOT: cuts object to clipboard
+*/
 void GLViewer_ViewPort2d::onCutObject()
 { 
     /*GLViewer_Object* aMovingObject = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->getCurrentObject();
@@ -147,6 +179,9 @@ void GLViewer_ViewPort2d::onCutObject()
     }
 }
 
+/*!
+  SLOT: copies object to clipboard
+*/
 void GLViewer_ViewPort2d::onCopyObject()
 {
     /*GLViewer_Object* aMovingObject = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->getCurrentObject();
@@ -178,6 +213,9 @@ void GLViewer_ViewPort2d::onCopyObject()
     }
 }
 
+/*!
+  SLOT: pastes object from clipboard
+*/
 void GLViewer_ViewPort2d::onPasteObject()
 {
     /*QClipboard *aClipboard = QApplication::clipboard();
@@ -223,6 +261,9 @@ void GLViewer_ViewPort2d::onPasteObject()
     */
 }
 
+/*!
+  SLOT: called when object is being dragged
+*/
 void GLViewer_ViewPort2d::onDragObject( QMouseEvent* e )
 {
   //cout << "---GLViewer_ViewPort2d::onDragObject()---" << endl;
@@ -331,6 +372,13 @@ void GLViewer_ViewPort2d::mouseMoveEvent( QMouseEvent* e )
 */
 void GLViewer_ViewPort2d::mouseReleaseEvent( QMouseEvent* e )
 {    
+    if ( myIsMouseReleaseBlock )
+    {
+      // skip mouse release after double click
+      myIsMouseReleaseBlock = false;
+      return;
+    }
+
     /* show popup menu */
     if ( e->button() == Qt::RightButton )
     {
@@ -374,6 +422,21 @@ void GLViewer_ViewPort2d::mouseReleaseEvent( QMouseEvent* e )
     }
 }
 
+/*!
+  Custom mouse double click event handler
+*/
+void GLViewer_ViewPort2d::mouseDoubleClickEvent( QMouseEvent * e )
+{
+  //redefined to block mouse release after mouse double click
+  myIsMouseReleaseBlock = true;
+  // invoke base implementation
+  GLViewer_ViewPort::mouseDoubleClickEvent( e );
+}
+
+/*!
+  Creates or deletes compass
+  \param on - if it is true, then to create
+*/
 void GLViewer_ViewPort2d::turnCompass( GLboolean on )
 {
     if( on )
@@ -382,6 +445,10 @@ void GLViewer_ViewPort2d::turnCompass( GLboolean on )
         delete myCompass;
 }
 
+/*!
+  Creates or deletes grid
+  \param on - if it is true, then to create
+*/
 void GLViewer_ViewPort2d::turnGrid( GLboolean on )
 {
     if( on )
@@ -396,6 +463,11 @@ void GLViewer_ViewPort2d::turnGrid( GLboolean on )
         delete myGrid;
 }
 
+/*!
+  Changes grid color
+  \param gridColor - new grid color
+  \param axisColor - new axis color
+*/
 void GLViewer_ViewPort2d::setGridColor( const QColor gridColor, const QColor axisColor )
 {
     if( myGrid )
@@ -409,6 +481,10 @@ void GLViewer_ViewPort2d::setGridColor( const QColor gridColor, const QColor axi
     }
 }
 
+/*!
+  Changes background color
+  \param color - new background color
+*/
 void GLViewer_ViewPort2d::setBackgroundColor( const QColor& color )
 {
     GLViewer_ViewPort::setBackgroundColor( color );
@@ -419,11 +495,17 @@ void GLViewer_ViewPort2d::setBackgroundColor( const QColor& color )
     myGLWidget->repaint();
 }
 
+/*!
+  \return background color
+*/
 QColor GLViewer_ViewPort2d::backgroundColor() const
 {
     return GLViewer_ViewPort::backgroundColor();
 }
 
+/*!
+  Resize view
+*/
 void GLViewer_ViewPort2d::initResize( int x, int y )
 {
     float xa, xb, ya, yb;
@@ -474,6 +556,9 @@ void GLViewer_ViewPort2d::initResize( int x, int y )
     myGLWidget->setScale( myXScale, myYScale, 1.0 );
 }
 
+/*!
+  Custom paint event handler
+*/
 void GLViewer_ViewPort2d::paintEvent( QPaintEvent* e )
 {
     //cout << "GLViewer_ViewPort2d::paintEvent" << endl;
@@ -481,12 +566,18 @@ void GLViewer_ViewPort2d::paintEvent( QPaintEvent* e )
     GLViewer_ViewPort::paintEvent( e );
 }
 
+/*!
+  Custom resize event handler
+*/
 void GLViewer_ViewPort2d::resizeEvent( QResizeEvent* e )
 {
     //cout << "GLViewer_ViewPort2d::resizeEvent" << endl;
     GLViewer_ViewPort::resizeEvent( e );
 }
 
+/*!
+  Resets view to start state
+*/
 void GLViewer_ViewPort2d::reset()
 {
     //cout << "GLViewer_ViewPort2d::reset" << endl;
@@ -522,6 +613,11 @@ void GLViewer_ViewPort2d::reset()
     myGLWidget->updateGL();
 }
 
+/*!
+  Sets offset to view
+  \param dx - X offset
+  \param dy - Y offset
+*/
 void GLViewer_ViewPort2d::pan( int dx, int dy )
 {
     //cout << "GLViewer_ViewPort2d::pan " << dx << " " << dy << endl;
@@ -553,6 +649,10 @@ void GLViewer_ViewPort2d::pan( int dx, int dy )
     myGLWidget->updateGL();
 }
 
+/*!
+  Sets view center in global coords
+  \param x, y - global co-ordinates of center
+*/
 void GLViewer_ViewPort2d::setCenter( int x, int y )
 {
     //cout << "GLViewer_ViewPort2d::setCenter" << endl;
@@ -582,6 +682,9 @@ void GLViewer_ViewPort2d::setCenter( int x, int y )
     myGLWidget->updateGL();
 }
 
+/*!
+  Process zoming transformation with mouse tracking from ( x0, y0 ) to ( x1, y1 )
+*/
 void GLViewer_ViewPort2d::zoom( int x0, int y0, int x, int y )
 {
     //cout << "GLViewer_ViewPort2d::zoom" << endl;
@@ -624,6 +727,10 @@ void GLViewer_ViewPort2d::zoom( int x0, int y0, int x, int y )
     }
 }
 
+/*!
+  Transforms view by rectangle
+  \param rect - rectangle
+*/
 void GLViewer_ViewPort2d::fitRect( const QRect& rect )
 {
     float x0, x1, y0, y1;
@@ -676,6 +783,9 @@ void GLViewer_ViewPort2d::fitRect( const QRect& rect )
     myGLWidget->updateGL();
 }
 
+/*!
+  Transforms view by selection
+*/
 void GLViewer_ViewPort2d::fitSelect()
 {
   GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
@@ -697,6 +807,10 @@ void GLViewer_ViewPort2d::fitSelect()
   }
 }
 
+/*!
+  Transform view by view borders
+  \param keepScale - if it is true, zoom does not change
+*/
 void GLViewer_ViewPort2d::fitAll( bool keepScale, bool withZ )
 {
     //cout << "GLViewer_ViewPort2d::fitAll" << endl;
@@ -785,11 +899,19 @@ void GLViewer_ViewPort2d::fitAll( bool keepScale, bool withZ )
         emit vpUpdateValues();
 }
 
+/*!
+  Begins rotation
+  \param x, y - start point
+*/
 void GLViewer_ViewPort2d::startRotation( int x, int y )
 {
     myGLWidget->setRotationStart( x, y, 1.0 );
 }
 
+/*!
+  Performs rotation
+  \param intX, intY - current point
+*/
 void GLViewer_ViewPort2d::rotate( int intX, int intY )
 {
     GLint val[4];
@@ -836,6 +958,9 @@ void GLViewer_ViewPort2d::rotate( int intX, int intY )
     myGLWidget->updateGL();
 }
 
+/*!
+  Finishes rotation
+*/
 void GLViewer_ViewPort2d::endRotation()
 {
     float ra, rx, ry, rz;
@@ -843,6 +968,9 @@ void GLViewer_ViewPort2d::endRotation()
     myGLWidget->setRotationAngle( ra );
 }
 
+/*!
+  Draws compass
+*/
 void GLViewer_ViewPort2d::drawCompass()
 {
     if( !myCompass->getVisible() )
@@ -1003,6 +1131,9 @@ void GLViewer_ViewPort2d::drawCompass()
         glCallList( aTextList );
 }
 
+/*!
+  \return blocking status for current started operations
+*/
 BlockStatus GLViewer_ViewPort2d::currentBlock()
 {
     if( myIsDragProcess == inDrag && myCurDragPosX != NULL && myCurDragPosY != NULL)
@@ -1014,6 +1145,10 @@ BlockStatus GLViewer_ViewPort2d::currentBlock()
     return BS_NoBlock;
 }
 
+/*!
+  Initializes rectangle selection
+  \param x, y - start point
+*/
 void GLViewer_ViewPort2d::startSelectByRect( int x, int y )
 {
     if( !mypFirstPoint && !mypLastPoint )
@@ -1022,6 +1157,11 @@ void GLViewer_ViewPort2d::startSelectByRect( int x, int y )
         mypLastPoint = new QPoint( x, y );
     }
 }
+
+/*!
+  Draws rectangle selection
+  \param x, y - current point
+*/
 void GLViewer_ViewPort2d::drawSelectByRect( int x, int y )
 {
     if( mypFirstPoint && mypLastPoint )
@@ -1040,6 +1180,10 @@ void GLViewer_ViewPort2d::drawSelectByRect( int x, int y )
     }
 
 }
+
+/*!
+  Finishes rectangle selection
+*/
 void GLViewer_ViewPort2d::finishSelectByRect()
 {
     if( mypFirstPoint && mypLastPoint )
@@ -1059,6 +1203,9 @@ void GLViewer_ViewPort2d::finishSelectByRect()
     }
 }
 
+/*!
+  \return rectangle selection
+*/
 QRect GLViewer_ViewPort2d::selectionRect()
 {
     QRect aRect;
@@ -1073,6 +1220,8 @@ QRect GLViewer_ViewPort2d::selectionRect()
     return aRect;
 }
 
+/*!
+*/
 bool GLViewer_ViewPort2d::startPulling( GLViewer_Pnt point )
 {
     GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
@@ -1096,6 +1245,8 @@ bool GLViewer_ViewPort2d::startPulling( GLViewer_Pnt point )
     return false;
 }
 
+/*!
+*/
 void GLViewer_ViewPort2d::drawPulling( GLViewer_Pnt point )
 {
     GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
@@ -1121,6 +1272,8 @@ void GLViewer_ViewPort2d::drawPulling( GLViewer_Pnt point )
     myPullingObject->pull( point, aLockedObject );
 }
 
+/*!
+*/
 void GLViewer_ViewPort2d::finishPulling()
 {
     myIsPulling = false;
@@ -1128,6 +1281,10 @@ void GLViewer_ViewPort2d::finishPulling()
     setCursor( *getDefaultCursor() );
 }
 
+/*!
+  Convert rectangle in window co-ordinates to GL co-ordinates
+  \return converted rectangle
+*/
 GLViewer_Rect GLViewer_ViewPort2d::win2GLV( const QRect& theRect ) const
 {
   GLViewer_Rect aRect;
@@ -1154,6 +1311,10 @@ GLViewer_Rect GLViewer_ViewPort2d::win2GLV( const QRect& theRect ) const
   return aRect;
 }
 
+/*!
+  Convert rectangle in GL co-ordinates to window co-ordinates
+  \return converted rectangle
+*/
 QRect GLViewer_ViewPort2d::GLV2win( const GLViewer_Rect& theRect ) const
 {
   QRect aRect;
@@ -1180,6 +1341,9 @@ QRect GLViewer_ViewPort2d::GLV2win( const GLViewer_Rect& theRect ) const
   return aRect;
 }
 
+/*!
+  SLOT: called when tooltip should be shown
+*/
 void GLViewer_ViewPort2d::onMaybeTip( QPoint thePoint, QString& theText, QFont& theFont, QRect& theTextReg, QRect& theRegion )
 {
   GLViewer_Context* aContext = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext();