From: ouv Date: Mon, 5 Aug 2013 09:50:47 +0000 (+0000) Subject: 1) HYDRO: Import Image operation. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a2c38cdad5b17bee8ac0eece2ceed0854268a438;p=modules%2Fgui.git 1) HYDRO: Import Image operation. 2) Moving Presentation classes from GraphicsView to HYDROGUI. 3) Raw development. --- diff --git a/src/GraphicsView/CMakeLists.txt b/src/GraphicsView/CMakeLists.txt index ef4f1a460..573cfc4d5 100755 --- a/src/GraphicsView/CMakeLists.txt +++ b/src/GraphicsView/CMakeLists.txt @@ -33,7 +33,6 @@ SET(COMMON_LIBS ) SET(GUI_HEADERS - GraphicsView_PrsPropDlg.h GraphicsView_Scene.h GraphicsView_Selector.h GraphicsView_ViewFrame.h @@ -53,9 +52,6 @@ SET(GraphicsView_SOURCES GraphicsView_ViewManager.cxx GraphicsView_ViewPort.cxx GraphicsView_ViewTransformer.cxx - GraphicsView_PrsImage.cxx - GraphicsView_PrsImageFrame.cxx - GraphicsView_PrsPropDlg.cxx ) SET(GUITS_SOURCES diff --git a/src/GraphicsView/GraphicsView_Object.cxx b/src/GraphicsView/GraphicsView_Object.cxx index a290044d3..c00f15f0f 100644 --- a/src/GraphicsView/GraphicsView_Object.cxx +++ b/src/GraphicsView/GraphicsView_Object.cxx @@ -37,7 +37,6 @@ GraphicsView_Object::GraphicsView_Object( QGraphicsItem* theParent ) myIsSelected( false ), myIsMoving( false ) { - myHighlightCursor = new QCursor( Qt::OpenHandCursor ); } //======================================================================= @@ -46,12 +45,6 @@ GraphicsView_Object::GraphicsView_Object( QGraphicsItem* theParent ) //======================================================================= GraphicsView_Object::~GraphicsView_Object() { - if( myHighlightCursor ) - { - delete myHighlightCursor; - myHighlightCursor = 0; - } - QListIterator aChildIter( children() ); while( aChildIter.hasNext() ) { diff --git a/src/GraphicsView/GraphicsView_Object.h b/src/GraphicsView/GraphicsView_Object.h index 14810d1e0..61c0fdbfd 100644 --- a/src/GraphicsView/GraphicsView_Object.h +++ b/src/GraphicsView/GraphicsView_Object.h @@ -96,9 +96,6 @@ public: virtual QTransform getViewTransform() const { return myViewTransform; } virtual void setViewTransform( const QTransform& theTransform ); -protected: - QCursor* getHighlightCursor() const { return myHighlightCursor; } - protected: QString myName; @@ -111,9 +108,6 @@ protected: bool myIsMoving; QTransform myViewTransform; - -private: - QCursor* myHighlightCursor; }; #endif diff --git a/src/GraphicsView/GraphicsView_PrsImage.cxx b/src/GraphicsView/GraphicsView_PrsImage.cxx deleted file mode 100644 index 6be39005d..000000000 --- a/src/GraphicsView/GraphicsView_PrsImage.cxx +++ /dev/null @@ -1,624 +0,0 @@ -// Copyright (C) 2007-2013 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. -// -// 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 "GraphicsView_PrsImage.h" - -#include "GraphicsView_PrsImageFrame.h" -#include "GraphicsView_ViewPort.h" - -#include -#include -#include -#include - -#include - -#define PREVIEW_Z_VALUE 2000 -#define EPSILON 1e-6 -#define PI 3.14159265359 - -//======================================================================= -// name : GraphicsView_PrsImage -// Purpose : Constructor -//======================================================================= -GraphicsView_PrsImage::GraphicsView_PrsImage() -: GraphicsView_Object(), - myIsLockAspectRatio( false ), - myPixmapItem( 0 ), - myPreviewPixmapItem( 0 ), - myPrsImageFrame( 0 ), - myPosX( 0.0 ), - myPosY( 0.0 ), - myScaleX( 1.0 ), - myScaleY( 1.0 ), - myRotationAngle( 0.0 ), - myPreviewPosX( 0.0 ), - myPreviewPosY( 0.0 ), - myPreviewScaleX( 1.0 ), - myPreviewScaleY( 1.0 ), - myPreviewRotationAngle( 0.0 ) -{ -} - -//======================================================================= -// name : GraphicsView_PrsImage -// Purpose : Destructor -//======================================================================= -GraphicsView_PrsImage::~GraphicsView_PrsImage() -{ - if( myPrsImageFrame ) - { - delete myPrsImageFrame; - myPrsImageFrame = 0; - } -} - -//================================================================ -// Function : updateTransform -// Purpose : -//================================================================ -void GraphicsView_PrsImage::updateTransform() -{ - QTransform aTransform = getTransform(); - - setTransform( aTransform ); - myPrsImageFrame->setTransform( aTransform ); - - // for anchors - myPrsImageFrame->setScaling( myScaleX, myScaleY ); - myPrsImageFrame->setRotationAngle( myRotationAngle ); - - aTransform = getTransform( true ); - myPreviewPixmapItem->setTransform( aTransform ); -} - -//================================================================ -// Function : setImage -// Purpose : -//================================================================ -void GraphicsView_PrsImage::setImage( const QImage& theImage ) -{ - myPixmap = QPixmap::fromImage( theImage ); -} - -//================================================================ -// Function : getImage -// Purpose : -//================================================================ -QImage GraphicsView_PrsImage::getImage() const -{ - return myPixmap.toImage(); -} - -//================================================================ -// Function : getTransform -// Purpose : -//================================================================ -QTransform GraphicsView_PrsImage::getTransform( const bool theIsPreview ) const -{ - double aPosX = theIsPreview ? myPreviewPosX : myPosX; - double aPosY = theIsPreview ? myPreviewPosY : myPosY; - double aScaleX = theIsPreview ? myPreviewScaleX : myScaleX; - double aScaleY = theIsPreview ? myPreviewScaleY : myScaleY; - double aRotationAngle = theIsPreview ? myPreviewRotationAngle : myRotationAngle; - - QTransform aTransform; - aTransform.translate( aPosX, aPosY ); - aTransform.rotate( aRotationAngle ); - aTransform.scale( aScaleX, aScaleY ); - return aTransform; -} - -//================================================================ -// Function : setPosition -// Purpose : -//================================================================ -void GraphicsView_PrsImage::setPosition( const double thePosX, const double thePosY ) -{ - myPosX = thePosX; - myPosY = thePosY; -} - -//================================================================ -// Function : getPosition -// Purpose : -//================================================================ -void GraphicsView_PrsImage::getPosition( double& thePosX, double& thePosY ) const -{ - thePosX = myPosX; - thePosY = myPosY; -} - -//================================================================ -// Function : setScaling -// Purpose : -//================================================================ -void GraphicsView_PrsImage::setScaling( const double theScaleX, const double theScaleY ) -{ - myScaleX = theScaleX; - myScaleY = theScaleY; -} - -//================================================================ -// Function : getScaling -// Purpose : -//================================================================ -void GraphicsView_PrsImage::getScaling( double& theScaleX, double& theScaleY ) const -{ - theScaleX = myScaleX; - theScaleY = myScaleY; -} - -//================================================================ -// Function : setRotationAngle -// Purpose : -//================================================================ -void GraphicsView_PrsImage::setRotationAngle( const double theRotationAngle ) -{ - myRotationAngle = theRotationAngle; -} - -//================================================================ -// Function : getRotationAngle -// Purpose : -//================================================================ -void GraphicsView_PrsImage::getRotationAngle( double& theRotationAngle ) const -{ - theRotationAngle = myRotationAngle; -} - -//================================================================ -// Function : setIsLockAspectRatio -// Purpose : -//================================================================ -void GraphicsView_PrsImage::setIsLockAspectRatio( const bool theIsLockAspectRatio ) -{ - myIsLockAspectRatio = theIsLockAspectRatio; -} - -//================================================================ -// Function : getIsLockAspectRatio -// Purpose : -//================================================================ -bool GraphicsView_PrsImage::getIsLockAspectRatio() const -{ - return myIsLockAspectRatio; -} - -//================================================================ -// Function : setIsSmoothTransformation -// Purpose : -//================================================================ -void GraphicsView_PrsImage::setIsSmoothTransformation( const bool theIsSmoothTransformation ) -{ - Qt::TransformationMode aMode = theIsSmoothTransformation ? - Qt::SmoothTransformation : Qt::FastTransformation; - myPixmapItem->setTransformationMode( aMode ); -} - -//================================================================ -// Function : getIsSmoothTransformation -// Purpose : -//================================================================ -bool GraphicsView_PrsImage::getIsSmoothTransformation() const -{ - return myPixmapItem->transformationMode() == Qt::SmoothTransformation; -} - -//================================================================ -// Function : boundingRect -// Purpose : -//================================================================ -QRectF GraphicsView_PrsImage::boundingRect() const -{ - return myPixmapItem->boundingRect(); -} - -//================================================================ -// Function : compute -// Purpose : -//================================================================ -void GraphicsView_PrsImage::compute() -{ - if( !myPixmapItem ) - { - myPixmapItem = new QGraphicsPixmapItem( this ); - addToGroup( myPixmapItem ); - } - if( !myPreviewPixmapItem ) - { - myPreviewPixmapItem = new QGraphicsPixmapItem(); - myPreviewPixmapItem->setTransformationMode( Qt::FastTransformation ); // always - //addToGroup( myPreviewPixmapItem ); // don't add - } - if( !myPrsImageFrame ) - { - myPrsImageFrame = new GraphicsView_PrsImageFrame(); - myPrsImageFrame->setPrsImage( this ); - } - - myPixmapItem->setPixmap( myPixmap ); - - myPreviewPixmapItem->setPixmap( myPixmap ); - myPreviewPixmapItem->setVisible( false ); - - myPrsImageFrame->compute(); - - updateTransform(); -} - -//================================================================ -// Function : addTo -// Purpose : -//================================================================ -void GraphicsView_PrsImage::addTo( GraphicsView_ViewPort* theViewPort ) -{ - GraphicsView_Object::addTo( theViewPort ); - theViewPort->addItem( myPrsImageFrame ); - theViewPort->addItem( myPreviewPixmapItem ); - - double aZValue = 0; - GraphicsView_ObjectListIterator anIter( theViewPort->getObjects() ); - while( anIter.hasNext() ) - { - if( GraphicsView_PrsImage* aPrs = dynamic_cast( anIter.next() ) ) - { - double aZValueRef = aPrs->zValue(); - aZValue = qMax( aZValue, aZValueRef ); - } - } - setZValue( aZValue + 1 ); -} - -//================================================================ -// Function : removeFrom -// Purpose : -//================================================================ -void GraphicsView_PrsImage::removeFrom( GraphicsView_ViewPort* theViewPort ) -{ - GraphicsView_Object::removeFrom( theViewPort ); - theViewPort->removeItem( myPrsImageFrame ); - theViewPort->removeItem( myPreviewPixmapItem ); -} - -//================================================================ -// Function : checkHighlight -// Purpose : -//================================================================ -bool GraphicsView_PrsImage::checkHighlight( double theX, double theY, QCursor& theCursor ) const -{ - QRect aRect = myPixmapItem->boundingRect().toRect(); - QPolygon aPolygon = sceneTransform().mapToPolygon( aRect ); - if( aPolygon.containsPoint( QPoint( theX, theY ), Qt::OddEvenFill ) ) - { - theCursor = *getHighlightCursor(); - return true; - } - return false; -} - -//================================================================ -// Function : select -// Purpose : -//================================================================ -bool GraphicsView_PrsImage::select( double theX, double theY, const QRectF& theRect ) -{ - bool anIsSelected = GraphicsView_Object::select( theX, theY, theRect ); - myPrsImageFrame->updateVisibility(); - return anIsSelected; -} - -//================================================================ -// Function : unselect -// Purpose : -//================================================================ -void GraphicsView_PrsImage::unselect() -{ - GraphicsView_Object::unselect(); - myPrsImageFrame->updateVisibility(); -} - -//================================================================ -// Function : setSelected -// Purpose : -//================================================================ -void GraphicsView_PrsImage::setSelected( bool theState ) -{ - GraphicsView_Object::setSelected( theState ); - myPrsImageFrame->updateVisibility(); -} - -//================================================================ -// Function : move -// Purpose : -//================================================================ -void GraphicsView_PrsImage::move( double theDX, double theDY, bool theIsAtOnce ) -{ - if( theIsAtOnce ) - { - finishMove( true ); - return; - } - - if( !myIsMoving ) - enablePreview( true ); - - myIsMoving = true; - - myPreviewPosX += theDX; - myPreviewPosY += theDY; - updateTransform(); -} - -//================================================================ -// Function : finishMove -// Purpose : -//================================================================ -bool GraphicsView_PrsImage::finishMove( bool theStatus ) -{ - if( myIsMoving ) - { - if( theStatus ) - { - myPosX = myPreviewPosX; - myPosY = myPreviewPosY; - updateTransform(); - } - enablePreview( false ); - } - return GraphicsView_Object::finishMove( theStatus ); -} - -//================================================================ -// Function : processResize -// Purpose : -//================================================================ -void GraphicsView_PrsImage::processResize( const int theAnchor, - const double theDX, - const double theDY ) -{ - if( fabs( theDX ) < EPSILON && fabs( theDY ) < EPSILON ) - return; - - if( !myPreviewPixmapItem->isVisible() ) - enablePreview( true ); - - double anAngle = -1 * myRotationAngle * PI / 180.; - - QVector2D aVec( theDX, theDY ); - QVector2D aVecHor( 10, 0 ); - - double aDist = sqrt( theDX * theDX + theDY * theDY ); - double anAngle1 = computeAngle( aVec, aVecHor ); - double anAngle2 = anAngle1 - anAngle; - - double aSizeDX = aDist * cos( anAngle2 ); - double aSizeDY = -aDist * sin( anAngle2 ); - - QPointF aSizeShift; - switch( theAnchor ) - { - case GraphicsView_PrsImageFrame::Top: aSizeShift = QPointF( 0, -aSizeDY ); break; - case GraphicsView_PrsImageFrame::Bottom: aSizeShift = QPointF( 0, aSizeDY ); break; - case GraphicsView_PrsImageFrame::Left: aSizeShift = QPointF( -aSizeDX, 0 ); break; - case GraphicsView_PrsImageFrame::Right: aSizeShift = QPointF( aSizeDX, 0 ); break; - case GraphicsView_PrsImageFrame::TopLeft: aSizeShift = QPointF( -aSizeDX, -aSizeDY ); break; - case GraphicsView_PrsImageFrame::TopRight: aSizeShift = QPointF( aSizeDX, -aSizeDY ); break; - case GraphicsView_PrsImageFrame::BottomLeft: aSizeShift = QPointF( -aSizeDX, aSizeDY ); break; - case GraphicsView_PrsImageFrame::BottomRight: aSizeShift = QPointF( aSizeDX, aSizeDY ); break; - } - - double aWidth = (double)myPixmap.width() * myScaleX; - double aHeight = (double)myPixmap.height() * myScaleY; - - double aNewWidth = aWidth + aSizeShift.x(); - double aNewHeight = aHeight + aSizeShift.y(); - - double aRatio = fabs( aHeight ) > EPSILON ? aWidth / aHeight : 1.0; - double aNewRatio = fabs( aNewHeight ) > EPSILON ? aNewWidth / aNewHeight : 1.0; - - double aDiffX = 0, aDiffY = 0; // only for TopLeft anchor - if( myIsLockAspectRatio && fabs( aRatio ) > EPSILON && - ( theAnchor == GraphicsView_PrsImageFrame::TopLeft || - theAnchor == GraphicsView_PrsImageFrame::TopRight || - theAnchor == GraphicsView_PrsImageFrame::BottomLeft || - theAnchor == GraphicsView_PrsImageFrame::BottomRight ) ) - { - double aCurrentSizeShiftX = aSizeShift.x(); - double aCurrentSizeShiftY = aSizeShift.y(); - - double aSign = myScaleX * myScaleY > 0 ? 1.0 : -1.0; - if( aSign * aNewRatio > aSign * aRatio ) - aSizeShift.setY( aSizeShift.x() / aRatio ); - else - aSizeShift.setX( aSizeShift.y() * aRatio ); - - aDiffX = aSizeShift.x() - aCurrentSizeShiftX; - aDiffY = aSizeShift.y() - aCurrentSizeShiftY; - - aNewWidth = aWidth + aSizeShift.x(); - aNewHeight = aHeight + aSizeShift.y(); - } - - QPointF aPosShift; - switch( theAnchor ) - { - case GraphicsView_PrsImageFrame::Top: - aPosShift = QPointF( -aSizeShift.y() * sin( anAngle ), -aSizeShift.y() * cos( anAngle ) ); - break; - case GraphicsView_PrsImageFrame::Bottom: - aPosShift = QPointF( 0, 0 ); - break; - case GraphicsView_PrsImageFrame::Left: - aPosShift = QPointF( -aSizeShift.x() * cos( anAngle ), aSizeShift.x() * sin( anAngle ) ); - break; - case GraphicsView_PrsImageFrame::Right: - aPosShift = QPointF( 0, 0 ); - break; - case GraphicsView_PrsImageFrame::TopLeft: - aPosShift = QPointF( theDX - aDiffX * cos( anAngle ) - aDiffY * sin( anAngle ), - theDY + aDiffX * sin( anAngle ) - aDiffY * cos( anAngle ) ); - break; - case GraphicsView_PrsImageFrame::TopRight: - aPosShift = QPointF( -aSizeShift.y() * sin( anAngle ), -aSizeShift.y() * cos( anAngle ) ); - break; - case GraphicsView_PrsImageFrame::BottomLeft: - aPosShift = QPointF( -aSizeShift.x() * cos( anAngle ), aSizeShift.x() * sin( anAngle ) ); - break; - case GraphicsView_PrsImageFrame::BottomRight: - aPosShift = QPointF( 0, 0 ); - break; - } - - myPreviewPosX = myPosX + aPosShift.x(); - myPreviewPosY = myPosY + aPosShift.y(); - - myPreviewScaleX = myScaleX * aNewWidth / aWidth; - myPreviewScaleY = myScaleY * aNewHeight / aHeight; - - updateTransform(); -} - -//================================================================ -// Function : finishResize -// Purpose : -//================================================================ -void GraphicsView_PrsImage::finishResize() -{ - myPosX = myPreviewPosX; - myPosY = myPreviewPosY; - - myScaleX = myPreviewScaleX; - myScaleY = myPreviewScaleY; - updateTransform(); - - enablePreview( false ); -} - -//================================================================ -// Function : computeRotationAngle -// Purpose : -//================================================================ -double GraphicsView_PrsImage::computeRotationAngle( const QPointF& thePoint1, - const QPointF& thePoint2 ) const -{ - QRectF aRect = getRect(); - QPointF aCenter = aRect.center(); - - QVector2D aVec1( thePoint1 - aCenter ); - QVector2D aVec2( thePoint2 - aCenter ); - - double anAngle = computeAngle( aVec1, aVec2 ); - double anAngleDeg = anAngle / PI * 180.; - return anAngleDeg; -} - -//================================================================ -// Function : processRotate -// Purpose : -//================================================================ -void GraphicsView_PrsImage::processRotate( const double theAngle ) -{ - if( fabs( theAngle ) < EPSILON ) - return; - - if( !myPreviewPixmapItem->isVisible() ) - enablePreview( true ); - - myPreviewRotationAngle = myRotationAngle + theAngle; - - QPointF aCenter( (double)myPixmap.width() / 2., - (double)myPixmap.height() / 2. ); - - myPreviewPosX = myPosX; - myPreviewPosY = myPosY; - QTransform aTransform1 = getTransform(); - QTransform aTransform2 = getTransform( true ); - - QPointF aPoint1 = aTransform1.map( aCenter ); - QPointF aPoint2 = aTransform2.map( aCenter ); - QPointF aDiff = aPoint2 - aPoint1; - - myPreviewPosX = myPosX - aDiff.x(); - myPreviewPosY = myPosY - aDiff.y(); - - updateTransform(); -} - -//================================================================ -// Function : finishRotate -// Purpose : -//================================================================ -void GraphicsView_PrsImage::finishRotate() -{ - myPosX = myPreviewPosX; - myPosY = myPreviewPosY; - myRotationAngle = myPreviewRotationAngle; - updateTransform(); - - enablePreview( false ); -} - -//================================================================ -// Function : enablePreview -// Purpose : -//================================================================ -void GraphicsView_PrsImage::enablePreview( const bool theState ) -{ - if( theState ) - { - myPreviewPixmapItem->setZValue( PREVIEW_Z_VALUE ); - myPreviewPixmapItem->setOpacity( opacity() / 2. ); - - myPreviewPosX = myPosX; - myPreviewPosY = myPosY; - myPreviewScaleX = myScaleX; - myPreviewScaleY = myScaleY; - myPreviewRotationAngle = myRotationAngle; - - myPreviewPixmapItem->setVisible( true ); - } - else - myPreviewPixmapItem->setVisible( false ); -} - -//================================================================ -// Function : computeAngle -// Purpose : -//================================================================ -double GraphicsView_PrsImage::computeAngle( const QVector2D& theVector1, - const QVector2D& theVector2 ) -{ - if( theVector1.isNull() || theVector2.isNull() ) - return 0.0; - - double aDotProduct = QVector2D::dotProduct( theVector1, theVector2 ); - double aCos = aDotProduct / theVector1.length() / theVector2.length(); - - double aCrossProduct = theVector1.x() * theVector2.y() - theVector1.y() * theVector2.x(); - - double anAngle = acos( aCos ); - if( aCrossProduct < 0 ) - anAngle *= -1; - - return anAngle; -} diff --git a/src/GraphicsView/GraphicsView_PrsImage.h b/src/GraphicsView/GraphicsView_PrsImage.h deleted file mode 100644 index e9ae9887d..000000000 --- a/src/GraphicsView/GraphicsView_PrsImage.h +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2007-2013 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. -// -// 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 -// - -#ifndef GRAPHICSVIEW_PRSIMAGE_H -#define GRAPHICSVIEW_PRSIMAGE_H - -#include "GraphicsView.h" - -#include "GraphicsView_Object.h" - -class GraphicsView_PrsImageFrame; - -/* - Class : GraphicsView_PrsImage - Description : Presentation for image object -*/ -class GRAPHICSVIEW_API GraphicsView_PrsImage : public GraphicsView_Object -{ -public: - GraphicsView_PrsImage(); - virtual ~GraphicsView_PrsImage(); - -public: - void updateTransform(); - - void setImage( const QImage& theImage ); - QImage getImage() const; - - QTransform getTransform( const bool theIsPreview = false ) const; - - void setPosition( const double thePosX, const double thePosY ); - void getPosition( double& thePosX, double& thePosY ) const; - - void setScaling( const double theScaleX, const double theScaleY ); - void getScaling( double& theScaleX, double& theScaleY ) const; - - void setRotationAngle( const double theRotationAngle ); - void getRotationAngle( double& theRotationAngle ) const; - - void setIsLockAspectRatio( const bool theIsLockAspectRatio ); - bool getIsLockAspectRatio() const; - - void setIsSmoothTransformation( const bool theIsSmoothTransformation ); - bool getIsSmoothTransformation() const; - -public: - // from QGraphicsItem - virtual QRectF boundingRect() const; - - // from GraphicsView_Object - virtual void compute(); - - virtual void addTo( GraphicsView_ViewPort* theViewPort ); - virtual void removeFrom( GraphicsView_ViewPort* theViewPort ); - - virtual bool checkHighlight( double theX, double theY, QCursor& theCursor ) const; - - virtual bool select( double theX, double theY, const QRectF& theRect ); - virtual void unselect(); - virtual void setSelected( bool theState ); - - virtual void move( double theDX, double theDY, bool theIsAtOnce = false ); - virtual bool finishMove( bool theStatus ); - -protected: - void processResize( const int theAnchor, - const double theDX, - const double theDY ); - void finishResize(); - - double computeRotationAngle( const QPointF& thePoint1, - const QPointF& thePoint2 ) const; - - void processRotate( const double theAngle ); - void finishRotate(); - -protected: - void enablePreview( const bool theState ); - - static double computeAngle( const QVector2D& theVector1, - const QVector2D& theVector2 ); - -protected: - QPixmap myPixmap; - - bool myIsLockAspectRatio; - - QGraphicsPixmapItem* myPixmapItem; - QGraphicsPixmapItem* myPreviewPixmapItem; - - GraphicsView_PrsImageFrame* myPrsImageFrame; - - double myPosX; - double myPosY; - double myScaleX; - double myScaleY; - double myRotationAngle; - - double myPreviewPosX; - double myPreviewPosY; - double myPreviewScaleX; - double myPreviewScaleY; - double myPreviewRotationAngle; - -private: - friend class GraphicsView_PrsImageFrame; -}; - -#endif diff --git a/src/GraphicsView/GraphicsView_PrsImageFrame.cxx b/src/GraphicsView/GraphicsView_PrsImageFrame.cxx deleted file mode 100644 index d550632f9..000000000 --- a/src/GraphicsView/GraphicsView_PrsImageFrame.cxx +++ /dev/null @@ -1,594 +0,0 @@ -// Copyright (C) 2007-2013 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. -// -// 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 "GraphicsView_PrsImageFrame.h" - -#include "GraphicsView_PrsImage.h" - -#include -#include - -#include -#include - -#include - -#define FRAME_Z_VALUE 1000 -#define ANCHOR_RADIUS 3 -#define EPSILON 1e-6 -#define PI 3.14159265359 - -//======================================================================= -// name : GraphicsView_PrsImageFrame -// Purpose : Constructor -//======================================================================= -GraphicsView_PrsImageFrame::GraphicsView_PrsImageFrame() -: GraphicsView_Object(), - myPrsImage( 0 ), - myIsPulling( false ), - myPullingAnchor( Undefined ) -{ - myVerCursor = new QCursor( Qt::SizeVerCursor ); - myHorCursor = new QCursor( Qt::SizeHorCursor ); - myBDiagCursor = new QCursor( Qt::SizeBDiagCursor ); - myFDiagCursor = new QCursor( Qt::SizeFDiagCursor ); - - SUIT_ResourceMgr* rmgr = SUIT_Session::session()->resourceMgr(); - myRotateCursor = new QCursor( rmgr->loadPixmap( "GraphicsView", QObject::tr( "ICON_GV_ROTATE" ) ) ); -} - -//======================================================================= -// name : GraphicsView_PrsImageFrame -// Purpose : Destructor -//======================================================================= -GraphicsView_PrsImageFrame::~GraphicsView_PrsImageFrame() -{ - if( myVerCursor ) - { - delete myVerCursor; - myVerCursor = 0; - } - if( myHorCursor ) - { - delete myHorCursor; - myHorCursor = 0; - } - if( myBDiagCursor ) - { - delete myBDiagCursor; - myBDiagCursor = 0; - } - if( myFDiagCursor ) - { - delete myFDiagCursor; - myFDiagCursor = 0; - } - if( myRotateCursor ) - { - delete myRotateCursor; - myRotateCursor = 0; - } -} - -//================================================================ -// Function : boundingRect -// Purpose : -//================================================================ -QRectF GraphicsView_PrsImageFrame::boundingRect() const -{ - QRectF aRect; - AnchorMapIterator anIter( myAnchorMap ); - while( anIter.hasNext() ) - { - if( QGraphicsEllipseItem* anAnchorItem = anIter.next().value() ) - { - QRectF anAnchorRect = anAnchorItem->boundingRect(); - if( !anAnchorRect.isNull() ) - { - if( aRect.isNull() ) - aRect = anAnchorRect; - else - aRect |= anAnchorRect; - } - } - } - return aRect; -} - -//================================================================ -// Function : compute -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::compute() -{ - if( myAnchorMap.isEmpty() ) - { - for( int aType = TopMost; aType <= BottomRight; aType++ ) - { - UnscaledGraphicsEllipseItem* anAnchorItem = new UnscaledGraphicsEllipseItem( this ); - - Qt::GlobalColor aColor = Qt::white; - if( aType == TopMost ) - aColor = Qt::green; - anAnchorItem->setBrush( QBrush( aColor ) ); - - myAnchorMap.insert( aType, anAnchorItem ); - - addToGroup( anAnchorItem ); - } - } - - setZValue( FRAME_Z_VALUE ); - - computeAnchorItems(); - updateVisibility(); -} - -//================================================================ -// Function : checkHighlight -// Purpose : -//================================================================ -bool GraphicsView_PrsImageFrame::checkHighlight( double theX, double theY, QCursor& theCursor ) const -{ - AnchorMapIterator anIter( myAnchorMap ); - while( anIter.hasNext() ) - { - int aType = anIter.next().key(); - if( UnscaledGraphicsEllipseItem* anAnchorItem = anIter.value() ) - { - QRectF aRect = anAnchorItem->sceneHighlightRect(); - if( aRect.contains( QPointF( theX, theY ) ) ) - { - if( aType >= Top && aType <= BottomRight ) - { - if( QCursor* aCursor = getResizeCursor( aType ) ) - theCursor = *aCursor; - } - else if( aType == TopMost ) - theCursor = *getRotateCursor(); - return true; - } - } - } - return false; -} - -//================================================================ -// Function : getPullingRect -// Purpose : -//================================================================ -QRectF GraphicsView_PrsImageFrame::getPullingRect() const -{ - return getRect(); -} - -//================================================================ -// Function : startPulling -// Purpose : -//================================================================ -bool GraphicsView_PrsImageFrame::startPulling( const QPointF& thePoint ) -{ - if( !isVisible() ) - return false; - - AnchorMapIterator anIter( myAnchorMap ); - while( anIter.hasNext() ) - { - int aType = anIter.next().key(); - if( UnscaledGraphicsEllipseItem* anAnchorItem = anIter.value() ) - { - QRectF aRect = anAnchorItem->sceneHighlightRect(); - if( aRect.contains( thePoint ) ) - { - myPullingAnchor = aType; - myPullingPoint = sceneTransform().map( anAnchorItem->getBasePoint() ); - return true; - } - } - } - return false; -} - -//================================================================ -// Function : pull -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::pull( const QPointF& thePoint, - GraphicsView_Object* theLockedObject, // unused - const GraphicsView_ObjectList& theSyncObjects ) -{ - if( !myPrsImage ) - return; - - if( thePoint == myPullingPoint ) - return; - - double aDX = thePoint.x() - myPullingPoint.x(); - double aDY = thePoint.y() - myPullingPoint.y(); - - double aDAngle = myPrsImage->computeRotationAngle( myPullingPoint, thePoint ); - - if( myPullingAnchor >= Top && myPullingAnchor <= BottomRight ) - myPrsImage->processResize( myPullingAnchor, aDX, aDY ); - else if( myPullingAnchor == TopMost ) - myPrsImage->processRotate( aDAngle ); - - QRectF aRect = myPrsImage->getRect(); - double anAngle = 0; - myPrsImage->getRotationAngle( anAngle ); - - GraphicsView_ObjectListIterator anIter( theSyncObjects ); - while( anIter.hasNext() ) - { - if( GraphicsView_PrsImage* aPrsImage = dynamic_cast( anIter.next() ) ) - { - if( aPrsImage != myPrsImage ) - { - if( myPullingAnchor >= Top && myPullingAnchor <= BottomRight ) - { - QRectF aRectRef = aPrsImage->getRect(); - double anAngleRef = 0; - aPrsImage->getRotationAngle( anAngleRef ); - - double aDXRef = aDX * aRectRef.width() / aRect.width(); - double aDYRef = aDY * aRectRef.height() / aRect.height(); - - double anAngleDiff = ( anAngleRef - anAngle ) * PI / 180.; - double aDXRefTrans = aDXRef * cos( anAngleDiff ) - aDYRef * sin( anAngleDiff ); - double aDYRefTrans = aDXRef * sin( anAngleDiff ) + aDYRef * cos( anAngleDiff ); - - aPrsImage->processResize( myPullingAnchor, aDXRefTrans, aDYRefTrans ); - } - else if( myPullingAnchor == TopMost ) - aPrsImage->processRotate( aDAngle ); - } - } - } -} - -//================================================================ -// Function : finishPulling -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::finishPulling( bool theStatus, - const GraphicsView_ObjectList& theSyncObjects ) -{ - if( !myPrsImage ) - return; - - if( !theStatus ) - { - myPrsImage->enablePreview( false ); - return; - } - - if( myPullingAnchor >= Top && myPullingAnchor <= BottomRight ) - myPrsImage->finishResize(); - else if( myPullingAnchor == TopMost ) - myPrsImage->finishRotate(); - - GraphicsView_ObjectListIterator anIter( theSyncObjects ); - while( anIter.hasNext() ) - { - if( GraphicsView_PrsImage* aPrsImage = dynamic_cast( anIter.next() ) ) - { - if( aPrsImage != myPrsImage ) - { - if( myPullingAnchor >= Top && myPullingAnchor <= BottomRight ) - aPrsImage->finishResize(); - else if( myPullingAnchor == TopMost ) - aPrsImage->finishRotate(); - } - } - } -} - -//================================================================ -// Function : setPrsImage -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::setPrsImage( GraphicsView_PrsImage* thePrsImage ) -{ - myPrsImage = thePrsImage; -} - -//================================================================ -// Function : computeAnchorItems -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::computeAnchorItems() -{ - if( !myPrsImage ) - return; - - QRectF aRect = myPrsImage->boundingRect(); - - QMap anAnchorPointMap; - anAnchorPointMap[ TopMost ] = ( aRect.topLeft() + aRect.topRight() ) / 2; - anAnchorPointMap[ Top ] = ( aRect.topLeft() + aRect.topRight() ) / 2; - anAnchorPointMap[ Bottom ] = ( aRect.bottomLeft() + aRect.bottomRight() ) / 2; - anAnchorPointMap[ Left ] = ( aRect.topLeft() + aRect.bottomLeft() ) / 2; - anAnchorPointMap[ Right ] = ( aRect.topRight() + aRect.bottomRight() ) / 2; - anAnchorPointMap[ TopLeft ] = aRect.topLeft(); - anAnchorPointMap[ TopRight ] = aRect.topRight(); - anAnchorPointMap[ BottomLeft ] = aRect.bottomLeft(); - anAnchorPointMap[ BottomRight ] = aRect.bottomRight(); - - qreal ar = ANCHOR_RADIUS; - QMapIterator anIter( anAnchorPointMap ); - while( anIter.hasNext() ) - { - int anAnchorType = anIter.next().key(); - const QPointF& anAnchorPoint = anIter.value(); - - QRectF anAnchorRect( anAnchorPoint - QPointF( ar, ar ), QSizeF( ar * 2, ar * 2 ) ); - myAnchorMap[ anAnchorType ]->setRect( anAnchorRect ); - myAnchorMap[ anAnchorType ]->setBasePoint( anAnchorPoint ); - - if( anAnchorType == TopMost ) - myAnchorMap[ anAnchorType ]->setOffset( QPointF( 0, -6 * ANCHOR_RADIUS ) ); - } -} - -//================================================================ -// Function : updateVisibility -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::updateVisibility() -{ - setVisible( myPrsImage && myPrsImage->isSelected() ); -} - -//================================================================ -// Function : setScaling -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::setScaling( const double theScaleX, - const double theScaleY ) -{ - AnchorMapIterator anIter( myAnchorMap ); - while( anIter.hasNext() ) - if( UnscaledGraphicsEllipseItem* anAnchorItem = anIter.next().value() ) - anAnchorItem->setScaling( theScaleX, theScaleY ); -} - -//================================================================ -// Function : setRotationAngle -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::setRotationAngle( const double theRotationAngle ) -{ - AnchorMapIterator anIter( myAnchorMap ); - while( anIter.hasNext() ) - if( UnscaledGraphicsEllipseItem* anAnchorItem = anIter.next().value() ) - anAnchorItem->setRotationAngle( theRotationAngle ); -} - -//================================================================ -// Function : getResizeCursor -// Purpose : -//================================================================ -QCursor* GraphicsView_PrsImageFrame::getResizeCursor( const int theAnchor ) const -{ - if( !myPrsImage ) - return 0; - - double aScaleX, aScaleY, aRotationAngle; - myPrsImage->getScaling( aScaleX, aScaleY ); - myPrsImage->getRotationAngle( aRotationAngle ); - - int anAngle = (int)aRotationAngle; // -inf <= anAngle <= inf - anAngle = anAngle % 360; // -359 <= anAngle <= 359 - anAngle = ( anAngle + 360 ) % 360; // 0 <= anAngle <= 359 - - int aSign = aScaleX * aScaleY < 0 ? -1 : 1; - - int aShift = 0; - switch( theAnchor ) - { - case Top: aShift = 0; break; - case TopRight: aShift = 45; break; - case Right: aShift = 90; break; - case BottomRight: aShift = 135; break; - case Bottom: aShift = 180; break; - case BottomLeft: aShift = 225; break; - case Left: aShift = 270; break; - case TopLeft: aShift = 315; break; - } - anAngle += aSign * aShift; // -315 <= anAngle <= 674 - anAngle = ( anAngle + 360 ) % 360; // 0 <= anAngle <= 359 - - // 360 = 8 sectors of 45 degrees - if( anAngle <= 22 || anAngle >= 338 ) - return getVerCursor(); - if( anAngle >= 23 && anAngle <= 67 ) - return getBDiagCursor(); - if( anAngle >= 68 && anAngle <= 112 ) - return getHorCursor(); - if( anAngle >= 113 && anAngle <= 157 ) - return getFDiagCursor(); - if( anAngle >= 158 && anAngle <= 202 ) - return getVerCursor(); - if( anAngle >= 203 && anAngle <= 247 ) - return getBDiagCursor(); - if( anAngle >= 248 && anAngle <= 292 ) - return getHorCursor(); - if( anAngle >= 293 && anAngle <= 337 ) - return getFDiagCursor(); - return 0; -} - -//======================================================================= -// name : GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem -// Purpose : Constructor -//======================================================================= -GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::UnscaledGraphicsEllipseItem( QGraphicsItem* theParent ) -: QGraphicsEllipseItem( theParent ), - myScaleX( 1.0 ), - myScaleY( 1.0 ), - myRotationAngle( 0.0 ) -{ -} - -//======================================================================= -// name : GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem -// Purpose : Destructor -//======================================================================= -GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::~UnscaledGraphicsEllipseItem() -{ -} - -//================================================================ -// Function : boundingRect -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem:: - setScaling( const double theScaleX, const double theScaleY ) -{ - myScaleX = theScaleX; - myScaleY = theScaleY; -} - -//================================================================ -// Function : boundingRect -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem:: - setRotationAngle( const double theRotationAngle ) -{ - myRotationAngle = theRotationAngle; -} - -//================================================================ -// Function : highlightRect -// Purpose : -//================================================================ -QRectF GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::highlightRect() const -{ - QRectF aRect = QGraphicsEllipseItem::boundingRect(); - - GraphicsView_Object* aParent = dynamic_cast( parentItem() ); - if( !aParent ) - return aRect; - - QTransform aTransform = aParent->getViewTransform(); - double aScale = aTransform.m11(); // same as m22(), viewer specific - if( fabs( aScale ) < EPSILON || - fabs( myScaleX ) < EPSILON || - fabs( myScaleY ) < EPSILON ) - return aRect; - - QPointF aCenter = aRect.center(); - double aWidth = aRect.width() / aScale / myScaleX; - double aHeight = aRect.height() / aScale / myScaleY; - - double anOffsetX = myOffset.x() / aScale / fabs( myScaleX ); - double anOffsetY = myOffset.y() / aScale / fabs( myScaleY ); - - aRect = QRectF( aCenter.x() - aWidth / 2 + anOffsetX, - aCenter.y() - aHeight / 2 + anOffsetY, - aWidth, aHeight ); - return aRect; -} - -//================================================================ -// Function : sceneHighlightRect -// Purpose : -//================================================================ -QRectF GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::sceneHighlightRect() const -{ - if( QGraphicsItem* aParentItem = parentItem() ) - return aParentItem->sceneTransform().mapRect( highlightRect() ); - return sceneBoundingRect(); -} - -//================================================================ -// Function : boundingRect -// Purpose : -//================================================================ -QRectF GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::boundingRect() const -{ - QRectF aHighlightRect = highlightRect(); - QRectF aBaseRect( myBasePoint, QSizeF( 1, 1 ) ); - return aHighlightRect | aBaseRect; -} - -//================================================================ -// Function : GenerateTranslationOnlyTransform -// Purpose : -//================================================================ -static QTransform GenerateTranslationOnlyTransform( const QTransform &theOriginalTransform, - const QPointF &theTargetPoint ) -{ - qreal dx = theOriginalTransform.m11() * theTargetPoint.x() - theTargetPoint.x() + - theOriginalTransform.m21() * theTargetPoint.y() + - theOriginalTransform.m31(); - qreal dy = theOriginalTransform.m22() * theTargetPoint.y() - theTargetPoint.y() + - theOriginalTransform.m12() * theTargetPoint.x() + - theOriginalTransform.m32(); - return QTransform::fromTranslate( dx, dy ); -} - -//================================================================ -// Function : paint -// Purpose : -//================================================================ -void GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::paint( - QPainter* thePainter, - const QStyleOptionGraphicsItem* theOption, - QWidget* theWidget ) -{ - // draw a connection line (mainly, for top-most anchor) - thePainter->drawLine( myBasePoint, highlightRect().center() ); - - thePainter->save(); - thePainter->setTransform( GenerateTranslationOnlyTransform( thePainter->transform(), - myBasePoint ) ); - - double anOffsetX = myOffset.x(); - double anOffsetY = myOffset.y(); - if( myScaleX < 0 ) - anOffsetX *= -1; - if( myScaleY < 0 ) - anOffsetY *= -1; - - double anAngle = myRotationAngle * PI / 180.; - double aDX = anOffsetX * cos( anAngle ) - anOffsetY * sin( anAngle ); - double aDY = anOffsetX * sin( anAngle ) + anOffsetY * cos( anAngle ); - thePainter->translate( aDX, aDY ); - - QGraphicsEllipseItem::paint( thePainter, theOption, theWidget ); - thePainter->restore(); - - // for debug - /* - thePainter->save(); - thePainter->setPen( QPen( Qt::magenta ) ); - thePainter->drawRect( boundingRect() ); - thePainter->restore(); - - thePainter->save(); - thePainter->setPen( QPen( Qt::blue ) ); - thePainter->drawRect( highlightRect() ); - thePainter->restore(); - */ -} diff --git a/src/GraphicsView/GraphicsView_PrsImageFrame.h b/src/GraphicsView/GraphicsView_PrsImageFrame.h deleted file mode 100644 index a6aecd689..000000000 --- a/src/GraphicsView/GraphicsView_PrsImageFrame.h +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2007-2013 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. -// -// 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 -// - -#ifndef GRAPHICSVIEW_PRSIMAGEFRAME_H -#define GRAPHICSVIEW_PRSIMAGEFRAME_H - -#include "GraphicsView.h" - -#include "GraphicsView_Object.h" - -#include - -class GraphicsView_PrsImage; - -/* - Class : GraphicsView_PrsImageFrame - Description : Presentation for image frame object -*/ -class GRAPHICSVIEW_API GraphicsView_PrsImageFrame : public GraphicsView_Object -{ -public: - class UnscaledGraphicsEllipseItem; - - enum AnchorType { Undefined = 0, TopMost, Top, Bottom, Left, Right, - TopLeft, TopRight, BottomLeft, BottomRight }; - - typedef QMap AnchorMap; - typedef QMapIterator AnchorMapIterator; - -public: - GraphicsView_PrsImageFrame(); - virtual ~GraphicsView_PrsImageFrame(); - -public: - // from QGraphicsItem - virtual QRectF boundingRect() const; - - // from GraphicsView_Object - virtual void compute(); - - virtual bool hasSpecificZValue() const { return true; } - - virtual bool isMovable() const { return false; } - - virtual bool checkHighlight( double theX, double theY, QCursor& theCursor ) const; - - virtual QRectF getPullingRect() const; - virtual bool portContains( const QPointF& ) { return false; } // useless - virtual bool startPulling( const QPointF& ); - virtual void pull( const QPointF&, - GraphicsView_Object*, - const GraphicsView_ObjectList& ); - virtual void finishPulling( bool, const GraphicsView_ObjectList& ); - virtual bool isPulling() { return myIsPulling; } - -public: - void setPrsImage( GraphicsView_PrsImage* ); - - void computeAnchorItems(); - void updateVisibility(); - - void setScaling( const double theScaleX, const double theScaleY ); - void setRotationAngle( const double theRotationAngle ); - -protected: - QCursor* getVerCursor() const { return myVerCursor; } - QCursor* getHorCursor() const { return myHorCursor; } - QCursor* getBDiagCursor() const { return myBDiagCursor; } - QCursor* getFDiagCursor() const { return myFDiagCursor; } - QCursor* getRotateCursor() const { return myRotateCursor; } - - QCursor* getResizeCursor( const int theAnchor ) const; - -protected: - GraphicsView_PrsImage* myPrsImage; - - bool myIsPulling; - int myPullingAnchor; - QPointF myPullingPoint; - - AnchorMap myAnchorMap; - -private: - QCursor* myVerCursor; - QCursor* myHorCursor; - QCursor* myBDiagCursor; - QCursor* myFDiagCursor; - QCursor* myRotateCursor; -}; - -/* - Class : UnscaledGraphicsEllipseItem - Description : Class for unscaled ellipse item -*/ -class GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem : public QGraphicsEllipseItem -{ -public: - UnscaledGraphicsEllipseItem( QGraphicsItem* ); - virtual ~UnscaledGraphicsEllipseItem(); - -public: - void setBasePoint( const QPointF& thePoint ) { myBasePoint = thePoint; } - const QPointF& getBasePoint() const { return myBasePoint; } - - void setOffset( const QPointF& theOffset ) { myOffset = theOffset; } - const QPointF& getOffset() const { return myOffset; } - - void setScaling( const double theScaleX, const double theScaleY ); - void setRotationAngle( const double theRotationAngle ); - - QRectF highlightRect() const; - QRectF sceneHighlightRect() const; - -public: - virtual QRectF boundingRect() const; - virtual void paint( QPainter*, const QStyleOptionGraphicsItem*, QWidget* ); - -private: - QPointF myBasePoint; - QPointF myOffset; - - double myScaleX; - double myScaleY; - double myRotationAngle; -}; - -#endif diff --git a/src/GraphicsView/GraphicsView_PrsPropDlg.cxx b/src/GraphicsView/GraphicsView_PrsPropDlg.cxx deleted file mode 100644 index dd925c7e6..000000000 --- a/src/GraphicsView/GraphicsView_PrsPropDlg.cxx +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (C) 2007-2013 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. -// -// 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 "GraphicsView_PrsPropDlg.h" - -#include - -#include -#include -#include -#include - -//================================================================ -// Function : GraphicsView_PrsPropDlg -// Purpose : -//================================================================ -GraphicsView_PrsPropDlg::GraphicsView_PrsPropDlg( QWidget* theParent ) -: QtxDialog( theParent, true, true, QtxDialog::OKCancel ) -{ - setWindowTitle( tr( "PROPERTIES" ) ); - - QFrame* aMainFrame = mainFrame(); - - // Geometry - QGroupBox* aGeomGroup = new QGroupBox( tr( "GEOMETRY" ), aMainFrame ); - - QLabel* aPositionXLabel = new QLabel( tr( "POSITION_X" ), aGeomGroup ); - myPositionX = new QtxDoubleSpinBox( -1e6, 1e6, 1, aGeomGroup ); - - QLabel* aPositionYLabel = new QLabel( tr( "POSITION_Y" ), aGeomGroup ); - myPositionY = new QtxDoubleSpinBox( -1e6, 1e6, 1, aGeomGroup ); - - QLabel* aScalingXLabel = new QLabel( tr( "SCALING_X" ), aGeomGroup ); - myScalingX = new QtxDoubleSpinBox( -1e6, 1e6, 1, aGeomGroup ); - - QLabel* aScalingYLabel = new QLabel( tr( "SCALING_Y" ), aGeomGroup ); - myScalingY = new QtxDoubleSpinBox( -1e6, 1e6, 1, aGeomGroup ); - - QLabel* aRotationAngleLabel = new QLabel( tr( "ROTATION_ANGLE" ), aGeomGroup ); - myRotationAngle = new QtxDoubleSpinBox( -1e6, 1e6, 1, aGeomGroup ); - - QGridLayout* aGeomLayout = new QGridLayout( aGeomGroup ); - aGeomLayout->setMargin( 5 ); - aGeomLayout->setSpacing( 5 ); - aGeomLayout->addWidget( aPositionXLabel, 0, 0 ); - aGeomLayout->addWidget( myPositionX, 0, 1 ); - aGeomLayout->addWidget( aPositionYLabel, 1, 0 ); - aGeomLayout->addWidget( myPositionY, 1, 1 ); - aGeomLayout->addWidget( aScalingXLabel, 2, 0 ); - aGeomLayout->addWidget( myScalingX, 2, 1 ); - aGeomLayout->addWidget( aScalingYLabel, 3, 0 ); - aGeomLayout->addWidget( myScalingY, 3, 1 ); - aGeomLayout->addWidget( aRotationAngleLabel, 4, 0 ); - aGeomLayout->addWidget( myRotationAngle, 4, 1 ); - aGeomLayout->setColumnStretch( 1, 1 ); - - // Representation - QGroupBox* aReprGroup = new QGroupBox( tr( "REPRESENTATION" ), aMainFrame ); - - QLabel* aZValueLabel = new QLabel( tr( "Z_VALUE" ), aReprGroup ); - myZValue = new QtxDoubleSpinBox( -1e6, 1e6, 1, aReprGroup ); - - QLabel* anOpacityLabel = new QLabel( tr( "OPACITY" ), aReprGroup ); - myOpacity = new QtxDoubleSpinBox( 0, 1, 0.1, aReprGroup ); - - QGridLayout* aReprLayout = new QGridLayout( aReprGroup ); - aReprLayout->setMargin( 5 ); - aReprLayout->setSpacing( 5 ); - aReprLayout->addWidget( aZValueLabel, 0, 0 ); - aReprLayout->addWidget( myZValue, 0, 1 ); - aReprLayout->addWidget( anOpacityLabel, 1, 0 ); - aReprLayout->addWidget( myOpacity, 1, 1 ); - aReprLayout->setColumnStretch( 1, 1 ); - - // Interaction - QGroupBox* anInterGroup = new QGroupBox( tr( "INTERACTION" ), aMainFrame ); - - myIsLockAspectRatio = new QCheckBox( tr( "LOCK_ASPECT_RATIO" ), anInterGroup ); - myIsSmoothTransformation = new QCheckBox( tr( "SMOOTH_TRANSFORMATION" ), anInterGroup ); - - QGridLayout* anInterLayout = new QGridLayout( anInterGroup ); - anInterLayout->setMargin( 5 ); - anInterLayout->setSpacing( 5 ); - anInterLayout->addWidget( myIsLockAspectRatio, 0, 0 ); - anInterLayout->addWidget( myIsSmoothTransformation, 1, 0 ); - anInterLayout->setColumnStretch( 1, 1 ); - - QVBoxLayout* aMainLayout = new QVBoxLayout( aMainFrame ); - aMainLayout->setMargin( 5 ); - aMainLayout->setSpacing( 5 ); - aMainLayout->addWidget( aGeomGroup ); - aMainLayout->addWidget( aReprGroup ); - aMainLayout->addWidget( anInterGroup ); - - setButtonPosition( Center, OK ); - setButtonPosition( Center, Cancel ); - setMinimumWidth( 250 ); -} - -//================================================================ -// Function : ~GraphicsView_PrsPropDlg -// Purpose : -//================================================================ -GraphicsView_PrsPropDlg::~GraphicsView_PrsPropDlg() -{ -} - -//============================================================================= -// Function : setData -// Purpose : -//============================================================================= -void GraphicsView_PrsPropDlg::setData( const double thePositionX, - const double thePositionY, - const double theScalingX, - const double theScalingY, - const double theRotationAngle, - const double theZValue, - const double theOpacity, - const bool theIsLockAspectRatio, - const bool theIsSmoothTransformation ) -{ - myPositionX->setValue( thePositionX ); - myPositionY->setValue( thePositionY ); - myScalingX->setValue( theScalingX ); - myScalingY->setValue( theScalingY ); - myRotationAngle->setValue( theRotationAngle ); - myZValue->setValue( theZValue ); - myOpacity->setValue( theOpacity ); - myIsLockAspectRatio->setChecked( theIsLockAspectRatio ); - myIsSmoothTransformation->setChecked( theIsSmoothTransformation ); -} - -//============================================================================= -// Function : getData -// Purpose : -//============================================================================= -void GraphicsView_PrsPropDlg::getData( double& thePositionX, - double& thePositionY, - double& theScalingX, - double& theScalingY, - double& theRotationAngle, - double& theZValue, - double& theOpacity, - bool& theIsLockAspectRatio, - bool& theIsSmoothTransformation ) const -{ - thePositionX = myPositionX->value(); - thePositionY = myPositionY->value(); - theScalingX = myScalingX->value(); - theScalingY = myScalingY->value(); - theRotationAngle = myRotationAngle->value(); - theZValue = myZValue->value(); - theOpacity = myOpacity->value(); - theIsLockAspectRatio = myIsLockAspectRatio->isChecked(); - theIsSmoothTransformation = myIsSmoothTransformation->isChecked(); -} diff --git a/src/GraphicsView/GraphicsView_PrsPropDlg.h b/src/GraphicsView/GraphicsView_PrsPropDlg.h deleted file mode 100644 index f34723fbd..000000000 --- a/src/GraphicsView/GraphicsView_PrsPropDlg.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2007-2013 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. -// -// 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 -// - -#ifndef GRAPHICSVIEW_PRSPROPDLG_H -#define GRAPHICSVIEW_PRSPROPDLG_H - -#include "GraphicsView.h" - -#include - -class QCheckBox; - -class QtxDoubleSpinBox; - -/* - Class : GraphicsView_PrsPropDlg - Description : Dialog for managing presentation properties -*/ -class GRAPHICSVIEW_API GraphicsView_PrsPropDlg : public QtxDialog -{ - Q_OBJECT - -public: - GraphicsView_PrsPropDlg( QWidget* = 0 ); - virtual ~GraphicsView_PrsPropDlg(); - -public: - void setData( const double thePositionX, - const double thePositionY, - const double theScalingX, - const double theScalingY, - const double theRotationAngle, - const double theZValue, - const double theOpacity, - const bool theIsLockAspectRatio, - const bool theIsSmoothTransformation ); - - void getData( double& thePositionX, - double& thePositionY, - double& theScalingX, - double& theScalingY, - double& theRotationAngle, - double& theZValue, - double& theOpacity, - bool& theIsLockAspectRatio, - bool& theIsSmoothTransformation ) const; - -private: - QtxDoubleSpinBox* myPositionX; - QtxDoubleSpinBox* myPositionY; - QtxDoubleSpinBox* myScalingX; - QtxDoubleSpinBox* myScalingY; - QtxDoubleSpinBox* myRotationAngle; - - QtxDoubleSpinBox* myOpacity; - QtxDoubleSpinBox* myZValue; - - QCheckBox* myIsLockAspectRatio; - QCheckBox* myIsSmoothTransformation; -}; - -#endif diff --git a/src/GraphicsView/GraphicsView_ViewPort.cxx b/src/GraphicsView/GraphicsView_ViewPort.cxx index 3ce7a5199..7dc569701 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.cxx +++ b/src/GraphicsView/GraphicsView_ViewPort.cxx @@ -53,21 +53,20 @@ QCursor* GraphicsView_ViewPort::zoomCursor = 0; QCursor* GraphicsView_ViewPort::sketchCursor = 0; //======================================================================= -// Name : GraphicsView_ViewPort::NameLabel +// Name : GraphicsView_ViewPort::ViewLabel // Purpose : Wrapper for label, which can ignore move events sent from // QGraphicsView::scrollContentsBy() method, which, // in its turn, called from GraphicsView_ViewPort::pan() //======================================================================= -class GraphicsView_ViewPort::NameLabel : public QLabel +class GraphicsView_ViewPort::ViewLabel : public QLabel { public: - NameLabel( QWidget* theParent ) - : - QLabel( theParent ), - myAcceptMoveEvents( false ) + ViewLabel( QWidget* theParent ) + : QLabel( theParent ), + myAcceptMoveEvents( false ) { } - ~NameLabel() {} + ~ViewLabel() {} void setAcceptMoveEvents( bool theFlag ) { @@ -129,9 +128,10 @@ void GraphicsView_ViewPort::destroyCursors() GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent ) : QGraphicsView( theParent ), myInteractionFlags( 0 ), - myNameLabel( 0 ), - myNamePosition( NP_None ), - myNameLayout( 0 ), + myViewLabel( 0 ), + myViewLabelPosition( VLP_None ), + myViewLabelLayout( 0 ), + myIsMousePositionEnabled( false ), myForegroundItem( 0 ), myGridItem( 0 ), myIsTransforming( false ), @@ -164,8 +164,8 @@ GraphicsView_ViewPort::GraphicsView_ViewPort( QWidget* theParent ) //setInteractionFlag( TraceBoundingRect ); //setInteractionFlag( DraggingByMiddleButton ); //setInteractionFlag( ImmediateContextMenu ); - setInteractionFlag( ImmediateSelection ); // testing ImageViewer - setInteractionFlag( Sketching ); // testing ImageViewer + //setInteractionFlag( ImmediateSelection ); // testing ImageViewer + //setInteractionFlag( Sketching ); // testing ImageViewer // background setBackgroundBrush( QBrush( Qt::white ) ); @@ -500,56 +500,75 @@ void GraphicsView_ViewPort::setInteractionFlags( InteractionFlags theFlags ) } //================================================================ -// Function : setViewNameEnabled +// Function : setViewLabelPosition // Purpose : //================================================================ -void GraphicsView_ViewPort::setViewNamePosition( NamePosition thePosition, - bool theIsForced ) +void GraphicsView_ViewPort::setViewLabelPosition( ViewLabelPosition thePosition, + bool theIsForced ) { - if( theIsForced && !myNameLabel ) - myNameLabel = new NameLabel( viewport() ); + if( theIsForced && !myViewLabel ) + myViewLabel = new ViewLabel( viewport() ); - if( !myNameLabel ) + if( !myViewLabel ) return; - if( thePosition == NP_None ) + if( thePosition == VLP_None ) { - myNameLabel->setVisible( false ); + myViewLabel->setVisible( false ); return; } - if( myNameLayout ) - delete myNameLayout; + if( myViewLabelLayout ) + delete myViewLabelLayout; - myNameLayout = new QGridLayout( viewport() ); - myNameLayout->setMargin( 10 ); - myNameLayout->setSpacing( 0 ); + myViewLabelLayout = new QGridLayout( viewport() ); + myViewLabelLayout->setMargin( 10 ); + myViewLabelLayout->setSpacing( 0 ); int aRow = 0, aColumn = 0; switch( thePosition ) { - case NP_TopLeft: aRow = 0; aColumn = 0; break; - case NP_TopRight: aRow = 0; aColumn = 1; break; - case NP_BottomLeft: aRow = 1; aColumn = 0; break; - case NP_BottomRight: aRow = 1; aColumn = 1; break; + case VLP_TopLeft: aRow = 0; aColumn = 0; break; + case VLP_TopRight: aRow = 0; aColumn = 1; break; + case VLP_BottomLeft: aRow = 1; aColumn = 0; break; + case VLP_BottomRight: aRow = 1; aColumn = 1; break; default: break; } - myNameLayout->addWidget( myNameLabel, aRow, aColumn ); - myNameLayout->setRowStretch( 1 - aRow, 1 ); - myNameLayout->setColumnStretch( 1 - aColumn, 1 ); + myViewLabelLayout->addWidget( myViewLabel, aRow, aColumn ); + myViewLabelLayout->setRowStretch( 1 - aRow, 1 ); + myViewLabelLayout->setColumnStretch( 1 - aColumn, 1 ); - myNameLabel->setVisible( true ); + myViewLabel->setVisible( true ); } //================================================================ -// Function : setViewName +// Function : setViewLabelText // Purpose : //================================================================ -void GraphicsView_ViewPort::setViewName( const QString& theName ) +void GraphicsView_ViewPort::setViewLabelText( const QString& theText ) { - if( myNameLabel ) - myNameLabel->setText( theName ); + if( myViewLabel ) + myViewLabel->setText( theText ); +} + +//================================================================ +// Function : setMousePositionEnabled +// Purpose : +//================================================================ +void GraphicsView_ViewPort::setMousePositionEnabled( bool theState ) +{ + myIsMousePositionEnabled = theState; + + if( theState ) + { + setViewLabelPosition( VLP_BottomLeft, true ); + + int aMouseX = 0, aMouseY = 0; + setViewLabelText( QString( "(%1, %2)" ).arg( aMouseX ).arg( aMouseY ) ); + } + else + setViewLabelPosition( VLP_None ); } //================================================================ @@ -765,16 +784,16 @@ void GraphicsView_ViewPort::pan( double theDX, double theDY ) { myIsTransforming = true; - if( myNameLabel ) - myNameLabel->setAcceptMoveEvents( false ); + if( myViewLabel ) + myViewLabel->setAcceptMoveEvents( false ); if( QScrollBar* aHBar = horizontalScrollBar() ) aHBar->setValue( aHBar->value() - theDX ); if( QScrollBar* aVBar = verticalScrollBar() ) aVBar->setValue( aVBar->value() + theDY ); - if( myNameLabel ) - myNameLabel->setAcceptMoveEvents( true ); + if( myViewLabel ) + myViewLabel->setAcceptMoveEvents( true ); myIsTransforming = false; @@ -1702,6 +1721,13 @@ void GraphicsView_ViewPort::onMouseEvent( QGraphicsSceneMouseEvent* e ) default: break; } + + if( myIsMousePositionEnabled ) + { + int aMouseX = (int)e->scenePos().x(); + int aMouseY = (int)e->scenePos().y(); + setViewLabelText( QString( "(%1, %2)" ).arg( aMouseX ).arg( aMouseY ) ); + } } //================================================================ @@ -1728,11 +1754,11 @@ void GraphicsView_ViewPort::onContextMenuEvent( QGraphicsSceneContextMenuEvent* //================================================================ void GraphicsView_ViewPort::scrollContentsBy( int theDX, int theDY ) { - if( myNameLabel ) - myNameLabel->setAcceptMoveEvents( false ); + if( myViewLabel ) + myViewLabel->setAcceptMoveEvents( false ); QGraphicsView::scrollContentsBy( theDX, theDY ); - if( myNameLabel ) - myNameLabel->setAcceptMoveEvents( true ); + if( myViewLabel ) + myViewLabel->setAcceptMoveEvents( true ); } diff --git a/src/GraphicsView/GraphicsView_ViewPort.h b/src/GraphicsView/GraphicsView_ViewPort.h index 897111b90..1066373a4 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.h +++ b/src/GraphicsView/GraphicsView_ViewPort.h @@ -44,7 +44,7 @@ class GRAPHICSVIEW_API GraphicsView_ViewPort : public QGraphicsView Q_OBJECT public: - class NameLabel; + class ViewLabel; enum InteractionFlag { @@ -69,13 +69,13 @@ public: BS_Dragging = 0x0002 // currently unused }; - enum NamePosition + enum ViewLabelPosition { - NP_None = 0, - NP_TopLeft = 1, - NP_TopRight = 2, - NP_BottomLeft = 3, - NP_BottomRight = 4 + VLP_None = 0, + VLP_TopLeft = 1, + VLP_TopRight = 2, + VLP_BottomLeft = 3, + VLP_BottomRight = 4 }; public: @@ -107,10 +107,13 @@ public: bool theIsEnabled = true ); void setInteractionFlags( InteractionFlags theFlags ); - // view name - void setViewNamePosition( NamePosition thePosition, - bool theIsForced = false ); - void setViewName( const QString& theName ); + // view label + void setViewLabelPosition( ViewLabelPosition thePosition, + bool theIsForced = false ); + void setViewLabelText( const QString& theText ); + + // displaying mouse position (currently, overlaps with view label feature) + void setMousePositionEnabled( bool theState ); // background / foreground QColor backgroundColor() const; @@ -265,10 +268,13 @@ private: // interaction flags InteractionFlags myInteractionFlags; - // view name - NameLabel* myNameLabel; - NamePosition myNamePosition; - QGridLayout* myNameLayout; + // view label + ViewLabel* myViewLabel; + ViewLabelPosition myViewLabelPosition; + QGridLayout* myViewLabelLayout; + + // displaying mouse position (currently, overlaps with view label feature) + bool myIsMousePositionEnabled; // foreground bool myIsForegroundEnabled; diff --git a/src/GraphicsView/GraphicsView_Viewer.cxx b/src/GraphicsView/GraphicsView_Viewer.cxx index 09eba4bb4..ddaa95713 100644 --- a/src/GraphicsView/GraphicsView_Viewer.cxx +++ b/src/GraphicsView/GraphicsView_Viewer.cxx @@ -41,9 +41,11 @@ #include // testing ImageViewer +/* #include "GraphicsView_PrsImage.h" #include "GraphicsView_PrsPropDlg.h" #include +*/ //======================================================================= // Name : GraphicsView_Viewer @@ -108,6 +110,7 @@ void GraphicsView_Viewer::contextMenuPopup( QMenu* thePopup ) thePopup->addSeparator(); // testing ImageViewer + /* if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() ) { int aNbSelected = aViewPort->nbSelected(); @@ -137,6 +140,7 @@ void GraphicsView_Viewer::contextMenuPopup( QMenu* thePopup ) } thePopup->addSeparator(); } + */ thePopup->addAction( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) ); } @@ -545,7 +549,7 @@ void GraphicsView_Viewer::handleWheel( QGraphicsSceneWheelEvent* e ) void GraphicsView_Viewer::onSketchingFinished( QPainterPath thePath ) { // testing ImageViewer - onTestCropOperatorPerform( thePath ); + //onTestCropOperatorPerform( thePath ); } //================================================================ @@ -590,6 +594,7 @@ void GraphicsView_Viewer::onSelectionCancel() emit selectionChanged( GVSCS_Invalid ); } +/* //================================================================ // Function : onAddImage // Purpose : @@ -894,3 +899,4 @@ void GraphicsView_Viewer::onTestCropOperatorPerform( QPainterPath thePath ) aViewPort->removeItem( anObj ); } } +*/ diff --git a/src/GraphicsView/GraphicsView_Viewer.h b/src/GraphicsView/GraphicsView_Viewer.h index c3d272583..ff4c048c4 100644 --- a/src/GraphicsView/GraphicsView_Viewer.h +++ b/src/GraphicsView/GraphicsView_Viewer.h @@ -101,6 +101,7 @@ protected slots: virtual void onChangeBgColor(); // testing ImageViewer + /* void onAddImage(); void onRemoveImages(); void onBringToFront(); @@ -111,6 +112,7 @@ protected slots: void onTestFuseOperator(); void onTestCropOperatorPrepare(); void onTestCropOperatorPerform( QPainterPath thePath ); + */ private: void handleKeyPress( QKeyEvent* ); diff --git a/src/GraphicsView/resources/GraphicsView_msg_en.ts b/src/GraphicsView/resources/GraphicsView_msg_en.ts index 936a1b401..919919eba 100644 --- a/src/GraphicsView/resources/GraphicsView_msg_en.ts +++ b/src/GraphicsView/resources/GraphicsView_msg_en.ts @@ -121,59 +121,4 @@ Graphics scene:%M - viewer:%V - - GraphicsView_PrsPropDlg - - PROPERTIES - Properties - - - GEOMETRY - Geometry - - - POSITION_X - Position X - - - POSITION_Y - Position Y - - - SCALING_X - Scaling X - - - SCALING_Y - Scaling Y - - - ROTATION_ANGLE - Rotation angle - - - REPRESENTATION - Representation - - - Z_VALUE - Z value - - - OPACITY - Opacity - - - INTERACTION - Interaction - - - LOCK_ASPECT_RATIO - Lock aspect ratio - - - SMOOTH_TRANSFORMATION - Smooth transformation - - diff --git a/src/LightApp/LightApp_GVSelector.cxx b/src/LightApp/LightApp_GVSelector.cxx index 8be3a7d0e..a19aa1c57 100644 --- a/src/LightApp/LightApp_GVSelector.cxx +++ b/src/LightApp/LightApp_GVSelector.cxx @@ -22,36 +22,19 @@ #include "LightApp_GVSelector.h" +#include "LightApp_DataOwner.h" + #include -#include #include #include -LightApp_GVDataOwner::LightApp_GVDataOwner( GraphicsView_Object* theObject ) -: myObject( theObject ) -{ -} - -LightApp_GVDataOwner::~LightApp_GVDataOwner() -{ -} - -QString LightApp_GVDataOwner::keyString() const -{ - return myObject->getName(); -} - -GraphicsView_Object* LightApp_GVDataOwner::object() const -{ - return myObject; -} - LightApp_GVSelector::LightApp_GVSelector( GraphicsView_Viewer* theViewer, SUIT_SelectionMgr* theSelMgr ) -: SUIT_Selector( theSelMgr ), myViewer( theViewer ) +: SUIT_Selector( theSelMgr, theViewer ), + myViewer( theViewer ) { - connect( theViewer->getSelector(), SIGNAL( selSelectionDone( GV_SelectionChangeStatus ) ), - this, SLOT( OnSelectionDone( GV_SelectionChangeStatus ) ) ); + connect( theViewer, SIGNAL( selectionChanged( GV_SelectionChangeStatus ) ), + this, SLOT( onSelectionChanged( GV_SelectionChangeStatus ) ) ); } LightApp_GVSelector::~LightApp_GVSelector() @@ -65,16 +48,16 @@ QString LightApp_GVSelector::type() const void LightApp_GVSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const { - GraphicsView_ViewPort* aViewport = myViewer->getActiveViewPort(); - for( aViewport->initSelected(); aViewport->moreSelected(); aViewport->nextSelected() ) - theList.append( new LightApp_GVDataOwner( aViewport->selectedObject() ) ); + if( GraphicsView_ViewPort* aViewport = myViewer->getActiveViewPort() ) + for( aViewport->initSelected(); aViewport->moreSelected(); aViewport->nextSelected() ) + theList.append( new LightApp_DataOwner( aViewport->selectedObject()->getName() ) ); } -void LightApp_GVSelector::setSelection( const SUIT_DataOwnerPtrList& ) +void LightApp_GVSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) { } -void LightApp_GVSelector::OnSelectionDone( GV_SelectionChangeStatus ) +void LightApp_GVSelector::onSelectionChanged( GV_SelectionChangeStatus ) { selectionChanged(); } diff --git a/src/LightApp/LightApp_GVSelector.h b/src/LightApp/LightApp_GVSelector.h index e977d0a4f..f9dfffe13 100644 --- a/src/LightApp/LightApp_GVSelector.h +++ b/src/LightApp/LightApp_GVSelector.h @@ -30,22 +30,8 @@ #include #include -class GraphicsView_Object; class GraphicsView_Viewer; -class LIGHTAPP_EXPORT LightApp_GVDataOwner : public SUIT_DataOwner -{ -public: - LightApp_GVDataOwner( GraphicsView_Object* ); - virtual ~LightApp_GVDataOwner(); - - virtual QString keyString() const; - GraphicsView_Object* object() const; - -private: - GraphicsView_Object* myObject; -}; - class LIGHTAPP_EXPORT LightApp_GVSelector : public QObject, public SUIT_Selector { Q_OBJECT @@ -61,9 +47,9 @@ protected: virtual void setSelection( const SUIT_DataOwnerPtrList& ); protected slots: - void OnSelectionDone( GV_SelectionChangeStatus ); + void onSelectionChanged( GV_SelectionChangeStatus ); -private: +protected: GraphicsView_Viewer* myViewer; }; diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index bdc987b59..3b6a196af 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -1794,6 +1794,16 @@ QWidget* QtxWorkstack::activeWindow() const return myWin; } +/*! + \brief Set active widget + \param wid widget to activate +*/ +void QtxWorkstack::setActiveWindow( QWidget* wid ) +{ + if( activeArea() ) + activeArea()->setActiveWidget( wid ); +} + /*! \brief Split workstack. diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 9394fed1a..5028325dc 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -93,6 +93,7 @@ public: QWidgetList splitWindowList() const; QWidget* activeWindow() const; + void setActiveWindow( QWidget* ); int accel( const int ) const; void setAccel( const int, const int );