#include "HYDROGUI_GeoreferencementDlg.h"
-#include <GEOMUtils.hxx>
+#include "HYDROGUI_Tool.h"
+
+#include <CurveCreator_Utils.h>
#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewManager.h>
//! 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;
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 );
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 );
+ anYg = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yg );
+ aXd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xd );
+ anYd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yd );
}
// Insert row with the data
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
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;
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 ) );
}
}
// 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() );
+ QString anYStr = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
+ myTable->item( aRow, aColumnX )->setText( aXStr );
+ myTable->item( aRow, aColumnY )->setText( anYStr );
}
void HYDROGUI_GeoreferencementDlg::onDataChanged()