Fix treatment of filters after starting usage of AddArgCmd()

This commit is contained in:
eap 2013-07-23 11:41:20 +00:00
parent 60b71b1c6c
commit eeba8f9c90

View File

@ -3547,7 +3547,7 @@ const TCollection_AsciiString & _pyCommand::GetObject()
if ( GetBegPos( OBJECT_IND ) == UNKNOWN ) if ( GetBegPos( OBJECT_IND ) == UNKNOWN )
{ {
// beginning // beginning
int begPos = GetBegPos( RESULT_IND ) + myRes.Length(); int begPos = GetBegPos( RESULT_IND );
if ( begPos < 1 ) { if ( begPos < 1 ) {
begPos = myString.Location( "=", 1, Length() ) + 1; begPos = myString.Location( "=", 1, Length() ) + 1;
// is '=' in the string argument (for example, name) or not // is '=' in the string argument (for example, name) or not
@ -3564,6 +3564,9 @@ const TCollection_AsciiString & _pyCommand::GetObject()
if ( nb1 % 2 != 0 || nb2 % 2 != 0 ) if ( nb1 % 2 != 0 || nb2 % 2 != 0 )
begPos = 1; begPos = 1;
} }
else {
begPos += myRes.Length();
}
myObj = GetWord( myString, begPos, true ); myObj = GetWord( myString, begPos, true );
if ( begPos != EMPTY ) if ( begPos != EMPTY )
{ {
@ -4327,7 +4330,9 @@ bool _pyGroup::CanClear()
if ( IsInStudy() ) if ( IsInStudy() )
return false; return false;
if ( !myCanClearCreationCmd && myCreationCmd->GetMethod() == "GetGroups" ) if ( !myCanClearCreationCmd &&
!myCreationCmd.IsNull() &&
myCreationCmd->GetMethod() == "GetGroups" )
{ {
TCollection_AsciiString grIDs = myCreationCmd->GetResultValue(); TCollection_AsciiString grIDs = myCreationCmd->GetResultValue();
list< _pyID > idList = myCreationCmd->GetStudyEntries( grIDs ); list< _pyID > idList = myCreationCmd->GetStudyEntries( grIDs );
@ -4413,6 +4418,7 @@ void _pyGroup::Process( const Handle(_pyCommand)& theCommand)
makeGroupCmd->SetMethod( "MakeGroupByFilter" ); makeGroupCmd->SetMethod( "MakeGroupByFilter" );
makeGroupCmd->SetArg( 1, name ); makeGroupCmd->SetArg( 1, name );
makeGroupCmd->SetArg( 2, idSource ); makeGroupCmd->SetArg( 2, idSource );
filter->AddArgCmd( makeGroupCmd );
} }
} }
else if ( theCommand->GetMethod() == "SetFilter" ) else if ( theCommand->GetMethod() == "SetFilter" )
@ -4452,7 +4458,7 @@ void _pyGroup::Process( const Handle(_pyCommand)& theCommand)
void _pyGroup::Flush() void _pyGroup::Flush()
{ {
if ( !theGen->IsToKeepAllCommands() && if ( !theGen->IsToKeepAllCommands() &&
myCreationCmd && !myCanClearCreationCmd ) !myCreationCmd.IsNull() && !myCanClearCreationCmd )
{ {
myCreationCmd.Nullify(); // this way myCreationCmd won't be cleared myCreationCmd.Nullify(); // this way myCreationCmd won't be cleared
} }
@ -4467,6 +4473,7 @@ void _pyGroup::Flush()
_pyFilter::_pyFilter(const Handle(_pyCommand)& theCreationCmd, const _pyID& newID/*=""*/) _pyFilter::_pyFilter(const Handle(_pyCommand)& theCreationCmd, const _pyID& newID/*=""*/)
:_pyObject(theCreationCmd), myNewID( newID ) :_pyObject(theCreationCmd), myNewID( newID )
{ {
//myIsPublished = true; // prevent clearing as a not published
theGen->KeepAgrCmds( GetID() ); // ask to fill myArgCmds theGen->KeepAgrCmds( GetID() ); // ask to fill myArgCmds
} }
@ -4500,8 +4507,11 @@ void _pyFilter::Process( const Handle(_pyCommand)& theCommand)
theCommand->SetObject( SMESH_2smeshpy::GenName() ); theCommand->SetObject( SMESH_2smeshpy::GenName() );
theCommand->SetMethod( "GetFilterFromCriteria" ); theCommand->SetMethod( "GetFilterFromCriteria" );
// Clear aFilterManager.CreateFilter() // Swap "aFilterManager.CreateFilter()" and "smesh.GetFilterFromCriteria(criteria)"
GetCreationCmd()->Clear(); GetCreationCmd()->Clear();
GetCreationCmd()->GetString() = theCommand->GetString();
theCommand->Clear();
theCommand->AddDependantCmd( GetCreationCmd() );
} }
else if ( theCommand->GetMethod() == "SetMesh" ) else if ( theCommand->GetMethod() == "SetMesh" )
{ {
@ -4551,9 +4561,6 @@ void _pyFilter::Flush()
bool _pyObject::CanClear() bool _pyObject::CanClear()
{ {
if ( !myIsPublished )
return true;
list< Handle(_pyCommand) >::iterator cmd = myArgCmds.begin(); list< Handle(_pyCommand) >::iterator cmd = myArgCmds.begin();
for ( ; cmd != myArgCmds.end(); ++cmd ) for ( ; cmd != myArgCmds.end(); ++cmd )
if ( !(*cmd)->IsEmpty() ) if ( !(*cmd)->IsEmpty() )
@ -4562,8 +4569,7 @@ bool _pyObject::CanClear()
if ( !obj.IsNull() && !obj->CanClear() ) if ( !obj.IsNull() && !obj->CanClear() )
return false; return false;
} }
return ( !myIsPublished );
return true;
} }
//================================================================================ //================================================================================