2) Moving Presentation classes from GraphicsView to HYDROGUI.
3) Raw development.
)
SET(GUI_HEADERS
- GraphicsView_PrsPropDlg.h
GraphicsView_Scene.h
GraphicsView_Selector.h
GraphicsView_ViewFrame.h
GraphicsView_ViewManager.cxx
GraphicsView_ViewPort.cxx
GraphicsView_ViewTransformer.cxx
- GraphicsView_PrsImage.cxx
- GraphicsView_PrsImageFrame.cxx
- GraphicsView_PrsPropDlg.cxx
)
SET(GUITS_SOURCES
myIsSelected( false ),
myIsMoving( false )
{
- myHighlightCursor = new QCursor( Qt::OpenHandCursor );
}
//=======================================================================
//=======================================================================
GraphicsView_Object::~GraphicsView_Object()
{
- if( myHighlightCursor )
- {
- delete myHighlightCursor;
- myHighlightCursor = 0;
- }
-
QListIterator<QGraphicsItem*> aChildIter( children() );
while( aChildIter.hasNext() )
{
virtual QTransform getViewTransform() const { return myViewTransform; }
virtual void setViewTransform( const QTransform& theTransform );
-protected:
- QCursor* getHighlightCursor() const { return myHighlightCursor; }
-
protected:
QString myName;
bool myIsMoving;
QTransform myViewTransform;
-
-private:
- QCursor* myHighlightCursor;
};
#endif
+++ /dev/null
-// 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 <QCursor>
-#include <QGraphicsView>
-#include <QPainter>
-#include <QVector2D>
-
-#include <math.h>
-
-#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<GraphicsView_PrsImage*>( 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;
-}
+++ /dev/null
-// 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
+++ /dev/null
-// 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 <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
-
-#include <QCursor>
-#include <QPainter>
-
-#include <math.h>
-
-#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<GraphicsView_PrsImage*>( 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<GraphicsView_PrsImage*>( 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<int, QPointF> 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<int, QPointF> 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<GraphicsView_Object*>( 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();
- */
-}
+++ /dev/null
-// 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 <QGraphicsEllipseItem>
-
-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 <int, UnscaledGraphicsEllipseItem*> AnchorMap;
- typedef QMapIterator<int, UnscaledGraphicsEllipseItem*> 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
+++ /dev/null
-// 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 <QtxDoubleSpinBox.h>
-
-#include <QCheckBox>
-#include <QGroupBox>
-#include <QLabel>
-#include <QLayout>
-
-//================================================================
-// 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();
-}
+++ /dev/null
-// 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 <QtxDialog.h>
-
-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
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 )
{
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 ),
//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 ) );
}
//================================================================
-// 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 );
}
//================================================================
{
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;
default:
break;
}
+
+ if( myIsMousePositionEnabled )
+ {
+ int aMouseX = (int)e->scenePos().x();
+ int aMouseY = (int)e->scenePos().y();
+ setViewLabelText( QString( "(%1, %2)" ).arg( aMouseX ).arg( aMouseY ) );
+ }
}
//================================================================
//================================================================
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 );
}
Q_OBJECT
public:
- class NameLabel;
+ class ViewLabel;
enum InteractionFlag
{
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:
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;
// 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;
#include <QMenu>
// testing ImageViewer
+/*
#include "GraphicsView_PrsImage.h"
#include "GraphicsView_PrsPropDlg.h"
#include <QFileDialog>
+*/
//=======================================================================
// Name : GraphicsView_Viewer
thePopup->addSeparator();
// testing ImageViewer
+ /*
if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() )
{
int aNbSelected = aViewPort->nbSelected();
}
thePopup->addSeparator();
}
+ */
thePopup->addAction( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) );
}
void GraphicsView_Viewer::onSketchingFinished( QPainterPath thePath )
{
// testing ImageViewer
- onTestCropOperatorPerform( thePath );
+ //onTestCropOperatorPerform( thePath );
}
//================================================================
emit selectionChanged( GVSCS_Invalid );
}
+/*
//================================================================
// Function : onAddImage
// Purpose :
aViewPort->removeItem( anObj );
}
}
+*/
virtual void onChangeBgColor();
// testing ImageViewer
+ /*
void onAddImage();
void onRemoveImages();
void onBringToFront();
void onTestFuseOperator();
void onTestCropOperatorPrepare();
void onTestCropOperatorPerform( QPainterPath thePath );
+ */
private:
void handleKeyPress( QKeyEvent* );
<translation>Graphics scene:%M - viewer:%V</translation>
</message>
</context>
- <context>
- <name>GraphicsView_PrsPropDlg</name>
- <message>
- <source>PROPERTIES</source>
- <translation>Properties</translation>
- </message>
- <message>
- <source>GEOMETRY</source>
- <translation>Geometry</translation>
- </message>
- <message>
- <source>POSITION_X</source>
- <translation>Position X</translation>
- </message>
- <message>
- <source>POSITION_Y</source>
- <translation>Position Y</translation>
- </message>
- <message>
- <source>SCALING_X</source>
- <translation>Scaling X</translation>
- </message>
- <message>
- <source>SCALING_Y</source>
- <translation>Scaling Y</translation>
- </message>
- <message>
- <source>ROTATION_ANGLE</source>
- <translation>Rotation angle</translation>
- </message>
- <message>
- <source>REPRESENTATION</source>
- <translation>Representation</translation>
- </message>
- <message>
- <source>Z_VALUE</source>
- <translation>Z value</translation>
- </message>
- <message>
- <source>OPACITY</source>
- <translation>Opacity</translation>
- </message>
- <message>
- <source>INTERACTION</source>
- <translation>Interaction</translation>
- </message>
- <message>
- <source>LOCK_ASPECT_RATIO</source>
- <translation>Lock aspect ratio</translation>
- </message>
- <message>
- <source>SMOOTH_TRANSFORMATION</source>
- <translation>Smooth transformation</translation>
- </message>
- </context>
</TS>
#include "LightApp_GVSelector.h"
+#include "LightApp_DataOwner.h"
+
#include <GraphicsView_Object.h>
-#include <GraphicsView_Selector.h>
#include <GraphicsView_ViewPort.h>
#include <GraphicsView_Viewer.h>
-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()
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();
}
#include <SUIT_DataOwner.h>
#include <GraphicsView_Defs.h>
-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
virtual void setSelection( const SUIT_DataOwnerPtrList& );
protected slots:
- void OnSelectionDone( GV_SelectionChangeStatus );
+ void onSelectionChanged( GV_SelectionChangeStatus );
-private:
+protected:
GraphicsView_Viewer* myViewer;
};
return myWin;
}
+/*!
+ \brief Set active widget
+ \param wid widget to activate
+*/
+void QtxWorkstack::setActiveWindow( QWidget* wid )
+{
+ if( activeArea() )
+ activeArea()->setActiveWidget( wid );
+}
+
/*!
\brief Split workstack.
QWidgetList splitWindowList() const;
QWidget* activeWindow() const;
+ void setActiveWindow( QWidget* );
int accel( const int ) const;
void setAccel( const int, const int );