#include <HYDROGUI_ZLayers.h>
#include <HYDROGUI_DataObject.h>
-#include <HYDROData_Bathymetry.h>
#include <HYDROData_Iterator.h>
#include <HYDROData_Profile.h>
HYDROGUI_ImportLandCoverOp::~HYDROGUI_ImportLandCoverOp()
{
-
+ erasePreview();
}
void HYDROGUI_ImportLandCoverOp::startOperation()
{
HYDROGUI_Operation::startOperation();
+
+ if ( !getPreviewManager() ) {
+ setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>(
+ module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
+ }
+
+ if ( !isApplyAndClose() ) {
+ return;
+ }
+
+ HYDROGUI_ImportLandCoverDlg* aPanel =
+ ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
+ if ( !aPanel ) {
+ return;
+ }
+
+ aPanel->reset();
}
return aPanel;
}
-void HYDROGUI_ImportLandCoverOp::onApply()
+bool HYDROGUI_ImportLandCoverOp::processApply( int& theUpdateFlags,
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
if ( !aPanel ) {
- return;
+ return false;
}
QStringList aSelectedtPolygons = aPanel->getSelectedPolygonNames();
}
if( !aLC.IsNull() )
{
- aLC->SetName( aPanel->getFileName() + "_polygon_" );
+ QString aLCName = aPanel->getObjectName() + "_polygon";
+ int i = 0;
+ for( ;HYDROGUI_Tool::FindObjectByName(module(), aLCName); i++)
+ aLCName = aPanel->getObjectName() + "_polygon_" + QString::number(i);
+ aLC->SetName( aLCName );
aLC->SetFillingColor( HYDROData_LandCover::DefaultFillingColor() );
aLC->SetBorderColor( HYDROData_LandCover::DefaultBorderColor() );
}
module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
-
- QApplication::restoreOverrideCursor();
-}
+ if ( isApplyAndClose() )
+ erasePreview();
+
+ return true;
+}
void HYDROGUI_ImportLandCoverOp::Parse(SHPHandle theHandle)
gp_Pln pln(gp_Pnt(0,0,0), gp_Dir(0,0,1));
BRepBuilderAPI_MakeFace aFBuilder(pln);
- Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
- sfs->FixFaceTool()->FixOrientationMode() = 1;
-
+ //Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
+ //sfs->FixFaceTool()->FixOrientationMode() = 1;
+
for ( int i = 0 ; i < nParts ; i++ )
{
BRepBuilderAPI_MakeWire aBuilder;
{
gp_Pnt P1 (anObj->padfX[k], anObj->padfY[k], 0);
gp_Pnt P2 (anObj->padfX[k+1], anObj->padfY[k+1], 0);
+ if (P1.Distance(P2) < Precision::Confusion())
+ continue;
BRepBuilderAPI_MakeEdge aMakeEdge(P1, P2);
aBuilder.Add(TopoDS::Edge(aMakeEdge.Shape()));
}
aFBuilder.Build();
TopoDS_Face DF = aFBuilder.Face();
- BRepLib::BuildCurves3d(DF);
+ BRepLib::BuildCurves3d(DF);
+ bool IsInf = DF.Infinite();
if(!DF.IsNull())
{
- sfs->Init ( DF );
- sfs->Perform();
- F = TopoDS::Face(sfs->Shape());
+ //sfs->Init ( DF );
+ //sfs->Perform();
+ F = DF; //TopoDS::Face(sfs->Shape());
}
}
HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
if ( !aPanel )
return;
-
+
QString anObjectName = aPanel->getObjectName().simplified();
- anObjectName = aPanel->getFileName();
- if ( !anObjectName.isEmpty() ) {
- anObjectName = QFileInfo( anObjectName ).baseName();
- }
+ anObjectName = aPanel->getFileName();
+ if ( !anObjectName.isEmpty() )
+ anObjectName = QFileInfo( anObjectName ).baseName();
- if ( anObjectName.isEmpty() ) {
- anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_BATHYMETRY_NAME" ) );
- }
- aPanel->setObjectName( anObjectName );
+ if ( anObjectName.isEmpty() )
+ anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LANDCOVER_NAME" ) );
+ aPanel->setObjectName( anObjectName );
- QString aFileName = aPanel->getFileName();
+ QString aFileName = aPanel->getFileName();
if ( aFileName.isEmpty() )
{
abort();
SHPHandle aHSHP;
aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
Parse(aHSHP);
-
+
startDocOperation();
QStringList aPolygonsList;
- for (int i = 1; i < mySHPObjects.size(); i++)
- aPolygonsList.append("polygon_" + QString::number(i));
+ for (int i = 0; i < mySHPObjects.size(); i++)
+ aPolygonsList.append("polygon_" + QString::number(i + 1));
aPanel->setPolygonNames(aPolygonsList);
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
}
}
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+
TopTools_SequenceOfShape aFaces;
TopoDS_Face aF;
if (aHSHP->nShapeType == 5)
{
- for (int i = 1; i < 4 /*mySHPObjects.size()*/; i++) { ///TODO temp
+ for (int i = 0; i < mySHPObjects.size(); i++)
+ {
ProcessSHP(mySHPObjects[i], i, aF);
aFaces.Append(aF);
}
}
else
SUIT_MessageBox::warning( module()->getApp()->desktop(), "Import Land cover", "Cannot land cover;\nThe shape type is not polygon" );
-
+ QApplication::restoreOverrideCursor();
Handle(HYDROData_LandCover) aLC = Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) );
for ( int i = 1; i <= aFaces.Length(); i++ )
if( !aFace.IsNull() )
aShape->setShape( aLC->GetShape() );
myPolygonName2PrsShape.insert( "polygon_" + QString::number(i), aShape);
-
}
-
}
aLC->Remove();
}
}
- if ( !aCtx.IsNull() ) {
+ if ( !aCtx.IsNull() )
+ {
QStringList aSelectedNames;
-
foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObject() );
if ( isSelected ) {
aSelectedNames << aName;
}
}
-
aPanel->setSelectedPolygonNames( aSelectedNames );
}
}