Salome HOME
Fix for the bug #42: point C is not activated, but point C is shown in preview in...
authorrkv <rkv@opencascade.com>
Wed, 13 Nov 2013 07:56:08 +0000 (07:56 +0000)
committerrkv <rkv@opencascade.com>
Wed, 13 Nov 2013 07:56:08 +0000 (07:56 +0000)
src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx
src/HYDROGUI/HYDROGUI_ImportImageDlg.h
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_ImportImageOp.h
src/HYDROGUI/HYDROGUI_PrsImage.cxx
src/HYDROGUI/HYDROGUI_PrsImage.h

index eaba5358b72a56eabf55dbec193f8e7d8e1c71ce..1d9510f41e2eec70e2ff8826f9e2817c4378e569 100644 (file)
@@ -288,6 +288,8 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
 
+  connect( myPointCEnabler, SIGNAL( toggled( bool ) ), SIGNAL( setIsByTwoPoints( bool ) ) );
+
   aTransformLayout->setColumnStretch( 1, 1 ); // double
   aTransformLayout->setColumnStretch( 3, 1 ); // degrees
   aTransformLayout->setColumnStretch( 5, 1 ); // minutes
index 8018366b7ddef7af8c12b4dbb9c57ac957f8eeee..59de8c6c6c89aebb9f4a79710099a1d41ab96bd1 100644 (file)
@@ -138,6 +138,7 @@ signals:
                                                 int theValue );
   void                       modeActivated( int );
   void                       refImageActivated( const QString& );
+  void                       setIsByTwoPoints( bool theIsByTwoPoints );
 
 private:
   QGroupBox*                   myFileNameGroup;    //!< The group for the source image file selection
index d3a82f89b9b147c73096e8a65dede7ee3bc5e361..82de7403539b8b971b7840dbdd4ed93afed7f3a5 100644 (file)
@@ -217,6 +217,7 @@ void HYDROGUI_ImportImageOp::setPresentationTrsfPoints( HYDROGUI_PrsImage* thePr
       if ( !theIsByTwoPoints )
         aPointMap[ HYDROGUI_PrsImage::PointC ].Point = theLocalPointC;
 
+      thePrs->setIsByTwoPoints( theIsByTwoPoints );
       thePrs->setTransformationPointMap( aPointMap );
     }
   }
@@ -262,19 +263,29 @@ void HYDROGUI_ImportImageOp::commitOperation()
 HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const
 {
   HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() );
-  connect( aPanel, SIGNAL( createPreview( QImage ) ),
-           this, SLOT( onCreatePreview( QImage ) ) );
-  connect( aPanel, SIGNAL( activatePointSelection( int ) ),
-           this, SLOT( onActivatePointSelection( int ) ) );
-  connect( aPanel, SIGNAL( pointCoordChanged( bool, int, bool, int ) ),
-           this, SLOT( onPointCoordChanged( bool, int, bool, int ) ) );
-  connect( aPanel, SIGNAL( modeActivated( int ) ),
-           this, SLOT( onModeActivated( int ) ) );
+  connect( aPanel, SIGNAL( createPreview( QImage ) ), SLOT( onCreatePreview( QImage ) ) );
+  connect( aPanel, SIGNAL( activatePointSelection( int ) ), SLOT( onActivatePointSelection( int ) ) );
+  connect( aPanel, SIGNAL( pointCoordChanged( bool, int, bool, int ) ), 
+                     SLOT( onPointCoordChanged( bool, int, bool, int ) ) );
+  connect( aPanel, SIGNAL( modeActivated( int ) ), SLOT( onModeActivated( int ) ) );
   connect( aPanel, SIGNAL( refImageActivated( const QString& ) ),
-           this, SLOT( onRefImageActivated( const QString& ) ) );
+                     SLOT( onRefImageActivated( const QString& ) ) );
+  connect( aPanel, SIGNAL( setIsByTwoPoints( bool ) ), SLOT( onSetIsByTwoPoints( bool ) ) );
   return aPanel;
 }
 
+void HYDROGUI_ImportImageOp::onSetIsByTwoPoints( bool theIsSetByTwoPoints )
+{
+  if ( myPreviewPrs )
+  {
+    myPreviewPrs->setIsByTwoPoints( theIsSetByTwoPoints );
+  }
+  if ( myRefPreviewPrs )
+  {
+    myRefPreviewPrs->setIsByTwoPoints( theIsSetByTwoPoints );
+  }
+}
+
 bool HYDROGUI_ImportImageOp::checkPoints( const QPointF& thePointA,
                                           const QPointF& thePointB,
                                           const QPointF& thePointC,
index e473373137ae9bc3ca10882a2981197555ee0866..ade485174bfb2a39eef581023540da042ee0a346 100644 (file)
@@ -57,6 +57,7 @@ protected slots:
   void                       onPointCoordChanged( bool, int, bool, int );
   void                       onModeActivated( int );
   void                       onRefImageActivated( const QString& );
+  void                       onSetIsByTwoPoints( bool theIsSetByTwoPoints );
 
   void                       onLastViewClosed( SUIT_ViewManager* );
 
index 9e7be1425bceb3b3ad0d459d8e889020f2e24f0a..250d4c859555c219b757dcf15fb2dc0a9fb3f511 100644 (file)
@@ -342,18 +342,46 @@ void HYDROGUI_PrsImage::computeTransformationPoints()
   }
 
   bool anIsVisible = myIsTransformationPointPreview;
+  bool anIsPointVisible;
   for( int aPointType = PointA; aPointType <= PointC; aPointType++ )
   {
+    // If image is transformed only by two points then the point C is invisible
+    anIsPointVisible = anIsVisible && ( 
+      ( !myIsByTwoPoints ) || ( myIsByTwoPoints && ( aPointType != PointC ) ) );
     TransformationPoint& aTransformationPoint = myTransformationPointMap[ aPointType ];
 
     double aRadius = 5;
     const QPointF& aPoint = aTransformationPoint.Point;
     QRectF aRect( aPoint - QPointF( aRadius, aRadius ), QSizeF( aRadius * 2 + 1, aRadius * 2 + 1 ) );
     aTransformationPoint.PointItem->setRect( aRect );
-    aTransformationPoint.PointItem->setVisible( anIsVisible );
+    aTransformationPoint.PointItem->setVisible( anIsPointVisible );
 
     QPointF aCaptionShift( -aRadius * 2, aRadius * 2 );
     aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift );
-    aTransformationPoint.CaptionItem->setVisible( anIsVisible );
+    aTransformationPoint.CaptionItem->setVisible( anIsPointVisible );
+  }
+}
+
+//================================================================
+// Function : IsByTwoPoints
+// Purpose  : 
+//================================================================
+bool HYDROGUI_PrsImage::getIsByTwoPoints() const
+{
+  return myIsByTwoPoints;
+}
+
+//================================================================
+// Function : SetIsByTwoPoints
+// Purpose  : 
+//================================================================
+void HYDROGUI_PrsImage::setIsByTwoPoints( const bool theIsByTwoPoints )
+{
+  myIsByTwoPoints = theIsByTwoPoints;
+  if ( myTransformationPointMap.contains( PointC ) )
+  {
+    TransformationPoint& aTransformationPoint = myTransformationPointMap[ PointC ];
+    aTransformationPoint.PointItem->setVisible( myIsTransformationPointPreview && theIsByTwoPoints );
+    aTransformationPoint.CaptionItem->setVisible( myIsTransformationPointPreview && theIsByTwoPoints );
   }
 }
index c5d57981ad8c57084b82adb4f98e829d99d06b15..0287839c8c60474f7b26d84884f18f1fa8b7aae9 100644 (file)
@@ -59,6 +59,9 @@ public:
   void                            setIsTransformationPointPreview( const bool theState );
   bool                            getIsTransformationPointPreview() const;
 
+  void                            setIsByTwoPoints( const bool theIsByTwoPoints );
+  bool                            getIsByTwoPoints() const;
+
   void                            setTransformationPointType( const int thePointType );
 
   void                            setTransformationPointMap( const TransformationPointMap& theMap );
@@ -100,6 +103,7 @@ protected:
   HYDROGUI_PrsImageFrame*         myPrsImageFrame;
 
   bool                            myIsTransformationPointPreview;
+  bool                            myIsByTwoPoints;
   int                             myTransformationPointType;
   TransformationPointMap          myTransformationPointMap;