]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #526: objects excluded from the final geometry
authorasl <asl@opencascade.com>
Tue, 19 May 2015 12:19:34 +0000 (15:19 +0300)
committerasl <asl@opencascade.com>
Tue, 19 May 2015 12:19:34 +0000 (15:19 +0300)
16 files changed:
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Region.h
src/HYDROData/HYDROData_Zone.cxx
src/HYDROData/HYDROData_Zone.h
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_SubmersibleOp.h [new file with mode: 0644]
src/HYDROGUI/resources/HYDROGUI_images.ts
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROGUI/resources/icon_submersible.png [new file with mode: 0644]

index d19e77e7dd3b142f540d7ce457571ba0dfecfbd4..ec18b345c6c57d472b2b97551fca68849579cedf 100644 (file)
@@ -961,7 +961,7 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
   {
     Handle(HYDROData_Region) aRegion =
       Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
-    if( aRegion.IsNull() )
+    if( aRegion.IsNull() || !aRegion->IsSubmersible() )
       continue;
 
     TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
index a2aeb4798d98797c346e9fb814e3d730b1f9f9e8..25b9e2625187447f1a6a2ad224eb99c530b2da13 100644 (file)
@@ -28,6 +28,7 @@
 #include <TNaming_NamedShape.hxx>
 
 #include <TopoDS_Shape.hxx>
+#include <TDataStd_Integer.hxx>
 
 #include <QColor>
 
@@ -376,3 +377,20 @@ void HYDROData_Object::removeShape3D()
     aLabel.ForgetAllAttributes();
 }
 
+bool HYDROData_Object::IsSubmersible() const
+{
+  Handle(TDataStd_Integer) aSubMersibleAttr;
+
+  bool isSubmersible = true; //default
+  if( myLab.FindAttribute(TDataStd_Integer::GetID(), aSubMersibleAttr ) )
+  {
+    int aValue = aSubMersibleAttr->Get();
+    isSubmersible = ( aValue != 0 );
+  }
+  return isSubmersible;
+}
+
+void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const
+{
+  TDataStd_Integer::Set( myLab, isSubmersible ? 1 : 0 );
+}
index 96cdaa3935492a9639148b4db1dd6747607b72e8..badf45ea385de93e5e1e53f3cee0ae5ef6b2ab4d 100644 (file)
@@ -66,6 +66,7 @@ protected:
     DataTag_Object3D,            ///< child 3D object
     DataTag_EdgesGroup,          ///< child group objects
     DataTag_ChildAltitudeObject, ///< child altitude object
+    DataTag_IsSubmersible,       ///< the attribute "is submersible"
   };
 
 public:
@@ -174,6 +175,9 @@ public:
    */
   HYDRODATA_EXPORT virtual QColor GetBorderColor() const;
 
+  HYDRODATA_EXPORT bool IsSubmersible() const;
+  HYDRODATA_EXPORT void SetIsSubmersible( bool ) const;
+
 protected:
 
   /**
index bf633f3f0f0bb9e76321a34cb53a32eaec48b9ce..0cbb266d27f1f5388730078fb6768ac00ee58b67 100644 (file)
@@ -438,4 +438,18 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec
   }
 
   return aResList;
-}
\ No newline at end of file
+}
+
+bool HYDROData_Region::IsSubmersible() const
+{
+  HYDROData_SequenceOfObjects aZones = GetZones();
+  HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
+  for ( ; aZonesIter.More(); aZonesIter.Next() )
+  {
+    Handle(HYDROData_Zone) aZone =
+      Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
+    if ( !aZone->IsSubmersible() )
+      return false; //if one of zones is not submersible the region is considered as not submersible
+  }
+  return true;
+}
index d1bc7ab8b62ce0a94dd79c4ff0a9062e340917d5..b8da0556160d93457d168e4c8480e8b67fa1633e 100644 (file)
@@ -114,6 +114,8 @@ public:
    */
   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups = 0 ) const;
 
+  HYDRODATA_EXPORT bool IsSubmersible() const;
+
 protected:
 
   /**
index b1c3a8792dcc291c12645c540e23bbda905e192f..53d40e5224d6bfc590d9ee791fc9d7f782ee7e38 100644 (file)
@@ -193,5 +193,17 @@ void HYDROData_Zone::RemoveGeometryObjects()
   ClearReferenceObjects( DataTag_GeometryObject );
 }
 
-
+bool HYDROData_Zone::IsSubmersible() const
+{
+  HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
+  HYDROData_SequenceOfObjects::Iterator aGeomObjsIter( aGeomObjects );
+  for ( ; aGeomObjsIter.More(); aGeomObjsIter.Next() )
+  {
+    Handle(HYDROData_Object) aRefGeomObj =
+      Handle(HYDROData_Object)::DownCast( aGeomObjsIter.Value() );
+    if( !aRefGeomObj->IsSubmersible() )
+      return false; //if one of geometry objects is not submersible the zone is considered as not submersible
+  }
+  return true;
+}
 
index 3fa4dfdff8a8591a389363fb4126912075808e98..b8a8c0d2c648fd86ac2c6b6d8ec5295ad5f648c1 100644 (file)
@@ -166,6 +166,8 @@ public:
    */
   HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
 
+  HYDRODATA_EXPORT bool IsSubmersible() const;
+
 protected:
 
   friend class HYDROData_Region;
index d15866492d180d52dbd5fc740c52876f08bdbd8e..fb6568b8d76088a0a72103002a6d9f828764bb9d 100644 (file)
@@ -68,6 +68,7 @@ set(PROJECT_HEADERS
     HYDROGUI_ShowHideOp.h
     HYDROGUI_StreamDlg.h
     HYDROGUI_StreamOp.h
+    HYDROGUI_SubmersibleOp.h
     HYDROGUI_Tool.h
     HYDROGUI_TwoImagesDlg.h
     HYDROGUI_TwoImagesOp.h
@@ -178,6 +179,7 @@ set(PROJECT_SOURCES
     HYDROGUI_ShowHideOp.cxx
     HYDROGUI_StreamDlg.cxx
     HYDROGUI_StreamOp.cxx
+    HYDROGUI_SubmersibleOp.cxx
     HYDROGUI_Tool.cxx
     HYDROGUI_TwoImagesDlg.cxx
     HYDROGUI_TwoImagesOp.cxx
index b697cec080b7c0fe61a3e0b006b98350639a8984..caad11e4d6d5b2cf692ad0c0bb8ede470373dc49 100644 (file)
@@ -700,6 +700,18 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
 
   if( isRoot )
     theMenu->addAction( action( EditLocalCSId ) );
+
+  if( anIsObjectBrowser && anOwners.size()==1 )
+  {
+    Handle( HYDROData_Object ) anObject = Handle( HYDROData_Object )::DownCast( aSeq.First() );
+    if( !anObject.IsNull() )
+    {
+      theMenu->addSeparator();
+      theMenu->addAction( action( SubmersibleId ) );
+      action( SubmersibleId )->setCheckable( true );
+      action( SubmersibleId )->setChecked( anObject->IsSubmersible() );
+    }
+  }
 }
 
 void HYDROGUI_Module::update( const int flags )
index 0db568abb60e0cea0df45cde7f0e3791279c929b..ce02c32f1f30a751957ef4b1b122ff2d325eb49a 100644 (file)
@@ -55,6 +55,7 @@
 #include "HYDROGUI_LocalCSOp.h"
 #include "HYDROGUI_RiverBottomOp.h"
 #include "HYDROGUI_ProfileInterpolateOp.h"
+#include "HYDROGUI_SubmersibleOp.h"
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Obstacle.h>
@@ -182,6 +183,8 @@ void HYDROGUI_Module::createActions()
   createAction( RiverBottomId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
   createAction( RiverBottomContextId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
   createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" );
+
+  createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
 }
 
 void HYDROGUI_Module::createMenus()
@@ -522,6 +525,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case HideAllId:
     anOp = new HYDROGUI_ShowHideOp( aModule, theId );
     break;
+  case SubmersibleId:
+    anOp = new HYDROGUI_SubmersibleOp( aModule );
+    break;
   }
 
   if( !anOp )
index 5640e00963717743b0952e87f04f965c4cf38b45..5362e538f98e083068eb0f46b35934043ad0e722 100644 (file)
@@ -105,7 +105,9 @@ enum OperationId
 
   RiverBottomId,
   RiverBottomContextId,
-  ProfileInterpolateId
+  ProfileInterpolateId,
+
+  SubmersibleId,
 };
 
 #endif
diff --git a/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx b/src/HYDROGUI/HYDROGUI_SubmersibleOp.cxx
new file mode 100644 (file)
index 0000000..630bf67
--- /dev/null
@@ -0,0 +1,54 @@
+// 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_SubmersibleOp.h>
+#include <HYDROGUI_Tool.h>
+#include <HYDROGUI_Module.h>
+
+HYDROGUI_SubmersibleOp::HYDROGUI_SubmersibleOp( HYDROGUI_Module* theModule )
+  : HYDROGUI_Operation( theModule )
+{
+}
+
+HYDROGUI_SubmersibleOp::~HYDROGUI_SubmersibleOp()
+{
+}
+
+void HYDROGUI_SubmersibleOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+  myObject = Handle(HYDROData_Object)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+  if( myObject.IsNull() )
+    onCancel();
+  else
+    onApply();
+}
+
+bool HYDROGUI_SubmersibleOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
+                                                QStringList& theBrowseObjectsEntries )
+{
+  bool isOK = !myObject.IsNull();
+  theUpdateFlags = 0;
+  if( isOK )
+  {
+    myObject->SetIsSubmersible( !myObject->IsSubmersible() );
+    theUpdateFlags = 0;
+  }
+  return isOK;
+}
+
diff --git a/src/HYDROGUI/HYDROGUI_SubmersibleOp.h b/src/HYDROGUI/HYDROGUI_SubmersibleOp.h
new file mode 100644 (file)
index 0000000..e4f26a5
--- /dev/null
@@ -0,0 +1,42 @@
+// 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_SUBMERSIBLEOP_H
+#define HYDROGUI_SUBMERSIBLEOP_H
+
+#include <HYDROGUI_Operation.h>
+#include <HYDROData_Object.h>
+
+class HYDROGUI_SubmersibleOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_SubmersibleOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_SubmersibleOp();
+
+protected:
+  virtual void startOperation();
+  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg,
+                             QStringList& theBrowseObjectsEntries );
+
+private:
+  Handle(HYDROData_Object) myObject;
+};
+
+#endif
index dbbf4380ba300b0b39783a8abcba871a218bb22b..cf09a9d9d9c4f526caee6d88be82eb2084e71c80 100644 (file)
       <source>ARROW_BOTTOM_ICO</source>
       <translation>icon_arrow_bottom.png</translation>
     </message>
+    <message>
+      <source>SUBMERSIBLE_ICO</source>
+      <translation>icon_submersible.png</translation>
+    </message>
 
 
     <!-- Icons for objects -->
index 58c93cdeccaed923a6999be83eeece96086bb9e2..996a948d956ad7d6056eb80241baa2d65cbcc657 100644 (file)
@@ -866,6 +866,10 @@ Would you like to remove all references from the image?</translation>
       <source>DSK_EDIT_LOCAL_CS</source>
       <translation>Change local CS</translation>
     </message>
+    <message>
+      <source>DSK_SUBMERSIBLE</source>
+      <translation>Submersible</translation>
+    </message>
     <message>
       <source>MEN_CREATE_CALCULATION</source>
       <translation>Create calculation case</translation>
@@ -1122,6 +1126,10 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_EDIT_LOCAL_CS</source>
       <translation>Change local CS</translation>
     </message>
+    <message>
+      <source>MEN_SUBMERSIBLE</source>
+      <translation>Submersible</translation>
+    </message>
     <message>
       <source>STB_CREATE_CALCULATION</source>
       <translation>Create calculation case</translation>
@@ -1359,6 +1367,11 @@ Would you like to remove all references from the image?</translation>
       <source>STB_CREATE_STREAM_BOTTOM</source>
       <translation>Creates the stream bottom polyline on selected stream object</translation>
     </message>
+    <message>
+      <source>STB_SUBMERSIBLE</source>
+      <translation>If the object is submersible</translation>
+    </message>
+
 
     <message>
       <source>MEN_PROFILE_INTERPOLATE</source>
diff --git a/src/HYDROGUI/resources/icon_submersible.png b/src/HYDROGUI/resources/icon_submersible.png
new file mode 100644 (file)
index 0000000..a134745
Binary files /dev/null and b/src/HYDROGUI/resources/icon_submersible.png differ