Salome HOME
Minor change.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageDlg.cxx
index f326790d17f0ed1de013aab808ba1fa03554bed3..7186d96e26ac3bac4fa238da812d353231de77cf 100644 (file)
@@ -26,6 +26,7 @@
 #include "HYDROGUI_Tool.h"
 
 #include <HYDROData_Lambert93.h>
+#include <HYDROData_Image.h>
 
 #include <SUIT_FileDlg.h>
 #include <SUIT_ResourceMgr.h>
@@ -102,9 +103,9 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   QRadioButton* aRefImageBtn = new QRadioButton( tr( "BY_REFERENCE_IMAGE" ), myTransformGroup );
 
   myModeGroup = new QButtonGroup( myTransformGroup );
-  myModeGroup->addButton( aManualCartesianBtn, ManualCartesian );
-  myModeGroup->addButton( aManualLambertBtn, ManualLambert );
-  myModeGroup->addButton( aRefImageBtn, RefImage );
+  myModeGroup->addButton( aManualCartesianBtn, HYDROData_Image::ManualCartesian );
+  myModeGroup->addButton( aManualLambertBtn, HYDROData_Image::ManualLambert );
+  myModeGroup->addButton( aRefImageBtn, HYDROData_Image::ReferenceImage );
 
   myRefImage = new QComboBox( myTransformGroup );
 
@@ -302,7 +303,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co
   connect( myRefImage, SIGNAL( activated( const QString& ) ),
            this, SLOT( onRefImageActivated( const QString& ) ) );
 
-  setTransformationMode( ManualLambert );
+  setTransformationMode( HYDROData_Image::ManualLambert );
 
   setMinimumWidth( 350 );
 }
@@ -351,7 +352,7 @@ void HYDROGUI_ImportImageDlg::reset()
   myTransformGroup->setEnabled( false );
   myRefImage->clear();
 
-  setTransformationMode( ManualLambert );
+  setTransformationMode( HYDROData_Image::ManualLambert );
 
   myPrsPointDataList.clear();
 
@@ -368,6 +369,16 @@ QString HYDROGUI_ImportImageDlg::getImageName() const
   return myImageName->text();
 }
 
+void HYDROGUI_ImportImageDlg::setRefImageName( const QString& theName )
+{
+  myRefImage->setCurrentIndex( myRefImage->findText( theName ) );
+}
+
+QString HYDROGUI_ImportImageDlg::getRefImageName() const
+{
+  return myRefImage->currentText();
+}
+
 QString HYDROGUI_ImportImageDlg::getFileName() const
 {
   return myFileName->text();
@@ -405,6 +416,16 @@ int HYDROGUI_ImportImageDlg::getTransformationMode() const
   return myModeGroup->checkedId();
 }
 
+void HYDROGUI_ImportImageDlg::setByTwoPoints( const bool theIsByTwoPoints )
+{
+  myPointCEnabler->setChecked( !theIsByTwoPoints );
+}
+
+bool HYDROGUI_ImportImageDlg::isByTwoPoints() const
+{
+  return !myPointCEnabler->isChecked();
+}
+
 void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap,
                                                         const bool theIsOnlyInput,
                                                         const bool theIsRefImage )
@@ -496,18 +517,13 @@ bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& t
   return true;
 }
 
-QString HYDROGUI_ImportImageDlg::getRefImageName() const
-{
-  return myRefImage->currentText();
-}
-
 void HYDROGUI_ImportImageDlg::setPrsPointDataList( const PrsPointDataList& theList )
 {
   myPrsPointDataList = theList;
 
   if( !myPrsPointDataList.isEmpty() )
   {
-    myModeGroup->button( RefImage )->setEnabled( true );
+    myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( true );
 
     myRefImage->clear();
     myRefImage->addItem( "" ); // first empty item
@@ -517,7 +533,7 @@ void HYDROGUI_ImportImageDlg::setPrsPointDataList( const PrsPointDataList& theLi
       myRefImage->addItem( anIter.next().first );
   }
   else
-    myModeGroup->button( RefImage )->setEnabled( false );
+    myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( false );
 }
 
 void HYDROGUI_ImportImageDlg::initializePointSelection()
@@ -584,6 +600,38 @@ void HYDROGUI_ImportImageDlg::initializePointSelection()
   blockSignalsCartesian( false );
 }
 
+HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsfData(
+  const int      theMode,
+  const QPoint&  theLocalPoint,
+  const QPointF& theGlobalPoint )
+{
+  TransformationData aResTrsfData;
+  aResTrsfData.ImagePoint = theLocalPoint;
+
+  double arx = theGlobalPoint.x();
+  double ary = theGlobalPoint.y();
+  if ( theMode == HYDROData_Image::ManualLambert )
+  {
+    // Lambert to Cartesian
+    double aXCart = 0, aYCart = 0;
+    HYDROData_Lambert93::toXY( arx, ary, aXCart, aYCart );
+
+    aResTrsfData.LambertPoint = theGlobalPoint;
+    aResTrsfData.CartesianPoint = QPointF( aXCart, aYCart );
+  }
+  else if ( theMode == HYDROData_Image::ManualCartesian )
+  {
+    // Cartesian to Lambert
+    double aLonDeg = 0, aLatDeg = 0;
+    HYDROData_Lambert93::toGeo( arx, ary, aLatDeg, aLonDeg );
+
+    aResTrsfData.CartesianPoint = theGlobalPoint;
+    aResTrsfData.LambertPoint = QPointF( aLonDeg, aLatDeg );
+  }
+
+  return aResTrsfData;
+}
+
 void HYDROGUI_ImportImageDlg::onBrowse()
 {
   QString aFilter( tr( "IMAGE_FILTER" ) );
@@ -603,9 +651,9 @@ void HYDROGUI_ImportImageDlg::onBrowse()
 
 void HYDROGUI_ImportImageDlg::onModeActivated( int theMode )
 {
-  bool anIsManualLambert = theMode == ManualLambert;
-  bool anIsManualCartesian = theMode == ManualCartesian;
-  bool anIsRefImage = theMode == RefImage;
+  bool anIsManualLambert = theMode == HYDROData_Image::ManualLambert;
+  bool anIsManualCartesian = theMode == HYDROData_Image::ManualCartesian;
+  bool anIsRefImage = theMode == HYDROData_Image::ReferenceImage;
 
   myRefImage->setEnabled( anIsRefImage );