From bc031d803bd1e3befc0e56d7d5a5b6342b9b2de5 Mon Sep 17 00:00:00 2001 From: adv Date: Tue, 10 Dec 2013 06:33:41 +0000 Subject: [PATCH] Sorting of profiles (Bug #210). --- src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx | 19 +++++++------ src/HYDROGUI/HYDROGUI_GeoreferencementDlg.h | 16 +++++++---- src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx | 28 ++++++++----------- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx index 7ef449c4..aa73cd03 100644 --- a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx @@ -45,9 +45,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; @@ -210,21 +212,20 @@ 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 = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xg ); @@ -238,7 +239,7 @@ void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap ) myTable->insertRow( aRow ); // "Profile" column - QTableWidgetItem* aNameItem = new QTableWidgetItem( aProfileName ); + QTableWidgetItem* aNameItem = new QTableWidgetItem( aGeoData.Name ); aNameItem->setFlags( Qt::ItemIsEnabled ); QFont aFont = aNameItem->font(); aFont.setBold( true ); @@ -267,10 +268,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; @@ -283,7 +284,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 ) ); } } diff --git a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.h b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.h index 1d2a72a0..52879a48 100644 --- a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.h +++ b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.h @@ -50,18 +50,22 @@ public: bool isIncomplete, isEmpty; + QString Name; + ProfileGeoData() : isEmpty( true ), isIncomplete( false ) {} - ProfileGeoData( const QString& theXg, const QString& theYg, + ProfileGeoData( const QString& theName, + const QString& theXg, const QString& theYg, const QString& theXd, const QString& theYd ); - ProfileGeoData( double theXg, double theYg, + ProfileGeoData( const QString& theName, + double theXg, double theYg, double theXd, double theYd ) - : Xg( theXg ), Yg( theYg ), Xd( theXd ), Yd( theYd ), + : Name( theName), Xg( theXg ), Yg( theYg ), Xd( theXd ), Yd( theYd ), isIncomplete(false), isEmpty(false) {} }; - typedef QMap< QString, ProfileGeoData > ProfilesGeoDataMap; + typedef QList ProfilesGeoDataList; public: HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* theModule, const QString& theTitle ); @@ -71,8 +75,8 @@ public: void setMode( const int theMode ); - void setData( const ProfilesGeoDataMap& theMap ); - void getData( ProfilesGeoDataMap& theMap ); + void setData( const ProfilesGeoDataList& theData ); + void getData( ProfilesGeoDataList& theData ) const; bool isModified() const; diff --git a/src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx b/src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx index fe1743ed..28fac4f9 100644 --- a/src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx +++ b/src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx @@ -212,31 +212,26 @@ bool HYDROGUI_GeoreferencementOp::store( QString& theErrorMsg ) } // Get georeferencement data from the panel - HYDROGUI_GeoreferencementDlg::ProfilesGeoDataMap aGeoDataMap; - aPanel->getData( aGeoDataMap ); - - if ( aGeoDataMap.empty() ) { + HYDROGUI_GeoreferencementDlg::ProfilesGeoDataList aGeoDataList; + aPanel->getData( aGeoDataList ); + if ( aGeoDataList.empty() ) { return true; } // Check the data validity - foreach ( const QString& aProfileName, aGeoDataMap.keys() ) { - HYDROGUI_GeoreferencementDlg::ProfileGeoData aGeoData = - aGeoDataMap.value( aProfileName ); + foreach ( const HYDROGUI_GeoreferencementDlg::ProfileGeoData& aGeoData, aGeoDataList ) { if ( aGeoData.isIncomplete ) { - theErrorMsg = tr( "INCOMPLETE_DATA" ).arg( aProfileName ); + theErrorMsg = tr( "INCOMPLETE_DATA" ).arg( aGeoData.Name ); return false; } } // Store the data in the data model - foreach ( const QString& aProfileName, aGeoDataMap.keys() ) { + foreach ( const HYDROGUI_GeoreferencementDlg::ProfileGeoData& aGeoData, aGeoDataList ) { Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( - HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); + HYDROGUI_Tool::FindObjectByName( module(), aGeoData.Name, KIND_PROFILE ) ); if ( !aProfile.IsNull() ) { - HYDROGUI_GeoreferencementDlg::ProfileGeoData aGeoData = - aGeoDataMap.value( aProfileName ); if ( !aGeoData.isEmpty ) { aProfile->SetFirstPoint( gp_XY( aGeoData.Xg, aGeoData.Yg ) ); aProfile->SetLastPoint( gp_XY( aGeoData.Xd, aGeoData.Yd ) ); @@ -275,7 +270,7 @@ void HYDROGUI_GeoreferencementOp::setPanelData( } // Get georeferencement data from the data model - HYDROGUI_GeoreferencementDlg::ProfilesGeoDataMap aDataMap; + HYDROGUI_GeoreferencementDlg::ProfilesGeoDataList aData; HYDROData_SequenceOfObjects::Iterator anIter( theProfiles ); for ( ; anIter.More(); anIter.Next() ) { @@ -290,13 +285,14 @@ void HYDROGUI_GeoreferencementOp::setPanelData( gp_XY aFirstPoint, aLastPoint; if ( aProfile->GetFirstPoint( aFirstPoint ) && aProfile->GetLastPoint( aLastPoint ) ) { aGeoData = - HYDROGUI_GeoreferencementDlg::ProfileGeoData( aFirstPoint.X(), aFirstPoint.Y(), + HYDROGUI_GeoreferencementDlg::ProfileGeoData( aProfile->GetName(), + aFirstPoint.X(), aFirstPoint.Y(), aLastPoint.X(), aLastPoint.Y() ); } - aDataMap.insert( aProfile->GetName(), aGeoData ); + aData.append( aGeoData ); } // Set the collected data to the dialog - aPanel->setData( aDataMap ); + aPanel->setData( aData ); } \ No newline at end of file -- 2.39.2