+// 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 */
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;
// myGLWidget->installEventFilter( myObjectTip );
}
+/*!
+ Destructor
+*/
GLViewer_ViewPort2d::~GLViewer_ViewPort2d()
{
if( myCompass )
delete myGLWidget;
}
+/*!
+ SLOT: initializes drag process
+*/
void GLViewer_ViewPort2d::onStartDragObject( )
{
if( myIsDragProcess == noDrag )
}
}
+/*!
+ SLOT: cuts object to clipboard
+*/
void GLViewer_ViewPort2d::onCutObject()
{
/*GLViewer_Object* aMovingObject = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->getCurrentObject();
}
}
+/*!
+ SLOT: copies object to clipboard
+*/
void GLViewer_ViewPort2d::onCopyObject()
{
/*GLViewer_Object* aMovingObject = ((GLViewer_Viewer2d*)getViewFrame()->getViewer())->getGLContext()->getCurrentObject();
}
}
+/*!
+ SLOT: pastes object from clipboard
+*/
void GLViewer_ViewPort2d::onPasteObject()
{
/*QClipboard *aClipboard = QApplication::clipboard();
*/
}
+/*!
+ SLOT: called when object is being dragged
+*/
void GLViewer_ViewPort2d::onDragObject( QMouseEvent* e )
{
//cout << "---GLViewer_ViewPort2d::onDragObject()---" << endl;
*/
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 )
{
}
}
+/*!
+ 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 )
delete myCompass;
}
+/*!
+ Creates or deletes grid
+ \param on - if it is true, then to create
+*/
void GLViewer_ViewPort2d::turnGrid( GLboolean on )
{
if( 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 )
}
}
+/*!
+ Changes background color
+ \param color - new background color
+*/
void GLViewer_ViewPort2d::setBackgroundColor( const QColor& color )
{
GLViewer_ViewPort::setBackgroundColor( 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;
myGLWidget->setScale( myXScale, myYScale, 1.0 );
}
+/*!
+ Custom paint event handler
+*/
void GLViewer_ViewPort2d::paintEvent( QPaintEvent* e )
{
//cout << "GLViewer_ViewPort2d::paintEvent" << endl;
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;
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;
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;
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;
}
}
+/*!
+ Transforms view by rectangle
+ \param rect - rectangle
+*/
void GLViewer_ViewPort2d::fitRect( const QRect& rect )
{
float x0, x1, y0, y1;
myGLWidget->updateGL();
}
+/*!
+ Transforms view by selection
+*/
void GLViewer_ViewPort2d::fitSelect()
{
GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
}
}
+/*!
+ 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;
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];
myGLWidget->updateGL();
}
+/*!
+ Finishes rotation
+*/
void GLViewer_ViewPort2d::endRotation()
{
float ra, rx, ry, rz;
myGLWidget->setRotationAngle( ra );
}
+/*!
+ Draws compass
+*/
void GLViewer_ViewPort2d::drawCompass()
{
if( !myCompass->getVisible() )
glCallList( aTextList );
}
+/*!
+ \return blocking status for current started operations
+*/
BlockStatus GLViewer_ViewPort2d::currentBlock()
{
if( myIsDragProcess == inDrag && myCurDragPosX != NULL && myCurDragPosY != NULL)
return BS_NoBlock;
}
+/*!
+ Initializes rectangle selection
+ \param x, y - start point
+*/
void GLViewer_ViewPort2d::startSelectByRect( int x, int y )
{
if( !mypFirstPoint && !mypLastPoint )
mypLastPoint = new QPoint( x, y );
}
}
+
+/*!
+ Draws rectangle selection
+ \param x, y - current point
+*/
void GLViewer_ViewPort2d::drawSelectByRect( int x, int y )
{
if( mypFirstPoint && mypLastPoint )
}
}
+
+/*!
+ Finishes rectangle selection
+*/
void GLViewer_ViewPort2d::finishSelectByRect()
{
if( mypFirstPoint && mypLastPoint )
}
}
+/*!
+ \return rectangle selection
+*/
QRect GLViewer_ViewPort2d::selectionRect()
{
QRect aRect;
return aRect;
}
+/*!
+*/
bool GLViewer_ViewPort2d::startPulling( GLViewer_Pnt point )
{
GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
return false;
}
+/*!
+*/
void GLViewer_ViewPort2d::drawPulling( GLViewer_Pnt point )
{
GLViewer_Viewer2d* aViewer = (GLViewer_Viewer2d*)getViewFrame()->getViewer();
myPullingObject->pull( point, aLockedObject );
}
+/*!
+*/
void GLViewer_ViewPort2d::finishPulling()
{
myIsPulling = false;
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;
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;
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();