Salome HOME
HYDRO Feature 1: Import images (T 1.3)
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_PrsImage.cxx
index 4c749d571e9cb3645bfb4564cda42d0be0784e51..90e54cf68acdb979535f67e67adc7d1b66cfd9b4 100644 (file)
@@ -37,7 +37,7 @@ HYDROGUI_PrsImage::HYDROGUI_PrsImage( const Handle(HYDROData_Object)& theObject
   myPixmapItem( 0 ),
   myPrsImageFrame( 0 ),
   myIsTransformationPointPreview( false ),
-  myTransformationPointMode( None )
+  myTransformationPointType( None )
 {
   myTransformationPointCursor = new QCursor( Qt::CrossCursor );
 }
@@ -92,13 +92,13 @@ bool HYDROGUI_PrsImage::getIsTransformationPointPreview() const
 }
 
 //================================================================
-// 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();
 }
 
@@ -113,6 +113,23 @@ void HYDROGUI_PrsImage::setTransformationPointMap( const TransformationPointMap&
     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  : 
@@ -174,7 +191,7 @@ bool HYDROGUI_PrsImage::checkHighlight( double theX, double theY, QCursor& theCu
   {
     if( myIsTransformationPointPreview )
     {
-      if( myTransformationPointMode != None )
+      if( myTransformationPointType != None )
         theCursor = *getTransformationPointCursor();
     }
     else
@@ -192,11 +209,13 @@ bool HYDROGUI_PrsImage::select( double theX, double theY, const QRectF& theRect
 {
   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;
   }