HYDROGUI_ImportImageDlg.h
HYDROGUI_ImportImageOp.h
HYDROGUI_ImportPolylineOp.h
+ HYDROGUI_ImportLandCoverOp.h
+ HYDROGUI_ImportLandCoverDlg.h
HYDROGUI_ImportSinusXOp.h
HYDROGUI_ExportSinusXOp.h
HYDROGUI_ExportSinusXDlg.h
HYDROGUI_ImportImageOp.cxx
HYDROGUI_ImportPolylineOp.cxx
HYDROGUI_ImportSinusXOp.cxx
+ HYDROGUI_ImportLandCoverOp.cxx
+ HYDROGUI_ImportLandCoverDlg.cxx
HYDROGUI_ExportSinusXOp.cxx
HYDROGUI_ExportSinusXDlg.cxx
HYDROGUI_InputPanel.cxx
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ImportLandCoverDlg.h"
+
+#include <SUIT_MessageBox.h>
+
+#include <QTextEdit>
+#include <QListWidget>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+
+HYDROGUI_ImportLandCoverDlg::HYDROGUI_ImportLandCoverDlg( std::vector<SHPObject*> theSHPObjects, std::map<QListWidgetItem*, SHPObject*>& theWItemToSObjectMap, QWidget* theParent )
+: QtxDialog( theParent, false, true, QtxDialog::YesNo )
+{
+ setWindowTitle( tr( "IMPORT_LANDCOVER_OBJECTS" ) );
+ setButtonPosition( Left, Yes );
+ setButtonPosition( Right, No );
+
+ QLabel* anIconLabelLabel = new QLabel( mainFrame() );
+ anIconLabelLabel->setPixmap( SUIT_MessageBox::standardIcon( QMessageBox::Question ) );
+ anIconLabelLabel->setScaledContents( false );
+ anIconLabelLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
+
+ myObjectsLabel = new QLabel( tr( "CONFIRM_SELECTION" ), mainFrame() );
+
+ myListW = new QListWidget(mainFrame());
+ for (int i = 1 ; i <= theSHPObjects.size(); i++)
+ {
+ myListW->addItem("Polygon_" + QString::number(i));
+ }
+ myListW->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ QGridLayout* aLayout = new QGridLayout( mainFrame() );
+ aLayout->setMargin( 5 );
+ aLayout->setSpacing( 5 );
+ aLayout->addWidget( anIconLabelLabel, 0, 0 );
+ aLayout->addWidget( myObjectsLabel, 0, 1 );
+
+ aLayout->addWidget( myListW, 1, 0, 1, 2 );
+
+ if ( QPushButton* aYesBtn = ::qobject_cast<QPushButton*>( button( Yes ) ) )
+ {
+ setFocusProxy( aYesBtn );
+ aYesBtn->setAutoDefault( true );
+ aYesBtn->setDefault( true );
+ }
+ if ( QPushButton* aNoBtn = ::qobject_cast<QPushButton*>( button( No ) ) )
+ {
+ aNoBtn->setAutoDefault( true );
+ }
+
+ setMinimumSize( 350, 450 );
+}
+
+HYDROGUI_ImportLandCoverDlg::~HYDROGUI_ImportLandCoverDlg()
+{
+}
+
+QList<QListWidgetItem*> HYDROGUI_ImportLandCoverDlg::GetSelectedItems()
+{
+ return myListW->selectedItems();
+}
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+
+#ifndef HYDROGUI_ImportLandCoverDlg_H
+#define HYDROGUI_ImportLandCoverDlg_H
+
+#include <QtxDialog.h>
+
+class QLabel;
+class QTextEdit;
+class QListWidget;
+class QListWidgetItem;
+
+#include <shapelib/shapefil.h>
+
+class HYDROGUI_ImportLandCoverDlg : public QtxDialog
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_ImportLandCoverDlg( std::vector<SHPObject*> theSHPObjects,
+ std::map<QListWidgetItem*, SHPObject*>& theWItemToSObjectMap, QWidget* = 0 );
+ virtual ~HYDROGUI_ImportLandCoverDlg();
+
+public:
+ QList<QListWidgetItem*> GetSelectedItems();
+
+private:
+ QLabel* myObjectsLabel;
+ QListWidget* myListW;
+
+public:
+
+ int GetSeleItemsSize();
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ImportLandCoverOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_ImportLandCoverDlg.h"
+
+#include <HYDROGUI_DataObject.h>
+#include <HYDROData_Bathymetry.h>
+#include <HYDROData_Iterator.h>
+
+#include <HYDROData_Profile.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_FileDlg.h>
+#include <LightApp_Application.h>
+
+#include <QApplication>
+#include <QFile>
+#include <QFileInfo>
+#include <SUIT_MessageBox.h>
+
+#include <BRep_Builder.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+#include <BRepBuilderAPI_MakeEdge2d.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <gp_Pnt2d.hxx>
+#include <BRepTools.hxx>
+#include <gp_Pln.hxx>
+
+
+HYDROGUI_ImportLandCoverOp::HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+ setName( tr( "IMPORT_LANDCOVER" ) );
+}
+
+HYDROGUI_ImportLandCoverOp::~HYDROGUI_ImportLandCoverOp()
+{
+}
+
+void HYDROGUI_ImportLandCoverOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ myFileDlg = new SUIT_FileDlg( module()->getApp()->desktop(), true );
+ myFileDlg->setWindowTitle( getName() );
+ myFileDlg->setFileMode( SUIT_FileDlg::ExistingFiles );
+ myFileDlg->setFilter( tr("LANDCOVER_FILTER") );
+
+ connect( myFileDlg, SIGNAL( accepted() ), this, SLOT( onApply() ) );
+ connect( myFileDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
+
+ myFileDlg->exec();
+}
+
+void HYDROGUI_ImportLandCoverOp::onApply()
+{
+ if ( !myFileDlg )
+ {
+ abort();
+ return;
+ }
+
+ QString aFileName = myFileDlg->selectedFile();
+ if ( aFileName.isEmpty() )
+ {
+ abort();
+ return;
+ }
+
+ QString anExt = aFileName.split('.', QString::SplitBehavior::SkipEmptyParts).back();
+
+ if (anExt == "shp")
+ {
+ SHPHandle aHSHP;
+ aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
+ Parse(aHSHP);
+ std::map<QListWidgetItem*, SHPObject*> aWItemToSObjectMap;
+ HYDROGUI_ImportLandCoverDlg anImportLandCoverDlg( mySHPObjects, aWItemToSObjectMap, module()->getApp()->desktop() );
+ if ( anImportLandCoverDlg.exec() == HYDROGUI_ImportLandCoverDlg::Accepted )
+ {
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+
+ startDocOperation();
+
+ int T = anImportLandCoverDlg.GetSelectedItems().size();
+
+ TopoDS_Compound cmp;
+ BRep_Builder BB;
+ BB.MakeCompound(cmp);
+ TopoDS_Face F;
+ if (aHSHP->nShapeType == 5)
+ {
+ for (int i = 0; i < this->mySHPObjects.size(); i++) {
+ ProcessSHP(mySHPObjects[i], i, F);
+ BB.Add(cmp, F);
+ }
+ ///to hydro_landcover
+ // BRepTools::Write(cmp, "d:/h1.brep");
+ }
+ else
+ SUIT_MessageBox::warning( module()->getApp()->desktop(), "Import Land cover", "Cannot land cover;\nThe shape type is not polygon" );
+ 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 );
+
+ QApplication::restoreOverrideCursor();
+}
+
+
+
+void HYDROGUI_ImportLandCoverOp::Parse(SHPHandle theHandle)
+{
+ int aShapeType;
+ mySHPObjects.clear();
+ SHPGetInfo( theHandle, NULL, &aShapeType, NULL, NULL );
+ if (aShapeType == 5)
+ {
+ for (int i = 0; i < theHandle->nRecords; i++)
+ mySHPObjects.push_back(SHPReadObject(theHandle, i));
+ }
+}
+
+void HYDROGUI_ImportLandCoverOp::ProcessSHP(SHPObject* anObj, int i, TopoDS_Face& F)
+{
+ TopoDS_Wire W;
+ TopoDS_Edge E;
+ int nParts = anObj->nParts;
+ gp_Pln pln(gp_Pnt(0,0,0), gp_Dir(0,0,1));
+ BRepBuilderAPI_MakeFace aFBuilder(pln);
+ for ( int i = 0 ; i < nParts ; i++ )
+ {
+ BRepBuilderAPI_MakeWire aBuilder;
+ int StartIndex = anObj->panPartStart[i];
+ int EndIndex;
+ if (i != nParts - 1)
+ EndIndex = anObj->panPartStart[i + 1];
+ else
+ EndIndex = anObj->nVertices;
+
+ for ( int k = StartIndex; k < EndIndex - 1 ; k++ )
+ {
+ gp_Pnt2d P1 (anObj->padfX[k], anObj->padfY[k]);
+ gp_Pnt2d P2 (anObj->padfX[k+1], anObj->padfY[k+1]);
+ BRepBuilderAPI_MakeEdge2d aMakeEdge(P1, P2);
+ aBuilder.Add(TopoDS::Edge(aMakeEdge.Shape()));
+ }
+ aBuilder.Build();
+ W = TopoDS::Wire(aBuilder.Shape());
+ aFBuilder.Add(W);
+ }
+
+ aFBuilder.Build();
+ F = aFBuilder.Face();
+
+ //TODO build curve 3d
+
+ /*aPolylineXY->SetWireColor( HYDROData_PolylineXY::DefaultWireColor() );
+ aPolylineXY->SetName( theFileName + "_PolyXY_" + QString::number(theInd) );
+
+ aPolylineXY->Update();
+
+ size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
+ if ( anActiveViewId == 0 )
+ anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() );
+
+ module()->setObjectVisible( anActiveViewId, aPolylineXY, true );
+
+ module()->setIsToUpdate( aPolylineXY );*/
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_IMPORTLANDCOVER_H
+#define HYDROGUI_IMPORTLANDCOVER_H
+
+#include "HYDROGUI_Operation.h"
+#include <vector>
+
+//extern "C" {
+#include <shapelib/shapefil.h>
+//};
+
+class SUIT_FileDlg;
+class TopoDS_Face;
+
+class HYDROGUI_ImportLandCoverOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_ImportLandCoverOp();
+
+protected:
+ virtual void startOperation();
+ virtual void onApply();
+ void Parse(SHPHandle theHandle);
+ void ProcessSHP(SHPObject* anObj, int i, TopoDS_Face& F);
+
+private:
+ SUIT_FileDlg* myFileDlg;
+ std::vector<SHPObject*> mySHPObjects;
+};
+
+#endif
#include "HYDROGUI_ExportSinusXOp.h"
#include "HYDROGUI_MergePolylinesOp.h"
#include "HYDROGUI_SplitPolylinesOp.h"
+#include "HYDROGUI_ImportLandCoverOp.h"
#include <HYDROData_Document.h>
#include <HYDROData_Obstacle.h>
createAction( ImportPolylineId, "IMPORT_POLYLINE", "IMPORT_POLYLINE_ICO" );
createAction( ImportSinusXId, "IMPORT_SINUSX", "IMPORT_SINUSX_ICO" );
createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" );
+ createAction( ImportLandcoverId, "IMPORT_LANDCOVER", "IMPORT_LANDCOVER_ICO" );
createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" );
createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" );
createMenu( ImportPolylineId, aHydroId, -1, -1 );
createMenu( ImportSinusXId, aHydroId, -1, -1 );
createMenu( ExportSinusXId, aHydroId, -1, -1 );
+ createMenu( ImportLandcoverId, aHydroId, -1, -1 );
createMenu( ImportBathymetryId, aHydroId, -1, -1 );
createMenu( ImportStricklerTableFromFileId, aHydroId, -1, -1 );
createTool( ImportPolylineId, aToolBar );
createTool( ImportSinusXId, aToolBar );
createTool( ExportSinusXId, aToolBar );
+ createTool( ImportLandcoverId, aToolBar );
createTool( ImportBathymetryId, aToolBar );
createTool( CreatePolylineId, aToolBar );
case ExportPolylineId:
anOp = new HYDROGUI_ExportFileOp( aModule );
break;
+ case ImportLandcoverId:
+ anOp = new HYDROGUI_ImportLandCoverOp( aModule );
+ break;
case RemoveImageRefsId:
anOp = new HYDROGUI_RemoveImageRefsOp( aModule );
break;
ImportPolylineId,
ImportSinusXId,
ExportSinusXId,
-
ExportPolylineId,
+ ImportLandcoverId,
ImportStricklerTableFromFileId,
ExportStricklerTableFromFileId,
return;
}
- Handle(AIS_InteractiveContext) aCtx = NULL;
OCCViewer_ViewManager* aViewManager = getPreviewManager();
+ Handle(AIS_InteractiveContext) aCtx = NULL;
if ( aViewManager ) {
if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
aCtx = aViewer->getAISContext();
<source>DSK_IMPORT_POLYLINE</source>
<translation>Import polyline from file(s)</translation>
</message>
+ <message>
+ <source>DSK_IMPORT_LANDCOVER</source>
+ <translation>Import land cover from file(s)</translation>
+ </message>
<message>
<source>DSK_IMPORT_SINUSX</source>
<translation>Import from SinusX</translation>
<source>MEN_IMPORT_POLYLINE</source>
<translation>Import polyline</translation>
</message>
+ <message>
+ <source>MEN_IMPORT_LANDCOVER</source>
+ <translation>Import land cover from file(s)</translation>
+ </message>
<message>
<source>MEN_IMPORT_SINUSX</source>
<translation>Import from SinusX</translation>
<source>STB_IMPORT_POLYLINE</source>
<translation>Import polyline</translation>
</message>
+ <message>
+ <source>STB_IMPORT_LANDCOVER</source>
+ <translation>Import land cover from file(s)</translation>
+ </message>
<message>
<source>STB_IMPORT_SINUSX</source>
<translation>Import from SinusX</translation>
</context>
+ <context>
+ <name>HYDROGUI_ImportLandcoverOp</name>
+ <message>
+ <source>IMPORT_LANDCOVER</source>
+ <translation>Import Land cover</translation>
+ </message>
+ <message>
+ <source>LANDCOVER_FILTER</source>
+ <translation>Shape files (*.shp)</translation>
+ </message>
+ <message>
+ <source>BAD_IMPORTED_LANDCOVER_FILES</source>
+ <translation>Land cover import error</translation>
+ </message>
+ <message>
+ <source>NO_ONE_LANDCOVER_IMPORTED</source>
+ <translation>Land cover cannot be read from seleted file</translation>
+ </message>
+ </context>
+
+
<context>
<name>HYDROGUI_ImportSinusXOp</name>
<message>