HYDROGUI_ExportSinusXDlg.h
HYDROGUI_ExportLandCoverMapDlg.h
HYDROGUI_InputPanel.h
+ HYDROGUI_LandCoverArgsFilter.h
HYDROGUI_LandCoverMapDlg.h
HYDROGUI_LandCoverMapOp.h
HYDROGUI_LandCoverMapPrs.h
HYDROGUI_ExportSinusXDlg.cxx
HYDROGUI_ExportLandCoverMapDlg.cxx
HYDROGUI_InputPanel.cxx
+ HYDROGUI_LandCoverArgsFilter.cxx
HYDROGUI_LandCoverMapDlg.cxx
HYDROGUI_LandCoverMapOp.cxx
HYDROGUI_LandCoverMapPrs.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_LandCoverArgsFilter.h>
+#include <HYDROGUI_Operations.h>
+#include <HYDROData_ArtificialObject.h>
+#include <HYDROData_NaturalObject.h>
+#include <HYDROData_PolylineXY.h>
+
+HYDROGUI_LandCoverArgsFilter::HYDROGUI_LandCoverArgsFilter( int theOperationId )
+ : myOperationId( theOperationId )
+{
+}
+
+HYDROGUI_LandCoverArgsFilter::~HYDROGUI_LandCoverArgsFilter()
+{
+}
+
+bool HYDROGUI_LandCoverArgsFilter::isOk( const Handle(HYDROData_Entity)& theEntity ) const
+{
+ if( theEntity.IsNull() )
+ return false;
+
+ ObjectKind aKind = theEntity->GetKind();
+ if( aKind==KIND_POLYLINEXY )
+ {
+ Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theEntity );
+ switch( myOperationId )
+ {
+ case CreateLandCoverMapId:
+ case AddLandCoverId:
+ return aPolylineXY->IsClosed(); // only closed polylines are allowed
+ case SplitLandCoverId:
+ return true; // any polylines are allowed
+ default:
+ return false;
+ }
+ }
+
+ Handle(HYDROData_NaturalObject) aNaturalObject = Handle(HYDROData_NaturalObject)::DownCast( theEntity );
+ Handle(HYDROData_ArtificialObject) anArtificialObject = Handle(HYDROData_ArtificialObject)::DownCast( theEntity );
+ bool isOK = !aNaturalObject.IsNull() || !anArtificialObject.IsNull();
+ return isOK;
+}
--- /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_LANDCOVER_ARGS_FILTER_H
+#define HYDROGUI_LANDCOVER_ARGS_FILTER_H
+
+#include <HYDROGUI_ObjComboBox.h>
+
+class HYDROGUI_LandCoverArgsFilter : public HYDROGUI_ObjComboBoxFilter
+{
+public:
+ HYDROGUI_LandCoverArgsFilter( int theOperationId );
+ virtual ~HYDROGUI_LandCoverArgsFilter();
+
+ virtual bool isOk( const Handle(HYDROData_Entity)& theEntity ) const;
+
+private:
+ int myOperationId;
+};
+
+#endif
const QString& theTitle,
const int theOperationId )
: HYDROGUI_InputPanel( theModule, theTitle ),
- HYDROGUI_ObjComboBoxFilter(),
- myOperationId( theOperationId )
+ myOperationId( theOperationId ),
+ myFilter( theOperationId )
{
// Land Cover Map name
myObjectNameGroup = new QGroupBox( tr( "LAND_COVER_MAP_NAME" ), mainFrame() );
myPolylinesFacesLabel = new QLabel( tr( "LAND_COVER_MAP_POLYLINE_FACE" ) );
aParamLayout->addWidget( myPolylinesFacesLabel, 0, 0, 1, 1 );
aParamLayout->addWidget( myPolylinesFaces = new HYDROGUI_ObjComboBox( theModule, "", KIND_UNKNOWN, myParamGroup ), 0, 1, 1, 1 );
- myPolylinesFaces->setObjectFilter( this );
+ myPolylinesFaces->setObjectFilter( &myFilter );
// Strickler type name
myStricklerTypesLabel = new QLabel( tr( "LAND_COVER_MAP_STRICKLER_TYPE" ), myParamGroup );
return myStricklerTypes->getSelectedStricklerTypeName();
}
-bool HYDROGUI_LandCoverMapDlg::isOk( const Handle(HYDROData_Entity)& theEntity ) const
-{
- Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast(theEntity);
- Handle(HYDROData_Object) anObject2d3dPrs = Handle(HYDROData_Object)::DownCast(theEntity);
- return ( !anObject2d3dPrs.IsNull() ||
- ( !aPolylineXY.IsNull() && ( ( myOperationId == CreateLandCoverMapId || myOperationId == AddLandCoverId ) && aPolylineXY->IsClosed() ||
- myOperationId == SplitLandCoverId ) ) );
-}
-
void HYDROGUI_LandCoverMapDlg::onLandCoverMapChanged()
{
if ( signalsBlocked() )
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// REMOVED FROM THE PROJECT, BUT KEPT AS A REFERENCE FILE. TO BE DELETED LATER.
-
#ifndef HYDROGUI_LANDCOVERMAPDLG_H
#define HYDROGUI_LANDCOVERMAPDLG_H
-#include "HYDROGUI_InputPanel.h"
-
-#include "HYDROGUI_ObjComboBox.h"
+#include <HYDROGUI_InputPanel.h>
+#include <HYDROGUI_LandCoverArgsFilter.h>
class HYDROGUI_StricklerTypeComboBox;
class QLineEdit;
class QLabel;
-class HYDROGUI_LandCoverMapDlg : public HYDROGUI_InputPanel, public HYDROGUI_ObjComboBoxFilter
+class HYDROGUI_LandCoverMapDlg : public HYDROGUI_InputPanel
{
Q_OBJECT
void setSelectedStricklerTypeName( const QString& theName );
QString getSelectedStricklerTypeName() const;
- virtual bool isOk( const Handle(HYDROData_Entity)& ) const;
-
signals:
void landCoverMapChanged( const QString& theName );
HYDROGUI_ObjComboBox* myPolylinesFaces;
QLabel* myStricklerTypesLabel;
HYDROGUI_StricklerTypeComboBox* myStricklerTypes;
+ HYDROGUI_LandCoverArgsFilter myFilter;
};
#endif
test_HYDROData_StricklerTable.h
test_HYDROGUI_ListModel.h
test_HYDROGUI_Shape.h
+ test_HYDROGUI_LandCoverMapDlg.h
test_Dependencies.h
TestShape.h
test_HYDROData_StricklerTable.cxx
test_HYDROGUI_ListModel.cxx
test_HYDROGUI_Shape.cxx
+ test_HYDROGUI_LandCoverMapDlg.cxx
test_Dependencies.cxx
TestShape.cxx
../HYDROGUI/HYDROGUI_ListModel.cxx
../HYDROGUI/HYDROGUI_DataObject.cxx
../HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx
+ ../HYDROGUI/HYDROGUI_LandCoverArgsFilter.cxx
../HYDROGUI/HYDROGUI_Polyline.cxx
../HYDROGUI/HYDROGUI_AISShape.cxx
../HYDROGUI/HYDROGUI_Shape.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
+//
+
+#undef HYDROGUI_EXPORTS
+
+#include <test_HYDROGUI_LandCoverMapDlg.h>
+#include <HYDROGUI_LandCoverArgsFilter.h>
+#include <HYDROGUI_Operations.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_PolylineXY.h>
+#include <gp_XY.hxx>
+
+bool isOK( const HYDROGUI_LandCoverArgsFilter& theFilter,
+ const Handle(HYDROData_Document)& theDocument,
+ ObjectKind theKind )
+{
+ Handle(HYDROData_Entity) anEntity = theDocument->CreateObject( theKind );
+ return theFilter.isOk( anEntity );
+}
+
+void test_HYDROGUI_LandCoverMapDlg::test_objects_filtering_refs_707()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+ HYDROGUI_LandCoverArgsFilter f( AddLandCoverId );
+
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_IMAGE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_POLYLINE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_BATHYMETRY ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_ALTITUDE ) );
+ CPPUNIT_ASSERT_EQUAL( true, isOK( f, aDoc, KIND_IMMERSIBLE_ZONE ) );
+ CPPUNIT_ASSERT_EQUAL( true, isOK( f, aDoc, KIND_RIVER ) );
+ CPPUNIT_ASSERT_EQUAL( true, isOK( f, aDoc, KIND_STREAM ) );
+ CPPUNIT_ASSERT_EQUAL( true, isOK( f, aDoc, KIND_CONFLUENCE ) );
+ CPPUNIT_ASSERT_EQUAL( true, isOK( f, aDoc, KIND_CHANNEL ) );
+ CPPUNIT_ASSERT_EQUAL( true, isOK( f, aDoc, KIND_OBSTACLE ) );
+ CPPUNIT_ASSERT_EQUAL( true, isOK( f, aDoc, KIND_DIGUE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_PROFILE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_PROFILEUZ ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_CALCULATION ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_ZONE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_REGION ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_VISUAL_STATE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_ARTIFICIAL_OBJECT ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_NATURAL_OBJECT ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_DUMMY_3D ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_SHAPES_GROUP ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_SPLITTED_GROUP ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_STREAM_ALTITUDE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_OBSTACLE_ALTITUDE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_STRICKLER_TABLE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_LAND_COVER_OBSOLETE ) );
+ CPPUNIT_ASSERT_EQUAL( false, isOK( f, aDoc, KIND_LAND_COVER_MAP ) );
+
+ Handle(HYDROData_PolylineXY) aClosedPoly = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+ aClosedPoly->AddSection( "", HYDROData_PolylineXY::SECTION_SPLINE, true );
+ aClosedPoly->AddPoint( 0, gp_XY( 0, 0 ) );
+ aClosedPoly->AddPoint( 0, gp_XY( 20, 0 ) );
+ aClosedPoly->AddPoint( 0, gp_XY( 10, 10 ) );
+ aClosedPoly->Update();
+ CPPUNIT_ASSERT_EQUAL( true, f.isOk( aClosedPoly ) );
+
+ Handle(HYDROData_PolylineXY) anOpenPoly = Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+ anOpenPoly->AddSection( "", HYDROData_PolylineXY::SECTION_SPLINE, false );
+ anOpenPoly->AddPoint( 0, gp_XY( 0, 0 ) );
+ anOpenPoly->AddPoint( 0, gp_XY( 20, 0 ) );
+ anOpenPoly->AddPoint( 0, gp_XY( 10, 10 ) );
+ anOpenPoly->Update();
+ CPPUNIT_ASSERT_EQUAL( false, f.isOk( anOpenPoly ) );
+
+ HYDROGUI_LandCoverArgsFilter fs( SplitLandCoverId );
+ CPPUNIT_ASSERT_EQUAL( true, fs.isOk( aClosedPoly ) );
+ CPPUNIT_ASSERT_EQUAL( true, fs.isOk( anOpenPoly ) );
+
+ aDoc->Close();
+}
--- /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 <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROGUI_LandCoverMapDlg : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(test_HYDROGUI_LandCoverMapDlg);
+ CPPUNIT_TEST(test_objects_filtering_refs_707);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void test_objects_filtering_refs_707();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROGUI_LandCoverMapDlg);
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROGUI_LandCoverMapDlg, "HYDROGUI_LandCoverMapDlg");