]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Drawing a connection line for the TopMost anchor.
authorouv <ouv@opencascade.com>
Fri, 5 Jul 2013 11:10:27 +0000 (11:10 +0000)
committerouv <ouv@opencascade.com>
Fri, 5 Jul 2013 11:10:27 +0000 (11:10 +0000)
src/GraphicsView/GraphicsView_PrsImageFrame.cxx
src/GraphicsView/GraphicsView_PrsImageFrame.h

index 2ffb80911a092aaca7386484faca4ac70e693beb..d550632f9e7e511d0589bdc7fed61904c0ab9cc5 100644 (file)
@@ -153,9 +153,9 @@ bool GraphicsView_PrsImageFrame::checkHighlight( double theX, double theY, QCurs
   while( anIter.hasNext() )
   {
     int aType = anIter.next().key();
-    if( QGraphicsEllipseItem* anAnchorItem = anIter.value() )
+    if( UnscaledGraphicsEllipseItem* anAnchorItem = anIter.value() )
     {
-      QRectF aRect = anAnchorItem->sceneBoundingRect();
+      QRectF aRect = anAnchorItem->sceneHighlightRect();
       if( aRect.contains( QPointF( theX, theY ) ) )
       {
         if( aType >= Top && aType <= BottomRight )
@@ -196,7 +196,7 @@ bool GraphicsView_PrsImageFrame::startPulling( const QPointF& thePoint )
     int aType = anIter.next().key();
     if( UnscaledGraphicsEllipseItem* anAnchorItem = anIter.value() )
     {
-      QRectF aRect = anAnchorItem->sceneBoundingRect();
+      QRectF aRect = anAnchorItem->sceneHighlightRect();
       if( aRect.contains( thePoint ) )
       {
         myPullingAnchor = aType;
@@ -479,10 +479,10 @@ void GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::
 }
 
 //================================================================
-// Function : boundingRect
+// Function : highlightRect
 // Purpose  : 
 //================================================================
-QRectF GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::boundingRect() const
+QRectF GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::highlightRect() const
 {
   QRectF aRect = QGraphicsEllipseItem::boundingRect();
 
@@ -507,12 +507,29 @@ QRectF GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::boundingRect() c
   aRect = QRectF( aCenter.x() - aWidth / 2 + anOffsetX,
                   aCenter.y() - aHeight / 2 + anOffsetY,
                   aWidth, aHeight );
+  return aRect;
+}
 
-  // to do
-  //QRectF aBaseRect( myBasePoint, QSizeF( 1, 1 ) );
-  //aRect |= aBaseRect;
+//================================================================
+// Function : sceneHighlightRect
+// Purpose  : 
+//================================================================
+QRectF GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::sceneHighlightRect() const
+{
+  if( QGraphicsItem* aParentItem = parentItem() )
+    return aParentItem->sceneTransform().mapRect( highlightRect() );
+  return sceneBoundingRect();
+}
 
-  return aRect;
+//================================================================
+// Function : boundingRect
+// Purpose  : 
+//================================================================
+QRectF GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::boundingRect() const
+{
+  QRectF aHighlightRect = highlightRect();
+  QRectF aBaseRect( myBasePoint, QSizeF( 1, 1 ) );
+  return aHighlightRect | aBaseRect;
 }
 
 //================================================================
@@ -541,7 +558,7 @@ void GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::paint(
   QWidget* theWidget )
 {
   // draw a connection line (mainly, for top-most anchor)
-  //thePainter->drawLine( myBasePoint, boundingRect().center() );
+  thePainter->drawLine( myBasePoint, highlightRect().center() );
 
   thePainter->save();
   thePainter->setTransform( GenerateTranslationOnlyTransform( thePainter->transform(),
@@ -563,8 +580,15 @@ void GraphicsView_PrsImageFrame::UnscaledGraphicsEllipseItem::paint(
   thePainter->restore();
 
   // for debug
-  //thePainter->save();
-  //thePainter->setPen( QPen( Qt::magenta ) );
-  //thePainter->drawRect( boundingRect() );
-  //thePainter->restore();
+  /*
+  thePainter->save();
+  thePainter->setPen( QPen( Qt::magenta ) );
+  thePainter->drawRect( boundingRect() );
+  thePainter->restore();
+
+  thePainter->save();
+  thePainter->setPen( QPen( Qt::blue ) );
+  thePainter->drawRect( highlightRect() );
+  thePainter->restore();
+  */
 }
index e5d42ec720eb4ca29b01ed996caa308662ccc16c..a6aecd689b37835403d8a05d59075987936f952a 100644 (file)
@@ -127,6 +127,9 @@ public:
   void           setScaling( const double theScaleX, const double theScaleY );
   void           setRotationAngle( const double theRotationAngle );
 
+  QRectF         highlightRect() const;
+  QRectF         sceneHighlightRect() const;
+
 public:
   virtual QRectF boundingRect() const;
   virtual void   paint( QPainter*, const QStyleOptionGraphicsItem*, QWidget* );