Salome HOME
refs #497: redesign of HYDRO main menu.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageDlg.cxx
index e39985b3675e23eb1fcf61d8f7dfc1e561afd468..7d2debddf7119d4fbb3c34294a1f8ddb53740e33 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -385,6 +385,9 @@ void HYDROGUI_ImportImageDlg::reset()
   myImageName->clear();
   myImageNameGroup->setEnabled( false );
   myGeoFileName->clear();
+  bool isPBlocked = blockSignalsPoints( true );
+  bool isGBlocked = blockSignalsGeodesic( true );
+  bool isCBlocked = blockSignalsCartesian( true );
   for( int aPointType = HYDROGUI_PrsImage::PointA;
        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
   {
@@ -393,21 +396,24 @@ void HYDROGUI_ImportImageDlg::reset()
     aBtn->setChecked( false );
     aBtn->blockSignals( anIsBlocked );
 
-    myPointXMap[ aPointType ]->clear();
-    myPointYMap[ aPointType ]->clear();
-    myPointXDegMap[ aPointType ]->clear();
-    myPointYDegMap[ aPointType ]->clear();
-    myPointXMinMap[ aPointType ]->clear();
-    myPointYMinMap[ aPointType ]->clear();
-    myPointXSecMap[ aPointType ]->clear();
-    myPointYSecMap[ aPointType ]->clear();
+    clearSpins( myPointXMap[ aPointType ] );
+    clearSpins( myPointYMap[ aPointType ] );
+    clearSpins( myPointXDegMap[ aPointType ] );
+    clearSpins( myPointYDegMap[ aPointType ] );
+    clearSpins( myPointXMinMap[ aPointType ] );
+    clearSpins( myPointYMinMap[ aPointType ] );
+    clearSpins( myPointXSecMap[ aPointType ] );
+    clearSpins( myPointYSecMap[ aPointType ] );
 
-    myRefPointXMap[ aPointType ]->clear();
-    myRefPointYMap[ aPointType ]->clear();
+    clearSpins( myRefPointXMap[ aPointType ] );
+    clearSpins( myRefPointYMap[ aPointType ] );
 
-    myCartPointXMap[ aPointType ]->clear();
-    myCartPointYMap[ aPointType ]->clear();
+    clearSpins( myCartPointXMap[ aPointType ] );
+    clearSpins( myCartPointYMap[ aPointType ] );
   }
+  blockSignalsPoints( isPBlocked );
+  blockSignalsGeodesic( isGBlocked );
+  blockSignalsCartesian( isCBlocked );
   
   // Emulate turning off C point usage
   myPointCEnabler->blockSignals( true );
@@ -465,6 +471,13 @@ QString HYDROGUI_ImportImageDlg::getFileName() const
   return myFileName->text();
 }
 
+void HYDROGUI_ImportImageDlg::setFileName( const QString& theName )
+{
+  myFileName->setText( theName );
+  myImageNameGroup->setEnabled( true );
+  myTransformGroup->setEnabled( true );
+}
+
 QString HYDROGUI_ImportImageDlg::getGeoreferencementFileName() const
 {
   return myGeoFileName->text();
@@ -701,10 +714,8 @@ void HYDROGUI_ImportImageDlg::onBrowse()
     }
     else
     {
-      myFileName->setText( aFileName );
+      setFileName( aFileName );
       emit createPreview( anImage );
-      myImageNameGroup->setEnabled( true );
-      myTransformGroup->setEnabled( true );
     }
   }
 }
@@ -908,26 +919,64 @@ void HYDROGUI_ImportImageDlg::onCartesianCoordChanged( const int thePointType )
   blockSignalsGeodesic( false );
 }
 
-void HYDROGUI_ImportImageDlg::blockSignalsGeodesic( const bool theState )
+void HYDROGUI_ImportImageDlg::clearSpins( QAbstractSpinBox* theSpin )
+{
+  if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
+  {
+    QtxIntSpinBox* aSpin = dynamic_cast<QtxIntSpinBox*>( theSpin );
+    aSpin->setValue( aSpin->minimum() );
+  }
+  else if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
+  {
+    QtxDoubleSpinBox* aDblSpin = dynamic_cast<QtxDoubleSpinBox*>( theSpin );
+    aDblSpin->setValue( aDblSpin->minimum() );
+  }
+
+  theSpin->clear();
+}
+
+bool HYDROGUI_ImportImageDlg::blockSignalsPoints( const bool theState )
+{
+  bool isBlocked = false;
+  for( int aPointType = HYDROGUI_PrsImage::PointA;
+       aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
+  {
+    isBlocked = 
+    myPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked;
+    myPointYMap[ aPointType ]->blockSignals( theState );
+
+    myRefPointXMap[ aPointType ]->blockSignals( theState );
+    myRefPointYMap[ aPointType ]->blockSignals( theState );
+  }
+  return isBlocked;
+}
+
+bool HYDROGUI_ImportImageDlg::blockSignalsGeodesic( const bool theState )
 {
+  bool isBlocked = false;
   for( int aPointType = HYDROGUI_PrsImage::PointA;
        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
   {
-    myPointXDegMap[ aPointType ]->blockSignals( theState );
+    isBlocked = 
+    myPointXDegMap[ aPointType ]->blockSignals( theState ) || isBlocked;
     myPointXMinMap[ aPointType ]->blockSignals( theState );
     myPointXSecMap[ aPointType ]->blockSignals( theState );
     myPointYDegMap[ aPointType ]->blockSignals( theState );
     myPointYMinMap[ aPointType ]->blockSignals( theState );
     myPointYSecMap[ aPointType ]->blockSignals( theState );
   }
+  return isBlocked;
 }
 
-void HYDROGUI_ImportImageDlg::blockSignalsCartesian( const bool theState )
+bool HYDROGUI_ImportImageDlg::blockSignalsCartesian( const bool theState )
 {
+  bool isBlocked = false;
   for( int aPointType = HYDROGUI_PrsImage::PointA;
        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
   {
-    myCartPointXMap[ aPointType ]->blockSignals( theState );
+    isBlocked = 
+    myCartPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked;
     myCartPointYMap[ aPointType ]->blockSignals( theState );
   }
+  return isBlocked;
 }