X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_PrsImage.cxx;h=172f5f72b41b7b4a2edb7eac4b3f10631d03cef4;hb=a1431f03eac1d1aed4203d0568d987c41ce939b3;hp=90e54cf68acdb979535f67e67adc7d1b66cfd9b4;hpb=859543b7cf29f1d56c1dc1aaf4811b22b7b0bf16;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx index 90e54cf6..172f5f72 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -32,9 +32,10 @@ // name : HYDROGUI_PrsImage // Purpose : Constructor //======================================================================= -HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Object)& theObject ) +HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Entity)& theObject ) : HYDROGUI_Prs( theObject ), myPixmapItem( 0 ), + myCaptionItem( 0 ), myPrsImageFrame( 0 ), myIsTransformationPointPreview( false ), myTransformationPointType( None ) @@ -73,6 +74,30 @@ QImage HYDROGUI_PrsImage::getImage() const return myImage; } +//================================================================ +// Function : setCaption +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setCaption( const QString& theCaption ) +{ + if( myCaptionItem ) + { + myCaptionItem->setText( theCaption ); + myCaptionItem->setVisible( !theCaption.isEmpty() ); + } +} + +//================================================================ +// Function : getCaption +// Purpose : +//================================================================ +QString HYDROGUI_PrsImage::getCaption() const +{ + if( myCaptionItem ) + return myCaptionItem->text(); + return QString(); +} + //================================================================ // Function : setIsTransformationPointPreview // Purpose : @@ -150,12 +175,27 @@ void HYDROGUI_PrsImage::compute() myPixmapItem = new QGraphicsPixmapItem( this ); addToGroup( myPixmapItem ); } + if( !myCaptionItem ) + { + myCaptionItem = new QGraphicsSimpleTextItem( this ); + + QFont aFont = myCaptionItem->font(); + aFont.setPointSize( 14 ); + myCaptionItem->setFont( aFont ); + + addToGroup( myCaptionItem ); + } if( !myPrsImageFrame ) { myPrsImageFrame = new HYDROGUI_PrsImageFrame( this ); addToGroup( myPrsImageFrame ); } + myPixmapItem->setPixmap( QPixmap::fromImage( myImage ) ); + + myCaptionItem->setPos( 0, -30 ); + myCaptionItem->setVisible( false ); + myPrsImageFrame->compute(); } @@ -258,6 +298,7 @@ void HYDROGUI_PrsImage::computeTransformationPoints() int aWidth = myImage.width(); int aHeight = myImage.height(); + // Create presentations for transformation points A, B and C for( int aPointType = PointA; aPointType <= PointC; aPointType++ ) { TransformationPoint aTransformationPoint; @@ -301,19 +342,54 @@ void HYDROGUI_PrsImage::computeTransformationPoints() } } - bool anIsVisible = myIsTransformationPointPreview; for( int aPointType = PointA; aPointType <= PointC; aPointType++ ) { - TransformationPoint& aTransformationPoint = myTransformationPointMap[ aPointType ]; + // Show/hide the point if necessary + updateTrsfPoint( aPointType ); + } +} - double aRadius = 5; - const QPointF& aPoint = aTransformationPoint.Point; - QRectF aRect( aPoint - QPointF( aRadius, aRadius ), QSizeF( aRadius * 2 + 1, aRadius * 2 + 1 ) ); - aTransformationPoint.PointItem->setRect( aRect ); - aTransformationPoint.PointItem->setVisible( anIsVisible ); +//================================================================ +// Function : updateTrsfPoint +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::updateTrsfPoint( const int thePointType ) +{ + // If image is transformed only by two points then the point C is invisible + bool anIsPointVisible = myIsTransformationPointPreview && ( + ( !myIsByTwoPoints ) || ( myIsByTwoPoints && ( thePointType != PointC ) ) ); + TransformationPoint& aTransformationPoint = myTransformationPointMap[ thePointType ]; + + double aRadius = 5; + const QPointF& aPoint = aTransformationPoint.Point; + QRectF aRect( aPoint - QPointF( aRadius, aRadius ), QSizeF( aRadius * 2 + 1, aRadius * 2 + 1 ) ); + aTransformationPoint.PointItem->setRect( aRect ); + aTransformationPoint.PointItem->setVisible( anIsPointVisible ); + + QPointF aCaptionShift( -aRadius * 2, aRadius * 2 ); + aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift ); + aTransformationPoint.CaptionItem->setVisible( anIsPointVisible ); +} - QPointF aCaptionShift( -aRadius * 2, aRadius * 2 ); - aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift ); - aTransformationPoint.CaptionItem->setVisible( anIsVisible ); +//================================================================ +// Function : getIsByTwoPoints +// Purpose : +//================================================================ +bool HYDROGUI_PrsImage::getIsByTwoPoints() const +{ + return myIsByTwoPoints; +} + +//================================================================ +// Function : setIsByTwoPoints +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::setIsByTwoPoints( const bool theIsByTwoPoints ) +{ + myIsByTwoPoints = theIsByTwoPoints; + if ( myTransformationPointMap.contains( PointC ) ) + { + // Show/hide the point C if necessary + updateTrsfPoint( PointC ); } }