]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Boundary polyline for calculation Cases added (Feature #10).
authoradv <adv@opencascade.com>
Fri, 13 Sep 2013 05:58:39 +0000 (05:58 +0000)
committeradv <adv@opencascade.com>
Fri, 13 Sep 2013 05:58:39 +0000 (05:58 +0000)
src/HYDROData/HYDROData_Calculation.cxx
src/HYDROData/HYDROData_Calculation.h
src/HYDROData/HYDROData_Iterator.h
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_InputPanel.cxx
src/HYDROGUI/HYDROGUI_InputPanel.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index d56296faa6f63366f663fc3853b8463b7e6b3d60..e22f7a575c00af47958f6ec196aa4f6a69e84081 100644 (file)
@@ -2,6 +2,10 @@
 #include "HYDROData_Calculation.h"
 
 #include "HYDROData_Document.h"
+#include "HYDROData_Iterator.h"
+#include "HYDROData_Polyline.h"
+
+#include <TDataStd_ReferenceList.hxx>
 
 #include <QStringList>
 
@@ -38,3 +42,32 @@ QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreated
 
   return aResList;
 }
+
+void HYDROData_Calculation::SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline )
+{
+  Handle(TDataStd_ReferenceList) aRefs;
+  myLab.FindChild( DataTag_BoundaryPolyline ).FindAttribute( TDataStd_ReferenceList::GetID(), aRefs );
+  if ( aRefs.IsNull() )
+    aRefs = TDataStd_ReferenceList::Set( myLab.FindChild( DataTag_BoundaryPolyline ) );
+
+  aRefs->Clear();
+
+  if ( thePolyline.IsNull() )
+    return;
+
+  aRefs->Append( thePolyline->Label() );
+}
+
+Handle(HYDROData_Polyline) HYDROData_Calculation::GetBoundaryPolyline() const
+{
+  Handle(HYDROData_Polyline) aRes;
+
+  Handle(TDataStd_ReferenceList) aRefs;
+  myLab.FindChild( DataTag_BoundaryPolyline ).FindAttribute( TDataStd_ReferenceList::GetID(), aRefs );
+  if ( !aRefs.IsNull() && !aRefs->IsEmpty() )
+  {
+    aRes = Handle(HYDROData_Polyline)::DownCast( HYDROData_Iterator::Object( aRefs->First() ) );
+  }
+
+  return aRes;
+}
index 1f9a7716d1d0f3abbdaedb229cf05d0d8c3496e4..cee923cecc6ca48b4206d7630844bf4771bff632 100644 (file)
@@ -9,6 +9,8 @@ class gp_XYZ;
 class QPointF;
 class QFile;
 
+class Handle(HYDROData_Polyline);
+
 DEFINE_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object)
 
 
@@ -28,6 +30,7 @@ protected:
   enum DataTag
   {
     DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_BoundaryPolyline,    ///< reference boundary polyline
   };
 
 public:
@@ -48,6 +51,9 @@ public:
 public:      
   // Public methods to work with Calculation
 
+  HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline );
+
+  HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline) GetBoundaryPolyline() const;
 
 protected:
 
index 617d54d4a94ab5390315ea021e2c883997bb62b8..8fc27f833e0f749e2f108a2e6c2081093840a0c3 100644 (file)
@@ -43,6 +43,7 @@ protected:
 
   friend class HYDROData_Document;
   friend class HYDROData_Image;
+  friend class HYDROData_Calculation;
 
   /**
    * Creates object in the document, call HYDROData_Document method to create 
index 5ecbbd432f9b5332e9ca73d3f1f7cf122b36bc35..b1f888174f1366048fa16c431475e8e73912ea78 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "HYDROGUI_CalculationDlg.h"
 
+#include "HYDROGUI_ObjSelector.h"
 #include "HYDROGUI_Tool.h"
 
 #include <SUIT_FileDlg.h>
@@ -39,7 +40,7 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
 : HYDROGUI_InputPanel( theModule, theTitle )
 {
   // Calculation name
-  myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ) );
+  myObjectNameGroup = new QGroupBox( tr( "CALCULATION_NAME" ), mainFrame() );
 
   myObjectName = new QLineEdit( myObjectNameGroup );
 
@@ -49,8 +50,19 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
   aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
   aNameLayout->addWidget( myObjectName );
 
+  QGroupBox* aBndGroup = new QGroupBox( tr( "CALCULATION_BOUNDARY" ), mainFrame() );
+
+  myBndPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINE, aBndGroup );
+
+  QBoxLayout* aBndLayout = new QHBoxLayout( aBndGroup );
+  aBndLayout->setMargin( 5 );
+  aBndLayout->setSpacing( 5 );
+  aBndLayout->addWidget( new QLabel( tr( "BOUNDARY_POLYLINE" ), aBndGroup ) );
+  aBndLayout->addWidget( myBndPolyline );
+
   // Common
   addWidget( myObjectNameGroup );
+  addWidget( aBndGroup );
   addStretch();
 }
 
@@ -61,6 +73,8 @@ HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
 void HYDROGUI_CalculationDlg::reset()
 {
   myObjectName->clear();
+
+  myBndPolyline->Clear();
 }
 
 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
@@ -73,6 +87,15 @@ QString HYDROGUI_CalculationDlg::getObjectName() const
   return myObjectName->text();
 }
 
+void HYDROGUI_CalculationDlg::setPolylineName( const QString& theName )
+{
+  myBndPolyline->SetName( theName );
+}
+
+QString HYDROGUI_CalculationDlg::getPolylineName() const
+{
+  return myBndPolyline->GetName();
+}
 
 
 
index 44b1b8ca56edd81efb6dcacf763a9ef51b2e5586..b9a0395cf63895e660dc5b420fbb003836e137f7 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "HYDROGUI_InputPanel.h"
 
+class HYDROGUI_ObjSelector;
 class QGroupBox;
 class QLineEdit;
 
@@ -41,10 +42,14 @@ public:
   void                       setObjectName( const QString& theName );
   QString                    getObjectName() const;
 
+  void                       setPolylineName( const QString& theName );
+  QString                    getPolylineName() const;
+
 private:
   QGroupBox*                 myObjectNameGroup;
   QLineEdit*                 myObjectName;
 
+  HYDROGUI_ObjSelector*      myBndPolyline;
 };
 
 #endif
index 25aac2717abbc34b2da26389c67bd370c649fda6..2e36bf50f5f5ab4ea51937c6cfe505af466b4bb0 100644 (file)
@@ -28,6 +28,8 @@
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
 
+#include <HYDROData_Polyline.h>
+
 #include <LightApp_Application.h>
 #include <LightApp_UpdateFlags.h>
 
@@ -60,7 +62,16 @@ void HYDROGUI_CalculationOp::startOperation()
   {
     myEditedObject = Handle(HYDROData_Calculation)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
     if ( !myEditedObject.IsNull() )
+    {
       anObjectName = myEditedObject->GetName();
+
+      Handle(HYDROData_Polyline) aBoundaryPolyline = myEditedObject->GetBoundaryPolyline();
+      if ( !aBoundaryPolyline.IsNull() )
+      {
+        QString aPolylineName = aBoundaryPolyline->GetName();
+        aPanel->setPolylineName( aPolylineName );
+      }
+    }
   }
 
   aPanel->setObjectName( anObjectName );
@@ -112,6 +123,17 @@ bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
 
   aCalculObj->SetName( anObjectName );
 
+  Handle(HYDROData_Polyline) aBndPolyline;
+
+  QString aPolylineName = aPanel->getPolylineName();
+  if ( !aPolylineName.isEmpty() )
+  {
+    aBndPolyline = Handle(HYDROData_Polyline)::DownCast(
+      HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINE ) );
+  }
+
+  aCalculObj->SetBoundaryPolyline( aBndPolyline );
+
   theUpdateFlags = UF_Model;
 
   return true;
index 5857decfd8efd5b27317b8119518f25620e92d9a..68c084a2534e12904e1ad29f1da8b200adbd862a 100644 (file)
@@ -108,3 +108,9 @@ void HYDROGUI_InputPanel::addStretch()
   QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
   aMainLayout->addStretch();
 }
+
+QFrame* HYDROGUI_InputPanel::mainFrame() const
+{
+  return myMainFrame;
+}
+
index 847dfc7282f949755e52f316a365e3d00c7618bd..3321f56d11df239cc6ccaf041394e97d977b4563 100644 (file)
@@ -57,6 +57,9 @@ protected slots:
   void onCancel();
   void onHelp();
 
+protected:
+  QFrame*         mainFrame() const;
+
 private:
   HYDROGUI_Module* myModule;
   QFrame* myMainFrame;
index b3a987710923f2093362a75db54724afa66fb7ab..0a8796b69e19a7bb35824880a7f7d0a7173b1027 100644 (file)
@@ -40,6 +40,14 @@ does not exist or you have not enough permissions to open it.</translation>
 
   <context>
     <name>HYDROGUI_CalculationDlg</name>
+    <message>
+      <source>BOUNDARY_POLYLINE</source>
+      <translation>Polyline</translation>
+    </message>
+    <message>
+      <source>CALCULATION_BOUNDARY</source>
+      <translation>Domain of calculation Case</translation>
+    </message>
     <message>
       <source>CALCULATION_NAME</source>
       <translation>Calculation Case name</translation>