This commit is contained in:
ouv 2009-12-11 09:38:55 +00:00
parent 8bd7e4737d
commit e5ed5aa5ac
13 changed files with 130 additions and 52 deletions

View File

@ -40,8 +40,6 @@ module SMESH
DIM_3D
};
typedef sequence<string> ListOfParameters;
interface SMESH_Hypothesis : SALOME::ParameterizedObject
{

View File

@ -37,19 +37,14 @@
#include <SalomeApp_IntSpinBox.h>
#include <SalomeApp_Notebook.h>
// IDL includes
//#include <SALOMEconfig.h>
//#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 QList<QAbstractSpinBo
// Function : getNotebook
// Purpose :
//================================================================
SalomeApp_Notebook* SMESHGUI_Helper::getNotebook()
SalomeApp_Notebook* SMESHGUI_Helper::getNotebook() const
{
if ( !myNotebook )
myNotebook = new SalomeApp_Notebook( mySMESHGUI->activeStudy() );
return myNotebook;
}

View File

@ -52,7 +52,7 @@ protected:
bool checkParameters( bool, int, QAbstractSpinBox*, ... );
bool checkParameters( bool, const QList<QAbstractSpinBox*>& );
SalomeApp_Notebook* getNotebook();
SalomeApp_Notebook* getNotebook() const;
private:
SMESHGUI* mySMESHGUI;

View File

@ -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

View File

@ -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,

View File

@ -749,6 +749,9 @@ SALOMEDS::SObject_ptr
SetName( aHypSO, theName, aHypName );
}
if( SMESH_Hypothesis_i* aServant = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( theHyp ).in() ) )
aServant->UpdateStringAttribute();
if(MYDEBUG) MESSAGE("PublishHypothesis--END")
return aHypSO._retn();
}

View File

@ -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<std::string> 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

View File

@ -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();

View File

@ -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

View File

@ -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

View File

@ -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<StdMeshersGUI_NbSegmentsCreator*>( this );
that->getNotebook()->setParameters( h, aVariablesList );
if( !isOnlyCheck )
getNotebook()->setParameters( h, aVariablesList );
}
catch(const SALOME::SALOME_Exception& ex)
{

View File

@ -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;

View File

@ -39,6 +39,7 @@
// SALOME GUI includes
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Notebook.h>
// IDL includes
#include <SALOMEconfig.h>
@ -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" )