From: ouv Date: Mon, 8 Sep 2008 07:25:07 +0000 (+0000) Subject: Merging from branch For_CTH_V12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3c125175f5b73f02e34f3fcb91907547cf5cbcd0;p=modules%2Fgui.git Merging from branch For_CTH_V12 --- diff --git a/src/GLViewer/GLViewer_Context.cxx b/src/GLViewer/GLViewer_Context.cxx index 496d79bed..984e53726 100644 --- a/src/GLViewer/GLViewer_Context.cxx +++ b/src/GLViewer/GLViewer_Context.cxx @@ -618,7 +618,12 @@ void GLViewer_Context::setSelected( GLViewer_Object* object, bool updateViewer ) } if( updateViewer ) - myGLViewer2d->activateDrawer( object, TRUE, TRUE ); + { + if( myUpdateAll ) + myGLViewer2d->updateAll(); + else + myGLViewer2d->activateDrawer( object, TRUE, TRUE ); + } } /*! diff --git a/src/GLViewer/GLViewer_Drawer.cxx b/src/GLViewer/GLViewer_Drawer.cxx index c60128488..082e59574 100644 --- a/src/GLViewer/GLViewer_Drawer.cxx +++ b/src/GLViewer/GLViewer_Drawer.cxx @@ -964,52 +964,6 @@ bool GLViewer_Drawer::translateToEMF( HDC hDC, GLViewer_CoordSystem* aViewerCS, } #endif -/*! - Draws rectangle - \param rect - instance of primitive - \param lineWidth - width of line - \param gap - gap of rectangle - \param color - color of primitive - \param filled - if it is true, then rectangle will be drawn filled with color "fillingColor" - \param fillingColor - color of filling -*/ -void GLViewer_Drawer::drawRectangle( GLViewer_Rect* rect, GLfloat lineWidth, GLfloat gap, - QColor color, bool filled, QColor fillingColor ) -{ - if( !rect ) - return; - - float x1 = rect->left() - gap; - float x2 = rect->right() + gap; - float y1 = rect->bottom() - gap; - float y2 = rect->top() + gap; - - if( filled ) - { - glColor3f( ( GLfloat )fillingColor.red() / 255, - ( GLfloat )fillingColor.green() / 255, - ( GLfloat )fillingColor.blue() / 255 ); - glBegin( GL_POLYGON ); - glVertex2f( x1, y1 ); - glVertex2f( x1, y2 ); - glVertex2f( x2, y2 ); - glVertex2f( x2, y1 ); - glEnd(); - } - - glColor3f( ( GLfloat )color.red() / 255, - ( GLfloat )color.green() / 255, - ( GLfloat )color.blue() / 255 ); - glLineWidth( lineWidth ); - - glBegin( GL_LINE_LOOP ); - glVertex2f( x1, y1 ); - glVertex2f( x1, y2 ); - glVertex2f( x2, y2 ); - glVertex2f( x2, y1 ); - glEnd(); -} - /*! Draws contour \param pntList - list of points diff --git a/src/GLViewer/GLViewer_Drawer.h b/src/GLViewer/GLViewer_Drawer.h index d81c19dc7..220e62ac3 100644 --- a/src/GLViewer/GLViewer_Drawer.h +++ b/src/GLViewer/GLViewer_Drawer.h @@ -403,10 +403,6 @@ public: static void drawFilledRectangle( GLViewer_Rect*, QColor = Qt::black ); protected: - //! Draw basic primitives: rectangle, contour, polygon, vertex, cross, arrow - //* with predefined color - static void drawRectangle( GLViewer_Rect*, GLfloat, GLfloat = 0, QColor = Qt::black, - bool = false, QColor = Qt::white ); static void drawContour( GLViewer_Rect*, QColor, GLfloat, GLushort, bool ); static void drawContour( const GLViewer_PntList&, QColor, GLfloat ); static void drawPolygon( GLViewer_Rect*, QColor, GLushort, bool ); diff --git a/src/GLViewer/GLViewer_Object.cxx b/src/GLViewer/GLViewer_Object.cxx index f0cfefe4f..40234b886 100644 --- a/src/GLViewer/GLViewer_Object.cxx +++ b/src/GLViewer/GLViewer_Object.cxx @@ -148,7 +148,7 @@ GLboolean GLViewer_Object::setZoom( GLfloat zoom, bool, bool ) } /*! - Performs zoom change by step + Performs vertical zoom change by step \param zoomIn - to increase to decrease zoom */ GLboolean GLViewer_Object::updateZoom( bool zoomIn ) diff --git a/src/GLViewer/GLViewer_ViewFrame.cxx b/src/GLViewer/GLViewer_ViewFrame.cxx index 8072df526..86a3436d0 100644 --- a/src/GLViewer/GLViewer_ViewFrame.cxx +++ b/src/GLViewer/GLViewer_ViewFrame.cxx @@ -279,6 +279,20 @@ QImage GLViewer_ViewFrame::dumpView() return img; } +/*! + Saves image to file according to the format + \param image - image + \param fileName - name of file + \param format - string contains name of format (for example, "BMP"(default) or "JPEG", "JPG") +*/ +bool GLViewer_ViewFrame::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format ) +{ + bool ok = SUIT_ViewWindow::dumpViewToFormat( img, fileName, format ); + if( ok ) + emit vfViewDumped( img, fileName, format ); + return ok; +} + /*! Start panning */ diff --git a/src/GLViewer/GLViewer_ViewFrame.h b/src/GLViewer/GLViewer_ViewFrame.h index f2fd165bf..ddc7eb537 100644 --- a/src/GLViewer/GLViewer_ViewFrame.h +++ b/src/GLViewer/GLViewer_ViewFrame.h @@ -80,6 +80,10 @@ public: signals: void vfDrawExternal( QPainter* ); void vfViewClosing( QCloseEvent* ); + void vfViewDumped( const QImage&, const QString&, const QString& ); + +protected: + virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); protected: GLViewer_Viewer* myViewer; diff --git a/src/GLViewer/GLViewer_ViewPort2d.cxx b/src/GLViewer/GLViewer_ViewPort2d.cxx index 69392f012..d8c70913c 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.cxx +++ b/src/GLViewer/GLViewer_ViewPort2d.cxx @@ -352,6 +352,9 @@ void GLViewer_ViewPort2d::mouseMoveEvent( QMouseEvent* e ) { emit vpMouseEvent( e ); + if( isPulling() ) + return; + if( myIsDragProcess == inDrag ) onDragObject( e ); @@ -398,6 +401,9 @@ void GLViewer_ViewPort2d::mouseReleaseEvent( QMouseEvent* e ) } emit vpMouseEvent( e ); + if( isPulling() ) + return; + if( myIsDragProcess == inDrag ) { bool isAnyMoved = false; @@ -1195,6 +1201,14 @@ void GLViewer_ViewPort2d::drawSelectByRect( int x, int y ) } +/*! + Returns tue if selection by rect is preformed +*/ +bool GLViewer_ViewPort2d::isSelectByRect() const +{ + return mypFirstPoint && mypLastPoint; +} + /*! Finishes rectangle selection */ @@ -1402,6 +1416,13 @@ void GLViewer_ViewPort2d::onMaybeTip( QPoint thePoint, QString& theText, QFont& theTextReg = QRect( thePoint.x(), thePoint.y() + cur_height, aSize.width(), aSize.height() ); theRegion = QRect( thePoint.x(), thePoint.y(), 1, 1 ); + + QPoint aBottomRightGlobal = mapToGlobal( theTextReg.bottomRight() ); + int dx = aBottomRightGlobal.x() - QApplication::desktop()->screenGeometry().width(); + int dy = aBottomRightGlobal.y() - QApplication::desktop()->screenGeometry().height(); + dx = dx < 0 ? 0 : -dx; + dy = dy < 0 ? 0 : -dy; + theTextReg.translate( dx, dy ); } } } diff --git a/src/GLViewer/GLViewer_ViewPort2d.h b/src/GLViewer/GLViewer_ViewPort2d.h index 03a4b149f..77fd11eb1 100644 --- a/src/GLViewer/GLViewer_ViewPort2d.h +++ b/src/GLViewer/GLViewer_ViewPort2d.h @@ -61,9 +61,11 @@ class QRubberBand; class GLViewer_ViewPort2d: public GLViewer_ViewPort { Q_OBJECT + friend class GLViewer_Widget; +public: //! Dragging states - enum vpDragState{ noDrag, initDrag, inDrag }; + enum vpDragState{ noDrag = 0, initDrag, inDrag }; public: GLViewer_ViewPort2d( QWidget* parent, GLViewer_ViewFrame* theViewFrame = NULL ); @@ -119,7 +121,7 @@ public: void endRotation(); //! Checks of dragging process state - bool isDragProcess(){ return myIsDragProcess; } + int isDragProcess(){ return myIsDragProcess; } //! On/off compass void turnCompass( GLboolean on ); @@ -139,6 +141,9 @@ public: //! Pass rect into selector and update void finishSelectByRect(); + //! Pass rect into selector and update + bool isSelectByRect() const; + //! \warnign It is for ouv bool startPulling( GLViewer_Pnt ); //! \warnign It is for ouv diff --git a/src/GLViewer/GLViewer_Viewer.h b/src/GLViewer/GLViewer_Viewer.h index c12d5f901..c03557351 100644 --- a/src/GLViewer/GLViewer_Viewer.h +++ b/src/GLViewer/GLViewer_Viewer.h @@ -107,7 +107,7 @@ protected: virtual void startOperations( QMouseEvent* ) {} virtual bool updateOperations( QMouseEvent* ) { return false; } - virtual void finishOperations( QMouseEvent* ) {} + virtual bool finishOperations( QMouseEvent* ) { return false; } virtual void startOperations( QWheelEvent* ) {} protected slots: diff --git a/src/GLViewer/GLViewer_Viewer2d.cxx b/src/GLViewer/GLViewer_Viewer2d.cxx index eaa41fb39..712bebbbf 100644 --- a/src/GLViewer/GLViewer_Viewer2d.cxx +++ b/src/GLViewer/GLViewer_Viewer2d.cxx @@ -937,9 +937,15 @@ void GLViewer_Viewer2d::startOperations( QMouseEvent* e ) transPoint( x, y ); GLViewer_Pnt point( x, y ); - if( e->button() == Qt::LeftButton && !myGLContext->getCurrentObject() && vp->startPulling( point ) ) + // Try to start pooling if rectangular selection is performed + if( e->button() == Qt::LeftButton && !vp->isSelectByRect() && + !vp->isDragProcess() && vp->startPulling( point ) ) + { + vp->finishSelectByRect(); return; + } + // Start rectangular selection if pulling was not started if( e->button() == Qt::LeftButton && !(vp->currentBlock() & BS_Selection) && !myGLContext->getCurrentObject() ) vp->startSelectByRect( e->x(), e->y() ); } @@ -951,17 +957,30 @@ bool GLViewer_Viewer2d::updateOperations( QMouseEvent* e ) { GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort(); + float x = e->pos().x(); + float y = e->pos().y(); + transPoint( x, y ); + GLViewer_Pnt point( x, y ); + if( vp->isPulling() ) { - float x = e->pos().x(); - float y = e->pos().y(); - transPoint( x, y ); - - vp->drawPulling( GLViewer_Pnt( x, y ) ); + vp->drawPulling( point ); updateAll(); return true; } + /*if( vp->isDragProcess() == GLViewer_ViewPort2d::inDrag ) + return true;*/ + + if( e->button() == Qt::LeftButton ) + { + if( !vp->isSelectByRect() && !vp->isDragProcess() && vp->startPulling( point ) ) + { + vp->finishSelectByRect(); + return true; + } + } + if( !myGLContext->getCurrentObject() ) { vp->drawSelectByRect( e->x(), e->y() ); @@ -971,9 +990,11 @@ bool GLViewer_Viewer2d::updateOperations( QMouseEvent* e ) } /*! - Completes started operation on mouse event + Completes started operation on mouse event, Returns true if operation is considered + as completely finished and there is no point in performing other actions after finish + the operation. */ -void GLViewer_Viewer2d::finishOperations( QMouseEvent* e ) +bool GLViewer_Viewer2d::finishOperations( QMouseEvent* e ) { GLViewer_ViewPort2d* vp = ( GLViewer_ViewPort2d* )((GLViewer_ViewFrame*)getActiveView())->getViewPort(); @@ -981,7 +1002,10 @@ void GLViewer_Viewer2d::finishOperations( QMouseEvent* e ) { vp->finishPulling(); updateAll(); - return; + // Although operation is finished, FALSE is returned because base class try to + // perform selection in this case. In the other case it is impossible to perform + // selection of pulled port + return false; } if( !myGLContext->getCurrentObject() ) @@ -992,8 +1016,11 @@ void GLViewer_Viewer2d::finishOperations( QMouseEvent* e ) { bool append = bool ( e->modifiers() & GLViewer_Selector::appendKey() ); getSelector()->select( aSelRect, append ); + return true; } } + + return false; } /*! diff --git a/src/GLViewer/GLViewer_Viewer2d.h b/src/GLViewer/GLViewer_Viewer2d.h index b31a4430a..5f7148b5c 100644 --- a/src/GLViewer/GLViewer_Viewer2d.h +++ b/src/GLViewer/GLViewer_Viewer2d.h @@ -209,7 +209,7 @@ protected: //! Updates started operations on mouse event virtual bool updateOperations( QMouseEvent* ); //! Completes started operations on mouse event - virtual void finishOperations( QMouseEvent* ); + virtual bool finishOperations( QMouseEvent* ); //! Starts any operations on mouse wheel event virtual void startOperations( QWheelEvent* ); diff --git a/src/GLViewer/GLViewer_Widget.cxx b/src/GLViewer/GLViewer_Widget.cxx index 5ad81e29c..e1de5e4c3 100644 --- a/src/GLViewer/GLViewer_Widget.cxx +++ b/src/GLViewer/GLViewer_Widget.cxx @@ -345,15 +345,16 @@ void GLViewer_Widget::resizeGL( int w, int h ) if( w < 1 ) w = 1; glViewport( 0, 0, w, h); + myViewPort->initResize( w, h ); + if( myStart ) { myWidth = w; myHeight = h; + myViewPort->fitAll(); myStart = GL_FALSE; } - myViewPort->initResize( w, h ); - glMatrixMode( GL_PROJECTION ); glLoadIdentity(); GLfloat w_c = w / 2., h_c = h / 2.;