X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ExportFileOp.cxx;h=b256ba4f28d70a4b9376bde57cff4aef3c63ecd7;hb=d37ac478f4055b8698aa200b8878af2cb6af5e45;hp=72915e5d7d2bd5bb15c6d035fa20e8dcfa2f86e2;hpb=6dd1807886655d96b021fbfb6ba736d79d49a492;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx index 72915e5d..b256ba4f 100644 --- a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx @@ -21,13 +21,16 @@ #include "HYDROGUI_DataModel.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_UpdateFlags.h" -#include "HYDROGUI_Tool.h" +#include "HYDROGUI_Tool2.h" +#include "HYDROGUI_ExportLandCoverMapDlg.h" #include #include #include #include #include +#include + #include #include @@ -50,6 +53,12 @@ #include #include #include +#include +#include +#include + +#include +#include HYDROGUI_ExportFileOp::HYDROGUI_ExportFileOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ) @@ -104,9 +113,77 @@ void HYDROGUI_ExportFileOp::startOperation() else { //Export polygons - //aSeq.Size() <= 1 + //Extract all attribute names from all strickler tables + Handle_HYDROData_Document aDoc = HYDROData_Document::Document( application()->activeStudy()->id() ); + QSet anAttrNames; + //use QSet to store attribute names. Yet it's not so good if the document contains two strickler types + //with the same name + if (aDoc) + { + HYDROData_Iterator anIt( aDoc, KIND_STRICKLER_TABLE ); + for( ; anIt.More(); anIt.Next() ) + { + Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() ); + if ( !aStricklerTableObj.IsNull()) + anAttrNames << aStricklerTableObj->GetAttrName(); + } + } + else + return; + + QStringList SortedListOfAttr = anAttrNames.toList(); + SortedListOfAttr.sort(); + // Handle_HYDROData_LandCoverMap aLCM = Handle(HYDROData_LandCoverMap)::DownCast( aSeq(1) ); - anExporter.Export(aFileName, aLCM, aNonExpList); + bool IsLinear = aLCM->CheckLinear(); + HYDROGUI_ExportLandCoverMapDlg aDlg( module()->getApp()->desktop(), IsLinear, SortedListOfAttr); + if ( aDlg.exec() == HYDROGUI_ExportLandCoverMapDlg::Accepted ) + { + //In our case : aSeq.Size() == 1 + //Export of multiple landcover maps into the one shp-file is disallowed. + QString aCItem = aDlg.getCurrentItem(); + Handle(HYDROData_StricklerTable) aStricklerTableObj; + { + HYDROData_Iterator anIt( aDoc, KIND_STRICKLER_TABLE ); + for( ; anIt.More(); anIt.Next() ) + { + aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() ); + if ( !aStricklerTableObj.IsNull() && aStricklerTableObj->GetAttrName() == aCItem) + break; + } + } + + //export shape-data + anExporter.Export(aFileName, aLCM, aNonExpList, false, !IsLinear, aDlg.getDeflValue()); + QString aDBFFileName = aFileName.replace( ".shp", ".dbf", Qt::CaseInsensitive); + //Even if attribute-checkbox is unchecked, the .dbf-file should be removed. + //otherwise it may be used with wrong .shp-file. This is an incorrect behaivor. + remove (aDBFFileName.toStdString().c_str()); + bool bToSaveAttrInfo = aDlg.getAttrCheckBoxState() && !aDlg.getCurrentItem().isEmpty(); + if (bToSaveAttrInfo) + { + //export attribute info + QStringList anAttrValues; + QStringList aStricklerTypes; + if (aNonExpList.empty()) + { + HYDROData_LandCoverMap::Explorer aLCMIt( aLCM ); + for( ; aLCMIt.More(); aLCMIt.Next() ) + { + QString aST = aLCMIt.StricklerType(); + anAttrValues << aStricklerTableObj->GetAttrValue(aST); + aStricklerTypes << aST; + } + } + aLCM->ExportDBF(aDBFFileName, aCItem, anAttrValues, aStricklerTypes); + } + } + else + { + abort(); + return; + } + } if (!aNonExpList.empty())