From: stv Date: Wed, 10 Jun 2015 11:09:30 +0000 (+0300) Subject: refs #560: Strickler table: import/export X-Git-Tag: v1.4.1~6^2^2~2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9495abe5b3f740ba34885addc514f9c1879579e8;p=modules%2Fhydro.git refs #560: Strickler table: import/export --- diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index cf515aa8..44b9fb60 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -229,6 +229,7 @@ bool HYDROData_Document::DumpToPython( const QString& theFileName, // Dump all model objects to Python script aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_IMAGE ); + aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_STRICKLER_TABLE ); aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_POLYLINEXY ); aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_BATHYMETRY ); aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_PROFILE ); diff --git a/src/HYDROData/HYDROData_StricklerTable.cxx b/src/HYDROData/HYDROData_StricklerTable.cxx index 903b915a..68995e82 100644 --- a/src/HYDROData/HYDROData_StricklerTable.cxx +++ b/src/HYDROData/HYDROData_StricklerTable.cxx @@ -17,12 +17,22 @@ // #include + #include +#include +#include + +#include +#include + +#include +#include + IMPLEMENT_STANDARD_HANDLE( HYDROData_StricklerTable, HYDROData_Entity ) -IMPLEMENT_STANDARD_RTTIEXT( HYDROData_StricklerTable, HYDROData_Entity ) + IMPLEMENT_STANDARD_RTTIEXT( HYDROData_StricklerTable, HYDROData_Entity ) -HYDROData_StricklerTable::HYDROData_StricklerTable() + HYDROData_StricklerTable::HYDROData_StricklerTable() { } @@ -32,51 +42,140 @@ HYDROData_StricklerTable::~HYDROData_StricklerTable() const ObjectKind HYDROData_StricklerTable::GetKind() const { - return KIND_STRICKLER_TABLE; + return KIND_STRICKLER_TABLE; } bool HYDROData_StricklerTable::Import( const TCollection_AsciiString& theFileName ) { - FILE* aFile = fopen( theFileName.ToCString(), "r" ); - if( !aFile ) - return false; - - const int aBufLen = 256; - char aBuf[aBufLen]; - while( !feof( aFile ) ) - { - fgets( aBuf, aBufLen, aFile ); - std::string aStr = aBuf; - } - return false; + std::ifstream aStream( theFileName.ToCString(), std::ios::in | std::ios::binary ); + if ( !aStream ) + return false; + + bool aRes = true; + + const int aBufLen = 512; + char aBuf[aBufLen]; + while( !aStream.eof() && aRes ) + { + aStream.getline( aBuf, aBufLen ); + TCollection_ExtendedString aStr( aBuf, Standard_True ); + + Standard_Integer aPos = aStr.SearchFromEnd( " " ); + if ( aPos < 0 ) + aRes = false; + else + { + TCollection_ExtendedString aValueStr = aStr.Split( aPos ); + while ( aStr.Length() > 0 && ( aStr.Value( aStr.Length() ) == ' ' || aStr.Value( aStr.Length() ) == '\t' ) ) + aStr.Remove( aStr.Length() ); + while ( aStr.Length() > 0 && ( aStr.Value( 1 ) == ' ' || aStr.Value( 1 ) == '\t' ) || aStr.Value( 1 ) < 0 ) + aStr.Remove( 1 ); + + if ( aStr.Length() > 0 && aStr.Value( aStr.Length() ) == '\"' ) + aStr.Remove( aStr.Length() ); + if ( aStr.Length() > 0 && aStr.Value( 1 ) == '\"' ) + aStr.Remove( 1 ); + + if ( aValueStr.IsEmpty() || aStr.IsEmpty() ) + aRes = false; + else + { + Standard_Real aValue = TCollection_AsciiString( aValueStr ).RealValue(); + Set( aStr, aValue ); + } + } + } + + aStream.close(); + return aRes; } bool HYDROData_StricklerTable::Export( const TCollection_AsciiString& theFileName ) { - //TODO - return false; + Handle(TDataStd_NamedData) aMap = Map(); + if ( aMap.IsNull() ) + return false; + + std::ofstream aStream( theFileName.ToCString(), std::ios::out | std::ios::binary ); + if ( !aStream ) + return false; + + bool aRes = true; + for ( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More() && aRes; it.Next() ) + { + TCollection_ExtendedString aLine = TCollection_ExtendedString( '\"' ) + it.Key() + TCollection_ExtendedString( '\"' ) + + TCollection_ExtendedString( ' ' ) + TCollection_ExtendedString( it.Value() ); + Standard_PCharacter aBuf = (Standard_PCharacter)malloc( aLine.LengthOfCString() + 1 ); + aStream.write( aBuf, aLine.ToUTF8CString( aBuf ) ); + aStream.write( "\r\n", 2 ); + free( aBuf ); + } + + aStream.close(); + return aRes; } double HYDROData_StricklerTable::Get( const TCollection_ExtendedString& theType, double theDefault ) const { - Handle( TDataStd_NamedData ) aMap = Map(); - if( aMap->HasReal( theType ) ) - return aMap->GetReal( theType ); - else - return theDefault; + Handle( TDataStd_NamedData ) aMap = Map(); + if( aMap->HasReal( theType ) ) + return aMap->GetReal( theType ); + else + return theDefault; } void HYDROData_StricklerTable::Set( const TCollection_ExtendedString& theType, double theCoefficient ) { - Handle( TDataStd_NamedData ) aMap = Map(); - aMap->SetReal( theType, theCoefficient ); + Handle(TDataStd_NamedData) aMap = Map(); + aMap->SetReal( theType, theCoefficient ); +} + +TColStd_SequenceOfExtendedString HYDROData_StricklerTable::GetTypes() const +{ + TColStd_SequenceOfExtendedString aSeq; + Handle(TDataStd_NamedData) aMap = Map(); + if ( !aMap.IsNull() ) + { + for ( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More(); it.Next() ) + aSeq.Append( it.Key() ); + } + return aSeq; +} + +void HYDROData_StricklerTable::Clear() +{ + Handle(TDataStd_NamedData) aMap = Map(); + if ( !aMap.IsNull() ) + aMap->ChangeReals( TDataStd_DataMapOfStringReal() ); +} + +QStringList HYDROData_StricklerTable::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +{ + QStringList aResList = dumpObjectCreation( theTreatedObjects ); + QString aPyName = GetObjPyName(); + + aResList << QString( "" ); + Handle(TDataStd_NamedData) aMap = Map(); + if ( !aMap.IsNull() ) + { + for ( TDataStd_DataMapIteratorOfDataMapOfStringReal it( aMap->GetRealsContainer() ); it.More(); it.Next() ) + { + TCollection_ExtendedString aType = it.Key(); + Standard_Real aValue = it.Value(); + aResList << QString( "%1.Set( \"%2\", %3 );" ).arg( aPyName ).arg( QString( (QChar*)aType.ToExtString(), aType.Length() ) ).arg( aValue ); + } + } + aResList << QString( "" ); + aResList << QString( "%1.Update();" ).arg( aPyName ); + + return aResList; } -Handle( TDataStd_NamedData ) HYDROData_StricklerTable::Map() const +Handle(TDataStd_NamedData) HYDROData_StricklerTable::Map() const { - TDF_Label aLabel = myLab.FindChild( DataTag_Table ); - Handle( TDataStd_NamedData ) aMap; - if( !aLabel.FindAttribute( TDataStd_NamedData::GetID(), aMap ) ) - aMap = TDataStd_NamedData::Set( aLabel ); - return aMap; + TDF_Label aLabel = myLab.FindChild( DataTag_Table ); + Handle( TDataStd_NamedData ) aMap; + if( !aLabel.FindAttribute( TDataStd_NamedData::GetID(), aMap ) ) + aMap = TDataStd_NamedData::Set( aLabel ); + return aMap; } diff --git a/src/HYDROData/HYDROData_StricklerTable.h b/src/HYDROData/HYDROData_StricklerTable.h index eae46e33..bbc553be 100644 --- a/src/HYDROData/HYDROData_StricklerTable.h +++ b/src/HYDROData/HYDROData_StricklerTable.h @@ -21,6 +21,8 @@ #include +#include + class Handle( TDataStd_NamedData ); DEFINE_STANDARD_HANDLE( HYDROData_StricklerTable, HYDROData_Entity ) @@ -46,11 +48,17 @@ public: HYDRODATA_EXPORT bool Import( const TCollection_AsciiString& theFileName ); HYDRODATA_EXPORT bool Export( const TCollection_AsciiString& theFileName ); - double Get( const TCollection_ExtendedString& theType, double theDefault ) const; - void Set( const TCollection_ExtendedString& theType, double theCoefficient ); + HYDRODATA_EXPORT double Get( const TCollection_ExtendedString& theType, double theDefault ) const; + HYDRODATA_EXPORT void Set( const TCollection_ExtendedString& theType, double theCoefficient ); + + HYDRODATA_EXPORT TColStd_SequenceOfExtendedString GetTypes() const; + + HYDRODATA_EXPORT void Clear(); + + HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; private: - Handle( TDataStd_NamedData ) Map() const; + Handle(TDataStd_NamedData) Map() const; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index b6537bfe..061428ea 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -379,14 +379,14 @@ void HYDROGUI_DataModel::update( const int theStudyId ) break; } - case KIND_STRICKLER_TABLE: + case KIND_STRICKLER_TABLE: { Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anObj ); if( !aStricklerTableObj.IsNull() ) { obj = createObject( aStricklerTablesRootObj, aStricklerTableObj ); } - aNoStricklerTableObj++; + aNoStricklerTableObj++; break; } @@ -798,8 +798,10 @@ void HYDROGUI_DataModel::createDefaultStricklerTable( const Handle(HYDROData_Doc Handle(HYDROData_StricklerTable)::DownCast( theDocument->CreateObject(KIND_STRICKLER_TABLE) ); if ( !aStricklerTableObj.IsNull() ) { - aStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( tr( "DEFAULT_STRICKLER_TABLE_FILE" ) ) ); - // Set name + SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr(); + QString defTablePath = resMgr->path( "resources", module()->name(), tr( "DEFAULT_STRICKLER_TABLE_FILE" ) ); + aStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( defTablePath ) ); + // Set name QString aStricklerTableName; if ( aStricklerTableObj->GetName().isEmpty() ) { diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 0a7b0157..0a96e798 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -494,8 +494,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const anOp = new HYDROGUI_DigueOp( aModule, theId == EditDigueId ); break; case ImportStricklerTableFromFileId: + case ExportStricklerTableFromFileId: case EditStricklerTableId: - anOp = new HYDROGUI_StricklerTableOp( aModule, theId == EditStricklerTableId ); + anOp = new HYDROGUI_StricklerTableOp( aModule, theId ); break; case CreateLandCoverId: case EditLandCoverId: diff --git a/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx b/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx index 3bcab2d8..40269457 100644 --- a/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StricklerTableDlg.cxx @@ -38,263 +38,280 @@ #include #include -HYDROGUI_StricklerTableDlg::HYDROGUI_StricklerTableDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_InputPanel( theModule, theTitle ), myName(NULL) +HYDROGUI_StricklerTableDlg::HYDROGUI_StricklerTableDlg( HYDROGUI_Module* theModule, const QString& theTitle, int theType ) +: HYDROGUI_InputPanel( theModule, theTitle ), + myType( theType ) { - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - - // Import Strickler table from file - myFileNameGroup = new QGroupBox( tr( "IMPORT_STRICKLER_TABLE_FROM_FILE" ), this ); - - QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup ); - - myFileName = new QLineEdit( myFileNameGroup ); - myFileName->setReadOnly( true ); - - myBrowseBtn = new QToolButton( myFileNameGroup ); - myBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); - - QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup ); - aFileNameLayout->setMargin( 5 ); - aFileNameLayout->setSpacing( 5 ); - aFileNameLayout->addWidget( aFileNameLabel ); - aFileNameLayout->addWidget( myFileName ); - aFileNameLayout->addWidget( myBrowseBtn ); - - // Strickler table name - myNameGroup = new QGroupBox( tr( "STRICKLER_TABLE_NAME" ), this ); - - QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myNameGroup ); - myName = new QLineEdit( myNameGroup ); - - QBoxLayout* anImageNameLayout = new QHBoxLayout( myNameGroup ); - anImageNameLayout->setMargin( 5 ); - anImageNameLayout->setSpacing( 5 ); - anImageNameLayout->addWidget( anImageNameLabel ); - anImageNameLayout->addWidget( myName ); - - // Strickler table - myTableGroup = new QGroupBox( tr( "STRICKLER_TABLE_TABLE" ), this ); - - // Main layout - QVBoxLayout* aTableLayout = new QVBoxLayout( myTableGroup ); - aTableLayout->setMargin( 5 ); - aTableLayout->setSpacing( 5 ); - - // Buttons - myAddBtn = new QToolButton; - myAddBtn->setText( tr( "ADD" ) ); - myRemoveBtn = new QToolButton; - myRemoveBtn->setText( tr( "REMOVE" ) ); - myClearBtn = new QToolButton; - myClearBtn->setText( tr( "CLEAR_ALL" ) ); - - // Table - myTable = new QTableWidget( mainFrame() ); - myTable->setItemDelegate( new HYDROGUI_LineEditDoubleValidator( this ) ); - myTable->setEditTriggers( QAbstractItemView::DoubleClicked | - QAbstractItemView::SelectedClicked | - QAbstractItemView::EditKeyPressed ); - - myTable->setColumnCount( 2 ); - QStringList aColumnNames; - aColumnNames << tr( "STRICKLER_TYPE" ) << tr( "STRICKLER_COEFFICIENT" ); - myTable->setHorizontalHeaderLabels( aColumnNames ); - - myTable->horizontalHeader()->setStretchLastSection( false); - myTable->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch ); - myTable->horizontalHeader()->setResizeMode( 1, QHeaderView::ResizeToContents ); - - myTable->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ); - - // Layout - // buttons - QHBoxLayout* aButtonsLayout = new QHBoxLayout(); - aButtonsLayout->addWidget( myAddBtn ); - aButtonsLayout->addWidget( myRemoveBtn ); - aButtonsLayout->addStretch( 1 ); - aButtonsLayout->addWidget( myClearBtn ); - - // main - aTableLayout->addLayout( aButtonsLayout ); - aTableLayout->addWidget( myTable ); - - // Common - addWidget( myFileNameGroup ); - addWidget( myNameGroup ); - addWidget( myTableGroup ); - - // Update controls - updateControls(); - - // Connections - connect( myBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); - connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddCoefficient() ) ); - connect( myRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemoveCoefficient() ) ); - connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onClearCoefficients() ) ); - connect( myTable->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), - this, SLOT( onSelectionChanged() ) ); - - setMinimumWidth( 350 ); -} + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + QString fileGroupTitle = theType == Export ? tr( "EXPORT_STRICKLER_TABLE_FILE" ) : tr( "IMPORT_STRICKLER_TABLE_FILE" ); + + // Import Strickler table from file + QGroupBox* aFileNameGroup = new QGroupBox( fileGroupTitle, this ); + aFileNameGroup->setVisible( theType != Edit ); + + QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFileNameGroup ); + + myFileName = new QLineEdit( aFileNameGroup ); + myFileName->setReadOnly( true ); + + QToolButton* aBrowseBtn = new QToolButton( aFileNameGroup ); + aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); + + QBoxLayout* aFileNameLayout = new QHBoxLayout( aFileNameGroup ); + aFileNameLayout->setMargin( 5 ); + aFileNameLayout->setSpacing( 5 ); + aFileNameLayout->addWidget( aFileNameLabel ); + aFileNameLayout->addWidget( myFileName ); + aFileNameLayout->addWidget( aBrowseBtn ); + + // Strickler table name + QGroupBox* aNameGroup = new QGroupBox( tr( "STRICKLER_TABLE_NAME" ), this ); + + QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), aNameGroup ); + myName = new QLineEdit( aNameGroup ); + + QBoxLayout* anImageNameLayout = new QHBoxLayout( aNameGroup ); + anImageNameLayout->setMargin( 5 ); + anImageNameLayout->setSpacing( 5 ); + anImageNameLayout->addWidget( anImageNameLabel ); + anImageNameLayout->addWidget( myName ); + + // Strickler table + QGroupBox* aTableGroup = new QGroupBox( tr( "STRICKLER_TABLE_TABLE" ), this ); + aTableGroup->setVisible( theType == Edit ); + + // Main layout + QVBoxLayout* aTableLayout = new QVBoxLayout( aTableGroup ); + aTableLayout->setMargin( 5 ); + aTableLayout->setSpacing( 5 ); + + // Buttons + myAddBtn = new QToolButton; + myAddBtn->setText( tr( "ADD" ) ); + myRemoveBtn = new QToolButton; + myRemoveBtn->setText( tr( "REMOVE" ) ); + myClearBtn = new QToolButton; + myClearBtn->setText( tr( "CLEAR_ALL" ) ); + + // Table + myTable = new QTableWidget( mainFrame() ); + myTable->setItemDelegate( new HYDROGUI_LineEditDoubleValidator( this ) ); + myTable->setEditTriggers( QAbstractItemView::DoubleClicked | + QAbstractItemView::SelectedClicked | + QAbstractItemView::EditKeyPressed ); + + myTable->setColumnCount( 2 ); + QStringList aColumnNames; + aColumnNames << tr( "STRICKLER_TYPE" ) << tr( "STRICKLER_COEFFICIENT" ); + myTable->setHorizontalHeaderLabels( aColumnNames ); + + myTable->horizontalHeader()->setStretchLastSection( false); + myTable->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch ); + myTable->horizontalHeader()->setResizeMode( 1, QHeaderView::ResizeToContents ); + + myTable->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ); + + // Layout + // buttons + QHBoxLayout* aButtonsLayout = new QHBoxLayout(); + aButtonsLayout->addWidget( myAddBtn ); + aButtonsLayout->addWidget( myRemoveBtn ); + aButtonsLayout->addStretch( 1 ); + aButtonsLayout->addWidget( myClearBtn ); + + // main + aTableLayout->addLayout( aButtonsLayout ); + aTableLayout->addWidget( myTable ); + + // Common + addWidget( aFileNameGroup ); + addWidget( aNameGroup ); + addWidget( aTableGroup ); + + // Update controls + updateControls(); -HYDROGUI_StricklerTableDlg::~HYDROGUI_StricklerTableDlg() -{ + // Connections + connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); + connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddCoefficient() ) ); + connect( myRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemoveCoefficient() ) ); + connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onClearCoefficients() ) ); + connect( myTable->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ), + this, SLOT( onSelectionChanged() ) ); + + setMinimumWidth( 350 ); + + if ( theType != Edit ) + addStretch(); } -void HYDROGUI_StricklerTableDlg::setIsEdit( const bool theIsEdit ) +HYDROGUI_StricklerTableDlg::~HYDROGUI_StricklerTableDlg() { - myFileNameGroup->setVisible( !theIsEdit ); - myNameGroup->setEnabled( theIsEdit ); - myTableGroup->setVisible( theIsEdit ); - if ( !theIsEdit ) - addStretch(); } void HYDROGUI_StricklerTableDlg::reset() { - myFileName->clear(); + myFileName->clear(); - myName->clear(); - myNameGroup->setEnabled( false ); + myName->clear(); } QString HYDROGUI_StricklerTableDlg::getFileName() const { - return myFileName->text(); + return myFileName->text(); } void HYDROGUI_StricklerTableDlg::setFileName( const QString& theName ) { - myFileName->setText( theName ); + myFileName->setText( theName ); +} - if ( !myNameGroup->isEnabled() ) - myNameGroup->setEnabled( true ); +void HYDROGUI_StricklerTableDlg::setTableName( const QString& theName ) +{ + myName->setText(theName); } -void HYDROGUI_StricklerTableDlg::setStricklerTableName( const QString& theName ) +QString HYDROGUI_StricklerTableDlg::getTableName() const { - myName->setText(theName); + return myName->text(); } -QString HYDROGUI_StricklerTableDlg::getStricklerTableName() const +bool HYDROGUI_StricklerTableDlg::isTableNameReadOnly() const { - return myName->text(); + return myName->isReadOnly(); } -void HYDROGUI_StricklerTableDlg::setData(const StricklerCoefficientList& theData) +void HYDROGUI_StricklerTableDlg::setTableNameReadOnly( bool on ) { - myTable->setRowCount( 0 ); + myName->setReadOnly( on ); +} - foreach ( const StricklerCoefficient& aData, theData ) { - // Check the current Strickler type - if ( aData.myType.isEmpty() ) { - continue; +HYDROGUI_StricklerTableDlg::StricklerCoefficientList HYDROGUI_StricklerTableDlg::getData() const +{ + StricklerCoefficientList aRes; + for ( int i = 0; i < myTable->rowCount(); i++ ) + { + QTableWidgetItem* typeItem = myTable->item( i, 0 ); + QTableWidgetItem* coeffItem = myTable->item( i, 1 ); + aRes.append( StricklerCoefficient( typeItem->text(), coeffItem->text().toDouble() ) ); } + return aRes; +} - // Get Strickler coefficient value for the current Strickler type - QString aCoefficient = HYDROGUI_Tool::GetCoordinateString( aData.myCoefficient, false ); - - // Insert row with the data - int aRow = myTable->rowCount(); - myTable->insertRow( aRow ); +void HYDROGUI_StricklerTableDlg::setData(const StricklerCoefficientList& theData) +{ + myTable->setRowCount( 0 ); + + foreach ( const StricklerCoefficient& aData, theData ) { + // Check the current Strickler type + if ( aData.myType.isEmpty() ) { + continue; + } + + // Get Strickler coefficient value for the current Strickler type + QString aCoefficient = HYDROGUI_Tool::GetCoordinateString( aData.myCoefficient, false ); + + // Insert row with the data + int aRow = myTable->rowCount(); + myTable->insertRow( aRow ); - // "Type" column - QTableWidgetItem* aTypeItem = new QTableWidgetItem( aData.myType ); - myTable->setItem( aRow, 0, aTypeItem ); + // "Type" column + QTableWidgetItem* aTypeItem = new QTableWidgetItem( aData.myType ); + myTable->setItem( aRow, 0, aTypeItem ); - // "Coefficient" column - myTable->setItem( aRow, 1, new QTableWidgetItem( aCoefficient ) ); - } + // "Coefficient" column + myTable->setItem( aRow, 1, new QTableWidgetItem( aCoefficient ) ); + } - myTable->resizeColumnToContents( 0 ); - myTable->resizeRowsToContents(); + myTable->resizeColumnToContents( 0 ); + myTable->resizeRowsToContents(); - updateControls(); + updateControls(); } void HYDROGUI_StricklerTableDlg::updateControls() { - bool isTableNotEmpty = myTable->rowCount() > 0; - myClearBtn->setEnabled( isTableNotEmpty ); - onSelectionChanged(); + bool isTableNotEmpty = myTable->rowCount() > 0; + myClearBtn->setEnabled( isTableNotEmpty ); + onSelectionChanged(); } void HYDROGUI_StricklerTableDlg::removeRows( const QList theRows ) { - QList aSortedRows = theRows; - qSort( aSortedRows ); - - int aRowToRemove = -1; - int aNbRemoved = 0; - foreach ( int aRow, aSortedRows ) { - aRowToRemove = aRow - aNbRemoved; - if ( myTable->model()->removeRow( aRowToRemove ) ) { - aNbRemoved++; + QList aSortedRows = theRows; + qSort( aSortedRows ); + + int aRowToRemove = -1; + int aNbRemoved = 0; + foreach ( int aRow, aSortedRows ) { + aRowToRemove = aRow - aNbRemoved; + if ( myTable->model()->removeRow( aRowToRemove ) ) { + aNbRemoved++; + } } - } - if ( aNbRemoved > 0 ) - updateControls(); + if ( aNbRemoved > 0 ) + updateControls(); } void HYDROGUI_StricklerTableDlg::onBrowse() { - QString aFilter( tr( "STRICKLER_TABLE_FILTER" ) ); - QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_STRICKLER_TABLE_FROM_FILE" ), true ); - if( !aFileName.isEmpty() ) - { - setFileName( aFileName ); - emit fileSelected( aFileName ); - } + QString aFilter( tr( "STRICKLER_TABLE_FILTER" ) ); + QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, myFileName->parent()->property( "title" ).toString(), myType == Import ); + if ( !aFileName.isEmpty() ) + { + setFileName( aFileName ); + emit fileSelected( aFileName ); + } } /** - Add the new default constructed Strickler coefficient. - */ +Add the new default constructed Strickler coefficient. +*/ void HYDROGUI_StricklerTableDlg::onAddCoefficient() { - int aRow = myTable->rowCount(); - myTable->insertRow( aRow ); + int aRow = myTable->rowCount(); + myTable->insertRow( aRow ); - // Set default type (=> generate unique type name) and coefficient - //... + // Set default type (=> generate unique type name) and coefficient + //... - updateControls(); + updateControls(); } /** - Remove the selected Strickler coefficient. - */ +Remove the selected Strickler coefficient. +*/ void HYDROGUI_StricklerTableDlg::onRemoveCoefficient() { - QList aRows; - QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); - foreach ( const QModelIndex& anIndex, aSelectedIndexes ) { - aRows << anIndex.row(); - } + QList aRows; + QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); + foreach ( const QModelIndex& anIndex, aSelectedIndexes ) { + aRows << anIndex.row(); + } - removeRows( aRows ); + removeRows( aRows ); } /** - Clear all Strickler coefficients. - */ +Clear all Strickler coefficients. +*/ void HYDROGUI_StricklerTableDlg::onClearCoefficients() { - QList aRows; - for ( int i=0; i< myTable->rowCount(); i++ ) { - aRows << i; - } + QList aRows; + for ( int i=0; i< myTable->rowCount(); i++ ) { + aRows << i; + } - removeRows( aRows ); + removeRows( aRows ); } /** - Slot called on table selection change. +Slot called on table selection change. */ void HYDROGUI_StricklerTableDlg::onSelectionChanged() { - QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); - myRemoveBtn->setEnabled( aSelectedIndexes.count() > 0 ); + QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); + myRemoveBtn->setEnabled( aSelectedIndexes.count() > 0 ); } diff --git a/src/HYDROGUI/HYDROGUI_StricklerTableDlg.h b/src/HYDROGUI/HYDROGUI_StricklerTableDlg.h index fef70326..0fa872b2 100644 --- a/src/HYDROGUI/HYDROGUI_StricklerTableDlg.h +++ b/src/HYDROGUI/HYDROGUI_StricklerTableDlg.h @@ -27,67 +27,68 @@ class QGroupBox; class QLineEdit; class QToolButton; class QTableWidget; +class QtxFilePath; class HYDROGUI_StricklerTableDlg : public HYDROGUI_InputPanel { - Q_OBJECT + Q_OBJECT public: - struct StricklerCoefficient - { - QString myType; - double myCoefficient; + struct StricklerCoefficient + { + QString myType; + double myCoefficient; - StricklerCoefficient( const QString& theType, - double theCoefficient ) - : myType( theType ), myCoefficient( theCoefficient ) {} - }; - typedef QList StricklerCoefficientList; + StricklerCoefficient( const QString& theType, + double theCoefficient ) + : myType( theType ), myCoefficient( theCoefficient ) {} + }; + typedef QList StricklerCoefficientList; + + enum { Edit, Import, Export }; public: - HYDROGUI_StricklerTableDlg( HYDROGUI_Module* theModule, const QString& theTitle ); - virtual ~HYDROGUI_StricklerTableDlg(); + HYDROGUI_StricklerTableDlg( HYDROGUI_Module* theModule, const QString& theTitle, int theType ); + virtual ~HYDROGUI_StricklerTableDlg(); + + void reset(); - void setIsEdit( const bool theIsEdit ); - void reset(); + QString getFileName() const; + void setFileName( const QString& theName ); - QString getFileName() const; - void setFileName( const QString& theName ); + void setTableName( const QString& theName ); + QString getTableName() const; - void setStricklerTableName( const QString& theName ); - QString getStricklerTableName() const; + bool isTableNameReadOnly() const; + void setTableNameReadOnly( bool ); - void setData(const StricklerCoefficientList& theData); + StricklerCoefficientList getData() const; + void setData(const StricklerCoefficientList& theData); protected: - void updateControls(); - void removeRows( const QList theRows ); + void updateControls(); + void removeRows( const QList theRows ); -protected slots: - void onBrowse(); +protected Q_SLOTS: + void onBrowse(); - void onAddCoefficient(); - void onRemoveCoefficient(); - void onClearCoefficients(); + void onAddCoefficient(); + void onRemoveCoefficient(); + void onClearCoefficients(); - void onSelectionChanged(); + void onSelectionChanged(); -signals: - void fileSelected( const QString& theFileName ); +Q_SIGNALS: + void fileSelected( const QString& theFileName ); private: - QGroupBox* myFileNameGroup; //!< The group for the source Strickler table file selection - QLineEdit* myFileName; //!< Source Strickler table file name input field - QToolButton* myBrowseBtn; - - QGroupBox* myNameGroup; //!< The group for the Strickler table name input field - QLineEdit* myName; //!< The Strickler table name input field - - QGroupBox* myTableGroup; //!< The group for the Strickler table table control and buttons - QTableWidget* myTable; //!< The table of Strickler coefficients - QToolButton* myAddBtn; //!< The add Strickler coefficient button - QToolButton* myRemoveBtn; //!< The remove Strickler coefficient button - QToolButton* myClearBtn; //!< The clear all Strickler coefficients button + int myType; + QLineEdit* myFileName; //!< Source Strickler table file name input field + QLineEdit* myName; //!< The Strickler table name input field + QTableWidget* myTable; //!< The table of Strickler coefficients + QToolButton* myAddBtn; //!< The add Strickler coefficient button + QToolButton* myRemoveBtn; //!< The remove Strickler coefficient button + QToolButton* myClearBtn; //!< The clear all Strickler coefficients button }; #endif diff --git a/src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx b/src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx index 464b7485..7cecf388 100644 --- a/src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StricklerTableOp.cxx @@ -19,8 +19,9 @@ #include "HYDROGUI_StricklerTableOp.h" #include "HYDROGUI_StricklerTableDlg.h" -#include "HYDROGUI_Tool.h" #include "HYDROGUI_DataObject.h" +#include "HYDROGUI_Operations.h" +#include "HYDROGUI_Tool.h" #include @@ -28,184 +29,197 @@ #include -HYDROGUI_StricklerTableOp::HYDROGUI_StricklerTableOp( HYDROGUI_Module* theModule, bool theIsEdit ) -: HYDROGUI_Operation( theModule ), - myIsEdit( theIsEdit ) +HYDROGUI_StricklerTableOp::HYDROGUI_StricklerTableOp( HYDROGUI_Module* theModule, int theType ) + : HYDROGUI_Operation( theModule ), + myType( theType ) { - setName( theIsEdit ? tr( "EDIT_STRICKLER_TABLE" ) : tr( "IMPORT_STRICKLER_TABLE" ) ); + setName( isEdit() ? tr( "EDIT_STRICKLER_TABLE" ) : tr( "IMPORT_STRICKLER_TABLE" ) ); } - HYDROGUI_StricklerTableOp::~HYDROGUI_StricklerTableOp() { } void HYDROGUI_StricklerTableOp::startOperation() { - HYDROGUI_Operation::startOperation(); + HYDROGUI_Operation::startOperation(); - HYDROGUI_StricklerTableDlg* aPanel = (HYDROGUI_StricklerTableDlg*)inputPanel(); - aPanel->reset(); - aPanel->setIsEdit( myIsEdit ); + HYDROGUI_StricklerTableDlg* aPanel = (HYDROGUI_StricklerTableDlg*)inputPanel(); + aPanel->reset(); - if( myIsEdit ) - { - if ( isApplyAndClose() ) - myEditedObject = Handle(HYDROData_StricklerTable)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); - if ( !myEditedObject.IsNull() ) + if ( !isImport() && isApplyAndClose() ) + myObject = Handle(HYDROData_StricklerTable)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + + if ( isEdit() ) { - // Edit selected Strickler table - - aPanel->setStricklerTableName( myEditedObject->GetName() ); - - // Get Strickler table data from the data model - // ... - - // The code below is a sample of data filling Strickler table - HYDROGUI_StricklerTableDlg::StricklerCoefficientList aData; - HYDROGUI_StricklerTableDlg::StricklerCoefficient aStricklerCoef1( "Zones de champs, prairies, sans cultures", 20.0 ); - HYDROGUI_StricklerTableDlg::StricklerCoefficient aStricklerCoef2( "Zones de champs cultivé à végétation basse", 17.5 ); - HYDROGUI_StricklerTableDlg::StricklerCoefficient aStricklerCoef3( "Zones de champs cultivé à végétation haute", 12.5 ); - HYDROGUI_StricklerTableDlg::StricklerCoefficient aStricklerCoef4( "Zones d'arbustes, de sous-bois", 10.0 ); - HYDROGUI_StricklerTableDlg::StricklerCoefficient aStricklerCoef5( "Zones à faible urbanization (bourg)", 9.0 ); - HYDROGUI_StricklerTableDlg::StricklerCoefficient aStricklerCoef6( "Zones à forte urbanization (agglomération)", 9.0 ); - HYDROGUI_StricklerTableDlg::StricklerCoefficient aStricklerCoef7( "Canaux naturels", 35.0 ); - HYDROGUI_StricklerTableDlg::StricklerCoefficient aStricklerCoef8( "Canaux artificiels en béton", 65.0 ); - aData.append( aStricklerCoef1 ); - aData.append( aStricklerCoef2 ); - aData.append( aStricklerCoef3 ); - aData.append( aStricklerCoef4 ); - aData.append( aStricklerCoef5 ); - aData.append( aStricklerCoef6 ); - aData.append( aStricklerCoef7 ); - aData.append( aStricklerCoef8 ); - aPanel->setData(aData); + if ( !myObject.IsNull() ) + { + // Edit selected Strickler table + aPanel->setTableName( myObject->GetName() ); + + // Get Strickler table data from the data model + HYDROGUI_StricklerTableDlg::StricklerCoefficientList aData; + TColStd_SequenceOfExtendedString aTypes = myObject->GetTypes(); + for ( int i = 1; i <= aTypes.Length(); i++ ) + aData.append( HYDROGUI_StricklerTableDlg::StricklerCoefficient( HYDROGUI_Tool::ToQString( aTypes.Value( i ) ), + myObject->Get( aTypes.Value( i ), 0 ) ) ); + + aPanel->setData( aData ); + } } - else + else if ( isExport() ) { - // Import Strickler table from file + if ( !myObject.IsNull() ) + aPanel->setTableName( myObject->GetName() ); } - } + aPanel->setTableNameReadOnly( isExport() ); } void HYDROGUI_StricklerTableOp::abortOperation() { - //... - - HYDROGUI_Operation::abortOperation(); + HYDROGUI_Operation::abortOperation(); } void HYDROGUI_StricklerTableOp::commitOperation() { - //... - - HYDROGUI_Operation::commitOperation(); + HYDROGUI_Operation::commitOperation(); } HYDROGUI_InputPanel* HYDROGUI_StricklerTableOp::createInputPanel() const { - HYDROGUI_StricklerTableDlg* aPanel = new HYDROGUI_StricklerTableDlg( module(), getName() ); - connect( aPanel, SIGNAL( fileSelected( const QString& ) ), SLOT( onFileSelected() ) ); - return aPanel; + int type = isEdit() ? HYDROGUI_StricklerTableDlg::Edit : ( isImport() ? HYDROGUI_StricklerTableDlg::Import : HYDROGUI_StricklerTableDlg::Export ); + HYDROGUI_StricklerTableDlg* aPanel = new HYDROGUI_StricklerTableDlg( module(), getName(), type ); + connect( aPanel, SIGNAL( fileSelected( const QString& ) ), SLOT( onFileSelected() ) ); + return aPanel; } bool HYDROGUI_StricklerTableOp::processApply( int& theUpdateFlags, QString& theErrorMsg, - QStringList& theBrowseObjectsEntries ) + QStringList& theBrowseObjectsEntries ) { - HYDROGUI_StricklerTableDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return false; - - QString aFilePath; - if( !myIsEdit ) - { - aFilePath = aPanel->getFileName(); - if ( aFilePath.isEmpty() ) + HYDROGUI_StricklerTableDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return false; + + QString aFilePath; + if( !isEdit() ) + { + aFilePath = aPanel->getFileName(); + if ( aFilePath.isEmpty() ) + { + theErrorMsg = tr( "SELECT_STRICKLER_TABLE_FILE" ).arg( aFilePath ); + return false; + } + } + + QString aStricklerTableName = aPanel->getTableName().simplified(); + if ( aStricklerTableName.isEmpty() ) + { + theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); + return false; + } + + if ( isImport() || ( isEdit() && !myObject.IsNull() && myObject->GetName() != aStricklerTableName ) ) + { + // check that there are no other objects with the same name in the document + Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), aStricklerTableName ); + if( !anObject.IsNull() ) + { + theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( aStricklerTableName ); + return false; + } + } + + Handle(HYDROData_StricklerTable) aStricklerTableObj; + if ( isImport() ) + { + aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( doc()->CreateObject( KIND_STRICKLER_TABLE ) ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ); + theBrowseObjectsEntries.append( anEntry ); + } + else + aStricklerTableObj = myObject; + + if ( aStricklerTableObj.IsNull() ) + return false; + + if ( isExport() ) + { + bool res = false; + QString aFilePath = aPanel->getFileName().simplified(); + if ( !aFilePath.isEmpty() ) + res = aStricklerTableObj->Export( HYDROGUI_Tool::ToAsciiString( aFilePath ) ); + return res; + } + + startDocOperation(); + + aStricklerTableObj->SetName( aStricklerTableName ); + + if( isEdit() ) + { + // Get data from input panel's table and save it into data model object + aStricklerTableObj->Clear(); + HYDROGUI_StricklerTableDlg::StricklerCoefficientList aData = aPanel->getData(); + for ( HYDROGUI_StricklerTableDlg::StricklerCoefficientList::iterator it = aData.begin(); it != aData.end(); ++it ) + { + const HYDROGUI_StricklerTableDlg::StricklerCoefficient& anInfo = *it; + aStricklerTableObj->Set( HYDROGUI_Tool::ToExtString( anInfo.myType ), anInfo.myCoefficient ); + } + } + else { - theErrorMsg = tr( "SELECT_STRICKLER_TABLE_FILE" ).arg( aFilePath ); - return false; + // Import data from Strickler table file into data model object + aStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( aFilePath ) ); } - } - - QString aStricklerTableName = aPanel->getStricklerTableName().simplified(); - if ( aStricklerTableName.isEmpty() ) - { - theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); - return false; - } - - if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != aStricklerTableName ) ) - { - // check that there are no other objects with the same name in the document - Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), aStricklerTableName ); - if( !anObject.IsNull() ) + + aStricklerTableObj->Update(); + + commitDocOperation(); + + if( !isEdit() ) { - theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( aStricklerTableName ); - return false; + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ); + theBrowseObjectsEntries.append( anEntry ); } - } - - Handle(HYDROData_StricklerTable) aStricklerTableObj; - if( myIsEdit ) - aStricklerTableObj = myEditedObject; - else - { - aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( doc()->CreateObject( KIND_STRICKLER_TABLE ) ); - QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ); - theBrowseObjectsEntries.append( anEntry ); - } - - if( aStricklerTableObj.IsNull() ) - return false; - - aStricklerTableObj->SetName( aStricklerTableName ); - - if( myIsEdit ) - { - // Get data from input panel's table and save it into data model object - - // Check, that type names are unique within the current - // Strickler table and show error message, if needed - - //... - } - else - { - // Import data from Strickler table file into data model object - aStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( aFilePath ) ); - } - - aStricklerTableObj->Update(); - - if( !myIsEdit ) - { - QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ); - theBrowseObjectsEntries.append( anEntry ); - } - - theUpdateFlags |= UF_ObjBrowser; - - return true; + + theUpdateFlags |= UF_ObjBrowser; + + return true; } void HYDROGUI_StricklerTableOp::onFileSelected() { - HYDROGUI_StricklerTableDlg* aPanel = - ::qobject_cast( inputPanel() ); - if ( !aPanel ) - return; - - QString anStricklerTableName = aPanel->getStricklerTableName().simplified(); - if ( anStricklerTableName.isEmpty() ) - { - anStricklerTableName = aPanel->getFileName(); - if ( !anStricklerTableName.isEmpty() ) { - anStricklerTableName = QFileInfo( anStricklerTableName ).baseName(); - } + HYDROGUI_StricklerTableDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; - if ( anStricklerTableName.isEmpty() ) { - anStricklerTableName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_STRICKLER_TABLE_NAME" ) ); + QString anStricklerTableName = aPanel->getTableName().simplified(); + if ( anStricklerTableName.isEmpty() ) + { + anStricklerTableName = aPanel->getFileName(); + if ( !anStricklerTableName.isEmpty() ) { + anStricklerTableName = QFileInfo( anStricklerTableName ).baseName(); + } + + if ( anStricklerTableName.isEmpty() ) { + anStricklerTableName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_STRICKLER_TABLE_NAME" ) ); + } + aPanel->setTableName( anStricklerTableName ); } - aPanel->setStricklerTableName( anStricklerTableName ); - } +} + +bool HYDROGUI_StricklerTableOp::isEdit() const +{ + return myType == EditStricklerTableId; +} + +bool HYDROGUI_StricklerTableOp::isImport() const +{ + return myType == ImportStricklerTableFromFileId; +} + +bool HYDROGUI_StricklerTableOp::isExport() const +{ + return myType == ExportStricklerTableFromFileId; } diff --git a/src/HYDROGUI/HYDROGUI_StricklerTableOp.h b/src/HYDROGUI/HYDROGUI_StricklerTableOp.h index a3b40e2f..3e2fc546 100644 --- a/src/HYDROGUI/HYDROGUI_StricklerTableOp.h +++ b/src/HYDROGUI/HYDROGUI_StricklerTableOp.h @@ -28,25 +28,30 @@ class HYDROGUI_StricklerTableOp : public HYDROGUI_Operation Q_OBJECT public: - HYDROGUI_StricklerTableOp( HYDROGUI_Module* theModule, bool isEdit ); - virtual ~HYDROGUI_StricklerTableOp(); + HYDROGUI_StricklerTableOp( HYDROGUI_Module*, int ); + virtual ~HYDROGUI_StricklerTableOp(); protected: - virtual void startOperation(); - virtual void abortOperation(); - virtual void commitOperation(); + virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); - virtual HYDROGUI_InputPanel* createInputPanel() const; + virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, - QStringList& theBrowseObjectsEntries ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); -protected slots: - void onFileSelected(); +protected Q_SLOTS: + void onFileSelected(); private: - bool myIsEdit; - Handle(HYDROData_StricklerTable) myEditedObject; + bool isEdit() const; + bool isImport() const; + bool isExport() const; + +private: + int myType; + Handle(HYDROData_StricklerTable) myObject; }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 0b6e4a6c..998b0f01 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2355,8 +2355,12 @@ Polyline should consist from one not closed curve. HYDROGUI_StricklerTableDlg - IMPORT_STRICKLER_TABLE_FROM_FILE - Import Strickler table from file + IMPORT_STRICKLER_TABLE_FILE + Import Strickler table file + + + EXPORT_STRICKLER_TABLE_FILE + Export Strickler table file FILE_NAME