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