Salome HOME
HYDROGUI_Wizard has been refactored and now uses QStackedWidget instead of QWizard.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationOp.cxx
index e826fb926f4e15ae7ff317c182ecc64c7b156502..b9089a7feb34ed047277060c737f43abaa07b027 100644 (file)
@@ -124,7 +124,7 @@ void HYDROGUI_CalculationOp::updateGeomObjectsList( HYDROGUI_CalculationDlg* the
       }
     }
   }
-  thePanel->setSelectedGeomObjects( aList );
+  thePanel->setGeomObjects( aList );
 }
 
 void HYDROGUI_CalculationOp::abortOperation()
@@ -160,10 +160,57 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
     SLOT( onCreateRegion( const QList<SUIT_DataObject*>& ) ) );
   connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ),
     SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
+  connect( aPanel, SIGNAL( objectSelected( const QString & ) ), 
+    SLOT( onObjectSelected( const QString & ) ) );
 
   return aPanel;
 }
 
+void HYDROGUI_CalculationOp::onObjectSelected ( const QString & theObjName )
+{
+  // Select the appropriate geometry object shape in the viewer
+  selectionMgr()->clearSelected();
+
+  // Unhighlight all objects except selected
+  HYDROGUI_Shape* aShape;
+  HYDROGUI_Shape* aSelectedShape = 0;
+  Handle(HYDROData_Entity) anEntity;
+  HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
+  HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+  bool isSelected;
+  QString aName;
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    anEntity = anIter.Value();
+    if ( !anEntity.IsNull() )
+    {
+      aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity );
+      if ( aShape )
+      {
+        aName = anEntity->GetName();
+        isSelected = ( aName == theObjName );
+        if ( isSelected )
+        {
+          aSelectedShape = aShape;
+        }
+        if ( aShape->isHighlighted() != isSelected )
+        {
+          if ( !isSelected )
+          {
+            aShape->highlight( isSelected );
+            aShape->update();
+          }
+        }
+      }
+    }
+  }
+  if ( aSelectedShape )
+  {
+    aSelectedShape->highlight( true );
+    aSelectedShape->update();
+  }
+}
+
 void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
 {
   HYDROGUI_Region* aRegionItem = dynamic_cast<HYDROGUI_Region*>(theItem);
@@ -425,27 +472,30 @@ void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
   HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
   HYDROData_SequenceOfObjects aZones;
   Handle(HYDROData_Region) aRegion;
-  if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
+  if ( myPreviewViewManager ) 
   {
-    Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
-    if ( !aCtx.IsNull() )
+    if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
     {
-      for ( ; aRegionsIter.More(); aRegionsIter.Next() )
+      Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+      if ( !aCtx.IsNull() )
       {
-        aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
-        if ( !aRegion.IsNull() )
+        for ( ; aRegionsIter.More(); aRegionsIter.Next() )
         {
-          aZones = aRegion->GetZones();
-          HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
-          for ( ; aZonesIter.More(); aZonesIter.Next() )
+          aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
+          if ( !aRegion.IsNull() )
           {
-            if ( theIsVisible )
-            {
-              showObject( aZonesIter.Value(), aCtx );
-            }
-            else
+            aZones = aRegion->GetZones();
+            HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
+            for ( ; aZonesIter.More(); aZonesIter.Next() )
             {
-              module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZonesIter.Value() );
+              if ( theIsVisible )
+              {
+                showObject( aZonesIter.Value(), aCtx );
+              }
+              else
+              {
+                module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZonesIter.Value() );
+              }
             }
           }
         }