From: nds Date: Thu, 9 Jan 2014 09:54:11 +0000 (+0000) Subject: Refs #311: point A size is indepenedent on size of image X-Git-Tag: BR_hydro_v_0_8~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d264a61b05e9124d2d7bd1d8b8c3f08df9311b2;p=modules%2Fhydro.git Refs #311: point A size is indepenedent on size of image Done --- diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx index 34307fda..fde01357 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -329,25 +329,29 @@ void HYDROGUI_PrsImage::computeTransformationPoints() aTransformationPoint.Point = aPoint; aTransformationPoint.Caption = aCaption; - aTransformationPoint.PointItem = new QGraphicsEllipseItem( this ); - aTransformationPoint.PointItem->setVisible( false ); - aTransformationPoint.PointItem->setPen( QPen( aColor ) ); - aTransformationPoint.PointItem->setBrush( QBrush( aColor ) ); + QGraphicsEllipseItem* aPointItem = new QGraphicsEllipseItem( this ); + aPointItem->setPen( QPen( aColor ) ); + aPointItem->setBrush( QBrush( aColor ) ); double aRadius = 3; QRectF aRect( -QPointF( aRadius, aRadius ), QSizeF( aRadius * 2 + 1, aRadius * 2 + 1 ) ); - aTransformationPoint.PointItem->setRect( aRect ); - aTransformationPoint.PointItem->setFlag( QGraphicsItem::ItemIgnoresTransformations ); - aTransformationPoint.PointItem->setPos( aPoint ); - - aTransformationPoint.CaptionItem = new QGraphicsSimpleTextItem( aCaption, this ); - aTransformationPoint.CaptionItem->setVisible( false ); - aTransformationPoint.CaptionItem->setPen( QPen( aColor ) ); - aTransformationPoint.CaptionItem->setBrush( QBrush( aColor ) ); - QFont aFont = aTransformationPoint.CaptionItem->font(); + aPointItem->setRect( aRect ); + aPointItem->setPos( QPointF( 0, 0 ) ); + + QGraphicsSimpleTextItem* aCaptionItem = aCaptionItem = new QGraphicsSimpleTextItem( aCaption, this ); + aCaptionItem->setPen( QPen( aColor ) ); + aCaptionItem->setBrush( QBrush( aColor ) ); + QFont aFont = aCaptionItem->font(); aFont.setPointSize( qApp->font().pointSize() ); - aTransformationPoint.CaptionItem->setFont( aFont ); - aTransformationPoint.CaptionItem->setFlag( QGraphicsItem::ItemIgnoresTransformations ); + aCaptionItem->setFont( aFont ); + aCaptionItem->setPos( QPointF( -aRadius * 2, aRadius * 2 ) ); + + aTransformationPoint.GroupItem = new QGraphicsItemGroup( this ); + aTransformationPoint.GroupItem->addToGroup( aPointItem ); + aTransformationPoint.GroupItem->addToGroup( aCaptionItem ); + aTransformationPoint.GroupItem->setVisible( false ); + aTransformationPoint.GroupItem->setFlag( QGraphicsItem::ItemIgnoresTransformations ); + aTransformationPoint.GroupItem->setPos( aPoint ); myTransformationPointMap[ aPointType ] = aTransformationPoint; } @@ -372,14 +376,9 @@ void HYDROGUI_PrsImage::updateTrsfPoint( const int thePointType ) TransformationPoint& aTransformationPoint = myTransformationPointMap[ thePointType ]; - double aRadius = 3; const QPointF& aPoint = aTransformationPoint.Point; - aTransformationPoint.PointItem->setPos( aPoint ); - aTransformationPoint.PointItem->setVisible( anIsPointVisible ); - - QPointF aCaptionShift( -aRadius * 2, aRadius * 2 ); - aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift ); - aTransformationPoint.CaptionItem->setVisible( anIsPointVisible ); + aTransformationPoint.GroupItem->setPos( aPoint ); + aTransformationPoint.GroupItem->setVisible( anIsPointVisible ); } //================================================================ diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.h b/src/HYDROGUI/HYDROGUI_PrsImage.h index f51ab35e..f0111520 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.h +++ b/src/HYDROGUI/HYDROGUI_PrsImage.h @@ -37,10 +37,9 @@ public: enum TransformationPointType { None = 0, PointA, PointB, PointC }; struct TransformationPoint { - QPoint Point; - QString Caption; - QGraphicsEllipseItem* PointItem; - QGraphicsSimpleTextItem* CaptionItem; + QPoint Point; + QString Caption; + QGraphicsItemGroup* GroupItem; }; typedef QMap < int, TransformationPoint > TransformationPointMap; typedef QMapIterator< int, TransformationPoint > TransformationPointMapIterator;