This commit is contained in:
asl 2009-09-04 08:21:40 +00:00
parent 5ff23c3748
commit 1f8dc8762c
11 changed files with 337 additions and 178 deletions

View File

@ -2099,9 +2099,9 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
{
// BUG 0020378
//SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
SMESH::HypothesisCreatorPtr aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypothesis->GetName());
if (aCreator) {
aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop() );
aCreator->edit( aHypothesis.in(), anIObject->getName(), desktop(), this, SLOT( onHypothesisEdit( int ) ) );
}
else
{
@ -2109,7 +2109,6 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
}
}
}
updateObjBrowser( true );
break;
}
@ -4427,8 +4426,11 @@ int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString
return tfont;
}
/*!
\brief Actions after hypothesis edition
Updates object browser after hypothesis edition
*/
void SMESHGUI::onHypothesisEdit( int result )
{
updateObjBrowser( true );
}

View File

@ -126,7 +126,7 @@ private slots:
void onViewManagerActivated( SUIT_ViewManager* );
void onOperationCommited( SUIT_Operation* );
void onOperationAborted( SUIT_Operation* );
void onHypothesisEdit( int result );
signals:
void SignalDeactivateActiveDialog();

View File

@ -48,13 +48,12 @@
#include <QLabel>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QEventLoop>
#define SPACING 6
#define MARGIN 11
SMESHGUI_GenericHypothesisCreator::SMESHGUI_GenericHypothesisCreator( const QString& theHypType )
: myHypType( theHypType ), myIsCreate( false ), myDlg( 0 ), myEventLoop( 0 )
: myHypType( theHypType ), myIsCreate( false ), myDlg( 0 )
{
}
@ -70,45 +69,36 @@ void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hyp
void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
const QString& theHypName,
QWidget* parent)
QWidget* parent, QObject* obj, const QString& slot )
{
MESSAGE( "Creation of hypothesis with initial params" );
setInitParamsHypothesis( initParamsHyp );
create( false, theHypName, parent );
create( false, theHypName, parent, obj, slot );
}
void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
const QString& theHypName,
QWidget* theParent )
QWidget* theParent, QObject* obj, const QString& slot )
{
MESSAGE( "Creation of hypothesis" );
myIsCreate = true;
// Create hypothesis/algorithm
if (isAlgo) {
if (isAlgo)
SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
}
else {
else
{
SMESH::SMESH_Hypothesis_var aHypothesis =
SMESH::CreateHypothesis( hypType(), theHypName, false );
if( !editHypothesis( aHypothesis.in(), theHypName, theParent ) )
{ //remove just created hypothesis
_PTR(SObject) aHypSObject = SMESH::FindSObject( aHypothesis.in() );
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
if( aStudy && !aStudy->GetProperties()->IsLocked() )
{
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
aBuilder->RemoveObjectWithChildren( aHypSObject );
}
}
editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
}
SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
}
void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
const QString& theHypName,
QWidget* theParent )
QWidget* theParent, QObject* obj, const QString& slot )
{
if( CORBA::is_nil( theHypothesis ) )
return;
@ -117,37 +107,21 @@ void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHyp
myIsCreate = false;
if( !editHypothesis( theHypothesis, theHypName, theParent ) )
return;
SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( theHypothesis );
if( listSOmesh.size() > 0 )
for( int i = 0; i < listSOmesh.size(); i++ )
{
_PTR(SObject) submSO = listSOmesh[i];
SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
if( !aSubMesh->_is_nil() )
aMesh = aSubMesh->GetFather();
_PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
}
SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
editHypothesis( theHypothesis, theHypName, theParent, obj, slot );
}
bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h,
void SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ptr h,
const QString& theHypName,
QWidget* theParent )
QWidget* theParent,
QObject* obj, const QString& slot )
{
if( CORBA::is_nil( h ) )
return false;
bool res = true;
myHypName = theHypName;
myHypo = SMESH::SMESH_Hypothesis::_duplicate( h );
SMESHGUI_HypothesisDlg* Dlg = new SMESHGUI_HypothesisDlg( this, theParent );
connect( Dlg, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
connect( this, SIGNAL( finished( int ) ), obj, slot.toLatin1().constData() );
myDlg = Dlg;
QFrame* fr = buildFrame();
if( fr )
@ -160,24 +134,9 @@ bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_
retrieveParams();
Dlg->show();
Dlg->resize( Dlg->minimumSizeHint() );
if ( !myEventLoop )
myEventLoop = new QEventLoop( this );
myEventLoop->exec(); // make myDlg not modal
res = myDlg->result();
if( res ) {
/*QString paramValues = */storeParams();
// No longer needed since NoteBook appears and "Value" OB field shows names of variable
// if ( !paramValues.isEmpty() ) {
// if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
// SMESH::SetValue( SHyp, paramValues );
// }
}
}
delete Dlg; myDlg = 0;
changeWidgets().clear();
myHypo = SMESH::SMESH_Hypothesis::_nil();
myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
return res;
else
emit finished( QDialog::Accepted );
}
QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
@ -284,10 +243,53 @@ void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
{
}
void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int /*result*/ )
void SMESHGUI_GenericHypothesisCreator::onDialogFinished( int result )
{
if ( myEventLoop )
myEventLoop->exit();
bool res = result==QDialog::Accepted;
if( res )
{
/*QString paramValues = */storeParams();
// No longer needed since NoteBook appears and "Value" OB field shows names of variable
// if ( !paramValues.isEmpty() ) {
// if ( _PTR(SObject) SHyp = SMESH::FindSObject( myHypo ))
// SMESH::SetValue( SHyp, paramValues );
// }
}
changeWidgets().clear();
if( myIsCreate && !res )
{
//remove just created hypothesis
_PTR(SObject) aHypSObject = SMESH::FindSObject( myHypo );
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
if( aStudy && !aStudy->GetProperties()->IsLocked() )
{
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
aBuilder->RemoveObjectWithChildren( aHypSObject );
}
}
else if( !myIsCreate && res )
{
SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis( myHypo );
if( listSOmesh.size() > 0 )
for( int i = 0; i < listSOmesh.size(); i++ )
{
_PTR(SObject) submSO = listSOmesh[i];
SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( submSO );
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( submSO );
if( !aSubMesh->_is_nil() )
aMesh = aSubMesh->GetFather();
_PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
}
}
SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
myHypo = SMESH::SMESH_Hypothesis::_nil();
myInitParamsHypo = SMESH::SMESH_Hypothesis::_nil();
myDlg->close(); myDlg = 0;
//delete myDlg; myDlg = 0;
emit finished( result );
}
bool SMESHGUI_GenericHypothesisCreator::stdParams( ListOfStdParams& ) const
@ -542,6 +544,7 @@ SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreato
: QtxDialog( parent, false, true ),
myCreator( creator )
{
setAttribute(Qt::WA_DeleteOnClose, true);
setMinimumSize( 300, height() );
// setFixedSize( 300, height() );
QVBoxLayout* topLayout = new QVBoxLayout( mainFrame() );
@ -573,6 +576,7 @@ SMESHGUI_HypothesisDlg::SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreato
SMESHGUI_HypothesisDlg::~SMESHGUI_HypothesisDlg()
{
delete myCreator;
}
void SMESHGUI_HypothesisDlg::setCustomFrame( QFrame* f )
@ -668,15 +672,69 @@ HypothesisData::HypothesisData( const QString& theTypeName,
}
HypothesesSet::HypothesesSet( const QString& theSetName )
: HypoSetName( theSetName )
: myHypoSetName( theSetName ),
myIsAlgo( false )
{
}
HypothesesSet::HypothesesSet( const QString& theSetName,
const QStringList& theHypoList,
const QStringList& theAlgoList )
: HypoSetName( theSetName ),
HypoList( theHypoList ),
AlgoList( theAlgoList )
: myHypoSetName( theSetName ),
myHypoList( theHypoList ),
myAlgoList( theAlgoList ),
myIsAlgo( false )
{
}
QStringList* HypothesesSet::list(bool is_algo) const
{
return const_cast<QStringList*>( &( is_algo ? myAlgoList : myHypoList ) );
}
QStringList* HypothesesSet::list() const
{
return list( myIsAlgo );
}
QString HypothesesSet::name() const
{
return myHypoSetName;
}
void HypothesesSet::set( bool isAlgo, const QStringList& lst )
{
*list(isAlgo) = lst;
}
int HypothesesSet::count( bool isAlgo ) const
{
return list(isAlgo)->count();
}
bool HypothesesSet::isAlgo() const
{
return myIsAlgo;
}
void HypothesesSet::init( bool isAlgo )
{
myIsAlgo = isAlgo;
myIndex = -1;
}
bool HypothesesSet::more() const
{
return myIndex < list()->count();
}
void HypothesesSet::next()
{
myIndex++;
}
QString HypothesesSet::current() const
{
return list()->at(myIndex);
}

View File

@ -28,6 +28,7 @@
// SMESH includes
#include "SMESH_SMESHGUI.hxx"
#include "SMESHGUI_HypothesesUtils.h"
// Qt includes
#include <QtxDialog.h>
@ -51,10 +52,9 @@ public:
virtual ~SMESHGUI_GenericHypothesisCreator();
void create( SMESH::SMESH_Hypothesis_ptr,
const QString&, QWidget* );
void create( bool, const QString&, QWidget* );
void edit( SMESH::SMESH_Hypothesis_ptr,
const QString&, QWidget* );
const QString&, QWidget*, QObject*, const QString& );
void create( bool, const QString&, QWidget*, QObject*, const QString& );
void edit( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*, QObject*, const QString& );
void setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr);
virtual bool checkParams( QString& ) const;
@ -68,6 +68,9 @@ public:
QString getShapeEntry() const { return myShapeEntry; }
void setShapeEntry( const QString& theEntry );
signals:
void finished( int );
protected:
struct StdParam
{
@ -113,8 +116,7 @@ private slots:
virtual void onDialogFinished( int );
private:
bool editHypothesis( SMESH::SMESH_Hypothesis_ptr,
const QString&, QWidget* );
void editHypothesis( SMESH::SMESH_Hypothesis_ptr, const QString&, QWidget*, QObject* obj, const QString& );
private:
SMESH::SMESH_Hypothesis_var myHypo, myInitParamsHypo;
@ -123,7 +125,6 @@ private:
ListOfWidgets myParamWidgets;
bool myIsCreate;
QtxDialog* myDlg;
QEventLoop* myEventLoop;
QString myShapeEntry;
};
@ -135,20 +136,19 @@ public:
SMESHGUI_HypothesisDlg( SMESHGUI_GenericHypothesisCreator*, QWidget* );
virtual ~SMESHGUI_HypothesisDlg();
void setHIcon( const QPixmap& );
void setCustomFrame( QFrame* );
void setType( const QString& );
void setHIcon( const QPixmap& );
void setCustomFrame( QFrame* );
void setType( const QString& );
protected slots:
virtual void accept();
virtual void reject();
void onHelp();
virtual void accept();
virtual void reject();
void onHelp();
private:
SMESHGUI_GenericHypothesisCreator* myCreator;
QLabel* myIconLabel;
QLabel* myTypeLabel;
QString myHelpFileName;
SMESHGUI_GenericHypothesisCreator* myCreator;
QLabel *myIconLabel, *myTypeLabel;
QString myHelpFileName;
};
/*!
@ -193,8 +193,28 @@ public:
HypothesesSet( const QString& );
HypothesesSet( const QString&, const QStringList&, const QStringList& );
QString HypoSetName;
QStringList HypoList, AlgoList;
QString name() const;
void set( bool, const QStringList& );
int count( bool ) const;
bool isAlgo() const;
//this method sets internal index to -1, thus before any data access it is necessary to call next()
void init( bool );
bool more() const;
void next();
QString current() const;
private:
QStringList* list(bool) const;
QStringList* list() const;
private:
bool myIsAlgo;
QString myHypoSetName;
QStringList myHypoList, myAlgoList;
int myIndex;
};
#endif // SMESHGUI_HYPOTHESES_H

View File

@ -251,8 +251,8 @@ namespace SMESH
hypoSet != myListOfHypothesesSets.end();
++hypoSet ) {
HypothesesSet* aSet = *hypoSet;
if ( aSet && aSet->AlgoList.count() ) {
aSetNameList.append( aSet->HypoSetName );
if ( aSet && aSet->count( true ) ) {
aSetNameList.append( aSet->name() );
}
}
@ -266,7 +266,7 @@ namespace SMESH
hypoSet != myListOfHypothesesSets.end();
++hypoSet ) {
HypothesesSet* aSet = *hypoSet;
if ( aSet && aSet->HypoSetName == theSetName )
if ( aSet && aSet->name() == theSetName )
return aSet;
}
return 0;
@ -321,7 +321,7 @@ namespace SMESH
return false;
}
HypothesisCreatorPtr GetHypothesisCreator(const QString& aHypType)
SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator(const QString& aHypType)
{
if(MYDEBUG) MESSAGE("Get HypothesisCreator for " << aHypType.toLatin1().data());
@ -340,7 +340,8 @@ namespace SMESH
// 2. Get names of plugin libraries
HypothesisData* aHypData = GetHypothesisData(aHypType);
if (!aHypData)
return HypothesisCreatorPtr(aCreator);
return aCreator;
QString aClientLibName = aHypData->ClientLibName;
QString aServerLibName = aHypData->ServerLibName;
@ -391,7 +392,7 @@ namespace SMESH
}
}
return HypothesisCreatorPtr(aCreator);
return aCreator;
}

View File

@ -58,8 +58,6 @@ class algo_error_array;
namespace SMESH
{
typedef boost::shared_ptr<SMESHGUI_GenericHypothesisCreator> HypothesisCreatorPtr;
SMESHGUI_EXPORT
void InitAvailableHypotheses();
@ -87,7 +85,7 @@ namespace SMESH
const HypothesisData* );
SMESHGUI_EXPORT
HypothesisCreatorPtr GetHypothesisCreator( const QString& );
SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& );
SMESHGUI_EXPORT
SMESH::SMESH_Hypothesis_ptr CreateHypothesis( const QString&,

View File

@ -1019,7 +1019,7 @@ namespace
*/
//================================================================================
void SMESHGUI_MeshOp::createHypothesis (const int theDim,
void SMESHGUI_MeshOp::createHypothesis(const int theDim,
const int theType,
const QString& theTypeName)
{
@ -1027,6 +1027,8 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim,
if (!aData)
return;
myDim = theDim;
myType = theType;
QStringList aHypNames;
TDim2Type2HypList::const_iterator aDimIter = myExistingHyps.begin();
for ( ; aDimIter != myExistingHyps.end(); aDimIter++) {
@ -1045,7 +1047,7 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim,
QString aHypName = GetUniqueName( aHypNames, aData->Label);
// existing hypos
int nbHyp = myExistingHyps[theDim][theType].count();
bool dialog = false;
QString aClientLibName = aData->ClientLibName;
if (aClientLibName == "") {
@ -1055,7 +1057,7 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim,
// Get hypotheses creator client (GUI)
// BUG 0020378
//SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
SMESH::HypothesisCreatorPtr aCreator = SMESH::GetHypothesisCreator(theTypeName);
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
// Create hypothesis
if (aCreator) {
@ -1063,7 +1065,6 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim,
SMESH::SMESH_Hypothesis_var initParamHyp =
getInitParamsHypothesis(theTypeName, aData->ServerLibName);
int obj = myDlg->getActiveObject();
removeCustomFilters(); // Issue 0020170
// Get Entry of the Geom object
@ -1080,23 +1081,49 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim,
aCreator->setShapeEntry( anObjEntry );
myDlg->setEnabled( false );
aCreator->create(initParamHyp, aHypName, myDlg);
onActivateObject( obj ); // Issue 0020170. Restore filters
myDlg->setEnabled( true );
} else {
SMESH::CreateHypothesis(theTypeName, aHypName, false);
aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) );
dialog = true;
}
else
SMESH::CreateHypothesis(theTypeName, aHypName, false);
}
if( !dialog )
onHypoCreated(2);
}
//================================================================================
/*!
* Necessary steps after hypothesis creation
* \param result - creation result:
* 0 = rejected
* 1 = accepted
* 2 = additional value meaning that slot is called not from dialog box
*/
//================================================================================
void SMESHGUI_MeshOp::onHypoCreated( int result )
{
if( result != 2 )
{
int obj = myDlg->getActiveObject();
onActivateObject( obj ); // Issue 0020170. Restore filters
myDlg->setEnabled( true );
}
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
HypothesisData* algoData = hypData( theDim, Algo, currentHyp( theDim, Algo ));
int nbHyp = myExistingHyps[myDim][myType].count();
HypothesisData* algoData = hypData( myDim, Algo, currentHyp( myDim, Algo ));
QStringList aNewHyps;
existingHyps(theDim, theType, aFather, aNewHyps, myExistingHyps[theDim][theType], algoData);
if (aNewHyps.count() > nbHyp) {
existingHyps(myDim, myType, aFather, aNewHyps, myExistingHyps[myDim][myType], algoData);
if (aNewHyps.count() > nbHyp)
{
for (int i = nbHyp; i < aNewHyps.count(); i++)
myDlg->tab(theDim)->addHyp(theType, aNewHyps[i]);
myDlg->tab(myDim)->addHyp(myType, aNewHyps[i]);
}
if( result!=2 && myHypoSet )
processSet();
}
//================================================================================
@ -1126,7 +1153,7 @@ void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
// BUG 0020378
//SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHyp->GetName());
SMESH::HypothesisCreatorPtr aCreator = SMESH::GetHypothesisCreator(aHyp->GetName());
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHyp->GetName());
if ( aCreator )
{
// Get initial parameters
@ -1147,15 +1174,27 @@ void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
}
aCreator->setShapeEntry( anObjEntry );
int obj = myDlg->getActiveObject();
removeCustomFilters(); // Issue 0020170
myDlg->setEnabled( false );
aCreator->edit( aHyp.in(), aHypItem.second, dlg() );
onActivateObject( obj ); // Issue 0020170. Restore filters
myDlg->setEnabled( true );
aCreator->edit( aHyp.in(), aHypItem.second, dlg(), this, SLOT( onHypoEdited( int ) ) );
}
}
//================================================================================
/*!
* Necessary steps after hypothesis edition
* \param result - creation result:
* 0 = rejected
* 1 = accepted
*/
//================================================================================
void SMESHGUI_MeshOp::onHypoEdited( int result )
{
int obj = myDlg->getActiveObject();
onActivateObject( obj ); // Issue 0020170. Restore filters
myDlg->setEnabled( true );
}
//================================================================================
/*!
* \brief access to hypothesis data
@ -1347,8 +1386,9 @@ void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
//================================================================================
void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
{
HypothesesSet* aHypoSet = SMESH::GetHypothesesSet(theSetName);
if (!aHypoSet) return;
myHypoSet = SMESH::GetHypothesesSet(theSetName);
if (!myHypoSet)
return;
// clear all hyps
for (int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++) {
@ -1357,45 +1397,68 @@ void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
setCurrentHyp(dim, MainHyp, -1);
}
for (int aHypType = Algo; aHypType < AddHyp; aHypType++) {
bool isAlgo = (aHypType == Algo);
myHypoSet->init(true); //algorithms
processSet();
myHypoSet->init(false); //hypotheses
processSet();
myHypoSet = 0;
}
// set hyps from the set
QStringList* aHypoList = isAlgo ? &aHypoSet->AlgoList : &aHypoSet->HypoList;
for (int i = 0, n = aHypoList->count(); i < n; i++) {
const QString& aHypoTypeName = (*aHypoList)[ i ];
HypothesisData* aHypData = SMESH::GetHypothesisData(aHypoTypeName);
if (!aHypData)
continue;
//================================================================================
/*!
* \brief One step of hypothesis/algorithm list creation
*
* Creates a hypothesis or an algorithm for current item of internal list of names myHypoSet
*/
//================================================================================
void SMESHGUI_MeshOp::processSet()
{
myHypoSet->next();
if( !myHypoSet->more() )
return;
int aDim = aHypData->Dim[0];
// create or/and set
if (isAlgo) {
int index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
if ( index < 0 ) {
QStringList anAvailable;
availableHyps( aDim, Algo, anAvailable, myAvailableHypData[aDim][Algo] );
myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
}
setCurrentHyp( aDim, Algo, index );
onAlgoSelected( index, aDim );
}
else {
bool mainHyp = true;
QStringList anAvailable;
availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] );
myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable );
int index = myAvailableHypData[aDim][MainHyp].indexOf( aHypData );
if ( index < 0 ) {
mainHyp = false;
index = myAvailableHypData[aDim][AddHyp].indexOf( aHypData );
}
if (index >= 0)
createHypothesis(aDim, mainHyp ? MainHyp : AddHyp, aHypoTypeName);
}
} // loop on hypos in the set
} // loop on algo/hypo
bool isAlgo = myHypoSet->isAlgo();
QString aHypoTypeName = myHypoSet->current();
HypothesisData* aHypData = SMESH::GetHypothesisData(aHypoTypeName);
if (!aHypData)
{
processSet();
return;
}
int aDim = aHypData->Dim[0];
// create or/and set
if (isAlgo)
{
int index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
if ( index < 0 )
{
QStringList anAvailable;
availableHyps( aDim, Algo, anAvailable, myAvailableHypData[aDim][Algo] );
myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
}
setCurrentHyp( aDim, Algo, index );
onAlgoSelected( index, aDim );
processSet();
}
else
{
bool mainHyp = true;
QStringList anAvailable;
availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] );
myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable );
int index = myAvailableHypData[aDim][MainHyp].indexOf( aHypData );
if ( index < 0 )
{
mainHyp = false;
index = myAvailableHypData[aDim][AddHyp].indexOf( aHypData );
}
if (index >= 0)
createHypothesis(aDim, mainHyp ? MainHyp : AddHyp, aHypoTypeName);
else
processSet();
}
}
//================================================================================
@ -1690,7 +1753,7 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
QStringList tmp;
existingHyps( theDim, Algo, pObj, tmp, myExistingHyps[ theDim ][ Algo ]);
// look for anexisting algo of such a type
// look for an existing algo of such a type
THypList& aHypVarList = myExistingHyps[ theDim ][ Algo ];
THypList::iterator anIter = aHypVarList.begin();
for ( ; anIter != aHypVarList.end(); anIter++)
@ -1704,23 +1767,27 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
}
}
if (anAlgoVar->_is_nil()) {
if (anAlgoVar->_is_nil())
{
HypothesisData* aHypData = SMESH::GetHypothesisData( aHypName );
if (aHypData) {
if (aHypData)
{
QString aClientLibName = aHypData->ClientLibName;
if (aClientLibName == "") {
if (aClientLibName == "")
{
// Call hypothesis creation server method (without GUI)
SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
} else {
}
else
{
// Get hypotheses creator client (GUI)
// BUG 0020378
//SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
SMESH::HypothesisCreatorPtr aCreator = SMESH::GetHypothesisCreator(aHypName);
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
// Create algorithm
if (aCreator) {
aCreator->create(true, aHypName, myDlg);
}
if (aCreator)
aCreator->create(true, aHypName, myDlg, 0, QString::null );
else
SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
}

View File

@ -31,6 +31,7 @@
#include "SMESHGUI_SelectionOp.h"
class HypothesesSet;
class SMESHGUI_MeshDlg;
class SMESHGUI_ShapeByMeshOp;
class HypothesisData;
@ -77,6 +78,9 @@ protected slots:
void onPublishShapeByMeshDlg( SUIT_Operation* );
void onCloseShapeByMeshDlg( SUIT_Operation* );
void onAlgoSelected( const int, const int = -1 );
void processSet();
void onHypoCreated( int );
void onHypoEdited( int );
private:
typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
@ -135,6 +139,8 @@ private:
THypDataList myAvailableHypData[4][NbHypTypes];
bool myIgnoreAlgoSelection;
HypothesesSet* myHypoSet;
int myDim, myType;
};
#endif // SMESHGUI_MESHOP_H

View File

@ -186,8 +186,7 @@ bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&,
{
QString aHypos = isHypo ? atts.value("hypos") : atts.value("algos");
aHypos = aHypos.remove( ' ' );
QStringList* aHypoList = isHypo ? & aHypoSet->HypoList : & aHypoSet->AlgoList;
*aHypoList = aHypos.split( ',', QString::SkipEmptyParts );
aHypoSet->set( !isHypo, aHypos.split( ',', QString::SkipEmptyParts ) );
}
}
}

View File

@ -200,18 +200,25 @@ void StdMeshersGUI_LayerDistributionParamWdg::onEdit()
CORBA::String_var hypType = myHyp->GetName();
// BUG 0020378
//SMESHGUI_GenericHypothesisCreator* editor = SMESH::GetHypothesisCreator(hypType.in());
SMESH::HypothesisCreatorPtr editor = SMESH::GetHypothesisCreator(hypType.in());
SMESHGUI_GenericHypothesisCreator* editor = SMESH::GetHypothesisCreator(hypType.in());
if ( !editor ) return;
if ( myDlg ) myDlg->hide();
if ( myDlg )
myDlg->hide();
try {
QWidget* parent = this;
if ( myDlg ) parent = myDlg->parentWidget();
editor->edit( myHyp, myName, parent );
if ( myDlg )
parent = myDlg->parentWidget();
editor->edit( myHyp, myName, parent, this, SLOT( onEdited( int ) ) );
}
catch(...) {
catch(...)
{
}
if ( myDlg ) myDlg->show();
}
void StdMeshersGUI_LayerDistributionParamWdg::onEdited( int result )
{
if ( myDlg )
myDlg->show();
}

View File

@ -65,6 +65,7 @@ private slots:
void onCreate();
void onEdit();
void onHypTypePopup( QAction* );
void onEdited(int);
private:
void init();