-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// 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
+// You should have received a copy of the GNU Lesser General Public
+// 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
// GEOM GEOMGUI : GUI for Geometry component
// File : GroupGUI_GroupDlg.cxx
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
-//
+
#include "GroupGUI_GroupDlg.h"
#include <DlgRef.h>
: GEOMBase_Skeleton(theGeometryGUI, parent, false),
myMode(mode),
myBusy(false),
- myIsShapeType(false)
+ myIsShapeType(false),
+ myIsHiddenMain(false)
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
aMedLayout->addWidget(myAddBtn, 6, 3);
aMedLayout->addWidget(myRemBtn, 7, 3);
- aMedLayout->setColumnStretch( 2, 5 );
+ aMedLayout->setColumnStretch(2, 5);
aMedLayout->setRowStretch(5, 5);
aMedLayout->setRowStretch(8, 5);
setHelpFileName("work_with_groups_page.html");
Init();
+ updateState();
}
GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
{
+ if (myIsHiddenMain) {
+ GEOM_Displayer* aDisplayer = getDisplayer();
+ aDisplayer->Display(myMainObj);
+ myIsHiddenMain = false;
+ }
}
//=================================================================================
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent()) {
- Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
- GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
+ GEOMBase::ConvertIOinGEOMObject(aSelList.First());
- if (aResult && !CORBA::is_nil(anObj) && anObj->GetType() == GEOM_GROUP) {
+ if (!CORBA::is_nil(anObj) && anObj->GetType() == GEOM_GROUP) {
myGroup = anObj;
mainFrame()->ResultName->setText(GEOMBase::GetName(myGroup));
//=================================================================================
void GroupGUI_GroupDlg::ClickOnOk()
{
+ setIsApplyAndClose(true);
if (ClickOnApply())
ClickOnCancel();
}
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)) {
+ GEOMBase::ConvertIOinGEOMObject(aSelList.First());
+ if (GEOMBase::IsShape(anObj)) {
if (!anObj->_is_equivalent(myMainObj) && !anObj->_is_equivalent(myGroup)) {
SUIT_OverrideCursor wc;
myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
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);
+ GEOM::GEOM_Object_var aSS = aShapesOp->GetSame(myMainObj, aSubObjects[i]);
+ if (!CORBA::is_nil(aSS)) {
+ CORBA::Long aMainIndex = aLocOp->GetSubShapeIndex(myMainObj, aSS);
+ CORBA::Long aPlaceIndex = aLocOp->GetSubShapeIndex(myInPlaceObj, aSubObjects[i]);
+ if (aMainIndex >= 0 && aPlaceIndex > 0)
+ myMain2InPlaceIndices.Bind(aMainIndex, aPlaceIndex);
+ }
}
}
myInPlaceObjSelectState = subSelectionWay();
int nbSel = aSelList.Extent();
if (nbSel == 1) {
- Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
- GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
+ GEOMBase::ConvertIOinGEOMObject(aSelList.First());
- if (aResult && !anObj->_is_nil() && GEOMBase::IsShape(anObj)) {
+ if (GEOMBase::IsShape(anObj)) {
+ if (myIsHiddenMain) {
+ GEOM_Displayer* aDisplayer = getDisplayer();
+ aDisplayer->Display(myMainObj);
+ myIsHiddenMain = false;
+ }
myMainObj = anObj;
myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
// activate subshapes selection by default
}
}
else {
+ if (myIsHiddenMain) {
+ GEOM_Displayer* aDisplayer = getDisplayer();
+ aDisplayer->Display(myMainObj);
+ myIsHiddenMain = false;
+ }
myMainObj = GEOM::GEOM_Object::_nil();
}
}
else { // an attempt to synchronize list box selection with 3d viewer
- if ( myBusy || myMainObj->_is_nil() ) {
+ if (myBusy || myMainObj->_is_nil()) {
return;
}
highlight = true;
}
}
- if ( highlight )
+ if (highlight)
highlightSubShapes();
}
myIdList->blockSignals(isBlocked);
GEOM_Displayer* aDisplayer = getDisplayer();
if (send == myHideSelBtn) {
- aDisplayer->Erase(aSelList, false, true);
+ aDisplayer->Erase(aSelList, /*forced=*/false, /*updateViewer=*/true);
}
else {
- aDisplayer->EraseAll();
+ // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
+ SALOME_View* view = GEOM_Displayer::GetActiveView();
+ if (view) {
+ CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
+ Handle(SALOME_InteractiveObject) io =
+ new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
+ if (view->isVisible(io)) myIsHiddenMain = true;
+ }
+
+ aDisplayer->EraseAll(/*forced = false, updateViewer = true*/);
aDisplayer->Display(aSelList, true);
+
+ // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
+ if (getShapeType() == TopAbs_VERTEX && myIsHiddenMain) {
+ aDisplayer->Display(myMainObj);
+ }
+
+ // for the case when selected ids were not displayed in the viewer: Mantis issue 0021367
+ highlightSubShapes();
}
}
theMapIndex.Clear();
SalomeApp_Application* app = myGeomGUI->getApp();
- if ( !app || myMainObj->_is_nil() )
+ if (!app || myMainObj->_is_nil())
return 0;
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
myIsShapeType) // check if shape type is already choosen by user
{
GEOM_Displayer* aDisplayer = getDisplayer();
+
+ // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
+ if (getShapeType() == TopAbs_VERTEX) {
+ if (myIsHiddenMain)
+ aDisplayer->Display(myMainObj);
+ }
+ else {
+ SALOME_View* view = GEOM_Displayer::GetActiveView();
+ if (view) {
+ CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
+ Handle(SALOME_InteractiveObject) io =
+ new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
+ if (view->isVisible(io)) {
+ aDisplayer->Erase(myMainObj, false, false);
+ myIsHiddenMain = true;
+ }
+ }
+ }
+
int prevDisplayMode = aDisplayer->SetDisplayMode(0);
SUIT_ViewWindow* aViewWindow = 0;
TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
TopoDS_Shape aRestrictionShape;
- if (subSelectionWay() == ALL_SUBSHAPES)
- aRestrictionShape = aMainShape;
- else if (!myInPlaceObj->_is_nil())
- aRestrictionShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myInPlaceObj);
- else ;
-
- TopTools_IndexedMapOfShape aSubShapesMap;
- TopExp::MapShapes(aMainShape, aSubShapesMap);
- CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
- QString anEntryBase = aMainEntry.in();
- TopExp_Explorer anExp (aRestrictionShape, getShapeType());
- for (; anExp.More(); anExp.Next())
- {
- TopoDS_Shape aSubShape = anExp.Current();
- int index = aSubShapesMap.FindIndex(aSubShape);
- QString anEntry = anEntryBase + QString("_%1").arg(index);
+ if (subSelectionWay() == ALL_SUBSHAPES) {
+ aRestrictionShape = aMainShape;
- SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
- if (aPrs) {
- displayPreview(aPrs, true, false); // append, do not update
+ TopTools_IndexedMapOfShape aSubShapesMap;
+ TopExp::MapShapes(aMainShape, aSubShapesMap);
+ CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
+ QString anEntryBase = aMainEntry.in();
+
+ TopExp_Explorer anExp (aRestrictionShape, getShapeType());
+ for (; anExp.More(); anExp.Next()) {
+ TopoDS_Shape aSubShape = anExp.Current();
+ int index = aSubShapesMap.FindIndex(aSubShape);
+ QString anEntry = anEntryBase + QString("_%1").arg(index);
+
+ SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
+ if (aPrs) {
+ displayPreview(aPrs, true, false); // append, do not update
+ // TODO: map or delete Prs
+ }
}
}
+ else if (!myInPlaceObj->_is_nil()) {
+ TopTools_IndexedMapOfShape aSubShapesMap;
+ TopExp::MapShapes(aMainShape, aSubShapesMap);
+ CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
+ QString anEntryBase = aMainEntry.in();
+
+ TColStd_DataMapIteratorOfDataMapOfIntegerInteger aM2IPit (myMain2InPlaceIndices);
+ for (; aM2IPit.More(); aM2IPit.Next()) {
+ int index = aM2IPit.Key();
+ TopoDS_Shape aSubShape = aSubShapesMap.FindKey(index);
+ QString anEntry = anEntryBase + QString("_%1").arg(index);
+
+ SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
+ if (aPrs) {
+ displayPreview(aPrs, true, false); // append, do not update
+ }
+ }
+ }
+ else ;
+
aDisplayer->UpdateViewer();
aDisplayer->SetDisplayMode(prevDisplayMode);
}
myRestrictGroupBox->setEnabled(!CORBA::is_nil(myMainObj));
mySelAllBtn->setEnabled(!CORBA::is_nil(myMainObj));
- mySelBtn2->setEnabled( subSelectionWay() != ALL_SUBSHAPES);
+ mySelBtn2->setEnabled(subSelectionWay() != ALL_SUBSHAPES);
myShape2Name->setEnabled(subSelectionWay() != ALL_SUBSHAPES);
if (subSelectionWay() == ALL_SUBSHAPES)
setInPlaceObj(GEOM::GEOM_Object::_nil());
int id = myIdList->item(ii)->text().toInt();
if (subSelectionWay() != ALL_SUBSHAPES &&
!myMain2InPlaceIndices.IsBound(id)) {
- myIdList->item(ii)->setSelected(false);
+ //myIdList->item(ii)->setSelected(false);
}
else {
anIds.Add(id);
SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
if (aView == 0) return;
- // TODO: use here GEOMBase_Helper::myPreview instead of ic->DisplayedObjects()
+ // TODO??: use here GEOMBase_Helper::myPreview instead of ic->DisplayedObjects()
OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)aViewManager)->getOCCViewer();
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
AIS_ListOfInteractive List;
- ic->DisplayedObjects(List);
+ //ic->DisplayedObjects(List);
+ ic->ObjectsInside(List); // Mantis issue 0021367
SALOME_ListIO aSelList;
- // To highlight the selected subshape in Object Browser, if it's already pudlished under the main shape
+ // To highlight the selected subshape in Object Browser, if it's already published under the main shape
GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations(getStudyId());
QMap<int, QString> childsMap;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
QString anEntry = aMainEntry.in();
_PTR(SObject) aSObj (aStudy->FindObjectID(anEntry.toLatin1().constData()));
- _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
- for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
+ _PTR(ChildIterator) anIt (aStudy->NewChildIterator(aSObj));
+ for (anIt->InitEx(true); anIt->More(); anIt->Next()) {
GEOM::GEOM_Object_var aChild = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(anIt->Value()));
- if ( !CORBA::is_nil( aChild ) ) {
+ if (!CORBA::is_nil(aChild)) {
int index = aLocOp->GetSubShapeIndex(myMainObj, aChild);
CORBA::String_var aChildEntry = aChild->GetStudyEntry();
QString anEntry = aChildEntry.in();
int index = anEntry.lastIndexOf("_");
anEntry.remove(0, index+1);
int anIndex = anEntry.toInt();
- if ( anIds.Contains(anIndex) ) {
+ if (anIds.Contains(anIndex)) {
aSelList.Append(anIO);
- if ( childsMap.contains ( anIndex )) {
- Handle(SALOME_InteractiveObject) tmpIO = new SALOME_InteractiveObject( childsMap.value(anIndex).toLatin1().constData(), "GEOM", "TEMP_IO" );
+ if (childsMap.contains (anIndex)) {
+ Handle(SALOME_InteractiveObject) tmpIO = new SALOME_InteractiveObject(childsMap.value(anIndex).toLatin1().constData(), "GEOM", "TEMP_IO");
aSelList.Append(tmpIO);
}
- }
+ }
}
}
}
//================================================================
// Function : getFather
// Purpose : Get father object for object to be added in study
-// ( called with addInStudy method )
+// (called with addInStudy method)
//================================================================
GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather(GEOM::GEOM_Object_ptr theObj)
{