From: isn Date: Thu, 25 Jun 2015 13:45:46 +0000 (+0300) Subject: Import/Export >> some minor corrections X-Git-Tag: v1.4.2~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ac939ad4e77e0fe3facca2a640e14b90457aaa6f;p=modules%2Fhydro.git Import/Export >> some minor corrections --- diff --git a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx index 17d24d16..b52e18b0 100644 --- a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx @@ -64,7 +64,7 @@ void HYDROGUI_ExportFileOp::startOperation() { HYDROGUI_Operation::startOperation(); - QString aFilter( tr("SHP_FILTER") ); //temp ext-n; replace with filter; TODO + QString aFilter( tr("SHP_FILTER") ); Handle(HYDROData_PolylineXY) aPolyXY; Handle(HYDROData_Polyline3D) aPoly3D; @@ -93,7 +93,12 @@ void HYDROGUI_ExportFileOp::startOperation() SUIT_MessageBox::warning( module()->getApp()->desktop(), "Export Polyline", "Cannot export polylines of different kind"); else { - QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), "", aFilter, tr( "EXPORT_TO_SHAPE_FILE" ), false ); + QString aPolyName = ""; + if (aPolyXYSeq.Size() == 1 && aPoly3DSeq.IsEmpty()) + aPolyName = aPolyXYSeq(1)->GetName(); + if (aPoly3DSeq.Size() == 1 && aPolyXYSeq.IsEmpty()) + aPolyName = aPoly3DSeq(1)->GetName(); + QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), aPolyName, aFilter, tr( "EXPORT_TO_SHAPE_FILE" ), false ); if (!aFileName.isEmpty()) { SHPHandle hSHPHandle; diff --git a/src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx b/src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx index 5151349c..e7063383 100644 --- a/src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx @@ -320,7 +320,7 @@ void HYDROGUI_ImportLandCoverOp::onFileSelected() } } else - SUIT_MessageBox::warning( module()->getApp()->desktop(), "Import Land cover", "Cannot land cover;\nThe shape type is not polygon" ); + SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_LANDCOVER" ), "Cannot import land cover;\nThe shape type is not polygon" ); QApplication::restoreOverrideCursor(); Handle(HYDROData_LandCover) aLC = Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) ); diff --git a/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx b/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx index 1d02a454..a3c7f833 100644 --- a/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx @@ -41,7 +41,7 @@ #include #include #include -#include +#include HYDROGUI_ImportPolylineOp::HYDROGUI_ImportPolylineOp( HYDROGUI_Module* theModule ) @@ -77,82 +77,91 @@ void HYDROGUI_ImportPolylineOp::onApply() return; } - QString aFileName = myFileDlg->selectedFile(); - if ( aFileName.isEmpty() ) + QStringList aFileNames = myFileDlg->selectedFiles(); + + QApplication::setOverrideCursor( Qt::WaitCursor ); + startDocOperation(); + + foreach (QString aFileName, aFileNames) { - abort(); - return; - } + if ( aFileName.isEmpty() ) + continue; - QString anExt = aFileName.split('.', QString::SkipEmptyParts).back(); + QString anExt = aFileName.split('.', QString::SkipEmptyParts).back(); - if (anExt == "shp") - { - SHPHandle aHSHP; - aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" ); - Parse(aHSHP); - - QApplication::setOverrideCursor( Qt::WaitCursor ); - - startDocOperation(); + if (anExt == "shp") + { + SHPHandle aHSHP; + aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" ); + Parse(aHSHP); - HYDROData_Iterator anIter( doc() ); - int anInd = 0; - QStringList anExistingNames; - std::vector anAllowedIndexes; - for( ; anIter.More(); anIter.Next() ) - anExistingNames.push_back(anIter.Current()->GetName()); + HYDROData_Iterator anIter( doc() ); + int anInd = 0; + QStringList anExistingNames; + std::vector anAllowedIndexes; + for( ; anIter.More(); anIter.Next() ) + anExistingNames.push_back(anIter.Current()->GetName()); - QFileInfo aFileInfo(aFileName); - QString aBaseFileName = aFileInfo.baseName(); + QFileInfo aFileInfo(aFileName); + QString aBaseFileName = aFileInfo.baseName(); - if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23) - { - anInd = 0; - for (;anAllowedIndexes.size() < mySHPObjects.size();) + if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23) { - if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd))) + anInd = 0; + for (;anAllowedIndexes.size() < mySHPObjects.size();) { - anAllowedIndexes.push_back(anInd); - anInd++; + if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd))) + { + anAllowedIndexes.push_back(anInd); + anInd++; + } + else + anInd++; + } + + for (size_t i = 0; i < mySHPObjects.size(); i++ ) + { + ProcessSHPPolyXY(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]); } - else - anInd++; - } - - for (size_t i = 0; i < mySHPObjects.size(); i++ ) - { - ProcessSHPPolyXY(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]); } - } - else if (aHSHP->nShapeType == 13) - { - anInd = 0; - for (;anAllowedIndexes.size() < mySHPObjects.size();) + else if (aHSHP->nShapeType == 13) { - if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)) && - !anExistingNames.contains(aBaseFileName + "_Poly3D_" + QString::number(anInd)) && - !anExistingNames.contains(aBaseFileName + "_Bath_" + QString::number(anInd))) + anInd = 0; + for (;anAllowedIndexes.size() < mySHPObjects.size();) { - anAllowedIndexes.push_back(anInd); - anInd++; + if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)) && + !anExistingNames.contains(aBaseFileName + "_Poly3D_" + QString::number(anInd)) && + !anExistingNames.contains(aBaseFileName + "_Bath_" + QString::number(anInd))) + { + anAllowedIndexes.push_back(anInd); + anInd++; + } + else + anInd++; } - else - anInd++; + for (size_t i = 0; i < mySHPObjects.size(); i++ ) + ProcessSHPPoly3D(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]); } + else + { + SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), "Cannot import polyline;\nThe shape type is incorrect" ); + } + for (size_t i = 0; i < mySHPObjects.size(); i++ ) - ProcessSHPPoly3D(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]); + free (mySHPObjects[i]); + + mySHPObjects.clear(); + SHPClose(aHSHP); } + } + if (!aFileNames.empty()) + { commitDocOperation(); commit(); - - for (size_t i = 0; i < mySHPObjects.size(); i++ ) - free (mySHPObjects[i]); - - mySHPObjects.clear(); - SHPClose(aHSHP); + module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init ); } - module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init ); + else + abort(); QApplication::restoreOverrideCursor(); }