// 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.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
#include "GroupGUI_GroupDlg.h"
+#include "LightApp_SelectionMgr.h"
#include "SUIT_Desktop.h"
+#include "SUIT_OverrideCursor.h"
#include "SUIT_Session.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Study.h"
-#include "LightApp_SelectionMgr.h"
#include "GEOMBase.h"
-
#include "GEOMImpl_Types.hxx"
#include <qlabel.h>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
+enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2 };
-
-
-GroupGUI_GroupDlg::GroupGUI_GroupDlg(Mode mode,
- QWidget* parent,
- const char* name,
- bool modal,
- WFlags fl)
- :GEOMBase_Skeleton( parent, "GroupGUI_GroupDlg", false,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myMode( mode ),
+GroupGUI_GroupDlg::GroupGUI_GroupDlg(Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent)
+ :GEOMBase_Skeleton( theGeometryGUI, parent, "GroupGUI_GroupDlg", false,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+ myMode( mode ),
myBusy( false )
{
- QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_VERTEX" ) ) );
- QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_EDGE" ) ) );
- QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_FACE" ) ) );
- QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_SOLID" ) ) );
-
- QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
+ QPixmap image0 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
+ QPixmap image1 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_EDGE")));
+ QPixmap image2 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_FACE")));
+ QPixmap image3 (resMgr->loadPixmap("GEOM", tr("ICON_OBJBROWSER_SOLID")));
+ QPixmap iconSelect (resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setCaption( myMode == CreateGroup ? tr( "CREATE_GROUP_TITLE" ) : tr( "EDIT_GROUP_TITLE" ) );
GroupBoxName->setTitle( tr( "GROUP_NAME" ) );
// Main shape and sub-shapes
- GroupMedium = new QGroupBox( 1, Qt::Vertical, tr( "MAIN_SUB_SHAPES" ), this );
+ QGroupBox* GroupMedium = new QGroupBox( 1, Qt::Vertical, tr( "MAIN_SUB_SHAPES" ), this );
GroupMedium->setInsideMargin( 10 );
Layout1->addWidget( GroupMedium, 2, 0 );
QWidget* aFrame = new QWidget( GroupMedium );
- QGridLayout* aMedLayout = new QGridLayout( aFrame, 4, 4, 0, 6 );
+ QGridLayout* aMedLayout = new QGridLayout( aFrame, 6, 4, 0, 6 );
QLabel* aMainLabel = new QLabel( tr( "MAIN_SHAPE" ), aFrame );
myMainName = new QLineEdit( aFrame );
myMainName->setReadOnly( true );
myMainName->setEnabled( myMode == CreateGroup );
-
- mySelSubBtn = new QPushButton( tr( "SELECT_SUB_SHAPES" ), aFrame );
- mySelAllBtn = new QPushButton( tr( "SELECT_ALL" ), aFrame );
- myAddBtn = new QPushButton( tr( "ADD" ), aFrame );
- myRemBtn = new QPushButton( tr( "REMOVE" ), aFrame );
+
+ QLabel* aSecondLabel = new QLabel( tr( "SECOND_SHAPE" ), aFrame );
+
+ mySelBtn2 = new QPushButton( aFrame );
+ mySelBtn2->setPixmap( iconSelect );
+ mySelBtn2->setEnabled( false );
+
+ myShape2Name = new QLineEdit( aFrame );
+ myShape2Name->setReadOnly( true );
+ myShape2Name->setEnabled( false );
+
+ //mySelSubBtn = new QRadioButton ( tr( "SELECT_SUB_SHAPES" ), aFrame );
+ //myPlaceCheckBox = new QCheckBox ( tr( "GET_IN_PLACE" ), aFrame );
+ mySelectionWayGroup = new QButtonGroup(1, Qt::Horizontal, tr("SHAPE_SEL_RESTR"),aFrame);
+ mySelectionWayGroup->setExclusive(true);
+ QRadioButton* allSubs = new QRadioButton(tr("NO_RESTR") ,mySelectionWayGroup);
+ QRadioButton* inPlaceSubs = new QRadioButton(tr("GEOM_PARTS_OF_SHAPE2"),mySelectionWayGroup);
+ QRadioButton* shape2Subs = new QRadioButton(tr("SUBSHAPES_OF_SHAPE2") ,mySelectionWayGroup);
+ mySelectionWayGroup->insert(allSubs , ALL_SUBSHAPES);
+ mySelectionWayGroup->insert(inPlaceSubs, GET_IN_PLACE);
+ mySelectionWayGroup->insert(shape2Subs , SUBSHAPES_OF_SHAPE2);
+ mySelectionWayGroup->setButton( ALL_SUBSHAPES );
+
+ mySelAllBtn = new QPushButton( tr( "SELECT_ALL" ), aFrame );
+ myAddBtn = new QPushButton( tr( "ADD" ), aFrame );
+ myRemBtn = new QPushButton( tr( "REMOVE" ), aFrame );
myIdList = new QListBox( aFrame );
-
+
myIdList->setSelectionMode( QListBox::Extended );
myIdList->setRowMode( QListBox::FitToWidth );
aMedLayout->addWidget( aMainLabel, 0, 0 );
aMedLayout->addWidget( mySelBtn, 0, 1 );
aMedLayout->addMultiCellWidget( myMainName, 0, 0, 2, 3 );
- aMedLayout->addMultiCellWidget( mySelSubBtn, 1, 1, 0, 2 );
- aMedLayout->addWidget( mySelAllBtn, 1, 3 );
- aMedLayout->addMultiCellWidget( myIdList, 2, 3, 0, 2 );
- aMedLayout->addWidget( myAddBtn, 2, 3 );
- aMedLayout->addWidget( myRemBtn, 3, 3 );
+
+ aMedLayout->addWidget( aSecondLabel, 1, 0 );
+ aMedLayout->addWidget( mySelBtn2, 1, 1 );
+ aMedLayout->addMultiCellWidget( myShape2Name, 1, 1, 2, 3 );
+
+
+ //aMedLayout->addMultiCellWidget( mySelSubBtn, 2, 2, 0, 1 );
+ //aMedLayout->addWidget( myPlaceCheckBox, 2, 2 );
+ //aMedLayout->addMultiCellWidget( myPlaceCheckBox, 2, 2, 0, 2 );
+ aMedLayout->addMultiCellWidget( mySelectionWayGroup, 2, 4, 0, 2 );
+ aMedLayout->addWidget( mySelAllBtn, 2, 3 );
+ aMedLayout->addWidget( myAddBtn, 3, 3 );
+ aMedLayout->addWidget( myRemBtn, 4, 3 );
+ aMedLayout->addMultiCellWidget( myIdList, 5, 5, 0, 3 );
+ aMedLayout->setRowStretch( 5, 1 );
+
+
+ setHelpFileName("work_with_groups_page.html");
Init();
}
void GroupGUI_GroupDlg::Init()
{
// san -- TODO: clear selected sub-shapes...
-
+ //mySelSubBtn->setChecked( true );
if ( myMode == CreateGroup ) {
initName( tr( "GROUP_PREFIX" ) );
// Get ready for main shape selection
myEditCurrentArgument = myMainName;
- connect( GroupConstructors, SIGNAL( clicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
- connect( mySelBtn, SIGNAL( clicked() ), this, SLOT(SetEditCurrentArgument()));
+ connect( GroupConstructors, SIGNAL( clicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
+ connect( mySelBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( mySelBtn2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
}
else if ( myMode == EditGroup && IObjectCount() ) {
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
-
+
if ( aResult && !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) {
myGroup = anObj;
GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
myMainObj = anOp->GetMainShape( myGroup );
if ( !CORBA::is_nil( myMainObj ) )
- myMainName->setText( GEOMBase::GetName( myMainObj ) );
+ myMainName->setText( GEOMBase::GetName( myMainObj ) );
setShapeType( (TopAbs_ShapeEnum)anOp->GetType( myGroup ) );
GEOM::ListOfLong_var aCurrList = anOp->GetObjects( myGroup );
QListBoxItem* anItem;
for ( int i = 0, n = aCurrList->length(); i < n; i++ ) {
- anItem = new QListBoxText( QString( "%1" ).arg(aCurrList[i] ) );
- myIdList->insertItem( anItem );
+ anItem = new QListBoxText( QString( "%1" ).arg(aCurrList[i] ) );
+ myIdList->insertItem( anItem );
}
myEditCurrentArgument = 0;
}
+ connect( mySelBtn2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
}
+ LightApp_SelectionMgr* aSelMgr =
+ ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr();
+
+ connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
- connect( mySelSubBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ //connect( mySelSubBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ //connect( myPlaceCheckBox, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( mySelectionWayGroup,SIGNAL(clicked(int)),this,SLOT(SetEditCurrentArgument()));
connect( mySelAllBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
- connect( mySelAllBtn, SIGNAL( clicked() ), this, SLOT( selectAllSubShapes() ) );
connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( add() ) );
connect( myRemBtn, SIGNAL( clicked() ), this, SLOT( remove() ) );
connect( myIdList, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
+ setInPlaceObj( GEOM::GEOM_Object::_nil() );
+
+ myBusy = true; // just activate but do not select in the list
activateSelection();
+ myBusy = false;
+ // activate subshapes selection if Main Shape is Selected
+// if ( !CORBA::is_nil( myMainObj ) ) {
+// myEditCurrentArgument = 0;
+// activateSelection();
+// updateState();
+// }
}
//=================================================================================
this->ActivateThisDialog();
}
+//=======================================================================
+//function : closeEvent
+//purpose : remove temporary geom object
+//=======================================================================
+
+void GroupGUI_GroupDlg::closeEvent(QCloseEvent* e)
+{
+ setInPlaceObj( GEOM::GEOM_Object::_nil() );
+
+ GEOMBase_Skeleton::closeEvent(e);
+}
+
//=================================================================================
// function : ClickOnOk()
// purpose :
ClickOnCancel();
}
-
//=================================================================================
// function : ClickOnApply()
// purpose :
return false;
if ( myMode == CreateGroup )
- initName();
+ {
+ initName();
+ myIdList->clear();
+ }
+ else
+ activateSelection();
return true;
}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
activateSelection();
}
void GroupGUI_GroupDlg::LineEditReturnPressed()
{
QLineEdit* send = ( QLineEdit* )sender();
-
+
if ( send == myMainName && !myEditCurrentArgument ) {
myEditCurrentArgument = myMainName;
activateSelection();
updateState();
}
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
{
QPushButton* send = (QPushButton*)sender();
- if ( send == mySelBtn )
+ if ( send == mySelBtn ) {
myEditCurrentArgument = myMainName;
- else if ( send == mySelSubBtn || send == mySelAllBtn )
+ myShape2Name->setText( "" );
+ }
+ else if ( /*(QRadioButton*)sender() == mySelSubBtn ||*/ send == mySelAllBtn )
myEditCurrentArgument = 0;
+ else if ( send == mySelBtn2 || sender() == mySelectionWayGroup ) {
+ setInPlaceObj( GEOM::GEOM_Object::_nil() );
+ //if ( myPlaceCheckBox->isChecked() )
+ myShape2Name->setText( "" );
+ if ( subSelectionWay() != ALL_SUBSHAPES )
+ {
+ myEditCurrentArgument = myShape2Name;
+ }
+ else {
+ //myEditCurrentArgument = myMainName;
+ myEditCurrentArgument = 0;
+ }
+ }
activateSelection();
- updateState();
+
+ if ( send == mySelAllBtn ) {
+// myShape2Name->setText( "" );
+// myPlaceCheckBox->setChecked( false );
+// mySelBtn2->setEnabled( false );
+// myShape2Name->setEnabled( false );
+ selectAllSubShapes();
+ }
+ else
+ updateState();
}
+//=================================================================================
+// function : onGetInPlace()
+// purpose :
+//=================================================================================
+void GroupGUI_GroupDlg::onGetInPlace()
+{
+ setInPlaceObj( GEOM::GEOM_Object::_nil() );
+ myEditCurrentArgument->setText( "" );
+
+ bool isBlocked = myIdList->signalsBlocked();
+ myIdList->blockSignals( true );
+ myIdList->clearSelection();
+ myIdList->blockSignals( isBlocked );
+
+ if (IObjectCount() != 1 )
+ return;
+
+ Standard_Boolean aResult = Standard_False;
+ GEOM::GEOM_Object_var anObj =
+ GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
+ if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) {
+ if ( !anObj->_is_equivalent(myMainObj) && !anObj->_is_equivalent( myGroup )) {
+ SUIT_OverrideCursor wc;
+ myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) );
+ GEOM::GEOM_IShapesOperations_var aShapesOp =
+ getGeomEngine()->GetIShapesOperations( getStudyId() );
+ if ( subSelectionWay() == GET_IN_PLACE ) {
+ GEOM::GEOM_Object_var aGetInPlaceObj = aShapesOp->GetInPlace(myMainObj, anObj);
+ setInPlaceObj( aGetInPlaceObj );
+ }
+ else {
+ setInPlaceObj( anObj );
+ }
+ myEditCurrentArgument = 0;
+ //myBusy = true; // just activate but do not select in the list
+ activateSelection();
+ //myBusy = false;
+ }
+ }
+}
+
+//=======================================================================
+//function : setInPlaceObj
+//purpose : temporarily add an object to study and remove old InPlaceObj
+//=======================================================================
+
+void GroupGUI_GroupDlg::setInPlaceObj( GEOM::GEOM_Object_var theObj )
+{
+ if ( ! myInPlaceObj->_is_equivalent( theObj ) )
+ {
+ const char* tmpName = "__InPlaceObj__";
+ // remove old InPlaceObj
+ if ( !myInPlaceObj->_is_nil() ) {
+ if (_PTR(SObject) SO = getStudy()->studyDS()->FindObject( tmpName )) {
+ getStudy()->studyDS()->NewBuilder()->RemoveObjectWithChildren( SO );
+ getGeomEngine()->RemoveObject(myInPlaceObj);
+ }
+ }
+ // publish InPlaceObj to enable localSelection(InPlaceObj)
+ if ( !theObj->_is_nil() && subSelectionWay() == GET_IN_PLACE ) {
+ SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(getStudy()->studyDS());
+ SALOMEDS::SObject_var aSO =
+ getGeomEngine()->AddInStudy(aStudyDS, theObj, tmpName, myMainObj);
+ }
+ myInPlaceObj = theObj;
+ }
+ // build map of indices
+ myMain2InPlaceIndices.Clear();
+ if ( !myInPlaceObj->_is_nil() ) {
+ GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+ GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
+
+ GEOM::ListOfGO_var aSubObjects = aShapesOp->MakeExplode( myInPlaceObj, getShapeType(), false);
+ for (int i = 0; i < aSubObjects->length(); i++)
+ {
+ CORBA::Long aMainIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
+ CORBA::Long aPlaceIndex = aLocOp->GetSubShapeIndex( myInPlaceObj, aSubObjects[i] );
+ if ( aMainIndex >= 0 && aPlaceIndex > 0)
+ myMain2InPlaceIndices.Bind( aMainIndex, aPlaceIndex );
+ }
+ }
+}
//=================================================================================
// function : SelectionIntoArgument()
//=================================================================================
void GroupGUI_GroupDlg::SelectionIntoArgument()
{
- if ( myEditCurrentArgument ) { // Selection of a main shape is active
+// if (myPlaceCheckBox->isChecked() && myEditCurrentArgument == myShape2Name )
+ if (subSelectionWay() != ALL_SUBSHAPES && myEditCurrentArgument == myShape2Name ) {
+ onGetInPlace();
+ return;
+ }
+
+ if ( myEditCurrentArgument == myMainName) { // Selection of a main shape is active
myEditCurrentArgument->setText( "" );
+ myIdList->clear();
if ( IObjectCount() == 1 ) {
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
- GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
+ GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) {
- myMainObj = anObj;
- myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) );
- updateState();
+ myMainObj = anObj;
+ myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) );
+ // activate subshapes selection by default
+ myEditCurrentArgument = 0;
+ activateSelection();
+ updateState();
return;
}
}
myMainObj = GEOM::GEOM_Object::_nil();
}
- else { // an attempt to synchronize list box selection with 3d viewer
- if ( myBusy )
+ else { // an attempt to synchronize list box selection with 3d viewer
+ if ( myBusy ) {
return;
+ }
bool isBlocked = myIdList->signalsBlocked();
myIdList->blockSignals( true );
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) {
+ QMap<QString, TColStd_IndexedMapOfInteger> aMap;
+ aSelMgr->selectedSubOwners(aMap);
+ if (aMap.size() == 1)
+ aMapIndex = aMap.begin().data();
+ }
+ }
+ bool subselected = aMapIndex.Extent();
+
+ // convert inPlace indices to main indices
+ //if ( subselected && myPlaceCheckBox->isChecked() )
+ if ( subselected && subSelectionWay() != ALL_SUBSHAPES )
+ {
+ TColStd_IndexedMapOfInteger aMapIndex2;
- if ( aResult && !anObj->_is_nil() )
- ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
+ TColStd_DataMapIteratorOfDataMapOfIntegerInteger m2ip( myMain2InPlaceIndices );
+ for ( ; m2ip.More(); m2ip.Next() ) {
+ int inPlaceId = m2ip.Value();
+ if ( aMapIndex.Contains( inPlaceId )) {
+ aMapIndex2.Add( m2ip.Key() );
+ }
+ }
+ aMapIndex = aMapIndex2;
}
-
- if ( !aMapIndex.Extent() ) // try to find out and process the object browser selection
+
+ // try to find out and process the object browser selection
+ if ( !subselected ) {
+ 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::ListOfGO anObjects;
- GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
- GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
- for (int i = 0; i < anObjects.length(); i++)
- {
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape(anObjects[i], aShape, getShapeType()) )
- {
- CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, anObjects[i] );
- if ( anIndex >= 0 )
- aMapIndex.Add( anIndex );
- }
- }
+ 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;
+ anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
+ if ( anIndex >= 0 ) {
+ //if ( myPlaceCheckBox->isChecked() && ! myMain2InPlaceIndices.IsBound( anIndex ))
+ if ( subSelectionWay() != ALL_SUBSHAPES &&
+ ! myMain2InPlaceIndices.IsBound( anIndex ))
+ continue;
+ aMapIndex.Add( anIndex );
+ }
+ }
+ }
}
-
- if ( aMapIndex.Extent()>=1 )
- {
+ if ( !myMainObj->_is_nil() /*&& mySelSubBtn->isChecked()*/)
+ if ( subSelectionWay() == ALL_SUBSHAPES )
+ localSelection( myMainObj, getShapeType() );
+ else if ( !myInPlaceObj->_is_nil() )
+ localSelection( myInPlaceObj, getShapeType() );
+ }
+
+ if (aMapIndex.Extent() >= 1) {
QMap<int, int> aMap;
for ( int i = 0, n = myIdList->count(); i < n; i++ )
- aMap.insert( myIdList->item( i )->text().toInt(), i );
-
- for ( int ii = 1, nn = aMapIndex.Extent(); ii <= nn; ii++ )
- {
- if ( aMap.contains( aMapIndex( ii ) ) )
- myIdList->setSelected( aMap[aMapIndex( ii )], true );
- }
+ aMap.insert( myIdList->item( i )->text().toInt(), i );
+
+ for ( int ii = 1, nn = aMapIndex.Extent(); ii <= nn; ii++ ) {
+ if ( aMap.contains( aMapIndex( ii ) ) )
+ myIdList->setSelected( aMap[aMapIndex( ii )], true );
+ }
}
myIdList->blockSignals( isBlocked );
}
myIdList->clear();
activateSelection();
updateState();
+ setInPlaceObj( myInPlaceObj ); // to rebuild myMain2InPlaceIndices
}
//=================================================================================
if ( CORBA::is_nil( myMainObj ) )
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 );
- if ( !aShOp->IsDone() )
- return;
+ GEOM::ListOfLong_var aSubShapes;
+// if ( !myPlaceCheckBox->isChecked() )
+ if ( subSelectionWay() == ALL_SUBSHAPES )
+ {
+ myIdList->clear();
+ GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+ aSubShapes = aShOp->SubShapeAllIDs(myMainObj, getShapeType(), false);
+ if ( !aShOp->IsDone() )
+ return;
+ }
+ else
+ {
+ aSubShapes = new GEOM::ListOfLong();
+ aSubShapes->length( myMain2InPlaceIndices.Extent() );
+ TColStd_DataMapIteratorOfDataMapOfIntegerInteger m2ip( myMain2InPlaceIndices );
+ for ( int i = 0; m2ip.More(); i++, m2ip.Next() )
+ aSubShapes[ i ] = m2ip.Key();
+ }
bool isBlocked = myIdList->signalsBlocked();
myIdList->blockSignals( true );
- myIdList->clear();
-
+
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;
-
- anItem = new QListBoxText( QString( "%1" ).arg( anIndex ) );
- myIdList->insertItem( anItem );
+ anItem = 0;
+ QString text = QString( "%1" ).arg( anIndex );
+ if ( !myInPlaceObj->_is_nil() )
+ anItem = myIdList->findItem( text, Qt::ExactMatch);
+ if ( !anItem ) {
+ anItem = new QListBoxText( text );
+ myIdList->insertItem( anItem );
+ }
myIdList->setSelected( anItem, true );
}
myIdList->blockSignals( isBlocked );
highlightSubShapes();
- updateState();
}
//=================================================================================
TColStd_MapOfInteger aMap;
for ( int i = 0, n = myIdList->count(); i < n; i++ )
aMap.Add( myIdList->item( i )->text().toInt() );
-
+
TColStd_IndexedMapOfInteger aMapIndex;
-
- if ( IObjectCount() == 1 ) {
- Standard_Boolean aResult = Standard_False;
- GEOM::GEOM_Object_var anObj =
- GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
-
- if ( aResult && !anObj->_is_nil() )
- ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
+
+ SALOME_ListIO aSelIOs;
+ SalomeApp_Application* app = myGeomGUI->getApp();
+ if (app) {
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ if (aSelMgr) {
+ QMap<QString, TColStd_IndexedMapOfInteger> aMap;
+ aSelMgr->selectedSubOwners(aMap);
+ if (aMap.size() == 1)
+ aMapIndex = aMap.begin().data();
+ }
}
-
- if ( !aMapIndex.Extent() ) // try to find out and process the object browser selection
+ GEOM::ListOfGO anObjects;
+ // get selected sub-shapes of myInPlaceObj
+ if ( aMapIndex.Extent() > 0 && !myInPlaceObj->_is_nil() )
+ {
+ GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
+
+ anObjects.length( aMapIndex.Extent() );
+ for ( int i = 1; i <= aMapIndex.Extent(); i++ )
+ anObjects[ i-1 ] = aShapesOp->GetSubShape( myInPlaceObj, aMapIndex( i ));
+
+ aMapIndex.Clear();
+ }
+
+ // try to find out and process the object browser selection or InPlace sub-shapes
+ if ( !aMapIndex.Extent() )
+ {
+ if ( anObjects.length() == 0 )
+ GEOMBase::ConvertListOfIOInListOfGO(aSelIOs, 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::ListOfGO anObjects;
- GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
- GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
- for (int i = 0; i < anObjects.length(); i++)
- {
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape(anObjects[i], aShape, getShapeType()) )
- {
- CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, anObjects[i] );
- if ( anIndex >= 0 )
- aMapIndex.Add( anIndex );
- }
- }
+ 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;
+ anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubObjects[i] );
+ if ( anIndex >= 0 )
+ aMapIndex.Add( anIndex );
+ }
+ }
}
-
- if ( aMapIndex.Extent()>=1 )
- {
- QListBoxItem* anItem;
- bool isBlocked = myIdList->signalsBlocked();
- myIdList->blockSignals( true );
+ }
- for ( int i = 1, n = aMapIndex.Extent(); i <= n; i++ ) {
- if ( aMap.Contains( aMapIndex( i ) ) )
- continue;
+ if ( aMapIndex.Extent() >= 1 ) {
+ QListBoxItem* anItem;
+ bool isBlocked = myIdList->signalsBlocked();
+ myIdList->blockSignals( true );
- anItem = new QListBoxText( QString( "%1" ).arg( aMapIndex( i ) ) );
- myIdList->insertItem( anItem );
- myIdList->setSelected( anItem, true );
- }
+ for ( int i = 1, n = aMapIndex.Extent(); i <= n; i++ ) {
+ if ( aMap.Contains( aMapIndex( i ) ) )
+ continue;
- myIdList->blockSignals( isBlocked );
+ anItem = new QListBoxText( QString( "%1" ).arg( aMapIndex( i ) ) );
+ myIdList->insertItem( anItem );
+ myIdList->setSelected( anItem, true );
}
-
+
+ myIdList->blockSignals( isBlocked );
+ }
+
updateState();
}
//=================================================================================
void GroupGUI_GroupDlg::remove()
{
+ bool isBlocked = myIdList->signalsBlocked();
+ myIdList->blockSignals( true );
+
for ( int i = myIdList->count() - 1; i >= 0; i-- ) {
- if ( myIdList->isSelected( i ) )
+ if ( myIdList->isSelected( i ) )
myIdList->removeItem( i );
}
- updateState();
+
+ myIdList->blockSignals( isBlocked );
+
+ highlightSubShapes();
}
return GroupConstructors->id( GroupConstructors->selected() );
}
+//=======================================================================
+//function : subSelectionWay
+//purpose :
+//=======================================================================
+
+int GroupGUI_GroupDlg::subSelectionWay() const
+{
+ return mySelectionWayGroup->id( mySelectionWayGroup->selected() );
+}
+
//=================================================================================
// function : getShapeType()
// purpose :
case TopAbs_EDGE: anId = 1; break;
case TopAbs_FACE: anId = 2; break;
case TopAbs_SOLID: anId = 3; break;
- }
+ }
GroupConstructors->setButton( anId );
}
{
globalSelection( GEOM_ALLSHAPES );
- if ( !myMainObj->_is_nil() && !myEditCurrentArgument ) {
- localSelection( myMainObj, getShapeType() );
+ // local selection
+ if ( !myMainObj->_is_nil() && !myEditCurrentArgument/* && mySelSubBtn->isChecked()*/) {
+// if ( !myPlaceCheckBox->isChecked() )
+ if ( subSelectionWay() == ALL_SUBSHAPES )
+ localSelection( myMainObj, getShapeType() );
+ else if ( !myInPlaceObj->_is_nil() )
+ localSelection( myInPlaceObj, getShapeType() );
}
SelectionIntoArgument();
bool isAdd = false;
TColStd_IndexedMapOfInteger aMapIndex;
-
- if ( IObjectCount() == 1 ) {
- Standard_Boolean aResult = Standard_False;
- GEOM::GEOM_Object_var anObj =
- GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
- if ( aResult && !anObj->_is_nil() )
- ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->GetIndexes( firstIObject(), aMapIndex );
+ SALOME_ListIO aSelIOs;
+ SalomeApp_Application* app = myGeomGUI->getApp();
+ if (app) {
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ if (aSelMgr) {
+ QMap<QString, TColStd_IndexedMapOfInteger> aMap;
+ aSelMgr->selectedSubOwners(aMap);
+ if (aMap.size() == 1)
+ aMapIndex = aMap.begin().data();
+ }
}
-
- if ( !aMapIndex.Extent() ) // 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 ) ) {
+ GEOM::ListOfGO 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++)
{
- isAdd = true;
- GEOM::ListOfGO anObjects;
- GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), anObjects);
- GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
- for (int i = 0; i < anObjects.length(); i++)
- {
- TopoDS_Shape aShape;
- if ( GEOMBase::GetShape(anObjects[i], aShape, getShapeType()) )
- {
- CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, anObjects[i] );
- if ( anIndex >= 0 )
- aMapIndex.Add( anIndex );
- else
- isAdd = false;
- }
- else
- isAdd = false;
-
- if ( !isAdd )
- {
- aMapIndex.Clear();
- break;
- }
- }
+ 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;
+ 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 );
bool hasSel = false;
for ( int ii = 0, nn = myIdList->count(); !hasSel && ii < nn; ii++ )
hasSel = myIdList->isSelected( ii );
myRemBtn->setEnabled( hasSel );
- mySelSubBtn->setEnabled( !CORBA::is_nil( myMainObj ) );
+ //mySelSubBtn->setEnabled( !CORBA::is_nil( myMainObj ) );
+ //myPlaceCheckBox->setEnabled( !CORBA::is_nil( myMainObj ) );
+ mySelectionWayGroup->setEnabled( !CORBA::is_nil( myMainObj ) );
mySelAllBtn->setEnabled( !CORBA::is_nil( myMainObj ) );
+// mySelBtn2->setEnabled( myPlaceCheckBox->isChecked() );
+// myShape2Name->setEnabled( myPlaceCheckBox->isChecked() );
+ mySelBtn2->setEnabled( subSelectionWay() != ALL_SUBSHAPES );
+ myShape2Name->setEnabled( subSelectionWay() != ALL_SUBSHAPES );
+// if ( !myPlaceCheckBox->isChecked() )
+ if ( subSelectionWay() == ALL_SUBSHAPES )
+ setInPlaceObj( GEOM::GEOM_Object::_nil() );
}
//=================================================================================
return;
Standard_Boolean isOk;
- Handle(GEOM_AISShape) aSh =
- GEOMBase::ConvertIORinGEOMAISShape( GEOMBase::GetIORFromObject( myMainObj ), isOk, true );
+ char* objIOR;
+
+ if ( myInPlaceObj->_is_nil() )
+ objIOR = GEOMBase::GetIORFromObject( myMainObj );
+ else
+ objIOR = GEOMBase::GetIORFromObject( myInPlaceObj );
+
+ Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape( objIOR, isOk, true );
+ free( objIOR );
if ( !isOk || aSh.IsNull() )
return;
myBusy = true;
- for ( int ii = 0, nn = myIdList->count(); ii < nn; ii++ )
- if ( myIdList->isSelected( ii ) )
- anIds.Add( myIdList->item( ii )->text().toInt() );
+ int ii = 0, nn = myIdList->count();
+ for ( ; ii < nn; ii++ )
+ if ( myIdList->isSelected( ii ) ) {
+ int id = myIdList->item( ii )->text().toInt();
+// if ( myPlaceCheckBox->isChecked() )
+ if ( subSelectionWay() != ALL_SUBSHAPES )
+ {
+ if (myMain2InPlaceIndices.IsBound( id ))
+ id = myMain2InPlaceIndices( id );
+ else {
+ myIdList->setSelected( ii, false );
+ continue;
+ }
+ }
+ anIds.Add( id );
+ }
- LightApp_SelectionMgr* aSelMgr = ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr();
+ SalomeApp_Application* app = myGeomGUI->getApp();
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
aSelMgr->clearSelected();
- aSelMgr->AddOrRemoveIndex( aSh->getIO(), anIds, false );
+
+ aSelMgr->AddOrRemoveIndex(aSh->getIO(), anIds, false);
myBusy = false;
- updateState();
+ if (nn < 3000)
+ updateState();
+ else {
+ myAddBtn->setEnabled( true );
+ myRemBtn->setEnabled( true );
+ }
}
//=================================================================================
RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_GROUP" ) )
}
- const char* aName = getNewObjectName();
- RETURN_WITH_MSG ( aName && strlen( aName ), tr( "EMPTY_NAME" ) )
+ QString aName (getNewObjectName());
+ RETURN_WITH_MSG ( !aName.stripWhiteSpace().isEmpty(), tr( "EMPTY_NAME" ) )
RETURN_WITH_MSG ( myIdList->count(), tr( "EMPTY_LIST" ) )
return true;
//=================================================================================
bool GroupGUI_GroupDlg::execute( ObjectList& objects )
{
- GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
-
+ setInPlaceObj( GEOM::GEOM_Object::_nil() );
+
+ 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;
}
SalomeApp_Study* study = getStudy();
if ( study ) {
- string IOR = GEOMBase::GetIORFromObject( aGroup );
+ char* objIOR = GEOMBase::GetIORFromObject( aGroup );
+ string IOR( objIOR );
+ free( objIOR );
if ( IOR != "" ) {
_PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
- if ( SO ) {
- _PTR(StudyBuilder) aBuilder (study->studyDS()->NewBuilder());
- aBuilder->SetName( SO, getNewObjectName() );
+ if ( SO ) {
+ _PTR(StudyBuilder) aBuilder (study->studyDS()->NewBuilder());
+ aBuilder->SetName( SO, getNewObjectName() );
}
}
}