X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_GeoreferencementDlg.cxx;h=45b8d55a95deb8035cb2a2aa69358c9dbf8a092d;hb=a53349567d67f4df0ef737798a25c24d9dc8f08e;hp=57bfafb6f4df207c3210b54852eb9be1f1d6f736;hpb=5cdade9a100cf8d3fdd10e3d7fed6e4128a4759b;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx index 57bfafb6..45b8d55a 100644 --- a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 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 -// +// Copyright (C) 2014-2015 EDF-R&D // 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 @@ -22,7 +18,9 @@ #include "HYDROGUI_GeoreferencementDlg.h" -#include +#include "HYDROGUI_Tool.h" + +#include #include #include @@ -43,9 +41,11 @@ //! Profile data structre constructor HYDROGUI_GeoreferencementDlg::ProfileGeoData::ProfileGeoData( + const QString& theName, const QString& theXg, const QString& theYg, const QString& theXd, const QString& theYd) { + this->Name = theName; this->isEmpty = theXg.isEmpty() && theYg.isEmpty() && theXd.isEmpty() && theYd.isEmpty(); this->isIncomplete = !isEmpty; @@ -93,7 +93,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 ); @@ -205,27 +208,26 @@ void HYDROGUI_GeoreferencementDlg::setMode( const int theMode ) myModeButtons->blockSignals( isBlocked ); } -void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap ) +void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataList& theData ) { disconnect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ), this, SLOT( onDataChanged() ) ); myTable->setRowCount( 0 ); - foreach ( const QString& aProfileName, theMap.keys() ) { + foreach ( const ProfileGeoData& aGeoData, theData ) { // Check the current profile name - if ( aProfileName.isEmpty() ) { + if ( aGeoData.Name.isEmpty() ) { continue; } // Get georeferencement data for the current profile - 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, false ); + anYg = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yg, false ); + aXd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xd, false ); + anYd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yd, false ); } // Insert row with the data @@ -233,11 +235,13 @@ void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap ) myTable->insertRow( aRow ); // "Profile" column - QTableWidgetItem* aNameItem = new QTableWidgetItem( aProfileName ); - aNameItem->setFlags( Qt::ItemIsEnabled ); + QTableWidgetItem* aNameItem = new QTableWidgetItem( aGeoData.Name ); + aNameItem->setFlags( aNameItem->flags() & ~Qt::ItemIsEnabled ); + /* Bold font is not used in other tables. Keep the common style. QFont aFont = aNameItem->font(); aFont.setBold( true ); - aNameItem->setFont( aFont ); + aNameItem->setFont( aFont ); + */ myTable->setItem( aRow, 0, aNameItem ); // "Xg" column @@ -262,10 +266,10 @@ void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap ) this, SLOT( onDataChanged() ) ); } -void HYDROGUI_GeoreferencementDlg::getData( ProfilesGeoDataMap& theMap ) +void HYDROGUI_GeoreferencementDlg::getData( ProfilesGeoDataList& theData ) const { - // Clear the map - theMap.clear(); + // Clear the list + theData.clear(); // Fill the map bool isOk = false; @@ -278,7 +282,7 @@ void HYDROGUI_GeoreferencementDlg::getData( ProfilesGeoDataMap& theMap ) aXd = myTable->item( aRow, 3 )->text(); anYd = myTable->item( aRow, 4 )->text(); - theMap.insert( aProfileName, ProfileGeoData( aXg, anYg, aXd, anYd ) ); + theData.append( ProfileGeoData( aProfileName, aXg, anYg, aXd, anYd ) ); } } @@ -301,20 +305,17 @@ void HYDROGUI_GeoreferencementDlg::onMousePress( // Get the selected point coordinates OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort(); - gp_Pnt aPnt = GEOMUtils::ConvertClickToPoint( theEvent->x(), theEvent->y(), - aViewPort->getView() ); + gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(), + aViewPort->getView() ); // Set the coordinates to the corresponding cells of the table 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(), false ); + QString anYStr = HYDROGUI_Tool::GetCoordinateString( aPnt.Y(), false ); + myTable->item( aRow, aColumnX )->setText( aXStr ); + myTable->item( aRow, aColumnY )->setText( anYStr ); } void HYDROGUI_GeoreferencementDlg::onDataChanged()