Salome HOME
Feature #102: Display of Lambert coordinates.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_GeoreferencementDlg.cxx
index 57bfafb6f4df207c3210b54852eb9be1f1d6f736..7ef449c44beb4d223d1d6887e31fd6257e12deab 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "HYDROGUI_GeoreferencementDlg.h"
 
+#include "HYDROGUI_Tool.h"
+
 #include <GEOMUtils.hxx>
 
 #include <OCCViewer_ViewWindow.h>
@@ -93,7 +95,10 @@ QWidget* HYDROGUI_GeoreferencementDlg::Delegate::createEditor(
 
   if ( theIndex.column() > 0 ) {
     QLineEdit* aLineEdit = new QLineEdit( theParent );
-    aLineEdit->setValidator( new QDoubleValidator( aLineEdit ) );
+    QDoubleValidator* aDoubleValidator = new QDoubleValidator();
+    aDoubleValidator->setNotation( QDoubleValidator::StandardNotation );
+    aDoubleValidator->setDecimals( 2 );
+    aLineEdit->setValidator( aDoubleValidator );
     anEditor = aLineEdit;
   } else {
     anEditor = QItemDelegate::createEditor( theParent, theOption, theIndex );
@@ -222,10 +227,10 @@ void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap )
     ProfileGeoData aGeoData = theMap.value( aProfileName );
     QString aXg, anYg, aXd, anYd;
     if ( !aGeoData.isEmpty ) {
-      aXg = getString( aGeoData.Xg );
-      anYg = getString( aGeoData.Yg );
-      aXd = getString( aGeoData.Xd );
-      anYd = getString( aGeoData.Yd );
+      aXg = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xg );
+      anYg = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yg );
+      aXd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xd );
+      anYd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yd );
     }
     
     // Insert row with the data
@@ -308,13 +313,10 @@ void HYDROGUI_GeoreferencementDlg::onMousePress(
   int aColumnX = aColumn < 3 ? 1 : 3;
   int aColumnY = aColumnX + 1;
   
-  myTable->item( aRow, aColumnX )->setText( getString( aPnt.X() ) );
-  myTable->item( aRow, aColumnY )->setText( getString( aPnt.Y() ) );
-}
-
-QString HYDROGUI_GeoreferencementDlg::getString( const double theNumber ) const
-{
-  return QString::number( theNumber, 'g', 12 );
+  QString aXStr = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
+  QString anYStr = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
+  myTable->item( aRow, aColumnX )->setText( aXStr );
+  myTable->item( aRow, aColumnY )->setText( anYStr );
 }
 
 void HYDROGUI_GeoreferencementDlg::onDataChanged()