]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #542: warning about changed objects order
authorasl <asl@opencascade.com>
Thu, 21 May 2015 05:58:31 +0000 (08:58 +0300)
committerasl <asl@opencascade.com>
Thu, 21 May 2015 05:58:31 +0000 (08:58 +0300)
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_ListModel.cxx
src/HYDROGUI/HYDROGUI_ListModel.h
src/HYDROGUI/HYDROGUI_OrderedListWidget.cxx
src/HYDROGUI/HYDROGUI_OrderedListWidget.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 49d6188827c69f86837afd2322ef17ba0e9c8110..c23683e9ac1c16eccefef716e6131012acc106fe 100644 (file)
@@ -738,5 +738,10 @@ void  HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules )
  */
 void HYDROGUI_CalculationDlg::onOrderChanged()
 {
-  myPriorityWidget->setObjects( getGeometryObjects() );
+  bool isConfirmed = true;
+  emit orderChanged( isConfirmed );
+  if( isConfirmed )
+    myPriorityWidget->setObjects( getGeometryObjects() );
+  else
+    myGeomObjects->undoLastMove();
 }
index 3578ec12aa9cd4581e83babe715df5b670c1cb0c..a769f3d44ddd8eecdd81bb41a939568eba419d1f 100644 (file)
@@ -108,6 +108,7 @@ signals:
   void                       addObjects();
   void                       removeObjects();
   void                       objectsSelected();
+  void                       orderChanged( bool& isConfirmed );
 
   void                       addGroups();
   void                       removeGroups();
index 66b9a89bb90b6b64be9ee0ea2145308221aff204..ec7c4c83a479e3b759fd08f99be4b807b7e755a6 100644 (file)
@@ -228,6 +228,7 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
   connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
   connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
   connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
+  connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
   connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
   connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) );
   //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
@@ -518,6 +519,31 @@ bool HYDROGUI_CalculationOp::confirmRegionsChange() const
   return isConfirmed;
 }
 
+bool HYDROGUI_CalculationOp::confirmOrderChange() const
+{
+  // Check if the case is already modified or not
+  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  if ( !isConfirmed )
+  {
+    // If not modified check if the case has already defined regions with zones
+    HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
+    if ( aSeq.Length() > 0 )
+    {
+      // If there are already defined zones then ask a user to confirm zones recalculation
+      isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
+                               tr( "ORDER_CHANGED" ),
+                               tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
+                               QMessageBox::Yes | QMessageBox::No,
+                               QMessageBox::No ) == QMessageBox::Yes );
+    }
+    else
+    {
+      isConfirmed = true; // No regions - no zones - nothing to recalculate
+    }
+  }
+  return isConfirmed;
+}
+
 bool HYDROGUI_CalculationOp::confirmModeChange() const
 {
   // Check if the case is already modified or not
@@ -683,27 +709,32 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     
     // Set parameters for automatic mode
     int aMode = aPanel->getMode();
-    if ( aMode == HYDROData_CalculationCase::AUTOMATIC ) {
+    if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
+    {
       // Set objects in the specified order
-      myEditedObject->RemoveGeometryObjects();
-      foreach ( const QString& aName, aPanel->getAllGeomObjects() ) {
-        Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast( 
-          HYDROGUI_Tool::FindObjectByName( module(), aName ) );
-        if ( anObject.IsNull() ) {
-          continue;
+      if( myEditedObject->IsMustBeUpdated() )
+      {
+        myEditedObject->RemoveGeometryObjects();
+        foreach ( const QString& aName, aPanel->getAllGeomObjects() )
+        {
+          Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast( 
+            HYDROGUI_Tool::FindObjectByName( module(), aName ) );
+          if ( anObject.IsNull() )
+          {
+            continue;
+          }
+          myEditedObject->AddGeometryObject( anObject );
         }
 
-        myEditedObject->AddGeometryObject( anObject );
-      }
-
-      // Clear priority rules
-      //@ASL if ( myEditedObject->GetRulesCount() > 0 ) {
-        myEditedObject->ClearRules( true );
-      //@ASL }
-      // Set priority rules
-      foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) {
-        myEditedObject->AddRule( aRule.Object1, aRule.Priority,
-                                 aRule.Object2, aRule.MergeType );
+        // Clear priority rules
+        //@ASL if ( myEditedObject->GetRulesCount() > 0 ) {
+          myEditedObject->ClearRules( true );
+        //@ASL }
+        // Set priority rules
+        foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) {
+          myEditedObject->AddRule( aRule.Object1, aRule.Priority,
+                                  aRule.Object2, aRule.MergeType );
+        }
       }
     }
     aPanel->setEditZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
@@ -1102,3 +1133,15 @@ void HYDROGUI_CalculationOp::onChangeMode( int theMode )
   myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)theMode );
   aPanel->setMode( theMode );
 }
+
+void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed )
+{
+  HYDROGUI_CalculationDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  isConfirmed = confirmOrderChange();
+  if( isConfirmed )
+    myEditedObject->SetToUpdate( true );
+}
index 9213bee1d2a723f72188298e233c1caf2b68b000..5ae6b3d887c8235401b685bac3a031c08eca0e26 100644 (file)
@@ -115,6 +115,8 @@ protected slots:
    */
   void                            onBoundarySelected ( const QString & theObjName );
 
+  void onOrderChanged( bool& isConfirmed );
+
 private:
   void                            createPreview();
   void                            closePreview();
@@ -143,24 +145,10 @@ private:
                                                              float theSaturation = 0.5,
                                                              float theValue = 0.95 ) const;
 
-  /**
-   * Ask user to confirm splitting zones recalculation after regions list modification.
-   * \return true if confirmed
-   */
-  bool                            confirmRegionsChange() const;
-
-  /**
-   * Ask user to confirm splitting zones recalculation after mode change.
-   * \return true if confirmed
-   */
-  bool                            confirmModeChange() const;
-
-  /**
-   * Ask user to confirm the operation continuation with warning.
-   * @param theWarning the warning
-   * \return true if confirmed
-   */
-  bool                            confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
+  bool confirmRegionsChange() const;
+  bool confirmModeChange() const;
+  bool confirmOrderChange() const;
+  bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
 
 private:
   bool                            myIsEdit;
index 8c1cb7208e2660b4b08a192b88fa450f345f0549..b112dd34a5c3d2261b47df452e377369f3654e54 100644 (file)
@@ -372,6 +372,7 @@ bool HYDROGUI_ListModel::move( const int theItem, const OpType theType,
   if ( aDestinationIndex >= 0 && aDestinationIndex < myObjects.count() ) {
     int aDestinationRow = isInsertBefore ? aDestinationIndex : aDestinationIndex + 1;
     if ( beginMoveRows( QModelIndex(), theItem, theItem, QModelIndex(), aDestinationRow ) ) {
+      myPrevObjects = myObjects;
       myObjects.move( theItem, aDestinationIndex );
       endMoveRows();
       aRes = true;
@@ -487,4 +488,10 @@ bool HYDROGUI_ListModel::isDragAndDropAllowed( const QList<int>& theItems,
 void HYDROGUI_ListModel::setDecorationEnabled( const bool theIsToEnable )
 {
   myIsDecorationEnabled = theIsToEnable;
-}
\ No newline at end of file
+}
+
+void HYDROGUI_ListModel::undoLastMove()
+{
+  myObjects = myPrevObjects;
+  reset();
+}
index 11fd1dfa3fcb0cafd28fe0eea9da80a91fb2b520..46a8487d3b268e241f2b852be1a377162d2be808 100644 (file)
@@ -75,6 +75,8 @@ public:
 
   void setDecorationEnabled( const bool theIsToEnable );
 
+  void undoLastMove();
+
 protected:
   bool isObjectVisible( int theIndex ) const;
   bool isDragAndDropAllowed( const QList<int>& theItems, const int theDropItem ) const;
@@ -82,7 +84,7 @@ protected:
 private:
   friend class test_HYDROGUI_ListModel;
 
-  Object2VisibleList myObjects;
+  Object2VisibleList myObjects, myPrevObjects;
   QPixmap myEmpty, myEye;
 
   bool myIsDecorationEnabled;
index decfd85ae28badba84c05dd31beaf5e218debbc7..1b551cfc17799a0f500add6305dadd8d2cd7b94e 100644 (file)
@@ -323,7 +323,8 @@ void HYDROGUI_OrderedListWidget::onMove( int theType )
     }
   }
 
-  if ( isMoved ) {
+  if ( isMoved )
+  {
     emit orderChanged();
   }
 }
@@ -358,4 +359,11 @@ void HYDROGUI_OrderedListWidget::setOrderingEnabled( const bool theIsToEnable )
 
   // enable/disable drag and drop
   myList->setDragEnabled( theIsToEnable );
-}
\ No newline at end of file
+}
+
+void HYDROGUI_OrderedListWidget::undoLastMove()
+{
+  HYDROGUI_ListModel* aModel = getSourceModel();
+  if( aModel )
+    aModel->undoLastMove();
+}
index 71913500de84fdd9e7ea6dcbc09f4a72aea27636..d0ac12626a2134e7c6d19c12fe5a69c01395aef8 100644 (file)
@@ -58,6 +58,8 @@ public:
   QStringList getSelectedNames() const;
   QStringList getAllNames() const;
 
+  void undoLastMove();
+
 signals:
   void selectionChanged();
   void orderChanged();
index 907037a6715ca68b824e4e815e283e8db3985dee..08446e0e1c885cd07167ad153e60fef6259cb11c 100644 (file)
@@ -337,6 +337,10 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>REGIONS_CHANGED</source>
       <translation>Regions list modification</translation>
     </message>
+    <message>
+      <source>ORDER_CHANGED</source>
+      <translation>Order of objects is changed</translation>
+    </message>
     <message>
       <source>CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS</source>
       <translation>Case splitting zones already exist and will be recalculated after regions list modification. Do you confirm the recalculation?</translation>