+//=================================================================================
+// 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 );
+
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ if (aSelList.Extent() != 1)
+ return;
+
+ Standard_Boolean aResult = Standard_False;
+ GEOM::GEOM_Object_var anObj =
+ GEOMBase::ConvertIOinGEOMObject(aSelList.First(), 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 {
+ bool isVisible = true;
+ if ( SALOME_View* view = GEOM_Displayer::GetActiveView() )
+ isVisible = view->isVisible( aSelList.First() );
+ setInPlaceObj( anObj, isVisible );
+ }
+ 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, const bool isVisible )
+{
+ if ( ! myInPlaceObj->_is_equivalent( theObj ) )
+ {
+ const char* tmpName = "__InPlaceObj__";
+ // remove old InPlaceObj
+ if ( !myInPlaceObj->_is_nil() ) {
+ if ( myInPlaceObjSelectState == GET_IN_PLACE ||
+ myInPlaceObjSelectState == SUBSHAPES_OF_INVISIBLE_SHAPE2 ) {
+ // hide temporary object or initially invisible shape 2 (issue 0014047)
+ GEOM_Displayer aDisplayer(getStudy());
+ aDisplayer.Erase( myInPlaceObj, true );
+ }
+ 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 );
+ }
+ }
+ myInPlaceObjSelectState = subSelectionWay();
+ if ( myInPlaceObjSelectState == SUBSHAPES_OF_SHAPE2 && !isVisible )
+ myInPlaceObjSelectState = SUBSHAPES_OF_INVISIBLE_SHAPE2;
+}