]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
- Preview for Calculation case wizard is improved.
authorrkv <rkv@opencascade.com>
Wed, 6 Nov 2013 07:50:42 +0000 (07:50 +0000)
committerrkv <rkv@opencascade.com>
Wed, 6 Nov 2013 07:50:42 +0000 (07:50 +0000)
- Zones are selectable now and visible only if the second page of the wizard is active.
- When select a region all its zones are selected.
- Split is done only if the case is modified.

src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Wizard.h

index 0de08e8a9f7be76fd084926ab93c7d75ae0a5721..0c83743c7ac595964a30f54cb92504e4f9100488 100644 (file)
@@ -66,6 +66,8 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
   aWizard->addPage( createObjectsPage() );
   aWizard->addPage( createZonesPage() );
   connect( aWizard->button( QWizard::NextButton ), SIGNAL( clicked() ), SIGNAL( splitZones() ) );
+  connect( aWizard->button( QWizard::BackButton ), SIGNAL( clicked() ), SIGNAL( hideZones() ) );
+  
   aWizard->show();
 }
 
@@ -167,6 +169,7 @@ QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
 
   aPage->setLayout( aLayout );
 
+  connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
   connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
   connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
   connect( myBrowser, 
index 627c9fe7d95cdff89d24033b60e3910481031f5f..6c533e701fff08e6c297c814ddefe2d009383218 100644 (file)
@@ -80,9 +80,11 @@ signals:
   void                       addObjects();
   void                       removeObjects();
   void                       splitZones();
+  void                       hideZones();
   void                       setMergeType( int theMergeType, QString& theBathymetryName );
   void                       createRegion( const QList<SUIT_DataObject*>& theZonesList );
   void                       moveZones( SUIT_DataObject* theRegion, const QList<SUIT_DataObject*>& theZonesList );
+  void                       clickedInZonesBrowser( SUIT_DataObject* );
 
 private:
 
index c37a2ffc59695733d7941fa82f828c21043b419e..e826fb926f4e15ae7ff317c182ecc64c7b156502 100644 (file)
@@ -41,6 +41,8 @@
 
 #include <LightApp_Application.h>
 #include <LightApp_UpdateFlags.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_DataOwner.h>
 
 #include <SUIT_MessageBox.h>
 #include <SUIT_Desktop.h>
@@ -73,7 +75,6 @@ void HYDROGUI_CalculationOp::startOperation()
   if ( !aPanel )
     return;
 
-  myRegionsList.clear();
   aPanel->reset();
 
   QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), "Case" );
@@ -150,16 +151,52 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
   connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
   connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
   connect( aPanel, SIGNAL( splitZones() ), SLOT( onSplitZones() ) );
+  connect( aPanel, SIGNAL( hideZones() ), SLOT( onHideZones() ) );
   connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
   connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
   connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
     SLOT( onMoveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ) );
   connect( aPanel, SIGNAL( createRegion( const QList<SUIT_DataObject*>& ) ),
     SLOT( onCreateRegion( const QList<SUIT_DataObject*>& ) ) );
+  connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ),
+    SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
 
   return aPanel;
 }
 
+void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
+{
+  HYDROGUI_Region* aRegionItem = dynamic_cast<HYDROGUI_Region*>(theItem);
+  HYDROGUI_Zone* aZoneItem;
+  selectionMgr()->clearSelected();
+  if ( aRegionItem )
+  {
+    // Select a region in preview
+    SUIT_DataOwnerPtrList aList( true );
+    DataObjectList aZones = aRegionItem->children();
+    for ( int i = 0; i < aZones.length(); i++ )
+    {
+      aZoneItem = dynamic_cast<HYDROGUI_Zone*>(aZones.at(i));
+      if ( aZoneItem )
+      {
+        aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
+      }
+    }
+    selectionMgr()->setSelected( aList );
+  }
+  else
+  {
+    // select a single zone
+    aZoneItem = dynamic_cast<HYDROGUI_Zone*>(theItem);
+    if ( aZoneItem )
+    {
+      SUIT_DataOwnerPtrList aList( true );
+      aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
+      selectionMgr()->setSelected( aList );
+    }
+  }
+}
+
 void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem, const QList<SUIT_DataObject*>& theZonesList )
 {
   HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theRegionItem);
@@ -185,6 +222,7 @@ void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem, const
       {
         aPanel->setEditedObject(myEditedObject);
       }
+      createPreview();
     }
   }
 }
@@ -211,6 +249,7 @@ void HYDROGUI_CalculationOp::onCreateRegion( const QList<SUIT_DataObject*>& theZ
     {
       aPanel->setEditedObject(myEditedObject);
     }
+    createPreview();
   }
 }
 
@@ -224,6 +263,11 @@ void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theBathy
     if ( aZone )
     {
       aZone->setMergeType( theMergeType, theBathymetryName );
+      HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() );
+      if ( aShape )
+      {
+        aShape->update();
+      }
     }
     aPanel->refreshZonesBrowser();
   }
@@ -345,24 +389,99 @@ void HYDROGUI_CalculationOp::onApply()
 
 void HYDROGUI_CalculationOp::onSplitZones()
 {
-  HYDROGUI_CalculationDlg* aPanel = 
-    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
-  if ( !aPanel )
-    return;
-
   QApplication::setOverrideCursor( Qt::WaitCursor );
 
-  myEditedObject->SplitGeometryObjects();
-  aPanel->setEditedObject( myEditedObject );
-  createPreview();
+  if ( myEditedObject->IsMustBeUpdated() )
+  {
+    myShowZones = true;
+    myEditedObject->SplitGeometryObjects();
+
+    HYDROGUI_CalculationDlg* aPanel = 
+      ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+    if ( aPanel )
+    {
+      aPanel->setEditedObject( myEditedObject );
+    }
+
+    createPreview();
+  }
+  else
+  {
+    setZonesVisible( true );
+  }
 
   QApplication::restoreOverrideCursor();
 }
 
+void HYDROGUI_CalculationOp::onHideZones()
+{
+  setZonesVisible( false );
+}
+
+void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
+{
+  myShowZones = theIsVisible;
+  HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
+  HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
+  HYDROData_SequenceOfObjects aZones;
+  Handle(HYDROData_Region) aRegion;
+  if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
+  {
+    Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+    if ( !aCtx.IsNull() )
+    {
+      for ( ; aRegionsIter.More(); aRegionsIter.Next() )
+      {
+        aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
+        if ( !aRegion.IsNull() )
+        {
+          aZones = aRegion->GetZones();
+          HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
+          for ( ; aZonesIter.More(); aZonesIter.Next() )
+          {
+            if ( theIsVisible )
+            {
+              showObject( aZonesIter.Value(), aCtx );
+            }
+            else
+            {
+              module()->removeObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZonesIter.Value() );
+            }
+          }
+        }
+      }
+    }
+  }
+}
+
 void HYDROGUI_CalculationOp::createPreview()
 {
   LightApp_Application* anApp = module()->getApp();
   HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
+  Handle(HYDROData_Entity) anEntity;
+
+  if ( myShowZones )
+  {
+    // Gather zones for displaying
+    HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
+    HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
+    HYDROData_SequenceOfObjects aZones;
+    Handle(HYDROData_Region) aRegion;
+    for ( ; aRegionsIter.More(); aRegionsIter.Next() )
+    {
+      anEntity = aRegionsIter.Value();
+      if ( !anEntity.IsNull() )
+      {
+        aRegion = Handle(HYDROData_Region)::DownCast( anEntity );
+        if ( !aRegion.IsNull() )
+        {
+          aZones = aRegion->GetZones();
+          aSeq.Append( aZones );
+        }
+      }
+    }
+  }
+
   module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones );
 
   if ( !myActiveViewManager )
@@ -396,26 +515,9 @@ void HYDROGUI_CalculationOp::createPreview()
     if ( !aCtx.IsNull() )
     {
       HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
-      Handle(HYDROData_Object) anObject;
-      Handle(HYDROData_Entity) anEntity;
-      HYDROGUI_Shape* aShape;
       for ( ; anIter.More(); anIter.Next() )
       {
-        anEntity = anIter.Value();
-        if ( !anEntity.IsNull() )
-        {
-          anObject = Handle(HYDROData_Object)::DownCast( anEntity );
-          if ( !anObject.IsNull() )
-          {
-            aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject );
-            if ( !aShape )
-            {
-              aShape = new HYDROGUI_Shape( aCtx, anObject );
-            }
-            aShape->update();
-            module()->setObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anObject, aShape );
-          }
-        }
+        showObject( anIter.Value(), aCtx );
       }
 
       //Process the draw events for viewer
@@ -426,6 +528,20 @@ void HYDROGUI_CalculationOp::createPreview()
   }
 }
 
+void HYDROGUI_CalculationOp::showObject( Handle(HYDROData_Entity) theEntity, Handle(AIS_InteractiveContext) theCtx )
+{
+  if ( !theEntity.IsNull() )
+  {
+    HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity );
+    if ( !aShape )
+    {
+      aShape = new HYDROGUI_Shape( theCtx, theEntity );
+      module()->setObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, theEntity, aShape );
+    }
+    aShape->update();
+  }
+}
+
 void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
 {
   closePreview();
index 3cf13988affa816f1adf4c57d1fd81a4d6c08db8..b5dec9d6bcd54909178c464e1f3885cb750c0052 100644 (file)
@@ -40,33 +40,6 @@ class HYDROGUI_CalculationOp : public HYDROGUI_Operation
 {
   Q_OBJECT
 
-  struct Region
-  {
-    QString                            RegionName;
-    QColor                             FillingColor;
-    QColor                             BorderColor;
-    HYDROData_SplitToZonesTool::SplitData SplitData;
-    HYDROGUI_Shape*                    Shape;
-    Handle(HYDROData_Region)           DataRegion;
-
-    Region()
-    : Shape( NULL ),
-      FillingColor( Qt::green ),
-      BorderColor( Qt::transparent )
-    { }
-
-    ~Region()
-    {
-      if ( Shape )
-      {
-        delete Shape;
-        Shape = NULL;
-      }
-    }
-  };
-
-  typedef QList<Region>         RegionsList;
-
 public:
   HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit );
   virtual ~HYDROGUI_CalculationOp();
@@ -99,20 +72,23 @@ protected slots:
   void                            onCreateRegion( const QList<SUIT_DataObject*>& theZonesList );
   void                            onSplitZones();
   void                            onLastViewClosed( SUIT_ViewManager* );
+  void                            onClickedInZonesBrowser( SUIT_DataObject* theItem );
+  void                            onHideZones();
 
 private:
   void                            createPreview();
   void                            closePreview();
   void                            updateGeomObjectsList( HYDROGUI_CalculationDlg* thePanel ) const;
+  void                            showObject( Handle(HYDROData_Entity) theEntity, Handle(AIS_InteractiveContext) theCtx );
+  void                            setZonesVisible( bool theIsVisible );
 
 private:
   bool                            myIsEdit;
+  bool                            myShowZones;
   Handle(HYDROData_CalculationCase) myEditedObject;
 
   SUIT_ViewManager*               myActiveViewManager;
-
   OCCViewer_ViewManager*          myPreviewViewManager;
-  RegionsList                     myRegionsList;
 };
 
 #endif
index 1ac88c741e745cc36bcc26dc7be4b0263ad64eb0..9a6c0ca700144bd562ff588259b0508e277063a9 100644 (file)
@@ -162,7 +162,15 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
       }
        
       setFace( aZoneFace, false, false );
-      setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) );
+      if (aZone->IsMergingNeed() && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN )
+      {
+        // Red color for a zone with bathymetry conflict
+        setFillingColor( Qt::red );
+      }
+      else
+      {
+        setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) );
+      }
     }
     else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Image) ) )
     {
index 0349029b7dbfafaeb9bea8150027a4a146d32da7..1ddf93f110e6d321aeb4d0645bfe80afa2a3e6c8 100644 (file)
@@ -39,7 +39,6 @@ public:
 
   void show();
 
-protected:
   QWizard* wizard() const;
 
 private: