]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #531: Show/Hide eye in HYDRO
authorstv <stv@opencascade.com>
Fri, 15 May 2015 10:13:50 +0000 (13:13 +0300)
committerstv <stv@opencascade.com>
Fri, 15 May 2015 10:13:50 +0000 (13:13 +0300)
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h

index 159851abf96c293a130ad8011efd8b7298f65a47..64e287dbf29b62f6d5c4e1aa692355e348de5e93 100644 (file)
@@ -288,6 +288,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
 
   HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN );
   for( ; anIterator.More(); anIterator.Next() ) {
+    LightApp_DataObject* obj = 0;
     Handle(HYDROData_Entity) anObj = anIterator.Current();
 
     if ( !anObj.IsNull() )
@@ -298,7 +299,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_Image) anImageObj =
             Handle(HYDROData_Image)::DownCast( anObj );
           if( !anImageObj.IsNull() ) {
-            createObject( anImageRootObj, anImageObj );
+            obj = createObject( anImageRootObj, anImageObj );
           }
 
           break;
@@ -308,7 +309,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_Bathymetry) aBathymetryObj =
             Handle(HYDROData_Bathymetry)::DownCast( anObj );
           if( !aBathymetryObj.IsNull() ) {
-            createObject( aBathymetryRootObj, aBathymetryObj );
+            obj = createObject( aBathymetryRootObj, aBathymetryObj );
           }
 
           break;
@@ -318,7 +319,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_Channel) aChannelObj =
             Handle(HYDROData_Channel)::DownCast( anObj );
           if( !aChannelObj.IsNull() ) {
-            createObject( anArtificialObjectsRootObj, aChannelObj );
+            obj = createObject( anArtificialObjectsRootObj, aChannelObj );
           }
 
           break;
@@ -328,7 +329,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_Digue) aDigueObj =
             Handle(HYDROData_Digue)::DownCast( anObj );
           if( !aDigueObj.IsNull() ) {
-            createObject( anArtificialObjectsRootObj, aDigueObj );
+            obj = createObject( anArtificialObjectsRootObj, aDigueObj );
           }
 
           break;
@@ -338,7 +339,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_ImmersibleZone) anImmersibleZoneObj =
             Handle(HYDROData_ImmersibleZone)::DownCast( anObj );
           if( !anImmersibleZoneObj.IsNull() ) {
-            createObject( aNaturalObjectsRootObj, anImmersibleZoneObj );
+            obj = createObject( aNaturalObjectsRootObj, anImmersibleZoneObj );
           }
 
           break;
@@ -348,7 +349,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_River) aRiverObj =
             Handle(HYDROData_River)::DownCast( anObj );
           if( !aRiverObj.IsNull() ) {
-            createObject( aNaturalObjectsRootObj, aRiverObj );
+            obj = createObject( aNaturalObjectsRootObj, aRiverObj );
           }
 
           break;
@@ -358,7 +359,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_Stream) aStreamObj =
             Handle(HYDROData_Stream)::DownCast( anObj );
           if( !aStreamObj.IsNull() ) {
-            createObject( aNaturalObjectsRootObj, aStreamObj );
+            obj = createObject( aNaturalObjectsRootObj, aStreamObj );
           }
 
           break;
@@ -368,7 +369,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_Obstacle) anObstacleObj =
             Handle(HYDROData_Obstacle)::DownCast( anObj );
           if( !anObstacleObj.IsNull() ) {
-            createObject( anObstaclesRootObj, anObstacleObj );
+            obj = createObject( anObstaclesRootObj, anObstacleObj );
           }
 
           break;
@@ -378,7 +379,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_CalculationCase) aCalculObj =
             Handle(HYDROData_CalculationCase)::DownCast( anObj );
           if( !aCalculObj.IsNull() ) {
-            createObject( aCalculRootObj, aCalculObj );
+            obj = createObject( aCalculRootObj, aCalculObj );
           }
 
           break;
@@ -388,7 +389,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_PolylineXY) aPolylineObj =
             Handle(HYDROData_PolylineXY)::DownCast( anObj );
           if( !aPolylineObj.IsNull() ) {
-            createObject( aPolylineRootObj, aPolylineObj );
+            obj = createObject( aPolylineRootObj, aPolylineObj );
           }
 
           break;
@@ -398,7 +399,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_Polyline3D) aPolylineObj =
             Handle(HYDROData_Polyline3D)::DownCast( anObj );
           if( !aPolylineObj.IsNull() ) {
-            createObject( aPolyline3DRootObj, aPolylineObj );
+            obj = createObject( aPolyline3DRootObj, aPolylineObj );
           }
 
           break;
@@ -408,7 +409,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_Profile) aProfileObj =
             Handle(HYDROData_Profile)::DownCast( anObj );
           if( !aProfileObj.IsNull() ) {
-            createObject( aProfileRootObj, aProfileObj );
+            obj = createObject( aProfileRootObj, aProfileObj );
           }
 
           break;
@@ -418,7 +419,7 @@ void HYDROGUI_DataModel::update( const int theStudyId )
           Handle(HYDROData_VisualState) aVisualStateObj =
             Handle(HYDROData_VisualState)::DownCast( anObj );
           if( !aVisualStateObj.IsNull() ) {
-            createObject( aVisualStateRootObj, aVisualStateObj );
+            obj = createObject( aVisualStateRootObj, aVisualStateObj );
           }
 
           break;
@@ -441,12 +442,12 @@ void HYDROGUI_DataModel::update( const int theStudyId )
   ::synchronize < suitPtr, suitPtr, HYDROGUI_DataModelSync >
     ( aNewRootObj, aRoot, aSync );
 
+  SUIT_DataBrowser* ob = anApp->objectBrowser();
 
-  if( !myStates.isEmpty() )
+  if ( !myStates.isEmpty() )
   {
-    LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( module()->application() );
-    anApp->objectBrowser()->updateTree();
-    anApp->objectBrowser()->setOpenStates( myStates, ENTRY_COLUMN );
+    ob->updateTree();
+    ob->setOpenStates( myStates, ENTRY_COLUMN );
     myStates.clear();
   }
 }
@@ -681,7 +682,36 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject*
                                                        const bool               theIsBuildTree )
 {
   HYDROGUI_DataObject* aResObj = new HYDROGUI_DataObject( theParent, theModelObject, theParentEntry );
-  
+
+  const ObjectKind aKind = theModelObject->GetKind();
+  bool visibility = aKind == KIND_IMAGE || aKind == KIND_POLYLINEXY || aKind == KIND_POLYLINE ||
+                    aKind == KIND_SHAPES_GROUP || aKind == KIND_SPLITTED_GROUP || aKind == KIND_ZONE ||
+                    aKind == KIND_IMMERSIBLE_ZONE || aKind == KIND_REGION || aKind == KIND_BATHYMETRY ||
+                    aKind == KIND_OBSTACLE || aKind == KIND_STREAM || aKind == KIND_CHANNEL ||
+                    aKind == KIND_DIGUE || aKind == KIND_DUMMY_3D;
+  if ( !visibility )
+  {
+    Handle(HYDROData_Profile) aProfObj = Handle(HYDROData_Profile)::DownCast( theModelObject );
+    visibility = !aProfObj.IsNull() && aProfObj->IsValid();
+  }
+
+  if ( aKind == KIND_REGION )
+  {
+      QString an = aResObj->name();
+      int a = 0;
+  }
+
+  if ( visibility )
+  {
+    SUIT_AbstractModel* treeModel = 0;
+    LightApp_Application* app = dynamic_cast<LightApp_Application*>( module()->application() );
+    if ( app )
+        treeModel = dynamic_cast<SUIT_AbstractModel*>( app->objectBrowser()->model() );
+
+    if ( treeModel )
+      treeModel->setVisibilityState( aResObj->text( aResObj->customData( Qtx::IdType ).toInt() ), Qtx::HiddenState, false );
+  }
+
   if ( theIsBuildTree )
   {
     buildObjectTree( theParent, aResObj, theParentEntry );
@@ -1108,4 +1138,3 @@ bool HYDROGUI_DataModel::rename( Handle(HYDROData_Entity) theEntity, const QStri
   }
   return true;
 }
-
index a9690cdb396f1195c7c6646afcf839c207c3f82a..87014307d5b963a43459185a89e821f7211d6584 100644 (file)
 #include <SALOME_Event.h>
 
 #include <SUIT_DataBrowser.h>
-#include <SUIT_Desktop.h>
-#include <SUIT_Study.h>
+#include <SUIT_DataObject.h>
 #include <SUIT_ViewManager.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Study.h>
 #include <SUIT_Session.h>
 
 #include <SVTK_ViewManager.h>
@@ -236,6 +237,10 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
     }
   }
 
+//  SUIT_DataBrowser* ob = getApp()->objectBrowser();
+//  SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
+//  treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
+
   return aRes;
 }
 
@@ -943,6 +948,14 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
 
     ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
     anObjectState.Visibility = theState;
+
+    HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
+
+    SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
+    QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
+    Qtx::VisibilityState visState = treeModel->visibilityState( id );
+    if ( visState != Qtx::UnpresentableState )
+        treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
   }
 }
 
@@ -1619,3 +1632,39 @@ HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
 
   return anOp;
 }
+
+/*!
+ * \brief Virtual public slot
+ *
+ * This method is called after the object inserted into data view to update their visibility state
+ * This is default implementation
+ */
+void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
+{
+  if ( !isActiveModule() )
+      return;
+
+  HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
+
+  // change visibility of object
+  if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
+      return;
+
+  SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
+
+  QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
+  Qtx::VisibilityState visState = treeModel->visibilityState( id );
+  if ( visState == Qtx::UnpresentableState )
+      return;
+
+  visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
+  treeModel->setVisibilityState( id, visState );
+
+  bool vis = visState == Qtx::ShownState;
+  if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
+      return;
+
+  setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
+
+  update( UF_OCCViewer | UF_FitAll );
+}
index 6aa6f6da2dd5692b097f792513705ce84286fe8e..4cf3a97bfbeaffa47d808822fb0426f121b7b5bb 100644 (file)
@@ -208,6 +208,7 @@ protected:
 public slots:
   virtual bool                    activateModule( SUIT_Study* );
   virtual bool                    deactivateModule( SUIT_Study* );
+  virtual void                    onObjectClicked( SUIT_DataObject*, int );
 
 protected:
   virtual LightApp_Operation*     createOperation( const int ) const;