mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-30 19:30:35 +05:00
Start implementation of the notebook in SMESH module.
This commit is contained in:
parent
7730fea77b
commit
df96082091
@ -55,6 +55,18 @@ module SMESH
|
|||||||
* Get the internal Id
|
* Get the internal Id
|
||||||
*/
|
*/
|
||||||
long GetId();
|
long GetId();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Set list of parameters
|
||||||
|
* \param theParameters is a string containing the notebook variables separated by ":" symbol,
|
||||||
|
* used for Hypothesis creation
|
||||||
|
*/
|
||||||
|
void SetParameters (in string theParameters);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Return list of notebook variables used for Hypothesis creation separated by ":" symbol
|
||||||
|
*/
|
||||||
|
string GetParameters();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Verify whether hypothesis supports given entity type
|
* Verify whether hypothesis supports given entity type
|
||||||
|
@ -226,12 +226,34 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
|
|||||||
break;
|
break;
|
||||||
case QVariant::String:
|
case QVariant::String:
|
||||||
{
|
{
|
||||||
QLineEdit* le = new QLineEdit( GroupC1 );
|
if((*anIt).isVariable) {
|
||||||
le->setObjectName( (*anIt).myName );
|
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||||
attuneStdWidget( le, i );
|
QString aVar = (*anIt).myValue.toString();
|
||||||
le->setText( (*anIt).myValue.toString() );
|
if(aStudy->IsInteger(aVar.toLatin1().constData())){
|
||||||
connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
|
SalomeApp_IntSpinBox* sb = new SalomeApp_IntSpinBox( GroupC1 );
|
||||||
w = le;
|
sb->setObjectName( (*anIt).myName );
|
||||||
|
attuneStdWidget( sb, i );
|
||||||
|
sb->setText( aVar );
|
||||||
|
connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
|
||||||
|
w = sb;
|
||||||
|
}
|
||||||
|
else if(aStudy->IsReal(aVar.toLatin1().constData())){
|
||||||
|
SalomeApp_DoubleSpinBox* sb = new SMESHGUI_SpinBox( GroupC1 );
|
||||||
|
sb->setObjectName( (*anIt).myName );
|
||||||
|
attuneStdWidget( sb, i );
|
||||||
|
sb->setText( aVar );
|
||||||
|
connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
|
||||||
|
w = sb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QLineEdit* le = new QLineEdit( GroupC1 );
|
||||||
|
le->setObjectName( (*anIt).myName );
|
||||||
|
attuneStdWidget( le, i );
|
||||||
|
le->setText( (*anIt).myValue.toString() );
|
||||||
|
connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
|
||||||
|
w = le;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -301,6 +323,42 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList SMESHGUI_GenericHypothesisCreator::getVariablesFromDlg() const
|
||||||
|
{
|
||||||
|
QStringList aResult;
|
||||||
|
QString item;
|
||||||
|
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||||
|
if(aStudy) {
|
||||||
|
ListOfWidgets::const_iterator anIt = widgets().begin(), aLast = widgets().end();
|
||||||
|
for( ; anIt!=aLast; anIt++ ) {
|
||||||
|
if( (*anIt)->inherits( "SalomeApp_IntSpinBox" ) )
|
||||||
|
{
|
||||||
|
SalomeApp_IntSpinBox* sb = ( SalomeApp_IntSpinBox* )( *anIt );
|
||||||
|
item = sb->text();
|
||||||
|
bool isVariable = aStudy->IsVariable(item.toLatin1().constData());
|
||||||
|
isVariable ? aResult.append( item ) : aResult.append(QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( (*anIt)->inherits( "QtxDoubleSpinBox" ) )
|
||||||
|
{
|
||||||
|
QtxDoubleSpinBox* sb = ( QtxDoubleSpinBox* )( *anIt );
|
||||||
|
item = sb->text();
|
||||||
|
bool isVariable = aStudy->IsVariable(item.toLatin1().constData());
|
||||||
|
isVariable ? aResult.append( item ) : aResult.append(QString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool hasVar = false;
|
||||||
|
for (int i = 0;i<aResult.size();i++)
|
||||||
|
if(!aResult[i].isEmpty())
|
||||||
|
hasVar = true;
|
||||||
|
|
||||||
|
if(!hasVar)
|
||||||
|
aResult.clear();
|
||||||
|
}
|
||||||
|
return aResult;
|
||||||
|
}
|
||||||
|
|
||||||
QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
|
QString SMESHGUI_GenericHypothesisCreator::stdParamValues( const ListOfStdParams& params)
|
||||||
{
|
{
|
||||||
QString valueStr = "";
|
QString valueStr = "";
|
||||||
|
@ -64,12 +64,15 @@ public:
|
|||||||
bool isCreation() const;
|
bool isCreation() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef struct
|
struct StdParam
|
||||||
{
|
{
|
||||||
QString myName;
|
QString myName;
|
||||||
QVariant myValue;
|
QVariant myValue;
|
||||||
|
bool isVariable;
|
||||||
} StdParam;
|
StdParam(){
|
||||||
|
isVariable = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
typedef QList<StdParam> ListOfStdParams;
|
typedef QList<StdParam> ListOfStdParams;
|
||||||
typedef QList<QWidget*> ListOfWidgets;
|
typedef QList<QWidget*> ListOfWidgets;
|
||||||
@ -86,6 +89,7 @@ protected:
|
|||||||
virtual QString storeParams() const = 0;
|
virtual QString storeParams() const = 0;
|
||||||
virtual bool stdParams( ListOfStdParams& ) const;
|
virtual bool stdParams( ListOfStdParams& ) const;
|
||||||
bool getStdParamFromDlg( ListOfStdParams& ) const;
|
bool getStdParamFromDlg( ListOfStdParams& ) const;
|
||||||
|
virtual QStringList getVariablesFromDlg() const;
|
||||||
static QString stdParamValues( const ListOfStdParams& );
|
static QString stdParamValues( const ListOfStdParams& );
|
||||||
virtual void attuneStdWidget( QWidget*, const int ) const;
|
virtual void attuneStdWidget( QWidget*, const int ) const;
|
||||||
virtual QWidget* getCustomWidget( const StdParam&,
|
virtual QWidget* getCustomWidget( const StdParam&,
|
||||||
|
@ -49,6 +49,7 @@ salomeinclude_HEADERS = \
|
|||||||
SMESH_MEDSupport_i.hxx \
|
SMESH_MEDSupport_i.hxx \
|
||||||
SMESH_Pattern_i.hxx \
|
SMESH_Pattern_i.hxx \
|
||||||
SMESH_2smeshpy.hxx \
|
SMESH_2smeshpy.hxx \
|
||||||
|
SMESH_NoteBook.hxx \
|
||||||
SMESH.hxx
|
SMESH.hxx
|
||||||
|
|
||||||
# Scripts to be installed.
|
# Scripts to be installed.
|
||||||
@ -78,7 +79,8 @@ dist_libSMESHEngine_la_SOURCES = \
|
|||||||
SMESH_Filter_i.cxx \
|
SMESH_Filter_i.cxx \
|
||||||
SMESH_Group_i.cxx \
|
SMESH_Group_i.cxx \
|
||||||
SMESH_Pattern_i.cxx \
|
SMESH_Pattern_i.cxx \
|
||||||
SMESH_2smeshpy.cxx
|
SMESH_2smeshpy.cxx \
|
||||||
|
SMESH_NoteBook.cxx
|
||||||
|
|
||||||
# Executables targets
|
# Executables targets
|
||||||
bin_PROGRAMS = SMESHEngine
|
bin_PROGRAMS = SMESHEngine
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "SMESH_PythonDump.hxx"
|
#include "SMESH_PythonDump.hxx"
|
||||||
|
#include "SMESH_NoteBook.hxx"
|
||||||
#include "Resource_DataMapOfAsciiStringAsciiString.hxx"
|
#include "Resource_DataMapOfAsciiStringAsciiString.hxx"
|
||||||
|
|
||||||
#include "SMESH_Gen_i.hxx"
|
#include "SMESH_Gen_i.hxx"
|
||||||
@ -123,14 +124,16 @@ SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScript,
|
|||||||
Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod)
|
Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod)
|
||||||
{
|
{
|
||||||
theGen = new _pyGen( theEntry2AccessorMethod );
|
theGen = new _pyGen( theEntry2AccessorMethod );
|
||||||
|
|
||||||
|
SMESH_NoteBook * aNoteBook = new SMESH_NoteBook();
|
||||||
|
|
||||||
// split theScript into separate commands
|
// split theScript into separate commands
|
||||||
int from = 1, end = theScript.Length(), to;
|
int from = 1, end = theScript.Length(), to;
|
||||||
while ( from < end && ( to = theScript.Location( "\n", from, end )))
|
while ( from < end && ( to = theScript.Location( "\n", from, end )))
|
||||||
{
|
{
|
||||||
if ( to != from )
|
if ( to != from )
|
||||||
// cut out and store a command
|
// cut out and store a command
|
||||||
theGen->AddCommand( theScript.SubString( from, to - 1 ));
|
theGen->AddCommand( aNoteBook->ReplaceVariables(theScript.SubString( from, to - 1 )));
|
||||||
from = to + 1;
|
from = to + 1;
|
||||||
}
|
}
|
||||||
// finish conversion
|
// finish conversion
|
||||||
|
@ -469,6 +469,9 @@ public:
|
|||||||
* \brief Find SObject for an algo
|
* \brief Find SObject for an algo
|
||||||
*/
|
*/
|
||||||
SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
|
SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
|
||||||
|
|
||||||
|
void UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters);
|
||||||
|
char* GetParameters(CORBA::Object_ptr theObject);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Create hypothesis of given type
|
// Create hypothesis of given type
|
||||||
|
@ -863,3 +863,59 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : UpdateSObject
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
|
||||||
|
{
|
||||||
|
SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
|
||||||
|
if(aStudy->_is_nil() || CORBA::is_nil(theObject))
|
||||||
|
return;
|
||||||
|
|
||||||
|
SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject);
|
||||||
|
if(aSObj->_is_nil())
|
||||||
|
return;
|
||||||
|
|
||||||
|
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
|
||||||
|
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theObject );
|
||||||
|
|
||||||
|
if ( !aHyp->_is_nil() ) {
|
||||||
|
CORBA::String_var objStr = aHyp->GetParameters();
|
||||||
|
TCollection_AsciiString aParams(theParameters);
|
||||||
|
if(aParams.Length()) {
|
||||||
|
SALOMEDS::GenericAttribute_var anAttr;
|
||||||
|
anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
|
||||||
|
SALOMEDS::AttributeString::_narrow(anAttr)->SetValue( aParams.ToCString() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aStudyBuilder->RemoveAttribute(aSObj,"AttributeString");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetParameters
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject)
|
||||||
|
{
|
||||||
|
TCollection_AsciiString aResult;
|
||||||
|
|
||||||
|
SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
|
||||||
|
SALOMEDS::SObject_var aSObj = ObjectToSObject(aStudy,theObject);
|
||||||
|
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theObject );
|
||||||
|
|
||||||
|
if(!aStudy->_is_nil() &&
|
||||||
|
!CORBA::is_nil(theObject) &&
|
||||||
|
!aSObj->_is_nil() &&
|
||||||
|
!aHyp->_is_nil()){
|
||||||
|
|
||||||
|
SALOMEDS::GenericAttribute_var anAttr;
|
||||||
|
if ( aSObj->FindAttribute(anAttr, "AttributeString")) {
|
||||||
|
aResult = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CORBA::string_dup( aResult.ToCString() );
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "SMESH_Hypothesis_i.hxx"
|
#include "SMESH_Hypothesis_i.hxx"
|
||||||
|
#include "SMESH_Gen_i.hxx"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -121,6 +122,27 @@ CORBA::Long SMESH_Hypothesis_i::GetId()
|
|||||||
return myBaseImpl->GetID();
|
return myBaseImpl->GetID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* SMESH_Hypothesis_i::SetParameters()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
void SMESH_Hypothesis_i::SetParameters(const char* theParameters)
|
||||||
|
{
|
||||||
|
string aNewParameters(theParameters);
|
||||||
|
string anOldParameters(GetParameters());
|
||||||
|
if(aNewParameters.compare(anOldParameters) != 0)
|
||||||
|
SMESH_Gen_i::GetSMESHGen()->UpdateParameters(SMESH::SMESH_Hypothesis::_narrow(_this()),
|
||||||
|
theParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* SMESH_Hypothesis_i::GetParameters()
|
||||||
|
{
|
||||||
|
SMESH_Gen_i *gen = SMESH_Gen_i::GetSMESHGen();
|
||||||
|
return CORBA::string_dup(gen->GetParameters(SMESH::SMESH_Hypothesis::_narrow(_this())));
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* SMESH_Hypothesis_i::GetImpl
|
* SMESH_Hypothesis_i::GetImpl
|
||||||
|
@ -66,6 +66,12 @@ public:
|
|||||||
// Get unique id of hypothesis
|
// Get unique id of hypothesis
|
||||||
CORBA::Long GetId();
|
CORBA::Long GetId();
|
||||||
|
|
||||||
|
// Set list of parameters separated by ":" symbol, used for Hypothesis creation
|
||||||
|
void SetParameters (const char* theParameters);
|
||||||
|
|
||||||
|
// Return list of notebook variables used for Hypothesis creation separated by ":" symbol
|
||||||
|
char* GetParameters();
|
||||||
|
|
||||||
// Get implementation
|
// Get implementation
|
||||||
::SMESH_Hypothesis* GetImpl();
|
::SMESH_Hypothesis* GetImpl();
|
||||||
|
|
||||||
|
161
src/SMESH_I/SMESH_NoteBook.cxx
Normal file
161
src/SMESH_I/SMESH_NoteBook.cxx
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
// Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
//
|
||||||
|
// File : SMESH_NoteBook.cxx
|
||||||
|
// Author : Roman NIKOLAEV
|
||||||
|
|
||||||
|
#include "SMESH_2smeshpy.hxx"
|
||||||
|
#include "SMESH_NoteBook.hxx"
|
||||||
|
#include "SMESH_Gen_i.hxx"
|
||||||
|
|
||||||
|
#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
|
||||||
|
#include <TColStd_SequenceOfAsciiString.hxx>
|
||||||
|
#include <TColStd_HSequenceOfInteger.hxx>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef _DEBUG_
|
||||||
|
static int MYDEBUG = 0;
|
||||||
|
#else
|
||||||
|
static int MYDEBUG = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Constructor
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
SMESH_NoteBook::SMESH_NoteBook()
|
||||||
|
{
|
||||||
|
InitObjectMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Constructor
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
SMESH_NoteBook::~SMESH_NoteBook()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Replace parameters of the functions on the Salome NoteBook Variables
|
||||||
|
* \param theString - Input string
|
||||||
|
* \retval TCollection_AsciiString - Convertion result
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
TCollection_AsciiString SMESH_NoteBook::ReplaceVariables(const TCollection_AsciiString& theString) const
|
||||||
|
{
|
||||||
|
_pyCommand aCmd( theString, -1);
|
||||||
|
TCollection_AsciiString aMethod = aCmd.GetMethod();
|
||||||
|
TCollection_AsciiString aObject = aCmd.GetObject();
|
||||||
|
TVariablesMap::const_iterator it = _objectMap.find(aObject);
|
||||||
|
if(!aMethod.IsEmpty() && it != _objectMap.end() ) {
|
||||||
|
|
||||||
|
if(aMethod == "SetLength" && !(*it).second.at(0).IsEmpty() ) {
|
||||||
|
aCmd.SetArg(1,(*it).second.at(0));
|
||||||
|
}
|
||||||
|
else if(aMethod == "SetPrecision" && !(*it).second.at(1).IsEmpty() ){
|
||||||
|
aCmd.SetArg(1,(*it).second.at(1));
|
||||||
|
}
|
||||||
|
return aCmd.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return theString;
|
||||||
|
}
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Private method
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
void SMESH_NoteBook::InitObjectMap()
|
||||||
|
{
|
||||||
|
SMESH_Gen_i *aGen = SMESH_Gen_i::GetSMESHGen();
|
||||||
|
if(!aGen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SALOMEDS::Study_ptr aStudy = aGen->GetCurrentStudy();
|
||||||
|
if(aStudy->_is_nil())
|
||||||
|
return;
|
||||||
|
|
||||||
|
SALOMEDS::SObject_var aSO = aStudy->FindComponent(aGen->ComponentDataType());
|
||||||
|
if(CORBA::is_nil(aSO))
|
||||||
|
return;
|
||||||
|
|
||||||
|
SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
|
||||||
|
TCollection_AsciiString aParameters;
|
||||||
|
for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
|
||||||
|
SALOMEDS::SObject_var aSObject = Itr->Value();
|
||||||
|
SALOMEDS::GenericAttribute_var anAttr;
|
||||||
|
if ( aSObject->FindAttribute(anAttr, "AttributeString")) {
|
||||||
|
aParameters = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value());
|
||||||
|
vector<string> vect = ParseVariables(aParameters.ToCString(),':');
|
||||||
|
if(MYDEBUG) {
|
||||||
|
cout<<"Entry : "<< aSObject->GetID()<<endl;
|
||||||
|
cout<<"aParameters : "<<aParameters<<endl;
|
||||||
|
}
|
||||||
|
vector<TCollection_AsciiString> aVars;
|
||||||
|
for(int i = 0;i<vect.size();i++) {
|
||||||
|
TCollection_AsciiString aVar(vect[i].c_str());
|
||||||
|
if(!aVar.IsEmpty() && aStudy->IsVariable(vect[i].c_str())) {
|
||||||
|
aVar.InsertBefore(1,"\"");
|
||||||
|
aVar.InsertAfter(aVar.Length(),"\"");
|
||||||
|
}
|
||||||
|
aVars.push_back(aVar);
|
||||||
|
if(MYDEBUG) {
|
||||||
|
cout<<"Variable: "<<aVar<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_objectMap.insert(pair<TCollection_AsciiString,vector<TCollection_AsciiString> >(TCollection_AsciiString(aSObject->GetID()),aVars));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Private method
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
vector<string> SMESH_NoteBook::ParseVariables(const string& theVariables, const char sep) const
|
||||||
|
{
|
||||||
|
vector<string> aResult;
|
||||||
|
if(theVariables[0] == sep ) aResult.push_back(string());
|
||||||
|
int pos = theVariables.find(sep);
|
||||||
|
if(pos < 0) {
|
||||||
|
aResult.push_back(theVariables);
|
||||||
|
return aResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
string s = theVariables;
|
||||||
|
if(s[0] == sep) s = s.substr(1, s.size());
|
||||||
|
while((pos = s.find(sep)) >= 0) {
|
||||||
|
aResult.push_back(s.substr(0, pos));
|
||||||
|
s = s.substr(pos+1, s.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!s.empty() && s[0] != sep) aResult.push_back(s);
|
||||||
|
if(theVariables[theVariables.size()-1] == sep) aResult.push_back(string());
|
||||||
|
|
||||||
|
return aResult;
|
||||||
|
}
|
51
src/SMESH_I/SMESH_NoteBook.hxx
Normal file
51
src/SMESH_I/SMESH_NoteBook.hxx
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
//
|
||||||
|
// File : SMESH_NoteBook.hxx
|
||||||
|
// Author : Roman NIKOLAEV ()
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SMESH_NoteBook_HeaderFile
|
||||||
|
#define SMESH_NoteBook_HeaderFile
|
||||||
|
|
||||||
|
#include <TCollection_AsciiString.hxx>
|
||||||
|
#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
class SMESH_NoteBook
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SMESH_NoteBook();
|
||||||
|
~SMESH_NoteBook();
|
||||||
|
TCollection_AsciiString ReplaceVariables(const TCollection_AsciiString& theString) const;
|
||||||
|
|
||||||
|
typedef std::map<TCollection_AsciiString,std::vector<TCollection_AsciiString> > TVariablesMap;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void InitObjectMap();
|
||||||
|
std::vector<std::string> ParseVariables(const std::string& theVariables, const char sep) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TVariablesMap _objectMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //SMESH_NoteBook_HeaderFile
|
@ -174,6 +174,8 @@ def GetName(obj):
|
|||||||
|
|
||||||
## Sets a name to the object
|
## Sets a name to the object
|
||||||
def SetName(obj, name):
|
def SetName(obj, name):
|
||||||
|
if isinstance(obj, BaseWrapper):
|
||||||
|
obj = obj.GetAlgorithm()
|
||||||
ior = salome.orb.object_to_string(obj)
|
ior = salome.orb.object_to_string(obj)
|
||||||
sobj = salome.myStudy.FindObjectIOR(ior)
|
sobj = salome.myStudy.FindObjectIOR(ior)
|
||||||
if not sobj is None:
|
if not sobj is None:
|
||||||
@ -942,7 +944,7 @@ class Mesh:
|
|||||||
# @return SMESH.Hypothesis_Status
|
# @return SMESH.Hypothesis_Status
|
||||||
# @ingroup l2_hypotheses
|
# @ingroup l2_hypotheses
|
||||||
def AddHypothesis(self, hyp, geom=0):
|
def AddHypothesis(self, hyp, geom=0):
|
||||||
if isinstance( hyp, Mesh_Algorithm ):
|
if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper):
|
||||||
hyp = hyp.GetAlgorithm()
|
hyp = hyp.GetAlgorithm()
|
||||||
pass
|
pass
|
||||||
if not geom:
|
if not geom:
|
||||||
@ -961,7 +963,7 @@ class Mesh:
|
|||||||
# @return SMESH.Hypothesis_Status
|
# @return SMESH.Hypothesis_Status
|
||||||
# @ingroup l2_hypotheses
|
# @ingroup l2_hypotheses
|
||||||
def RemoveHypothesis(self, hyp, geom=0):
|
def RemoveHypothesis(self, hyp, geom=0):
|
||||||
if isinstance( hyp, Mesh_Algorithm ):
|
if isinstance( hyp, Mesh_Algorithm ) or isinstance( hyp, BaseWrapper):
|
||||||
hyp = hyp.GetAlgorithm()
|
hyp = hyp.GetAlgorithm()
|
||||||
pass
|
pass
|
||||||
if not geom:
|
if not geom:
|
||||||
@ -2876,6 +2878,7 @@ class Mesh_Algorithm:
|
|||||||
pass
|
pass
|
||||||
status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
|
status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
|
||||||
TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
|
TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
|
||||||
|
hypo = WrapHypothesis(hypo,hyp)
|
||||||
return hypo
|
return hypo
|
||||||
|
|
||||||
|
|
||||||
@ -4012,3 +4015,74 @@ class Mesh_UseExisting(Mesh_Algorithm):
|
|||||||
self.Create(mesh, geom, "UseExisting_1D")
|
self.Create(mesh, geom, "UseExisting_1D")
|
||||||
else:
|
else:
|
||||||
self.Create(mesh, geom, "UseExisting_2D")
|
self.Create(mesh, geom, "UseExisting_2D")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def WrapHypothesis(hypo, hyp):
|
||||||
|
if hyp == "LocalLength":
|
||||||
|
return LocalLength(hypo)
|
||||||
|
return hypo
|
||||||
|
|
||||||
|
from salome_notebook import *
|
||||||
|
|
||||||
|
##Base class for wrap all StdMeshers interfaces
|
||||||
|
class BaseWrapper:
|
||||||
|
|
||||||
|
##Return instance of a _objref_StdMeshers hypothesis
|
||||||
|
def GetAlgorithm(self):
|
||||||
|
return self.hypo
|
||||||
|
|
||||||
|
##Return values of the notebook variables
|
||||||
|
def ParseParameters(self, params ,nbParams, nbParam, arg):
|
||||||
|
result = None
|
||||||
|
strResult = ""
|
||||||
|
isVar = False
|
||||||
|
if isinstance(arg, str):
|
||||||
|
if notebook.isVariable(arg):
|
||||||
|
result = notebook.get(arg)
|
||||||
|
isVar = True
|
||||||
|
else:
|
||||||
|
result = arg
|
||||||
|
|
||||||
|
isEmpty = True
|
||||||
|
paramsList = []
|
||||||
|
if len(params) > 0:
|
||||||
|
paramsList = params.split(":")
|
||||||
|
isEmpty = False
|
||||||
|
|
||||||
|
for n in range(1,nbParams+1):
|
||||||
|
if n != nbParam and not isEmpty and len(paramsList[n-1])> 0:
|
||||||
|
strResult = paramsList[n-1] + ":"
|
||||||
|
pass
|
||||||
|
if isVar and n == nbParam:
|
||||||
|
if len(strResult) == 0 and nbParam != 1:
|
||||||
|
strResult = strResult + ":"
|
||||||
|
pass
|
||||||
|
strResult = strResult+arg
|
||||||
|
if n != nbParams:
|
||||||
|
strResult = strResult + ":"
|
||||||
|
|
||||||
|
return result, strResult
|
||||||
|
|
||||||
|
|
||||||
|
#Wrapper class for StdMeshers_LocalLength hypothesis
|
||||||
|
class LocalLength(BaseWrapper):
|
||||||
|
def __init__(self, hypo):
|
||||||
|
self.hypo = hypo
|
||||||
|
|
||||||
|
def SetLength(self, length):
|
||||||
|
length,parameters = self.ParseParameters(self.hypo.GetParameters(),2,1,length)
|
||||||
|
self.hypo.SetParameters(parameters)
|
||||||
|
self.hypo.SetLength(length)
|
||||||
|
|
||||||
|
def SetPrecision(self, precision):
|
||||||
|
precision,parameters = self.ParseParameters(self.hypo.GetParameters(),2,2,precision)
|
||||||
|
self.hypo.SetParameters(parameters)
|
||||||
|
self.hypo.SetPrecision(precision)
|
||||||
|
|
||||||
|
def GetLength(self):
|
||||||
|
return self.hypo.GetLength()
|
||||||
|
|
||||||
|
def GetPrecision(self):
|
||||||
|
return self.hypo.GetLength()
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <SMESH_NumberFilter.hxx>
|
#include <SMESH_NumberFilter.hxx>
|
||||||
#include <StdMeshersGUI_ObjectReferenceParamWdg.h>
|
#include <StdMeshersGUI_ObjectReferenceParamWdg.h>
|
||||||
#include <StdMeshersGUI_LayerDistributionParamWdg.h>
|
#include <StdMeshersGUI_LayerDistributionParamWdg.h>
|
||||||
|
#include <SALOMEDSClient_Study.hxx>
|
||||||
|
|
||||||
// SALOME GUI includes
|
// SALOME GUI includes
|
||||||
#include <SUIT_ResourceMgr.h>
|
#include <SUIT_ResourceMgr.h>
|
||||||
@ -400,6 +401,7 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString valueStr = stdParamValues( params );
|
QString valueStr = stdParamValues( params );
|
||||||
|
QStringList aVariablesList = getVariablesFromDlg();
|
||||||
|
|
||||||
if( res && !params.isEmpty() )
|
if( res && !params.isEmpty() )
|
||||||
{
|
{
|
||||||
@ -407,7 +409,13 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
|
|||||||
{
|
{
|
||||||
StdMeshers::StdMeshers_LocalLength_var h =
|
StdMeshers::StdMeshers_LocalLength_var h =
|
||||||
StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
|
StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
|
||||||
|
if(!aVariablesList.isEmpty()) {
|
||||||
|
QString aVariables = aVariablesList.join(":");
|
||||||
|
h->SetParameters(aVariables.toLatin1().constData());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
h->SetParameters("");
|
||||||
|
|
||||||
h->SetLength( params[0].myValue.toDouble() );
|
h->SetLength( params[0].myValue.toDouble() );
|
||||||
h->SetPrecision( params[1].myValue.toDouble() );
|
h->SetPrecision( params[1].myValue.toDouble() );
|
||||||
}
|
}
|
||||||
@ -546,7 +554,7 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
|
|||||||
p.append( item );
|
p.append( item );
|
||||||
customWidgets()->append(0);
|
customWidgets()->append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
|
SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
|
||||||
|
|
||||||
if( hypType()=="LocalLength" )
|
if( hypType()=="LocalLength" )
|
||||||
@ -554,12 +562,31 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
|
|||||||
StdMeshers::StdMeshers_LocalLength_var h =
|
StdMeshers::StdMeshers_LocalLength_var h =
|
||||||
StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
|
StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
|
||||||
|
|
||||||
|
QString aParameters(h->GetParameters());
|
||||||
|
QStringList aParametersList;
|
||||||
|
if(aParameters.length())
|
||||||
|
aParametersList = aParameters.split(":");
|
||||||
|
|
||||||
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
|
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
|
||||||
item.myValue = h->GetLength();
|
QVariant aVariable = parseParameter(aParametersList,0);
|
||||||
|
if(aVariable.type() != QVariant::Invalid) {
|
||||||
|
item.myValue = aVariable;
|
||||||
|
item.isVariable = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
item.myValue = h->GetLength();
|
||||||
p.append( item );
|
p.append( item );
|
||||||
|
|
||||||
item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
|
item.myName = tr("SMESH_LOCAL_LENGTH_PRECISION");
|
||||||
item.myValue = h->GetPrecision();
|
aVariable = parseParameter(aParametersList,1);
|
||||||
|
if(aVariable.type() != QVariant::Invalid) {
|
||||||
|
item.myValue = aVariable;
|
||||||
|
item.isVariable = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
item.myValue = h->GetPrecision();
|
||||||
p.append( item );
|
p.append( item );
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( hypType()=="SegmentLengthAroundVertex" )
|
else if( hypType()=="SegmentLengthAroundVertex" )
|
||||||
{
|
{
|
||||||
@ -915,3 +942,35 @@ void StdMeshersGUI_StdHypothesisCreator::onReject()
|
|||||||
deactivateObjRefParamWdg( customWidgets() );
|
deactivateObjRefParamWdg( customWidgets() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
QVariant StdMeshersGUI_StdHypothesisCreator::
|
||||||
|
parseParameter(const QStringList& theList, int theNbParam) const
|
||||||
|
{
|
||||||
|
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||||
|
QVariant aResult;
|
||||||
|
if(theList.size() > theNbParam) {
|
||||||
|
QString aParameter = theList[theNbParam];
|
||||||
|
if(QString::compare(QString(""),aParameter) !=0 ) {
|
||||||
|
if(aStudy->IsVariable(aParameter.toLatin1().constData())) {
|
||||||
|
aResult=aParameter;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bool aResult = false;
|
||||||
|
int anIResult = aParameter.toInt(&aResult);
|
||||||
|
if(aResult)
|
||||||
|
aResult = anIResult;
|
||||||
|
else {
|
||||||
|
double aDResult = aParameter.toDouble(&aResult);
|
||||||
|
if(aResult)
|
||||||
|
aResult = aDResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aResult;
|
||||||
|
}
|
||||||
|
@ -58,6 +58,7 @@ protected:
|
|||||||
virtual QWidget* getWidgetForParam( int paramIndex ) const;
|
virtual QWidget* getWidgetForParam( int paramIndex ) const;
|
||||||
virtual ListOfWidgets* customWidgets() const;
|
virtual ListOfWidgets* customWidgets() const;
|
||||||
virtual void onReject();
|
virtual void onReject();
|
||||||
|
virtual QVariant parseParameter(const QStringList& theList, int theNbParam) const;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T* widget(int i) const {
|
T* widget(int i) const {
|
||||||
|
Loading…
Reference in New Issue
Block a user