// 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 )
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 :
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();
}
}
bool anIsVisible = myIsTransformationPointPreview;
+ bool anIsPointVisible;
for( int aPointType = PointA; aPointType <= PointC; aPointType++ )
{
+ // If image is transformed only by two points then the point C is invisible
+ anIsPointVisible = anIsVisible && (
+ ( !myIsByTwoPoints ) || ( myIsByTwoPoints && ( aPointType != PointC ) ) );
TransformationPoint& aTransformationPoint = myTransformationPointMap[ 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 );
+ aTransformationPoint.PointItem->setVisible( anIsPointVisible );
QPointF aCaptionShift( -aRadius * 2, aRadius * 2 );
aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift );
- aTransformationPoint.CaptionItem->setVisible( anIsVisible );
+ aTransformationPoint.CaptionItem->setVisible( anIsPointVisible );
+ }
+}
+
+//================================================================
+// Function : IsByTwoPoints
+// Purpose :
+//================================================================
+bool HYDROGUI_PrsImage::getIsByTwoPoints() const
+{
+ return myIsByTwoPoints;
+}
+
+//================================================================
+// Function : SetIsByTwoPoints
+// Purpose :
+//================================================================
+void HYDROGUI_PrsImage::setIsByTwoPoints( const bool theIsByTwoPoints )
+{
+ myIsByTwoPoints = theIsByTwoPoints;
+ if ( myTransformationPointMap.contains( PointC ) )
+ {
+ TransformationPoint& aTransformationPoint = myTransformationPointMap[ PointC ];
+ aTransformationPoint.PointItem->setVisible( myIsTransformationPointPreview && theIsByTwoPoints );
+ aTransformationPoint.CaptionItem->setVisible( myIsTransformationPointPreview && theIsByTwoPoints );
}
}