mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-21 00:09:42 +05:00
NPAL17269: Performance pb. when creating a group with GUI.
This commit is contained in:
parent
f9e7e9c10e
commit
faef7428c3
@ -17,31 +17,31 @@
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#include "GEOMGUI_OCCSelector.h"
|
||||
|
||||
#include <LightApp_DataSubOwner.h>
|
||||
|
||||
#include <OCCViewer_ViewModel.h>
|
||||
|
||||
#include <SALOME_InteractiveObject.hxx>
|
||||
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <SelectMgr_IndexedMapOfOwner.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <SelectBasics_SensitiveEntity.hxx>
|
||||
#include <StdSelect_BRepOwner.hxx>
|
||||
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||
#include <SelectMgr_IndexedMapOfOwner.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SalomeApp_Study.h>
|
||||
#include <SALOME_InteractiveObject.hxx>
|
||||
|
||||
#include <StdSelect_BRepOwner.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <SelectMgr_IndexedMapOfOwner.hxx>
|
||||
#include <SelectBasics_SensitiveEntity.hxx>
|
||||
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
|
||||
//================================================================
|
||||
@ -68,71 +68,78 @@ GEOMGUI_OCCSelector::~GEOMGUI_OCCSelector()
|
||||
void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
|
||||
{
|
||||
OCCViewer_Viewer* vw = viewer();
|
||||
if ( !vw )
|
||||
if (!vw)
|
||||
return;
|
||||
|
||||
Handle(AIS_InteractiveContext) ic = vw->getAISContext();
|
||||
|
||||
if ( ic->HasOpenedContext() )
|
||||
{
|
||||
for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() )
|
||||
{
|
||||
Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(ic->SelectedOwner());
|
||||
if ( anOwner.IsNull() )
|
||||
continue;
|
||||
|
||||
Handle(AIS_InteractiveObject) io = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
|
||||
|
||||
QString entryStr = entry( io );
|
||||
int index = -1;
|
||||
|
||||
if ( anOwner->ComesFromDecomposition() ) // == Local Selection
|
||||
{
|
||||
TopoDS_Shape subShape = anOwner->Shape();
|
||||
Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast( io );
|
||||
if ( !aisShape.IsNull() )
|
||||
{
|
||||
TopoDS_Shape bigShape = aisShape->Shape();
|
||||
|
||||
TopTools_IndexedMapOfShape subShapes;
|
||||
TopExp::MapShapes( bigShape, subShapes );
|
||||
index = subShapes.FindIndex( subShape );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !entryStr.isEmpty() )
|
||||
{
|
||||
LightApp_DataOwner* owner;
|
||||
if ( index > -1 ) // Local Selection
|
||||
owner = new LightApp_DataSubOwner( entryStr, index );
|
||||
else // Global Selection
|
||||
owner = new LightApp_DataOwner( entryStr );
|
||||
|
||||
aList.append( SUIT_DataOwnerPtr( owner ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (ic->HasOpenedContext())
|
||||
{
|
||||
TopoDS_Shape curBigShape;
|
||||
TopTools_IndexedMapOfShape subShapes;
|
||||
|
||||
for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected())
|
||||
{
|
||||
for ( ic->InitCurrent(); ic->MoreCurrent(); ic->NextCurrent() )
|
||||
{
|
||||
Handle(AIS_InteractiveObject) io = ic->Current();
|
||||
|
||||
QString entryStr = entry( io );
|
||||
|
||||
if ( !entryStr.isEmpty() )
|
||||
{
|
||||
LightApp_DataOwner* owner = new LightApp_DataOwner( entryStr );
|
||||
aList.append( SUIT_DataOwnerPtr( owner ) );
|
||||
}
|
||||
}
|
||||
Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(ic->SelectedOwner());
|
||||
if (anOwner.IsNull())
|
||||
continue;
|
||||
|
||||
Handle(AIS_InteractiveObject) io = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
|
||||
|
||||
QString entryStr = entry(io);
|
||||
int index = -1;
|
||||
|
||||
if (anOwner->ComesFromDecomposition()) // == Local Selection
|
||||
{
|
||||
TopoDS_Shape subShape = anOwner->Shape();
|
||||
Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast(io);
|
||||
if (!aisShape.IsNull())
|
||||
{
|
||||
TopoDS_Shape bigShape = aisShape->Shape();
|
||||
|
||||
if (!bigShape.IsEqual(curBigShape))
|
||||
{
|
||||
curBigShape = bigShape;
|
||||
TopExp::MapShapes(bigShape, subShapes);
|
||||
}
|
||||
index = subShapes.FindIndex(subShape);
|
||||
}
|
||||
}
|
||||
|
||||
if (!entryStr.isEmpty())
|
||||
{
|
||||
LightApp_DataOwner* owner;
|
||||
if (index > -1) // Local Selection
|
||||
owner = new LightApp_DataSubOwner (entryStr, index);
|
||||
else // Global Selection
|
||||
owner = new LightApp_DataOwner (entryStr);
|
||||
|
||||
aList.append(SUIT_DataOwnerPtr(owner));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ic->InitCurrent(); ic->MoreCurrent(); ic->NextCurrent())
|
||||
{
|
||||
Handle(AIS_InteractiveObject) io = ic->Current();
|
||||
|
||||
QString entryStr = entry( io );
|
||||
|
||||
if ( !entryStr.isEmpty() )
|
||||
{
|
||||
LightApp_DataOwner* owner = new LightApp_DataOwner( entryStr );
|
||||
aList.append( SUIT_DataOwnerPtr( owner ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add externally selected objects
|
||||
SUIT_DataOwnerPtrList::const_iterator anExtIter;
|
||||
for(anExtIter = mySelectedExternals.begin(); anExtIter != mySelectedExternals.end(); anExtIter++) {
|
||||
for (anExtIter = mySelectedExternals.begin(); anExtIter != mySelectedExternals.end(); anExtIter++)
|
||||
{
|
||||
aList.append(*anExtIter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//================================================================
|
||||
@ -182,10 +189,12 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
|
||||
|
||||
Handle(AIS_InteractiveContext) ic = vw->getAISContext();
|
||||
|
||||
NCollection_DataMap<TCollection_AsciiString, TColStd_IndexedMapOfInteger> indexesMap; // "entry - list_of_int" map for LOCAL selection
|
||||
// "entry - list_of_int" map for LOCAL selection
|
||||
NCollection_DataMap<TCollection_AsciiString, TColStd_IndexedMapOfInteger> indexesMap;
|
||||
|
||||
QMap<QString,int> globalSelMap; // only Key=entry from this map is used. value(int) is NOT used at all.
|
||||
SelectMgr_IndexedMapOfOwner ownersmap; // map of owners to be selected
|
||||
|
||||
|
||||
AIS_ListOfInteractive aDispList;
|
||||
ic->DisplayedObjects( aDispList );
|
||||
|
||||
@ -213,15 +222,16 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
|
||||
subIndexes.Add( subOwner->index() );
|
||||
indexesMap.Bind((char*)entry.latin1(), subIndexes);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // the owner is NOT a sub owner, maybe it is a DataOwner == GLOBAL selection
|
||||
{
|
||||
const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
|
||||
if ( owner )
|
||||
{
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||
SalomeApp_Study* appStudy =
|
||||
dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||
QString anEntry = appStudy->referencedToEntry( owner->entry() );
|
||||
|
||||
|
||||
globalSelMap[anEntry] = 1;
|
||||
}
|
||||
}
|
||||
@ -238,51 +248,73 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
|
||||
SelectMgr_IndexedMapOfOwner owners;
|
||||
getEntityOwners( io, ic, owners ); // get all owners
|
||||
|
||||
for ( int i = 1, n = owners.Extent(); i <= n; i++ )
|
||||
int i, n = owners.Extent();
|
||||
|
||||
// 1. Prepare map of shapes for local selection
|
||||
TopTools_IndexedMapOfShape aMapOfShapes;
|
||||
bool isLocal = false;
|
||||
|
||||
Handle(StdSelect_BRepOwner) anOwner;
|
||||
for (i = 1; i <= n && !isLocal; i++)
|
||||
{
|
||||
anOwner = Handle(StdSelect_BRepOwner)::DownCast(owners( i ));
|
||||
if (!anOwner.IsNull() && anOwner->HasShape())
|
||||
{
|
||||
if (anOwner->ComesFromDecomposition() || !globalSelMap.contains(entryStr))
|
||||
{
|
||||
// has a local selection
|
||||
Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast( io );
|
||||
if (!aisShape.IsNull() && indexesMap.IsBound((char*)entryStr.latin1()))
|
||||
{
|
||||
isLocal = true;
|
||||
TopoDS_Shape shape = aisShape->Shape();
|
||||
TopExp::MapShapes(shape, aMapOfShapes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(owners( i ));
|
||||
// 2. Process all owners
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
anOwner = Handle(StdSelect_BRepOwner)::DownCast(owners( i ));
|
||||
|
||||
if ( anOwner.IsNull() || !anOwner->HasShape() )
|
||||
continue;
|
||||
if ( anOwner.IsNull() || !anOwner->HasShape() )
|
||||
continue;
|
||||
|
||||
// GLOBAL selection
|
||||
if ( !anOwner->ComesFromDecomposition() && globalSelMap.contains( entryStr ) )
|
||||
{
|
||||
ownersmap.Add( anOwner );
|
||||
globalSelMap[entryStr]++;
|
||||
}
|
||||
// LOCAL selection
|
||||
else
|
||||
{
|
||||
Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast( io );
|
||||
// GLOBAL selection
|
||||
if ( !anOwner->ComesFromDecomposition() && globalSelMap.contains( entryStr ) )
|
||||
{
|
||||
ownersmap.Add( anOwner );
|
||||
globalSelMap[entryStr]++;
|
||||
}
|
||||
// LOCAL selection
|
||||
else
|
||||
{
|
||||
if (isLocal)
|
||||
{
|
||||
const TColStd_IndexedMapOfInteger& subIndexes =
|
||||
indexesMap.ChangeFind((char*)entryStr.latin1());
|
||||
|
||||
if ( !aisShape.IsNull() && indexesMap.IsBound( (char*)entryStr.latin1() ) )
|
||||
{
|
||||
TopoDS_Shape shape = aisShape->Shape();
|
||||
TopTools_IndexedMapOfShape aMapOfShapes;
|
||||
TopExp::MapShapes( shape, aMapOfShapes );
|
||||
const TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind((char*)entryStr.latin1());
|
||||
const TopoDS_Shape& aSubShape = anOwner->Shape();
|
||||
int aSubShapeId = aMapOfShapes.FindIndex( aSubShape );
|
||||
|
||||
const TopoDS_Shape& aSubShape = anOwner->Shape();
|
||||
int aSubShapeId = aMapOfShapes.FindIndex( aSubShape );
|
||||
|
||||
// check if the "sub_shape_index" is found in the "map of indexes for this entry",
|
||||
// which was passes in the parameter
|
||||
if ( subIndexes.Contains( aSubShapeId ) )
|
||||
{
|
||||
ownersmap.Add( anOwner );
|
||||
}
|
||||
}
|
||||
} // end of local selection
|
||||
// check if the "sub_shape_index" is found in the "map of indexes for this entry",
|
||||
// which was passes in the parameter
|
||||
if ( subIndexes.Contains( aSubShapeId ) )
|
||||
{
|
||||
ownersmap.Add( anOwner );
|
||||
}
|
||||
}
|
||||
} // end of LOCAL selection
|
||||
} // end of for(owners)
|
||||
}// end of if(entry)
|
||||
}// end of for(AIS_all_ios)
|
||||
} // end of if(entry)
|
||||
} // end of for(AIS_all_ios)
|
||||
|
||||
vw->unHighlightAll( false );
|
||||
|
||||
// DO the selection
|
||||
for ( int i = 1, n = ownersmap.Extent(); i <= n; i++ )
|
||||
for ( int i = 1, n = ownersmap.Extent(); i <= n; i++ )
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) owner = ownersmap( i );
|
||||
if ( owner->State() )
|
||||
@ -295,17 +327,20 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
|
||||
}
|
||||
|
||||
vw->update();
|
||||
|
||||
|
||||
// fill extra selected
|
||||
mySelectedExternals.clear();
|
||||
for ( SUIT_DataOwnerPtrList::const_iterator itr2 = aList.begin(); itr2 != aList.end(); ++itr2 ) {
|
||||
const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( (*itr2).operator->() );
|
||||
for ( SUIT_DataOwnerPtrList::const_iterator itr2 = aList.begin(); itr2 != aList.end(); ++itr2 )
|
||||
{
|
||||
const LightApp_DataSubOwner* subOwner =
|
||||
dynamic_cast<const LightApp_DataSubOwner*>( (*itr2).operator->() );
|
||||
if ( !subOwner )
|
||||
{
|
||||
const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr2).operator->() );
|
||||
if ( owner )
|
||||
{
|
||||
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||
SalomeApp_Study* appStudy =
|
||||
dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||
QString anEntry = appStudy->referencedToEntry( owner->entry() );
|
||||
if (globalSelMap[anEntry] == 1) mySelectedExternals.append(*itr2);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
// 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
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
//
|
||||
//
|
||||
@ -326,42 +326,42 @@ void GroupGUI_GroupDlg::SelectionIntoArgument()
|
||||
// try to find out and process the object browser selection
|
||||
if ( !aMapIndex.Extent() ) {
|
||||
globalSelection( GEOM_ALLSHAPES );
|
||||
|
||||
|
||||
GEOM::ListOfGO anObjects;
|
||||
GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
|
||||
|
||||
GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
|
||||
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
|
||||
|
||||
for (int i = 0; i < anObjects.length(); i++)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGeomObj = anObjects[i];
|
||||
GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) )
|
||||
{
|
||||
aSubObjects->length(1);
|
||||
aSubObjects[0] = aGeomObj;
|
||||
}
|
||||
else if (aGeomObj->GetType() == GEOM_GROUP)
|
||||
aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
|
||||
else
|
||||
continue;
|
||||
for (int i = 0; i < anObjects.length(); i++)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGeomObj = anObjects[i];
|
||||
GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) )
|
||||
{
|
||||
aSubObjects->length(1);
|
||||
aSubObjects[0] = aGeomObj;
|
||||
}
|
||||
else if (aGeomObj->GetType() == GEOM_GROUP)
|
||||
aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
|
||||
else
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < aSubObjects->length(); i++)
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
|
||||
{
|
||||
CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
|
||||
if ( anIndex >= 0 )
|
||||
aMapIndex.Add( anIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < aSubObjects->length(); i++)
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
|
||||
{
|
||||
CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
|
||||
if ( anIndex >= 0 )
|
||||
aMapIndex.Add( anIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !myMainObj->_is_nil() )
|
||||
localSelection( myMainObj, getShapeType() );
|
||||
localSelection( myMainObj, getShapeType() );
|
||||
}
|
||||
|
||||
if (aMapIndex.Extent() >= 1) {
|
||||
@ -401,9 +401,8 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
|
||||
return;
|
||||
|
||||
GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
|
||||
GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
|
||||
|
||||
GEOM::ListOfGO_var aSubShapes = aShOp->MakeExplode( myMainObj, getShapeType(), false );
|
||||
GEOM::ListOfLong_var aSubShapes = aShOp->SubShapeAllIDs(myMainObj, getShapeType(), false);
|
||||
if ( !aShOp->IsDone() )
|
||||
return;
|
||||
|
||||
@ -413,7 +412,7 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
|
||||
|
||||
QListBoxItem* anItem;
|
||||
for ( int i = 0, n = aSubShapes->length(); i < n; i++ ) {
|
||||
CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubShapes[i] );
|
||||
CORBA::Long anIndex = aSubShapes[i];
|
||||
if ( anIndex < 0 )
|
||||
continue;
|
||||
|
||||
@ -424,7 +423,7 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
|
||||
|
||||
myIdList->blockSignals( isBlocked );
|
||||
highlightSubShapes();
|
||||
updateState();
|
||||
//updateState(); // already done in highlightSubShapes()
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -453,36 +452,36 @@ void GroupGUI_GroupDlg::add()
|
||||
if ( !aMapIndex.Extent() ) {
|
||||
GEOM::ListOfGO anObjects;
|
||||
GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
|
||||
|
||||
|
||||
GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
|
||||
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
|
||||
|
||||
for (int i = 0; i < anObjects.length(); i++)
|
||||
|
||||
for (int i = 0; i < anObjects.length(); i++)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGeomObj = anObjects[i];
|
||||
GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) )
|
||||
{
|
||||
GEOM::GEOM_Object_var aGeomObj = anObjects[i];
|
||||
GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) )
|
||||
{
|
||||
aSubObjects->length(1);
|
||||
aSubObjects[0] = aGeomObj;
|
||||
}
|
||||
else if (aGeomObj->GetType() == GEOM_GROUP)
|
||||
aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
|
||||
else
|
||||
break;
|
||||
|
||||
for (int i = 0; i < aSubObjects->length(); i++)
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
|
||||
{
|
||||
CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
|
||||
if ( anIndex >= 0 )
|
||||
aMapIndex.Add( anIndex );
|
||||
}
|
||||
}
|
||||
aSubObjects->length(1);
|
||||
aSubObjects[0] = aGeomObj;
|
||||
}
|
||||
else if (aGeomObj->GetType() == GEOM_GROUP)
|
||||
aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
|
||||
else
|
||||
break;
|
||||
|
||||
for (int i = 0; i < aSubObjects->length(); i++)
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
|
||||
{
|
||||
CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
|
||||
if ( anIndex >= 0 )
|
||||
aMapIndex.Add( anIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( aMapIndex.Extent() >= 1 ) {
|
||||
@ -585,72 +584,80 @@ void GroupGUI_GroupDlg::updateState()
|
||||
|
||||
TColStd_IndexedMapOfInteger aMapIndex;
|
||||
|
||||
if ( IObjectCount() == 1 ) {
|
||||
Standard_Boolean aResult = Standard_False;
|
||||
GEOM::GEOM_Object_var anObj =
|
||||
GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
|
||||
SALOME_ListIO aSelIOs;
|
||||
SalomeApp_Application* app = myGeomGUI->getApp();
|
||||
if (app) {
|
||||
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
||||
if (aSelMgr) {
|
||||
aSelMgr->selectedObjects(aSelIOs);
|
||||
|
||||
if ( aResult && !anObj->_is_nil() )
|
||||
((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->
|
||||
selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
|
||||
if ( aSelIOs.Extent() == 1 ) {
|
||||
Standard_Boolean aResult = Standard_False;
|
||||
GEOM::GEOM_Object_var anObj =
|
||||
GEOMBase::ConvertIOinGEOMObject( aSelIOs.First(), aResult );
|
||||
|
||||
if ( aResult && !anObj->_is_nil() )
|
||||
aSelMgr->GetIndexes( aSelIOs.First(), aMapIndex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try to find out and process the object browser selection
|
||||
if ( !aMapIndex.Extent() && !CORBA::is_nil( myMainObj ) ) {
|
||||
GEOM::ListOfGO anObjects;
|
||||
GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
|
||||
|
||||
//GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
|
||||
GEOMBase::ConvertListOfIOInListOfGO(aSelIOs, anObjects);
|
||||
|
||||
GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
|
||||
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
|
||||
|
||||
isAdd = true;
|
||||
|
||||
for (int i = 0; i < anObjects.length(); i++)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGeomObj = anObjects[i];
|
||||
GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) )
|
||||
{
|
||||
aSubObjects->length(1);
|
||||
aSubObjects[0] = aGeomObj;
|
||||
}
|
||||
else if (aGeomObj->GetType() == GEOM_GROUP)
|
||||
aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
|
||||
else
|
||||
{
|
||||
aMapIndex.Clear();
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < aSubObjects->length(); i++)
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
aSubObjects[i];
|
||||
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
|
||||
{
|
||||
CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
|
||||
if ( anIndex >= 0 )
|
||||
aMapIndex.Add( anIndex );
|
||||
else
|
||||
isAdd = false;
|
||||
}
|
||||
else
|
||||
isAdd = false;
|
||||
|
||||
if ( !isAdd ) {
|
||||
aMapIndex.Clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isAdd ) {
|
||||
aMapIndex.Clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
isAdd = true;
|
||||
|
||||
for (int i = 0; i < anObjects.length(); i++)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGeomObj = anObjects[i];
|
||||
GEOM::ListOfGO_var aSubObjects = new GEOM::ListOfGO();
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape(aGeomObj, aShape, getShapeType()) ) {
|
||||
aSubObjects->length(1);
|
||||
aSubObjects[0] = aGeomObj;
|
||||
}
|
||||
else if (aGeomObj->GetType() == GEOM_GROUP) {
|
||||
aSubObjects = aShapesOp->MakeExplode( aGeomObj, getShapeType(), false);
|
||||
}
|
||||
else {
|
||||
aMapIndex.Clear();
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < aSubObjects->length(); i++)
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
aSubObjects[i];
|
||||
if ( GEOMBase::GetShape(aSubObjects[i], aShape, getShapeType()) )
|
||||
{
|
||||
CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
|
||||
if ( anIndex >= 0 )
|
||||
aMapIndex.Add( anIndex );
|
||||
else
|
||||
isAdd = false;
|
||||
}
|
||||
else
|
||||
isAdd = false;
|
||||
|
||||
if ( !isAdd ) {
|
||||
aMapIndex.Clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isAdd ) {
|
||||
aMapIndex.Clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
isAdd = aMapIndex.Extent() > 0;
|
||||
|
||||
myAddBtn->setEnabled( !myEditCurrentArgument && !CORBA::is_nil( myMainObj ) && isAdd );
|
||||
@ -682,8 +689,7 @@ void GroupGUI_GroupDlg::highlightSubShapes()
|
||||
|
||||
Standard_Boolean isOk;
|
||||
char* objIOR = GEOMBase::GetIORFromObject( myMainObj );
|
||||
Handle(GEOM_AISShape) aSh =
|
||||
GEOMBase::ConvertIORinGEOMAISShape( objIOR, isOk, true );
|
||||
Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape( objIOR, isOk, true );
|
||||
free( objIOR );
|
||||
if ( !isOk || aSh.IsNull() )
|
||||
return;
|
||||
@ -751,30 +757,38 @@ bool GroupGUI_GroupDlg::isValid( QString& theMessage )
|
||||
//=================================================================================
|
||||
bool GroupGUI_GroupDlg::execute( ObjectList& objects )
|
||||
{
|
||||
GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
|
||||
GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
|
||||
|
||||
GEOM::GEOM_Object_var aGroup;
|
||||
if ( myMode == CreateGroup )
|
||||
aGroup = anOp->CreateGroup( myMainObj, getShapeType() );
|
||||
else if ( myMode == EditGroup )
|
||||
if (myMode == CreateGroup)
|
||||
aGroup = anOp->CreateGroup(myMainObj, getShapeType());
|
||||
else if (myMode == EditGroup)
|
||||
aGroup = myGroup;
|
||||
|
||||
if ( CORBA::is_nil( aGroup ) || ( myMode == CreateGroup && !anOp->IsDone() ) )
|
||||
if (CORBA::is_nil(aGroup) || (myMode == CreateGroup && !anOp->IsDone()))
|
||||
return false;
|
||||
|
||||
GEOM::ListOfLong_var aCurrList = anOp->GetObjects( aGroup );
|
||||
if ( !anOp->IsDone() )
|
||||
GEOM::ListOfLong_var aCurrList = anOp->GetObjects(aGroup);
|
||||
if (!anOp->IsDone())
|
||||
return false;
|
||||
|
||||
for ( int i = 0, n = aCurrList->length(); i < n; i++ ) {
|
||||
anOp->RemoveObject( aGroup, aCurrList[i] );
|
||||
if ( !anOp->IsDone() )
|
||||
if (aCurrList->length() > 0)
|
||||
{
|
||||
anOp->DifferenceIDs(aGroup, aCurrList);
|
||||
if (!anOp->IsDone())
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int ii = 0, nn = myIdList->count(); ii < nn; ii++ ) {
|
||||
anOp->AddObject( aGroup, myIdList->item( ii )->text().toInt() );
|
||||
if ( !anOp->IsDone() )
|
||||
int ii, nn = myIdList->count();
|
||||
if (nn > 0)
|
||||
{
|
||||
GEOM::ListOfLong_var aNewList = new GEOM::ListOfLong;
|
||||
aNewList->length(nn);
|
||||
for (ii = 0; ii < nn; ii++) {
|
||||
aNewList[ii] = myIdList->item(ii)->text().toInt();
|
||||
}
|
||||
anOp->UnionIDs(aGroup, aNewList);
|
||||
if (!anOp->IsDone())
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -811,4 +825,3 @@ GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather( GEOM::GEOM_Object_ptr theObj
|
||||
}
|
||||
return aFatherObj._retn();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user