]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
- Bathymetry names are shown in the browser in Calculation Case dialog;
authorrkv <rkv@opencascade.com>
Tue, 29 Oct 2013 12:18:29 +0000 (12:18 +0000)
committerrkv <rkv@opencascade.com>
Tue, 29 Oct 2013 12:18:29 +0000 (12:18 +0000)
- Transaction management is changed for the Calculation Case operation, onApply is overriden.

src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/HYDROGUI_DataObject.cxx

index f2f4b79e930295af697a4d766ec3fed4bd04ae45..30292fac85e0e881ea3edd837a8a591e40e21740 100644 (file)
@@ -206,11 +206,6 @@ QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
 void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_Calculation) theCase )
 {
   myEditedObject = theCase;
-  ///////////////////
-  Handle(HYDROData_Object) anEntity = Handle(HYDROData_Object)::DownCast( 
-    module()->getDataModel()->getDocument()->CreateObject( KIND_IMMERSIBLE_ZONE ) );
-  myEditedObject->AddGeometryObject( anEntity );
-  ////////////////
 
   HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" );
   myBrowser->setRoot(anobj);
index aab45580dc26e1e65d000c0f1bab0865ddc2a476..145701827eb6f16b886db05a37c08c044c0d6b6c 100644 (file)
@@ -39,6 +39,9 @@
 #include <LightApp_Application.h>
 #include <LightApp_UpdateFlags.h>
 
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
+
 #include <QApplication>
 
 HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit )
@@ -58,6 +61,9 @@ HYDROGUI_CalculationOp::~HYDROGUI_CalculationOp()
 void HYDROGUI_CalculationOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
+  
+  // Begin transaction
+  startDocOperation();
 
   HYDROGUI_CalculationDlg* aPanel = 
     ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
@@ -100,6 +106,7 @@ void HYDROGUI_CalculationOp::startOperation()
   {
     myEditedObject =
       Handle(HYDROData_Calculation)::DownCast( doc()->CreateObject( KIND_CALCULATION ) );
+    myEditedObject->SetName(anObjectName);
   }
 
   aPanel->setObjectName( anObjectName );
@@ -112,14 +119,16 @@ void HYDROGUI_CalculationOp::startOperation()
 void HYDROGUI_CalculationOp::abortOperation()
 {
   closePreview();
-
+  // Abort transaction
+  abortDocOperation();
   HYDROGUI_Operation::abortOperation();
 }
 
 void HYDROGUI_CalculationOp::commitOperation()
 {
   closePreview();
-
+  // Commit transaction
+  commitDocOperation();
   HYDROGUI_Operation::commitOperation();
 }
 
@@ -140,40 +149,83 @@ bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
   if ( !aPanel )
     return false;
 
-  QString anObjectName = aPanel->getObjectName().simplified();
-  if ( anObjectName.isEmpty() )
-  {
-    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
-    return false;
-  }
+  //QString anObjectName = aPanel->getObjectName().simplified();
+  //if ( anObjectName.isEmpty() )
+  //{
+  //  theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+  //  return false;
+  //}
+
+  //// check that there are no other objects with the same name in the document
+  //if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
+  //{
+  //  Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+  //  if ( !anObject.IsNull() )
+  //  {
+  //    theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
+  //    return false;
+  //  }
+  //}
+
+  //Handle(HYDROData_Document) aDocument = doc();
+
+  //Handle(HYDROData_Calculation) aCalculObj = myIsEdit ? myEditedObject :
+  //  Handle(HYDROData_Calculation)::DownCast( aDocument->CreateObject( KIND_CALCULATION ) );
+  //if ( aCalculObj.IsNull() )
+  //  return false;
+
+  //aCalculObj->SetName( anObjectName );
+
+  //QStringList aRefObjectNames = aPanel->getSelectedGeomObjects();
+  //HYDROData_SequenceOfObjects aGeomObjects = 
+  //  HYDROGUI_Tool::FindObjectsByNames( module(), aRefObjectNames );
 
-  // check that there are no other objects with the same name in the document
-  if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
-  {
-    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
-    if ( !anObject.IsNull() )
-    {
-      theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
-      return false;
-    }
-  }
+  theUpdateFlags = UF_Model;
 
-  Handle(HYDROData_Document) aDocument = doc();
+  return true;
+}
 
-  Handle(HYDROData_Calculation) aCalculObj = myIsEdit ? myEditedObject :
-    Handle(HYDROData_Calculation)::DownCast( aDocument->CreateObject( KIND_CALCULATION ) );
-  if ( aCalculObj.IsNull() )
-    return false;
+void HYDROGUI_CalculationOp::onApply()
+{
+  QApplication::setOverrideCursor( Qt::WaitCursor );
 
-  aCalculObj->SetName( anObjectName );
+  int anUpdateFlags = 0;
+  QString anErrorMsg;
 
-  QStringList aRefObjectNames = aPanel->getSelectedGeomObjects();
-  HYDROData_SequenceOfObjects aGeomObjects = 
-    HYDROGUI_Tool::FindObjectsByNames( module(), aRefObjectNames );
-
-  theUpdateFlags = UF_Model;
+  bool aResult = false;
+  
+  try
+  {
+    aResult = processApply( anUpdateFlags, anErrorMsg );
+  }
+  catch ( Standard_Failure )
+  {
+    Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
+    anErrorMsg = aFailure->GetMessageString();
+    aResult = false;
+  }
+  catch ( ... )
+  {
+    aResult = false;
+  }
+  
+  QApplication::restoreOverrideCursor();
 
-  return true;
+  if ( aResult )
+  {
+    module()->update( anUpdateFlags );
+    commit();
+  }
+  else
+  {
+    abort();
+    QString aMsg = tr( "INPUT_VALID_DATA" );
+    if( !anErrorMsg.isEmpty() )
+      aMsg.prepend( anErrorMsg + "\n" );
+    SUIT_MessageBox::critical( module()->getApp()->desktop(),
+                               tr( "INSUFFICIENT_INPUT_DATA" ),
+                               aMsg ); 
+  }
 }
 
 void HYDROGUI_CalculationOp::onSplitZones()
index 394afcd9bc306ae1b074cb869d5bcedc4ce6d79c..52ae693569549d6d9458ce12e3d79c218b4317d4 100644 (file)
@@ -76,6 +76,7 @@ protected:
 
   virtual HYDROGUI_InputPanel*    createInputPanel() const;
 
+  virtual void                    onApply();
   virtual bool                    processApply( int& theUpdateFlags, QString& theErrorMsg );
 
 protected slots:
index 83be9e8fb4a7230e9b40486228f37da91faeb6e1..133a99d36ff72d7e2fa2ba00abadb27e70af2e3f 100644 (file)
@@ -25,6 +25,7 @@
 #include <HYDROData_Image.h>
 #include <HYDROData_Zone.h>
 #include <HYDROData_Object.h>
+#include <HYDROData_Bathymetry.h>
 
 #include <SUIT_DataObject.h>
 
@@ -94,12 +95,12 @@ QString HYDROGUI_DataObject::text( const int theColumnId ) const
             switch ( theColumnId )
             {
               case RefObjectId:
+                // Get Ref.Object name
                 aRes += aRefGeomObj->GetName() + ", ";
                 break;
               case BathymetryId:
-                //TODO: Get bathymetry name
-                //aRes += aRefGeomObj->
-                ;
+                // Get bathymetry name
+                aRes += aRefGeomObj->GetBathymetry()->GetName();
             }
           }
         }