From: adv Date: Fri, 13 Sep 2013 05:58:39 +0000 (+0000) Subject: Boundary polyline for calculation Cases added (Feature #10). X-Git-Tag: BR_hydro_v_0_1~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6a7b1d68094c60ceebc46449530a3f12fe16b080;p=modules%2Fhydro.git Boundary polyline for calculation Cases added (Feature #10). --- diff --git a/src/HYDROData/HYDROData_Calculation.cxx b/src/HYDROData/HYDROData_Calculation.cxx index d56296fa..e22f7a57 100644 --- a/src/HYDROData/HYDROData_Calculation.cxx +++ b/src/HYDROData/HYDROData_Calculation.cxx @@ -2,6 +2,10 @@ #include "HYDROData_Calculation.h" #include "HYDROData_Document.h" +#include "HYDROData_Iterator.h" +#include "HYDROData_Polyline.h" + +#include #include @@ -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; +} diff --git a/src/HYDROData/HYDROData_Calculation.h b/src/HYDROData/HYDROData_Calculation.h index 1f9a7716..cee923ce 100644 --- a/src/HYDROData/HYDROData_Calculation.h +++ b/src/HYDROData/HYDROData_Calculation.h @@ -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: diff --git a/src/HYDROData/HYDROData_Iterator.h b/src/HYDROData/HYDROData_Iterator.h index 617d54d4..8fc27f83 100644 --- a/src/HYDROData/HYDROData_Iterator.h +++ b/src/HYDROData/HYDROData_Iterator.h @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 5ecbbd43..b1f88817 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -22,6 +22,7 @@ #include "HYDROGUI_CalculationDlg.h" +#include "HYDROGUI_ObjSelector.h" #include "HYDROGUI_Tool.h" #include @@ -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(); +} diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 44b1b8ca..b9a0395c 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 25aac271..2e36bf50 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -28,6 +28,8 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" +#include + #include #include @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index 5857decf..68c084a2 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -108,3 +108,9 @@ void HYDROGUI_InputPanel::addStretch() QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); aMainLayout->addStretch(); } + +QFrame* HYDROGUI_InputPanel::mainFrame() const +{ + return myMainFrame; +} + diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 847dfc72..3321f56d 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -57,6 +57,9 @@ protected slots: void onCancel(); void onHelp(); +protected: + QFrame* mainFrame() const; + private: HYDROGUI_Module* myModule; QFrame* myMainFrame; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index b3a98771..0a8796b6 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -40,6 +40,14 @@ does not exist or you have not enough permissions to open it. HYDROGUI_CalculationDlg + + BOUNDARY_POLYLINE + Polyline + + + CALCULATION_BOUNDARY + Domain of calculation Case + CALCULATION_NAME Calculation Case name