From e5ed5aa5ac8420179aa37e3bf3a175e22ef3f69a Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 11 Dec 2009 09:38:55 +0000 Subject: [PATCH] Debug --- idl/SMESH_Hypothesis.idl | 2 - src/SMESHGUI/SMESHGUI_Helper.cxx | 13 ++---- src/SMESHGUI/SMESHGUI_Helper.h | 2 +- src/SMESH_I/SMESH_Gen_i.cxx | 23 ++++++++++ src/SMESH_I/SMESH_Gen_i.hxx | 3 ++ src/SMESH_I/SMESH_Gen_i_1.cxx | 3 ++ src/SMESH_I/SMESH_Hypothesis_i.cxx | 43 ++++++++++++++++++- src/SMESH_I/SMESH_Hypothesis_i.hxx | 11 +++-- src/SMESH_I/SMESH_Mesh_i.cxx | 17 ++++++-- src/SMESH_I/SMESH_Mesh_i.hxx | 13 ++++-- .../StdMeshersGUI_NbSegmentsCreator.cxx | 11 +++-- .../StdMeshersGUI_NbSegmentsCreator.h | 2 +- .../StdMeshersGUI_StdHypothesisCreator.cxx | 39 +++++++++-------- 13 files changed, 130 insertions(+), 52 deletions(-) diff --git a/idl/SMESH_Hypothesis.idl b/idl/SMESH_Hypothesis.idl index d7be98fca..14a0dbad9 100644 --- a/idl/SMESH_Hypothesis.idl +++ b/idl/SMESH_Hypothesis.idl @@ -40,8 +40,6 @@ module SMESH DIM_3D }; - typedef sequence ListOfParameters; - interface SMESH_Hypothesis : SALOME::ParameterizedObject { diff --git a/src/SMESHGUI/SMESHGUI_Helper.cxx b/src/SMESHGUI/SMESHGUI_Helper.cxx index 493ca2337..123dc296f 100644 --- a/src/SMESHGUI/SMESHGUI_Helper.cxx +++ b/src/SMESHGUI/SMESHGUI_Helper.cxx @@ -37,19 +37,14 @@ #include #include -// IDL includes -//#include -//#include CORBA_SERVER_HEADER(SMESH_Mesh) -//#include CORBA_SERVER_HEADER(SMESH_MeshEditor) - //================================================================================= // name : SMESHGUI_Helper::SMESHGUI_Helper // Purpose : //================================================================================= SMESHGUI_Helper::SMESHGUI_Helper( SMESHGUI* theModule ) : - mySMESHGUI( theModule ), - myNotebook( 0 ) + mySMESHGUI( theModule ) { + myNotebook = new SalomeApp_Notebook( mySMESHGUI->activeStudy() ); } //======================================================================= @@ -129,9 +124,7 @@ bool SMESHGUI_Helper::checkParameters( bool theMess, const QListactiveStudy() ); return myNotebook; } diff --git a/src/SMESHGUI/SMESHGUI_Helper.h b/src/SMESHGUI/SMESHGUI_Helper.h index b94ef8239..934be9a84 100644 --- a/src/SMESHGUI/SMESHGUI_Helper.h +++ b/src/SMESHGUI/SMESHGUI_Helper.h @@ -52,7 +52,7 @@ protected: bool checkParameters( bool, int, QAbstractSpinBox*, ... ); bool checkParameters( bool, const QList& ); - SalomeApp_Notebook* getNotebook(); + SalomeApp_Notebook* getNotebook() const; private: SMESHGUI* mySMESHGUI; diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 899581804..a97fde5c2 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -4341,6 +4341,29 @@ int SMESH_Gen_i::GetCurrentStudyID() return myCurrentStudy->_is_nil() || myCurrentStudy->_non_existent() ? -1 : myCurrentStudy->StudyId(); } +//================================================================================= +// function : GetStudy() +// purpose : Returns a pointer to SALOMEDS Study object by its id +//================================================================================= +SALOMEDS::Study_ptr SMESH_Gen_i::GetStudy(CORBA::Long theStudyID) +{ + CORBA::Object_var aSMObject = GetNS()->Resolve( "/myStudyManager" ); + SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject ); + SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( theStudyID ); + return aStudy._retn(); +} + +//================================================================================= +// function : GetNotebook() +// purpose : Returns a pointer to SALOME Notebook object by an id of the study +//================================================================================= +SALOME::Notebook_ptr SMESH_Gen_i::GetNotebook( CORBA::Long theStudyID ) +{ + SALOMEDS::Study_ptr aStudy = GetStudy( theStudyID ); + SALOME::Notebook_var aNotebook = aStudy->GetNotebook(); + return aNotebook._retn(); +} + //============================================================================= /*! * SMESHEngine_factory diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index ed872eee3..1a43e4b3e 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -505,6 +505,9 @@ public: */ SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo); + SALOMEDS::Study_ptr GetStudy(CORBA::Long theStudyID); + SALOME::Notebook_ptr GetNotebook(CORBA::Long theStudyID); + private: // Create hypothesis of given type SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName, diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index cb761b89b..c3123b3f5 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -749,6 +749,9 @@ SALOMEDS::SObject_ptr SetName( aHypSO, theName, aHypName ); } + if( SMESH_Hypothesis_i* aServant = dynamic_cast( GetServant( theHyp ).in() ) ) + aServant->UpdateStringAttribute(); + if(MYDEBUG) MESSAGE("PublishHypothesis--END") return aHypSO._retn(); } diff --git a/src/SMESH_I/SMESH_Hypothesis_i.cxx b/src/SMESH_I/SMESH_Hypothesis_i.cxx index e4f3a43c2..219c1e126 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.cxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.cxx @@ -191,6 +191,8 @@ void SMESH_Hypothesis_i::SetParameters( SALOME::Notebook_ptr theNotebook, const theNotebook->AddDependency( _this(), aParamPtr ); } myBaseImpl->SetParameters( aParams ); + + UpdateStringAttribute(); } //============================================================================= @@ -199,7 +201,6 @@ void SMESH_Hypothesis_i::SetParameters( SALOME::Notebook_ptr theNotebook, const * */ //============================================================================= -//char* SMESH_Hypothesis_i::GetParameters() SALOME::StringArray* SMESH_Hypothesis_i::GetParameters() { std::list aParams = myBaseImpl->GetParameters(); @@ -221,6 +222,46 @@ void SMESH_Hypothesis_i::Update( SALOME::Notebook_ptr theNotebook ) { } +//============================================================================= +/*! + * SMESH_Hypothesis_i::UpdateStringAttribute() + * + */ +//============================================================================= +void SMESH_Hypothesis_i::UpdateStringAttribute() +{ + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + + SALOME::Notebook_ptr aNotebook = aSMESHGen->GetNotebook( myBaseImpl->GetStudyId() ); + + SALOME::StringArray* anObjectParameters = aNotebook->GetObjectParameters( GetComponent(), GetEntry() ); + int aParametersLength = anObjectParameters ? anObjectParameters->length() : 0; + if( aParametersLength == 0 ) + return; + + SALOMEDS::Study_ptr aStudy = aSMESHGen->GetStudy( myBaseImpl->GetStudyId() ); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject( aStudy, SMESH::SMESH_Hypothesis::_narrow( _this() ) ); + if( CORBA::is_nil( aSObject ) ) + return; + + SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute( aSObject, "AttributeString" ); + SALOMEDS::AttributeString_var aStringAttrib = SALOMEDS::AttributeString::_narrow( anAttr ); + + std::string aString; + for( int i = 0, n = anObjectParameters->length(); i < n; i++ ) { + std::string aParameter = anObjectParameters->operator[](i).in(); + if( aParameter != "" ) + { + if( aString != "" ) + aString += ", "; + aString += aParameter; + } + } + aStringAttrib->SetValue( aString.c_str() ); + aStringAttrib->Destroy(); +} + //============================================================================= /*! * SMESH_Hypothesis_i::GetImpl diff --git a/src/SMESH_I/SMESH_Hypothesis_i.hxx b/src/SMESH_I/SMESH_Hypothesis_i.hxx index 6add2c263..939c55c3a 100644 --- a/src/SMESH_I/SMESH_Hypothesis_i.hxx +++ b/src/SMESH_I/SMESH_Hypothesis_i.hxx @@ -65,13 +65,13 @@ public: // Get unique id of hypothesis CORBA::Long GetId(); - // ... + // Get internal entry of hypothesis virtual char* GetEntry(); - // ... + // Get name of the component virtual char* GetComponent(); - // ... + // Get validity status of hypothesis virtual CORBA::Boolean IsValid(); // Set list of parameters, used for Hypothesis creation @@ -80,9 +80,12 @@ public: // Return list of notebook variables used for Hypothesis creation virtual SALOME::StringArray* GetParameters(); - // ... + // Update hypothesis according to the SALOME Notebook virtual void Update( SALOME::Notebook_ptr theNotebook ); + // Update string attribute of hypothesis + virtual void UpdateStringAttribute(); + //Return true if hypothesis was published in study bool IsPublished(); diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index a9235af91..643492dc1 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -3380,7 +3380,7 @@ void SMESH_Mesh_i::checkGroupNames() //============================================================================= /*! - * \brief ... + * \brief Get internal entry of mesh */ //============================================================================= char* SMESH_Mesh_i::GetEntry() @@ -3390,7 +3390,7 @@ char* SMESH_Mesh_i::GetEntry() //============================================================================= /*! - * \brief ... + * \brief Get name of the component */ //============================================================================= char* SMESH_Mesh_i::GetComponent() @@ -3400,7 +3400,7 @@ char* SMESH_Mesh_i::GetComponent() //============================================================================= /*! - * \brief ... + * \brief Get validity status of mesh */ //============================================================================= CORBA::Boolean SMESH_Mesh_i::IsValid() @@ -3429,13 +3429,22 @@ SALOME::StringArray* SMESH_Mesh_i::GetParameters() //============================================================================= /*! - * \brief ... + * \brief Update mesh according to the SALOME Notebook */ //============================================================================= void SMESH_Mesh_i::Update( SALOME::Notebook_ptr theNotebook ) { } +//============================================================================= +/*! + * \brief Update string attribute of mesh + */ +//============================================================================= +void SMESH_Mesh_i::UpdateStringAttribute() +{ +} + //============================================================================= /*! * \brief Returns statistic of mesh elements diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index d8fbb6cf1..c36146ecc 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -472,17 +472,17 @@ public: virtual SALOME_MED::MedFileInfo* GetMEDFileInfo(); /*! - * ... + * Get internal entry of mesh */ virtual char* GetEntry(); /*! - * ... + * Get name of the component */ virtual char* GetComponent(); /*! - * ... + * Get validity status of mesh */ virtual CORBA::Boolean IsValid(); @@ -497,10 +497,15 @@ public: virtual SALOME::StringArray* GetParameters(); /*! - * ... + * Update mesh according to the SALOME Notebook */ virtual void Update( SALOME::Notebook_ptr theNotebook ); + /*! + * Update string attribute of mesh + */ + virtual void UpdateStringAttribute(); + /*! * Returns statistic of mesh elements * Result array of number enityties diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx index 805cdae27..f55424795 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx @@ -91,8 +91,8 @@ bool StdMeshersGUI_NbSegmentsCreator::checkParams( QString& msg, QStringList& ab bool res = true; res = myNbSeg->isValid( msg, absentParams, true ) && res; res = myScale->isValid( msg, absentParams, true ) && res; - res = res && storeParamsToHypo( data_new ); - res = res && storeParamsToHypo( data_old ); + res = res && storeParamsToHypo( data_new, true ); + storeParamsToHypo( data_old, true ); return res; } @@ -342,7 +342,7 @@ bool StdMeshersGUI_NbSegmentsCreator::readParamsFromHypo( NbSegmentsHypothesisDa return true; } -bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothesisData& h_data ) const +bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothesisData& h_data, bool isOnlyCheck ) const { StdMeshers::StdMeshers_NumberOfSegments_var h = StdMeshers::StdMeshers_NumberOfSegments::_narrow( hypothesis() ); @@ -381,9 +381,8 @@ bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothe //the function will be checked with old conversion mode, so that it may occurs //unexpected errors for user - // temporal workaround - StdMeshersGUI_NbSegmentsCreator* that = const_cast( this ); - that->getNotebook()->setParameters( h, aVariablesList ); + if( !isOnlyCheck ) + getNotebook()->setParameters( h, aVariablesList ); } catch(const SALOME::SALOME_Exception& ex) { diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h index 34682a25f..1c9612b28 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h @@ -77,7 +77,7 @@ protected slots: private: bool readParamsFromHypo( NbSegmentsHypothesisData& ) const; bool readParamsFromWidgets( NbSegmentsHypothesisData& ) const; - bool storeParamsToHypo( const NbSegmentsHypothesisData& ) const; + bool storeParamsToHypo( const NbSegmentsHypothesisData&, bool = false ) const; private: SalomeApp_IntSpinBox* myNbSeg; diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index f929b5ffa..3c0075c60 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -39,6 +39,7 @@ // SALOME GUI includes #include +#include // IDL includes #include @@ -421,9 +422,8 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() ); h->SetLength( params[0].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); h->SetPrecision( params[1].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="MaxLength" ) { @@ -431,13 +431,13 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() ); h->SetLength( params[0].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() ); if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) { StdMeshers::StdMeshers_MaxLength_var hInit = StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() ); h->SetPreestimatedLength( hInit->GetPreestimatedLength() ); } + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="SegmentLengthAroundVertex" ) { @@ -445,7 +445,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_SegmentLengthAroundVertex::_narrow( hypothesis() ); h->SetLength( params[0].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="Arithmetic1D" ) { @@ -456,13 +456,12 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 ); h->SetStartLength( params[0].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); h->SetEndLength( params[1].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); if (w) { h->SetReversedEdges( w->GetListOfIDs() ); h->SetObjectEntry( w->GetMainShapeEntry() ); } + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="FixedPoints1D" ) { @@ -476,9 +475,9 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const widget< StdMeshersGUI_SubShapeSelectorWdg >( 1 ); if (w1) { - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); h->SetPoints( w1->GetListOfPoints() ); h->SetNbSegments( w1->GetListOfSegments() ); + getNotebook()->setParameters( h, aVariablesList ); } if (w2) { h->SetReversedEdges( w2->GetListOfIDs() ); @@ -489,8 +488,8 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const { StdMeshers::StdMeshers_MaxElementArea_var h = StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); h->SetMaxElementArea( params[0].myValue.toDouble() ); + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="MaxElementVolume" ) { @@ -498,7 +497,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() ); h->SetMaxElementVolume( params[0].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="StartEndLength" ) { @@ -509,20 +508,19 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const widget< StdMeshersGUI_SubShapeSelectorWdg >( 2 ); h->SetStartLength( params[0].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); h->SetEndLength( params[1].myValue.toDouble() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); if (w) { h->SetReversedEdges( w->GetListOfIDs() ); h->SetObjectEntry( w->GetMainShapeEntry() ); } + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="Deflection1D" ) { StdMeshers::StdMeshers_Deflection1D_var h = StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); h->SetDeflection( params[0].myValue.toDouble() ); + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="AutomaticLength" ) { @@ -537,7 +535,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() ); h->SetNumberOfLayers( params[0].myValue.toInt() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="LayerDistribution" ) { @@ -547,8 +545,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 ); h->SetLayerDistribution( w->GetHypothesis() ); - //h->SetParameters(w->GetHypothesis()->GetParameters()); - //w->GetHypothesis()->ClearParameters(); + /* ouv: temporarily disabled + h->SetParameters(w->GetHypothesis()->GetParameters()); + w->GetHypothesis()->ClearParameters(); + */ } else if( hypType()=="NumberOfLayers2D" ) { @@ -556,7 +556,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_NumberOfLayers2D::_narrow( hypothesis() ); h->SetNumberOfLayers( params[0].myValue.toInt() ); - //h->SetParameters(aVariablesList.join(":").toLatin1().constData()); + getNotebook()->setParameters( h, aVariablesList ); } else if( hypType()=="LayerDistribution2D" ) { @@ -566,8 +566,10 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 ); h->SetLayerDistribution( w->GetHypothesis() ); - //h->SetParameters(w->GetHypothesis()->GetParameters()); - //w->GetHypothesis()->ClearParameters(); + /* ouv: temporarily disabled + h->SetParameters(w->GetHypothesis()->GetParameters()); + w->GetHypothesis()->ClearParameters(); + */ } else if( hypType()=="ProjectionSource1D" ) { @@ -653,7 +655,6 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const } SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis(); - //SMESH::ListOfParameters_var aParameters = hyp->GetLastParameters(); SALOME::StringArray* aParameters = hyp->GetParameters(); if( hypType()=="LocalLength" ) -- 2.39.2