0020428: EDF 906 GEOM : Performance for Group creation in GEOM

This commit is contained in:
ptv 2009-08-25 11:59:24 +00:00
parent b62eb94767
commit dd69f2ef27
4 changed files with 58 additions and 17 deletions

View File

@ -289,12 +289,37 @@ int GEOMBase_Skeleton::getConstructorId() const
return -1; return -1;
} }
//=================================================================================
// function : setConstructorId( id )
// purpose :
//=================================================================================
void GEOMBase_Skeleton::setConstructorId( const int id ) void GEOMBase_Skeleton::setConstructorId( const int id )
{ {
if ( myRBGroup && myRBGroup->button( id ) ) if ( myRBGroup && myRBGroup->button( id ) )
myRBGroup->button( id )->setChecked( true ); myRBGroup->button( id )->setChecked( true );
} }
//=================================================================================
// function : unsetConstructorId
// purpose :
//=================================================================================
void GEOMBase_Skeleton::unsetConstructorId()
{
// 0020428: EDF 906 GEOM : Performance for Group creation in GEOM
// uncheck all buttons
// workaround, because setChecked( false ) does not result in Qt4
bool isExclusive = myRBGroup->exclusive();
myRBGroup->setExclusive( false );
QList<QAbstractButton*> btnList = myRBGroup->buttons();
for ( int j = 0; j < 2; j++ )
{
QList<QAbstractButton*>::const_iterator it = btnList.constBegin();
for ( ; it != btnList.constEnd(); ++it )
(*it)->setCheckable( j == 1 );
}
myRBGroup->setExclusive( isExclusive );
}
//================================================================================= //=================================================================================
// function : ClickOnHelp() // function : ClickOnHelp()
// purpose : // purpose :

View File

@ -81,6 +81,9 @@ protected:
/*! set selected "constructor" radio button id /*! set selected "constructor" radio button id
*/ */
void setConstructorId( const int ); void setConstructorId( const int );
/*! unset selection on all "constructor" radio buttons
*/
void unsetConstructorId();
void setHelpFileName( const QString& ); void setHelpFileName( const QString& );

View File

@ -53,7 +53,8 @@ enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2, SUBSHAPES_OF_INVISI
GroupGUI_GroupDlg::GroupGUI_GroupDlg( Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent ) GroupGUI_GroupDlg::GroupGUI_GroupDlg( Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent )
: GEOMBase_Skeleton( theGeometryGUI, parent, false ), : GEOMBase_Skeleton( theGeometryGUI, parent, false ),
myMode( mode ), myMode( mode ),
myBusy( false ) myBusy( false ),
myIsShapeType( false )
{ {
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
@ -164,6 +165,11 @@ void GroupGUI_GroupDlg::Init()
//mySelSubBtn->setChecked( true ); //mySelSubBtn->setChecked( true );
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
//unset shape type to avoid preparation of selection before exact user shape type selection
//setConstructorId( -1 ); //non valid shape type
unsetConstructorId();
myIsShapeType = false;
if ( myMode == CreateGroup ) { if ( myMode == CreateGroup ) {
initName( tr( "GROUP_PREFIX" ) ); initName( tr( "GROUP_PREFIX" ) );
@ -470,16 +476,16 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
if (aSelList.Extent() == 1) { if (aSelList.Extent() == 1) {
Standard_Boolean aResult = Standard_False; Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object_var anObj =
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) {
myMainObj = anObj; myMainObj = anObj;
myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) ); myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) );
// activate subshapes selection by default // activate subshapes selection by default
myEditCurrentArgument = 0; myEditCurrentArgument = 0;
activateSelection(); activateSelection();
updateState(); updateState();
return; return;
} }
} }
@ -548,8 +554,8 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) ) if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
{ {
CORBA::Long anIndex; CORBA::Long anIndex;
anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] ); anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
if ( anIndex >= 0 ) { if ( anIndex >= 0 ) {
//if ( myPlaceCheckBox->isChecked() && ! myMain2InPlaceIndices.IsBound( anIndex )) //if ( myPlaceCheckBox->isChecked() && ! myMain2InPlaceIndices.IsBound( anIndex ))
if ( subSelectionWay() != ALL_SUBSHAPES && if ( subSelectionWay() != ALL_SUBSHAPES &&
@ -560,7 +566,7 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
} }
} }
} }
if ( !myMainObj->_is_nil() /*&& mySelSubBtn->isChecked()*/) if ( !myMainObj->_is_nil() && myIsShapeType/*&& mySelSubBtn->isChecked()*/)
if ( subSelectionWay() == ALL_SUBSHAPES ) if ( subSelectionWay() == ALL_SUBSHAPES )
localSelection( myMainObj, getShapeType() ); localSelection( myMainObj, getShapeType() );
else if ( !myInPlaceObj->_is_nil() ) else if ( !myInPlaceObj->_is_nil() )
@ -589,6 +595,7 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
//================================================================================= //=================================================================================
void GroupGUI_GroupDlg::ConstructorsClicked( int constructorId ) void GroupGUI_GroupDlg::ConstructorsClicked( int constructorId )
{ {
myIsShapeType = true;
myIdList->clear(); myIdList->clear();
activateSelection(); activateSelection();
updateState(); updateState();
@ -608,6 +615,8 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
// if ( !myPlaceCheckBox->isChecked() ) // if ( !myPlaceCheckBox->isChecked() )
if ( subSelectionWay() == ALL_SUBSHAPES ) if ( subSelectionWay() == ALL_SUBSHAPES )
{ {
if ( !myIsShapeType )
return;
myIdList->clear(); myIdList->clear();
GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSubShapes = aShOp->SubShapeAllIDs(myMainObj, getShapeType(), false); aSubShapes = aShOp->SubShapeAllIDs(myMainObj, getShapeType(), false);
@ -713,8 +722,8 @@ void GroupGUI_GroupDlg::add()
TopoDS_Shape aShape; TopoDS_Shape aShape;
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) ) if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
{ {
CORBA::Long anIndex; CORBA::Long anIndex;
anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] ); anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
if ( anIndex >= 0 ) if ( anIndex >= 0 )
aMapIndex.Add( anIndex ); aMapIndex.Add( anIndex );
} }
@ -798,6 +807,7 @@ void GroupGUI_GroupDlg::setShapeType( const TopAbs_ShapeEnum theType )
case TopAbs_SOLID: anId = 3; break; case TopAbs_SOLID: anId = 3; break;
} }
setConstructorId( anId ); setConstructorId( anId );
myIsShapeType = true;
} }
@ -810,7 +820,9 @@ void GroupGUI_GroupDlg::activateSelection()
globalSelection( GEOM_ALLSHAPES ); globalSelection( GEOM_ALLSHAPES );
// local selection // local selection
if ( !myMainObj->_is_nil() && !myEditCurrentArgument/* && mySelSubBtn->isChecked()*/) { if ( !myMainObj->_is_nil() && !myEditCurrentArgument/* && mySelSubBtn->isChecked()*/
&& myIsShapeType) { // check if shape type is already choosen by user
// if ( !myPlaceCheckBox->isChecked() ) // if ( !myPlaceCheckBox->isChecked() )
if ( subSelectionWay() == ALL_SUBSHAPES ) if ( subSelectionWay() == ALL_SUBSHAPES )
localSelection( myMainObj, getShapeType() ); localSelection( myMainObj, getShapeType() );
@ -877,8 +889,8 @@ void GroupGUI_GroupDlg::updateState()
aSubObjects[i]; aSubObjects[i];
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) ) if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
{ {
CORBA::Long anIndex; CORBA::Long anIndex;
anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] ); anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
if ( anIndex >= 0 ) if ( anIndex >= 0 )
aMapIndex.Add( anIndex ); aMapIndex.Add( anIndex );
else else

View File

@ -91,6 +91,7 @@ private:
private: private:
Mode myMode; Mode myMode;
bool myBusy; bool myBusy;
bool myIsShapeType;
GEOM::GEOM_Object_var myMainObj; GEOM::GEOM_Object_var myMainObj;
GEOM::GEOM_Object_var myGroup; GEOM::GEOM_Object_var myGroup;
GEOM::GEOM_Object_var myInPlaceObj; GEOM::GEOM_Object_var myInPlaceObj;