// 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 ),
- myTransformationPointMode( None )
+ myTransformationPointType( None )
{
- myHighlightCursor = new QCursor( Qt::PointingHandCursor );
myTransformationPointCursor = new QCursor( Qt::CrossCursor );
}
//=======================================================================
HYDROGUI_PrsImage::~HYDROGUI_PrsImage()
{
- if( myHighlightCursor )
- {
- delete myHighlightCursor;
- myHighlightCursor = 0;
- }
-
if( myTransformationPointCursor )
{
delete myTransformationPointCursor;
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 :
}
//================================================================
-// Function : setTransformationPointMode
+// Function : setTransformationPointType
// Purpose :
//================================================================
-void HYDROGUI_PrsImage::setTransformationPointMode( const int theMode )
+void HYDROGUI_PrsImage::setTransformationPointType( const int thePointType )
{
- myTransformationPointMode = theMode;
- if( theMode != None )
+ myTransformationPointType = thePointType;
+ if( thePointType != None )
computeTransformationPoints();
}
computeTransformationPoints();
}
+//================================================================
+// Function : updateTransformationPoint
+// Purpose :
+//================================================================
+void HYDROGUI_PrsImage::updateTransformationPoint( const int thePointType,
+ const bool theIsY,
+ const int theValue )
+{
+ if( myTransformationPointMap.find( thePointType ) != myTransformationPointMap.end() )
+ {
+ TransformationPoint& aTransformationPoint = myTransformationPointMap[ thePointType ];
+ QPoint& aPoint = aTransformationPoint.Point;
+ theIsY ? aPoint.setY( theValue ) : aPoint.setX( theValue );
+ computeTransformationPoints();
+ }
+}
+
//================================================================
// Function : boundingRect
// 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();
}
//================================================================
void HYDROGUI_PrsImage::addTo( GraphicsView_ViewPort* theViewPort )
{
- GraphicsView_Object::addTo( theViewPort );
+ HYDROGUI_Prs::addTo( theViewPort );
theViewPort->addItem( myPrsImageFrame );
-
- double aZValue = 0;
- GraphicsView_ObjectListIterator anIter( theViewPort->getObjects() );
- while( anIter.hasNext() )
- {
- if( HYDROGUI_PrsImage* aPrs = dynamic_cast<HYDROGUI_PrsImage*>( anIter.next() ) )
- {
- double aZValueRef = aPrs->zValue();
- aZValue = qMax( aZValue, aZValueRef );
- }
- }
- setZValue( aZValue + 1 );
}
//================================================================
//================================================================
void HYDROGUI_PrsImage::removeFrom( GraphicsView_ViewPort* theViewPort )
{
- GraphicsView_Object::removeFrom( theViewPort );
+ HYDROGUI_Prs::removeFrom( theViewPort );
theViewPort->removeItem( myPrsImageFrame );
}
{
if( myIsTransformationPointPreview )
{
- if( myTransformationPointMode != None )
+ if( myTransformationPointType != None )
theCursor = *getTransformationPointCursor();
}
else
{
if( myIsTransformationPointPreview )
{
- if( myTransformationPointMode == None || !theRect.isEmpty() )
+ if( myTransformationPointType == None || !theRect.isEmpty() )
return false;
- TransformationPoint& aTransformationPoint = myTransformationPointMap[ myTransformationPointMode ];
- aTransformationPoint.Point = QPoint( (int)theX, (int)theY );
+ QPoint aPos = pos().toPoint();
+
+ TransformationPoint& aTransformationPoint = myTransformationPointMap[ myTransformationPointType ];
+ aTransformationPoint.Point = QPoint( (int)theX, (int)theY ) - aPos;
computeTransformationPoints();
return true;
}
- bool anIsSelected = GraphicsView_Object::select( theX, theY, theRect );
+ bool anIsSelected = HYDROGUI_Prs::select( theX, theY, theRect );
myPrsImageFrame->updateVisibility();
return anIsSelected;
}
//================================================================
void HYDROGUI_PrsImage::unselect()
{
- GraphicsView_Object::unselect();
- myPrsImageFrame->updateVisibility();
+ HYDROGUI_Prs::unselect();
+ if( !myIsTransformationPointPreview )
+ myPrsImageFrame->updateVisibility();
}
//================================================================
//================================================================
void HYDROGUI_PrsImage::setSelected( bool theState )
{
- GraphicsView_Object::setSelected( theState );
- myPrsImageFrame->updateVisibility();
+ HYDROGUI_Prs::setSelected( theState );
+ if( !myIsTransformationPointPreview )
+ myPrsImageFrame->updateVisibility();
}
//================================================================