]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Refs #311: point A size is indepenedent on size of image
authornds <nds@opencascade.com>
Thu, 9 Jan 2014 09:54:11 +0000 (09:54 +0000)
committernds <nds@opencascade.com>
Thu, 9 Jan 2014 09:54:11 +0000 (09:54 +0000)
Done

src/HYDROGUI/HYDROGUI_PrsImage.cxx
src/HYDROGUI/HYDROGUI_PrsImage.h

index 34307fda02c8afb371f07f5a74f501470c39d6cf..fde013574161227fb50a732413aafa8f889ebd67 100644 (file)
@@ -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 );
 }
 
 //================================================================
index f51ab35e69638eb20e499ea6ac23af952c1f4545..f01115208cb747d1d7260f8c6a1c864553eff288 100644 (file)
@@ -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;