From: isn Date: Mon, 26 Oct 2015 17:02:08 +0000 (+0300) Subject: LCM // Import/Export of SHP p.1 X-Git-Tag: v1.5~58^2~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bfb47f35b807312281b69a52494b9147c22759dd;p=modules%2Fhydro.git LCM // Import/Export of SHP p.1 --- diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index ff197152..00592dd7 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -200,6 +200,24 @@ const ObjectKind HYDROData_LandCoverMap::GetKind() const return KIND_LAND_COVER_MAP; } +int HYDROData_LandCoverMap::GetLCCount() const +{ + Iterator anIt( *this ); + int i = 0; + for( ; anIt.More(); anIt.Next() ) + i++; + return i; +} + +bool HYDROData_LandCoverMap::IsEmpty() const +{ + Iterator anIt( *this ); + if ( anIt.More() ) + return true; + else + return false; +} + /** Load attributes from DBF File /// diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index cf6b7ca5..75c2182e 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -110,6 +110,9 @@ public: HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + HYDRODATA_EXPORT int GetLCCount() const; + HYDRODATA_EXPORT bool IsEmpty() const; + protected: void SetShape( const TopoDS_Shape& ); diff --git a/src/HYDROData/HYDROData_ShapeFile.cxx b/src/HYDROData/HYDROData_ShapeFile.cxx index 688ef2b9..ef50acef 100644 --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -63,10 +64,9 @@ HYDROData_ShapeFile::~HYDROData_ShapeFile() void HYDROData_ShapeFile::Export(const QString& aFileName, NCollection_Sequence aPolyXYSeq, NCollection_Sequence aPoly3DSeq, - const Handle_HYDROData_LandCoverMap& aLCSeq, + const Handle_HYDROData_LandCoverMap& aLCM, QStringList& aNonExpList) { - /*TODO SHPHandle hSHPHandle; if (!aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty()) { @@ -83,12 +83,19 @@ void HYDROData_ShapeFile::Export(const QString& aFileName, if (WriteObjectPoly3D(hSHPHandle, aPoly3DSeq(i)) != 1) aNonExpList.append(aPoly3DSeq(i)->GetName()); } - else if (aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty() && !aLCSeq.IsEmpty()) + else if (aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty() && !aLCM->IsEmpty()) { hSHPHandle = SHPCreate( aFileName.toAscii().data(), SHPT_POLYGON ); - for (int i = 1; i <= aLCSeq.Size(); i++) + HYDROData_LandCoverMap::Iterator It( aLCM ); + for( ; It.More(); It.Next() ) + { + TopoDS_Face aFace = It.Face(); + if (WriteObjectPolygon(hSHPHandle, aFace) != 1) + aNonExpList.append(aLCM->GetName() + "_" + QString::number(It.Index())); + } + /*for (int i = 1; i <= aLCSeq.Size(); i++) if (WriteObjectLC(hSHPHandle, aLCSeq(i)) != 1) - aNonExpList.append(aLCSeq(i)->GetName()); + aNonExpList.append(aLCSeq(i)->GetName());*/ } if (hSHPHandle->nRecords > 0) SHPClose( hSHPHandle ); @@ -98,7 +105,7 @@ void HYDROData_ShapeFile::Export(const QString& aFileName, QString aFN = aFileName.simplified(); remove (aFN.toStdString().c_str()); remove (aFN.replace( ".shp", ".shx", Qt::CaseInsensitive).toStdString().c_str()); - }*/ + } } int HYDROData_ShapeFile::WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly ) @@ -168,12 +175,11 @@ int HYDROData_ShapeFile::WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROD return 1; } -/*TODO:int HYDROData_ShapeFile::WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC ) +int HYDROData_ShapeFile::WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape ) { - TopoDS_Shape aSh = theLC->GetShape(); - if (aSh.IsNull()) + if (theInputShape.IsNull()) return 0; - TopExp_Explorer anEdgeEx(aSh, TopAbs_EDGE); + TopExp_Explorer anEdgeEx(theInputShape, TopAbs_EDGE); for (; anEdgeEx.More(); anEdgeEx.Next()) { TopoDS_Edge E = TopoDS::Edge(anEdgeEx.Current()); @@ -194,13 +200,13 @@ int HYDROData_ShapeFile::WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROD } } - if (aSh.ShapeType() == TopAbs_FACE) + if (theInputShape.ShapeType() == TopAbs_FACE) { - ProcessFace(TopoDS::Face(aSh), theShpHandle); + ProcessFace(TopoDS::Face(theInputShape), theShpHandle); } - else if (aSh.ShapeType() == TopAbs_COMPOUND) + else if (theInputShape.ShapeType() == TopAbs_COMPOUND) { - TopExp_Explorer Ex(aSh, TopAbs_FACE); + TopExp_Explorer Ex(theInputShape, TopAbs_FACE); for (; Ex.More(); Ex.Next()) { TopoDS_Face aF = TopoDS::Face(Ex.Current()); @@ -215,7 +221,7 @@ int HYDROData_ShapeFile::WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROD return 1; } -*/ + void HYDROData_ShapeFile::ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle) { SHPObject *aSHPObj; @@ -257,7 +263,6 @@ void HYDROData_ShapeFile::ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandl } //x.push_back( aNPnts(1).X()); //y.push_back( aNPnts(1).Y()); - } aSHPObj = SHPCreateObject( SHPT_POLYGON, -1, NbWires, &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL ); @@ -333,15 +338,9 @@ void HYDROData_ShapeFile::ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F BRepBuilderAPI_MakeFace aFBuilder(pln, TopoDS::Wire(aWires(1))); for (int i = 2; i <= aWires.Length(); i++) aFBuilder.Add(TopoDS::Wire(aWires(i))); - TopoDS_Face DF = TopoDS::Face(aFBuilder.Shape()); + F = TopoDS::Face(aFBuilder.Shape()); - BRepLib::BuildCurves3d(DF); - if(!DF.IsNull()) - { - //sfs->Init ( DF ); - //sfs->Perform(); - F = DF; //TopoDS::Face(sfs->Shape()); - } + BRepLib::BuildCurves3d(F); } int HYDROData_ShapeFile::ImportLandCovers(const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile) diff --git a/src/HYDROData/HYDROData_ShapeFile.h b/src/HYDROData/HYDROData_ShapeFile.h index 88e3f3af..bd33a735 100644 --- a/src/HYDROData/HYDROData_ShapeFile.h +++ b/src/HYDROData/HYDROData_ShapeFile.h @@ -34,6 +34,7 @@ class Handle_HYDROData_Polyline3D; class Handle(HYDROData_Document); class TopTools_SequenceOfShape; class TopoDS_Face; +class TopoDS_Shape; class Handle_HYDROData_Entity; class Handle_HYDROData_LandCoverMap; @@ -83,11 +84,11 @@ public: HYDRODATA_EXPORT void Export(const QString& aFileName, NCollection_Sequence aPolyXYSeq, NCollection_Sequence aPoly3DSeq, - const Handle_HYDROData_LandCoverMap& aLCSeq, + const Handle_HYDROData_LandCoverMap& aLCM, QStringList& aNonExpList); int WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly ); int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly ); - //TODO:int WriteObjectLC(SHPHandle theShpHandle, Handle_HYDROData_LandCover theLC ); + int WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape ); //Import bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile); //Import Landcover diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index bbaf85f3..6c670c1d 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -36,6 +36,8 @@ set(PROJECT_HEADERS HYDROGUI_ImportBathymetryOp.h HYDROGUI_ImportImageDlg.h HYDROGUI_ImportImageOp.h + HYDROGUI_ImportLandCoverMapOp.h + HYDROGUI_ImportLandCoverMapDlg.h HYDROGUI_ImportPolylineOp.h HYDROGUI_ImportSinusXOp.h HYDROGUI_ExportSinusXOp.h @@ -173,6 +175,8 @@ set(PROJECT_SOURCES HYDROGUI_ImportBathymetryOp.cxx HYDROGUI_ImportImageDlg.cxx HYDROGUI_ImportImageOp.cxx + HYDROGUI_ImportLandCoverMapOp.cxx + HYDROGUI_ImportLandCoverMapDlg.cxx HYDROGUI_ImportPolylineOp.cxx HYDROGUI_ImportSinusXOp.cxx HYDROGUI_ExportSinusXOp.cxx diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx deleted file mode 100644 index 0e1f4772..00000000 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx +++ /dev/null @@ -1,225 +0,0 @@ -// 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -HYDROGUI_ImportLandCoverDlg::HYDROGUI_ImportLandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_Wizard( theModule, theTitle ) -{ - addPage( createPage1() ); - addPage( createPage2() ); -} - -QWizardPage* HYDROGUI_ImportLandCoverDlg::createPage1() { - QWizardPage* aPage = new QWizardPage( mainFrame() ); - QFrame* aFrame = new QFrame( aPage ); - - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - - myFileNameGroup = new QGroupBox( tr( "IMPORT_LANDCOVER_FROM_FILE" ) ); - - QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup ); - - myFileName = new QLineEdit( myFileNameGroup ); - myFileName->setReadOnly( true ); - - QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup ); - aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); - - QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup ); - aFileNameLayout->setMargin( 5 ); - aFileNameLayout->setSpacing( 5 ); - aFileNameLayout->addWidget( aFileNameLabel ); - aFileNameLayout->addWidget( myFileName ); - aFileNameLayout->addWidget( aBrowseBtn ); - - myObjectNameGroup = new QGroupBox( tr( "LANDCOVER_NAME" ) ); - - QLabel* aLandcoverNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup ); - myObjectName = new QLineEdit( myObjectNameGroup ); - - QBoxLayout* aLandcoverNameLayout = new QHBoxLayout( myObjectNameGroup ); - aLandcoverNameLayout->setMargin( 5 ); - aLandcoverNameLayout->setSpacing( 5 ); - aLandcoverNameLayout->addWidget( aLandcoverNameLabel ); - aLandcoverNameLayout->addWidget( myObjectName ); - - QGroupBox* aPolygonsGroup = new QGroupBox( tr( "FOUNDED_POLYGONS" ) ); - myPolygons = new QListWidget( aPolygonsGroup ); - myPolygons->setSelectionMode( QListWidget::ExtendedSelection ); - myPolygons->setEditTriggers( QListWidget::NoEditTriggers ); - myPolygons->setViewMode( QListWidget::ListMode ); - myPolygons->setSortingEnabled( false ); - - QBoxLayout* aPolygonsLayout = new QVBoxLayout; - aPolygonsLayout->addWidget( myPolygons ); - aPolygonsGroup->setLayout( aPolygonsLayout ); - - // Layout - QVBoxLayout* aPageLayout = new QVBoxLayout; - aPageLayout->setMargin( 5 ); - aPageLayout->setSpacing( 5 ); - aPageLayout->addWidget( myFileNameGroup ); - aPageLayout->addWidget( myObjectNameGroup ); - aPageLayout->addWidget( aPolygonsGroup ); - aPage->setLayout( aPageLayout ); - - // Conections - connect( myPolygons, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) ); - connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); - - return aPage; -} - -QWizardPage* HYDROGUI_ImportLandCoverDlg::createPage2() { - QWizardPage* aPage = new QWizardPage( mainFrame() ); - QFrame* aFrame = new QFrame( aPage ); - - myAttrNameGroup = new QGroupBox( "Available attributes" ); - - QCheckBox* anAttrCheckBox = new QCheckBox( "Use dBase attributes as a Strickler Types", myAttrNameGroup ); - - QBoxLayout* aFileNameLayout = new QHBoxLayout( myAttrNameGroup ); - aFileNameLayout->setMargin( 5 ); - aFileNameLayout->setSpacing( 5 ); - aFileNameLayout->addWidget( anAttrCheckBox ); - - - myDBFAttr = new QListWidget( aPage ); - myDBFAttr->setSelectionMode( QListWidget::ExtendedSelection ); - myDBFAttr->setEditTriggers( QListWidget::NoEditTriggers ); - myDBFAttr->setViewMode( QListWidget::ListMode ); - myDBFAttr->setSortingEnabled( false ); - - // Layout - QVBoxLayout* aPageLayout = new QVBoxLayout; - aPageLayout->setMargin( 5 ); - aPageLayout->setSpacing( 5 ); - aPageLayout->addWidget( myAttrNameGroup ); - aPageLayout->addWidget( myDBFAttr ); - aPage->setLayout( aPageLayout ); - return aPage; -} - - - -HYDROGUI_ImportLandCoverDlg::~HYDROGUI_ImportLandCoverDlg() -{ -} - -void HYDROGUI_ImportLandCoverDlg::reset() -{ - myPolygons->clear(); -} - -void HYDROGUI_ImportLandCoverDlg::setPolygonNames( const QStringList& theNames ) -{ - myPolygons->clear(); - myPolygons->addItems( theNames ); -} - -void HYDROGUI_ImportLandCoverDlg::removePolygonNames( const QStringList& theNames ) -{ - QList aFoundItems; - - foreach ( const QString& aName, theNames ) { - aFoundItems = myPolygons->findItems( aName, Qt::MatchExactly ); - foreach ( QListWidgetItem* anItem, aFoundItems ) { - anItem = myPolygons->takeItem( myPolygons->row( anItem ) ); - delete anItem; - } - } -} - -void HYDROGUI_ImportLandCoverDlg::setSelectedPolygonNames( const QStringList& theNames ) -{ - myPolygons->clearSelection(); - - foreach( const QString aName, theNames ) { - QList anItems = myPolygons->findItems( aName, Qt::MatchExactly ); - if ( anItems.count() == 1 ) { - anItems.first()->setSelected( true ); - } - } -} - -void HYDROGUI_ImportLandCoverDlg::onItemSelectionChanged() -{ - emit selectionChanged( getSelectedPolygonNames() ); -} - -QStringList HYDROGUI_ImportLandCoverDlg::getSelectedPolygonNames() const -{ - QStringList aSelectedNames; - - QList aSelectedItems = myPolygons->selectedItems(); - foreach( const QListWidgetItem* anItem, aSelectedItems ) { - aSelectedNames << anItem->text(); - } - - return aSelectedNames; -} - - -void HYDROGUI_ImportLandCoverDlg::onBrowse() -{ - QString aFilter( tr( "LANDCOVER_FILTER" ) ); - QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_LANDCOVER_FROM_FILE" ), true ); - - if( !aFileName.isEmpty() ) - { - setFileName( aFileName ); - emit FileSelected( aFileName ); - } -} - -void HYDROGUI_ImportLandCoverDlg::setObjectName( const QString& theName ) -{ - myObjectName->setText( theName ); - myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileName->text().isEmpty() ); -} - -QString HYDROGUI_ImportLandCoverDlg::getObjectName() const -{ - return myObjectName->text(); -} - -void HYDROGUI_ImportLandCoverDlg::setFileName( const QString& theFileName ) -{ - myFileName->setText( theFileName ); - - if ( !myObjectNameGroup->isEnabled() ) - myObjectNameGroup->setEnabled( !theFileName.isEmpty() ); -} - -QString HYDROGUI_ImportLandCoverDlg::getFileName() const -{ - return myFileName->text(); -} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.h b/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.h deleted file mode 100644 index 581956da..00000000 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.h +++ /dev/null @@ -1,83 +0,0 @@ -// 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 "HYDROGUI_Wizard.h" - -class QListWidget; -class QLineEdit; -class QGroupBox; - -class HYDROGUI_ImportLandCoverDlg : public HYDROGUI_Wizard -{ - Q_OBJECT - -public: - HYDROGUI_ImportLandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle ); - virtual ~HYDROGUI_ImportLandCoverDlg(); - - void reset(); - - void setPolygonNames( const QStringList& theNames ); - void removePolygonNames( const QStringList& theNames ); - - void setSelectedPolygonNames( const QStringList& theNames ); - - QStringList getSelectedPolygonNames() const; - - void setObjectName( const QString& theName ); - QString getObjectName() const; - - void setFileName( const QString& theFileName ); - QString getFileName() const; - -signals: - void FileSelected( const QString& theFileName ); - -protected slots: - void onBrowse(); - -signals: - void selectionChanged( const QStringList& ); - -public slots: - void onItemSelectionChanged(); - -private: - - QWizardPage* createPage1(); - QWizardPage* createPage2(); - - QLineEdit* myFileName; - QGroupBox* myFileNameGroup; - QListWidget* myPolygons; - - QGroupBox* myObjectNameGroup; - QLineEdit* myObjectName; - - //second page - QGroupBox* myAttrNameGroup; - QListWidget* myDBFAttr; - - -}; - -#endif diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx new file mode 100644 index 00000000..5c7c5ccd --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx @@ -0,0 +1,262 @@ +// 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_ImportLandCoverMapDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +HYDROGUI_ImportLandCoverMapDlg::HYDROGUI_ImportLandCoverMapDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_Wizard( theModule, theTitle ) +{ + addPage( createPage1() ); + addPage( createPage2() ); + addPage( createPage3() ); +} + +QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() { + QWizardPage* aPage = new QWizardPage( mainFrame() ); + QFrame* aFrame = new QFrame( aPage ); + + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + myFileNameGroup = new QGroupBox( tr( "IMPORT_LANDCOVERMAP_FROM_FILE" ) ); + + QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup ); + + myFileName = new QLineEdit( myFileNameGroup ); + myFileName->setReadOnly( true ); + + QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup ); + aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); + + QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup ); + aFileNameLayout->setMargin( 5 ); + aFileNameLayout->setSpacing( 5 ); + aFileNameLayout->addWidget( aFileNameLabel ); + aFileNameLayout->addWidget( myFileName ); + aFileNameLayout->addWidget( aBrowseBtn ); + + myObjectNameGroup = new QGroupBox( tr( "LANDCOVERMAP_NAME" ) ); + + QLabel* aLandcoverNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup ); + myObjectName = new QLineEdit( myObjectNameGroup ); + + QBoxLayout* aLandcoverNameLayout = new QHBoxLayout( myObjectNameGroup ); + aLandcoverNameLayout->setMargin( 5 ); + aLandcoverNameLayout->setSpacing( 5 ); + aLandcoverNameLayout->addWidget( aLandcoverNameLabel ); + aLandcoverNameLayout->addWidget( myObjectName ); + + QGroupBox* aPolygonsGroup = new QGroupBox( tr( "FOUNDED_POLYGONS" ) ); + myPolygons = new QListWidget( aPolygonsGroup ); + myPolygons->setSelectionMode( QListWidget::ExtendedSelection ); + myPolygons->setEditTriggers( QListWidget::NoEditTriggers ); + myPolygons->setViewMode( QListWidget::ListMode ); + myPolygons->setSortingEnabled( false ); + + QBoxLayout* aPolygonsLayout = new QVBoxLayout; + aPolygonsLayout->addWidget( myPolygons ); + aPolygonsGroup->setLayout( aPolygonsLayout ); + + // Layout + QVBoxLayout* aPageLayout = new QVBoxLayout; + aPageLayout->setMargin( 5 ); + aPageLayout->setSpacing( 5 ); + aPageLayout->addWidget( myFileNameGroup ); + aPageLayout->addWidget( myObjectNameGroup ); + aPageLayout->addWidget( aPolygonsGroup ); + aPage->setLayout( aPageLayout ); + + // Conections + connect( myPolygons, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) ); + connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); + + return aPage; +} + +QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage2() { + QWizardPage* aPage = new QWizardPage( mainFrame() ); + QFrame* aFrame = new QFrame( aPage ); + + myAttrNameGroup = new QGroupBox( "Available attributes" ); + + QCheckBox* anAttrCheckBox = new QCheckBox( "Use dBase attributes as a Strickler Types", myAttrNameGroup ); + + QBoxLayout* aFileNameLayout = new QHBoxLayout( myAttrNameGroup ); + aFileNameLayout->setMargin( 5 ); + aFileNameLayout->setSpacing( 5 ); + aFileNameLayout->addWidget( anAttrCheckBox ); + + + myDBFAttr = new QListWidget( aPage ); + myDBFAttr->setSelectionMode( QListWidget::ExtendedSelection ); + myDBFAttr->setEditTriggers( QListWidget::NoEditTriggers ); + myDBFAttr->setViewMode( QListWidget::ListMode ); + myDBFAttr->setSortingEnabled( false ); + + // Layout + QVBoxLayout* aPageLayout = new QVBoxLayout; + aPageLayout->setMargin( 5 ); + aPageLayout->setSpacing( 5 ); + aPageLayout->addWidget( myAttrNameGroup ); + aPageLayout->addWidget( myDBFAttr ); + aPage->setLayout( aPageLayout ); + return aPage; +} + +QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage3() { + + QWizardPage* aPage = new QWizardPage( mainFrame() ); + QFrame* aFrame = new QFrame( aPage ); + myCLabel = new QLabel(); + myCLabel->setText("Correspondence"); + + myTableW = new QTableWidget(); + + myTableW->setRowCount(5); + myTableW->setColumnCount(2); + + QStringList list; + list << "1" << "2" << "3"; + + for (int i = 0; i < 5; i++) + for (int j = 0; j < 2; j++) + { + QComboBox* CB = new QComboBox(); + CB->addItems(list); + myTableW->setCellWidget(i,j,CB); + } + + // Layout + QVBoxLayout* aPageLayout = new QVBoxLayout; + aPageLayout->setMargin( 5 ); + aPageLayout->setSpacing( 5 ); + aPageLayout->addWidget( myCLabel ); + aPageLayout->addWidget( myTableW ); + aPage->setLayout( aPageLayout ); + return aPage; +} + + +HYDROGUI_ImportLandCoverMapDlg::~HYDROGUI_ImportLandCoverMapDlg() +{ +} + +void HYDROGUI_ImportLandCoverMapDlg::reset() +{ + myPolygons->clear(); +} + +void HYDROGUI_ImportLandCoverMapDlg::setPolygonNames( const QStringList& theNames ) +{ + myPolygons->clear(); + myPolygons->addItems( theNames ); +} + +void HYDROGUI_ImportLandCoverMapDlg::removePolygonNames( const QStringList& theNames ) +{ + QList aFoundItems; + + foreach ( const QString& aName, theNames ) { + aFoundItems = myPolygons->findItems( aName, Qt::MatchExactly ); + foreach ( QListWidgetItem* anItem, aFoundItems ) { + anItem = myPolygons->takeItem( myPolygons->row( anItem ) ); + delete anItem; + } + } +} + +void HYDROGUI_ImportLandCoverMapDlg::setSelectedPolygonNames( const QStringList& theNames ) +{ + myPolygons->clearSelection(); + + foreach( const QString aName, theNames ) { + QList anItems = myPolygons->findItems( aName, Qt::MatchExactly ); + if ( anItems.count() == 1 ) { + anItems.first()->setSelected( true ); + } + } +} + +void HYDROGUI_ImportLandCoverMapDlg::onItemSelectionChanged() +{ + emit selectionChanged( getSelectedPolygonNames() ); +} + +QStringList HYDROGUI_ImportLandCoverMapDlg::getSelectedPolygonNames() const +{ + QStringList aSelectedNames; + + QList aSelectedItems = myPolygons->selectedItems(); + foreach( const QListWidgetItem* anItem, aSelectedItems ) { + aSelectedNames << anItem->text(); + } + + return aSelectedNames; +} + + +void HYDROGUI_ImportLandCoverMapDlg::onBrowse() +{ + QString aFilter( tr( "LANDCOVERMAP_FILTER" ) ); + QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_LANDCOVERMAP_FROM_FILE" ), true ); + + if( !aFileName.isEmpty() ) + { + setFileName( aFileName ); + emit FileSelected( aFileName ); + } +} + +void HYDROGUI_ImportLandCoverMapDlg::setObjectName( const QString& theName ) +{ + myObjectName->setText( theName ); + myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileName->text().isEmpty() ); +} + +QString HYDROGUI_ImportLandCoverMapDlg::getObjectName() const +{ + return myObjectName->text(); +} + +void HYDROGUI_ImportLandCoverMapDlg::setFileName( const QString& theFileName ) +{ + myFileName->setText( theFileName ); + + if ( !myObjectNameGroup->isEnabled() ) + myObjectNameGroup->setEnabled( !theFileName.isEmpty() ); +} + +QString HYDROGUI_ImportLandCoverMapDlg::getFileName() const +{ + return myFileName->text(); +} + diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h new file mode 100644 index 00000000..864c2258 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h @@ -0,0 +1,93 @@ +// 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_ImportLandCoverMapDlg_H +#define HYDROGUI_ImportLandCoverMapDlg_H + +#include "HYDROGUI_Wizard.h" + +class QListWidget; +class QLineEdit; +class QGroupBox; +class QComboBox; +class QLabel; +class QTableWidget; + +class HYDROGUI_ImportLandCoverMapDlg : public HYDROGUI_Wizard +{ + Q_OBJECT + +public: + HYDROGUI_ImportLandCoverMapDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_ImportLandCoverMapDlg(); + + void reset(); + + void setPolygonNames( const QStringList& theNames ); + void removePolygonNames( const QStringList& theNames ); + + void setSelectedPolygonNames( const QStringList& theNames ); + + QStringList getSelectedPolygonNames() const; + + void setObjectName( const QString& theName ); + QString getObjectName() const; + + void setFileName( const QString& theFileName ); + QString getFileName() const; + +signals: + void FileSelected( const QString& theFileName ); + +protected slots: + void onBrowse(); + + +signals: + void selectionChanged( const QStringList& ); + +public slots: + void onItemSelectionChanged(); + +private: + + QWizardPage* createPage1(); + QWizardPage* createPage2(); + QWizardPage* createPage3(); + + QLineEdit* myFileName; + QGroupBox* myFileNameGroup; + QListWidget* myPolygons; + + QGroupBox* myObjectNameGroup; + QLineEdit* myObjectName; + + //second page + QGroupBox* myAttrNameGroup; + QListWidget* myDBFAttr; + QGroupBox* myCorrNameGroup; + + //third page + QLabel* myCLabel; + QTableWidget* myTableW; + + +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx new file mode 100644 index 00000000..540a1592 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx @@ -0,0 +1,390 @@ +// 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_ImportLandCoverMapOp.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_UpdateFlags.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_ImportLandCoverMapDlg.h" +#include "HYDROGUI_Shape.h" +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + + +#include + + +HYDROGUI_ImportLandCoverMapOp::HYDROGUI_ImportLandCoverMapOp( HYDROGUI_Module* theModule ) +: HYDROGUI_Operation( theModule ) +{ + setName( tr( "IMPORT_LANDCOVER" ) ); +} + +HYDROGUI_ImportLandCoverMapOp::~HYDROGUI_ImportLandCoverMapOp() +{ + erasePreview(); +} + +void HYDROGUI_ImportLandCoverMapOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + if ( !getPreviewManager() ) { + setPreviewManager( ::qobject_cast( + module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); + } + + if ( !isApplyAndClose() ) { + return; + } + + HYDROGUI_ImportLandCoverMapDlg* aPanel = + ::qobject_cast( inputPanel() ); + if ( !aPanel ) { + return; + } + + aPanel->reset(); +} + +void HYDROGUI_ImportLandCoverMapOp::onFileSelected() +{ + HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + QString anObjectName = aPanel->getObjectName().simplified(); + anObjectName = aPanel->getFileName(); + if ( !anObjectName.isEmpty() ) + anObjectName = QFileInfo( anObjectName ).baseName(); + + if ( anObjectName.isEmpty() ) + anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LANDCOVERMAP_NAME" ) ); + aPanel->setObjectName( anObjectName ); + + QString aFileName = aPanel->getFileName(); + if ( aFileName.isEmpty() ) + { + abort(); + return; + } + + QString anExt = aFileName.split('.', QString::SkipEmptyParts).back(); + + if (anExt == "shp") + { + startDocOperation(); + QApplication::setOverrideCursor(Qt::WaitCursor); + + QStringList aPolygonsList; + TopTools_SequenceOfShape aFaces; + HYDROData_ShapeFile anImporter; + + SalomeApp_Study* aStudy = dynamic_cast( module()->getApp()->activeStudy() ); + if ( !aStudy ) + return; + + erasePreview(); + + Handle(AIS_InteractiveContext) aCtx = NULL; + int aShapeTypeOfFile = -1; + int aStat = anImporter.ImportLandCovers(aFileName, aPolygonsList, aFaces, aShapeTypeOfFile); + if (aStat == 1) + { + aPanel->setPolygonNames(aPolygonsList); + + LightApp_Application* anApp = module()->getApp(); + if ( !getPreviewManager() ) + setPreviewManager( ::qobject_cast( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + + if ( aViewManager ) + { + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) + { + aCtx = aViewer->getAISContext(); + connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) ); + } + } + + for ( int i = 1; i <= aFaces.Length(); i++ ) + { + TopoDS_Face aFace = TopoDS::Face(aFaces.Value( i )); + if ( aViewManager && !aCtx.IsNull() ) + { + HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); + //Green color for now.. + aShape->setFillingColor(QColor(0,255,0), false, false); + aShape->setBorderColor(QColor(0,255,0), false, false); + if( !aFace.IsNull() ) + aShape->setShape( aFace); + + myPolygonName2PrsShape.insert( "polygon_" + QString::number(i), aShape); + } + } + if ( !aCtx.IsNull() ) + { + UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, Graphic3d_ZLayerId_TopOSD ); + aCtx->UpdateCurrentViewer(); + } + + QApplication::restoreOverrideCursor(); + commitDocOperation(); + } + else + { + erasePreview(); + aPanel->setPolygonNames(QStringList()); + aPanel->setObjectName(""); + QApplication::restoreOverrideCursor(); + QString aMess = "Cannot import land cover;\n"; + if (aStat == -1) + aMess += "Cannot open SHP file"; + else if (aStat == -2) + aMess += "Cannot open SHX file"; + else + aMess += "The shape type of file is " + anImporter.GetShapeTypeName(aShapeTypeOfFile); + SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_LANDCOVER" ), aMess); + commitDocOperation(); + //abort(); + } + anImporter.Free(); + + } + +} + +HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverMapOp::createInputPanel() const +{ + HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportLandCoverMapDlg( module(), getName() ); + + connect( aPanel, SIGNAL( FileSelected( const QString& ) ), SLOT( onFileSelected() ) ); + + connect( aPanel, SIGNAL( selectionChanged( const QStringList& ) ), this, SLOT( onSelectionChanged( const QStringList& ) ) ); + + connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) ); + connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onBack( const int ) ) ); + connect( aPanel, SIGNAL( Finish( const int ) ), SLOT( onFinish( const int ) ) ); + + return aPanel; +} + +bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags, + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + + HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) { + return false; + } + + QStringList aSelectedtPolygons = aPanel->getSelectedPolygonNames(); + aPanel->removePolygonNames( aSelectedtPolygons ); + + if (!aSelectedtPolygons.empty()) + { + Handle(HYDROData_LandCoverMap) aLCM = Handle(HYDROData_LandCoverMap)::DownCast( doc()->CreateObject( KIND_LAND_COVER_MAP ) ); + TopoDS_Shape aResShape; + if (aSelectedtPolygons.size() > 1) + { + TopoDS_Compound cmp; + BRep_Builder BB; + BB.MakeCompound(cmp); + + foreach ( QString aName, aSelectedtPolygons ) { + TopoDS_Shape aShape = myPolygonName2PrsShape.value( aName )->getTopoShape(); + if ( aShape.IsNull() ) + continue; + BB.Add(cmp, aShape); + HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aName ); + delete aShapeToDelete; + } + aResShape = cmp; + } + else + { + TopoDS_Shape aShape = myPolygonName2PrsShape.value( aSelectedtPolygons.first() )->getTopoShape(); + if ( !aShape.IsNull() ) + { + HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aSelectedtPolygons.first() ); + delete aShapeToDelete; + aResShape = aShape; + } + } + if( !aLCM.IsNull() ) + { + QString aLCName = aPanel->getObjectName() + "_polygon"; + int i = 0; + for( ;HYDROGUI_Tool::FindObjectByName(module(), aLCName); i++) + aLCName = aPanel->getObjectName() + "_polygon_" + QString::number(i); + aLCM->SetName( aLCName ); + //TODO add color + //aLCM->SetFillingColor( aLCM->DefaultFillingColor() ); + //aLCM->SetBorderColor( aLCM->DefaultBorderColor() ); + + //aLCM->SetShape(aResShape); + aLCM->Show(); + + //erasePreview(); + + module()->setIsToUpdate( aLCM ); + + } + } + + module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init ); + + if ( isApplyAndClose() ) + erasePreview(); + + return true; +} + +void HYDROGUI_ImportLandCoverMapOp::onSelectionChanged( const QStringList& theSelectedNames ) +{ + Handle(AIS_InteractiveContext) aCtx = NULL; + + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + if ( aViewManager ) { + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) { + aCtx = aViewer->getAISContext(); + } + } + + if ( !aCtx.IsNull() ) { + foreach ( QString aName, myPolygonName2PrsShape.keys() ) { + Handle(AIS_InteractiveObject) anObject = + myPolygonName2PrsShape.value(aName)->getAISObject(); + + bool isSelected = theSelectedNames.contains( aName ); + if ( ( isSelected && !aCtx->IsSelected( anObject) ) || + ( !isSelected && aCtx->IsSelected( anObject) ) ) { + aCtx->AddOrRemoveSelected( anObject, Standard_False ); + } + /*if (isSelected) + { + HYDROGUI_Shape* aHydroSh = myPolygonName2PrsShape.value( aName ); + aHydroSh->setFillingColor(QColor(0,255,255), true, true); + }*/ + } + aCtx->UpdateCurrentViewer(); + } +} + + +void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged() +{ + // Get panel + HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) { + return; + } + + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + Handle(AIS_InteractiveContext) aCtx = NULL; + if ( aViewManager ) { + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) { + aCtx = aViewer->getAISContext(); + } + } + + 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 ); + } +} + + +void HYDROGUI_ImportLandCoverMapOp::erasePreview() +{ + foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape ) { + delete aShape; + } + + myPolygonName2PrsShape.clear(); +} + + +void HYDROGUI_ImportLandCoverMapOp::abortOperation() +{ + LightApp_Application* anApp = module()->getApp(); + if ( anApp ) { + anApp->disconnect( this ); + } + + erasePreview(); + + HYDROGUI_Operation::abortOperation(); +} + + +void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex ) +{ + +} + +void HYDROGUI_ImportLandCoverMapOp::onBack( const int theIndex ) +{ + +} diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.h b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.h new file mode 100644 index 00000000..7582f667 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.h @@ -0,0 +1,63 @@ +// 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_IMPORTLANDCOVERMAP_H +#define HYDROGUI_IMPORTLANDCOVERMAP_H + +#include "HYDROGUI_Operation.h" +#include +#include + +class SUIT_FileDlg; +class HYDROGUI_Shape; +class TopoDS_Face; + + +class HYDROGUI_ImportLandCoverMapOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_ImportLandCoverMapOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_ImportLandCoverMapOp(); + +protected: + virtual void startOperation(); + virtual void abortOperation(); + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ); + HYDROGUI_InputPanel* createInputPanel() const; + + void erasePreview(); + +protected slots: + void onFileSelected(); + void onSelectionChanged( const QStringList& theSelectedNames ); + void onViewerSelectionChanged (); + void onNext( const int theIndex ); + void onBack( const int theIndex ); + +private: + QMap myPolygonName2PrsShape; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 1715bc47..d71b8d7a 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -68,8 +68,8 @@ #include "HYDROGUI_MergePolylinesOp.h" #include "HYDROGUI_SplitPolylinesOp.h" #include "HYDROGUI_LandCoverColoringOp.h" -// TODO -//#include "HYDROGUI_ImportLandCoverMapOp.h" + +#include "HYDROGUI_ImportLandCoverMapOp.h" #include #include @@ -504,8 +504,7 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const anOp = new HYDROGUI_ExportFileOp( aModule ); break; case ImportLandCoverMapId: - // TODO - //anOp = new HYDROGUI_ImportLandCoverMapOp( aModule ); + anOp = new HYDROGUI_ImportLandCoverMapOp( aModule ); break; case RemoveImageRefsId: anOp = new HYDROGUI_RemoveImageRefsOp( aModule ); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 95c6c91e..4ce8f6d6 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2296,22 +2296,22 @@ file cannot be correctly imported for an Obstacle definition. - HYDROGUI_ImportLandCoverDlg + HYDROGUI_ImportLandCoverMapDlg - LANDCOVER_FILTER + LANDCOVERMAP_FILTER Shape files (*.shp) - IMPORT_LANDCOVER_FROM_FILE - Import land cover from file + IMPORT_LANDCOVERMAP_FROM_FILE + Import land cover map from file FILE_NAME File name - LANDCOVER_NAME - Land cover name + LANDCOVERMAP_NAME + Land cover map name NAME @@ -2322,24 +2322,24 @@ file cannot be correctly imported for an Obstacle definition. Founded polygons: - BAD_IMPORTED_LANDCOVER_FILES - Land cover import error + BAD_IMPORTED_LANDCOVERMAP_FILES + Land cover map import error - NO_ONE_LANDCOVER_IMPORTED - Land cover cannot be read from seleted file + NO_ONE_LANDCOVERMAP_IMPORTED + Land cover map cannot be read from seleted file - HYDROGUI_ImportLandCoverOp + HYDROGUI_ImportLandCoverMapOp - IMPORT_LANDCOVER - Import land cover + IMPORT_LANDCOVER_MAP + Import land cover map - DEFAULT_LANDCOVER_NAME - Landcover_0 + DEFAULT_LANDCOVER_MAP_NAME + Landcovermap_0