{
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;
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;
#include <QApplication>
#include <QFile>
#include <QFileInfo>
-#include <QMessageBox>
+#include <SUIT_MessageBox.h>
HYDROGUI_ImportPolylineOp::HYDROGUI_ImportPolylineOp( HYDROGUI_Module* theModule )
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<int> anAllowedIndexes;
- for( ; anIter.More(); anIter.Next() )
- anExistingNames.push_back(anIter.Current()->GetName());
+ HYDROData_Iterator anIter( doc() );
+ int anInd = 0;
+ QStringList anExistingNames;
+ std::vector<int> 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();
}