-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File: XGUI_Displayer.cpp
-// Created: 20 Apr 2014
-// Author: Natalia ERMOLAEVA
+// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+//
+// 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, or (at your option) any later version.
+//
+// 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<mailto:webmaster.salome@opencascade.com>
+//
#include "XGUI_Displayer.h"
#include "XGUI_Workshop.h"
}
bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSelectionModes,
- bool theUpdateViewer)
+ const Standard_Integer theDisplayMode, bool theUpdateViewer)
{
bool aDisplayed = false;
Handle(AIS_InteractiveContext) aContext = AISContext();
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!aContext.IsNull() && !anAISIO.IsNull()) {
- aContext->Display(anAISIO, 0/*wireframe*/, 0, false/*update viewer*/, true, AIS_DS_Displayed);
+ aContext->Display(anAISIO, theDisplayMode, 0, false/*update viewer*/, true, AIS_DS_Displayed);
#ifdef TINSPECTOR
if (getCallBack()) getCallBack()->Display(anAISIO);
#endif
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult.get()) {
AISObjectPtr aAISObj = getAISObject(aResult);
+ if (aAISObj.get() == NULL) {
+ // if result is a result of a composite feature, it is visualized by visualization of
+ // composite children, so we should get one of this presentations
+ ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
+ if (aCompSolid.get() && aCompSolid->numberOfSubs() > 0) {
+ aAISObj = getAISObject(aCompSolid->subResult(0));
+ }
+ }
if (aAISObj.get() != NULL) {
Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull() && !thePresentations.Contains(anAIS))
} else {
deactivateTrihedron(false);
- aContext->Erase(aTrihedron);
+ aContext->Erase(aTrihedron, Standard_True);
#ifdef TINSPECTOR
if (getCallBack()) getCallBack()->Remove(aTrihedron);
#endif
const NCollection_DataMap<TopoDS_Shape,
NCollection_Map<Handle(AIS_InteractiveObject)>>& theShapesToBeSelected)
{
+ NCollection_Map<Handle(AIS_InteractiveObject)> aCompsolidPresentations;
+ NCollection_Map<Handle(AIS_InteractiveObject)> aSelectedPresentations;
+
NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
theContext->MainSelector()->ActiveOwners(anActiveOwners);
NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
if (aShape.IsNull())
continue;
+ Handle(ModuleBase_BRepOwner) aCustomOwner = Handle(ModuleBase_BRepOwner)::DownCast(anOwner);
+
NCollection_DataMap<TopoDS_Shape, NCollection_Map<Handle(AIS_InteractiveObject)> >
::Iterator aShapeIt(theShapesToBeSelected);
for (; aShapeIt.More(); aShapeIt.Next()) {
- if (aShapeIt.Key().IsSame(aShape)) {
- const TopoDS_Shape& aParameterShape = aShapeIt.Key();
- // isSame should be used here as it does not check orientation of shapes
- // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is
- // different for Edges shapes in model shape and owner even if this is the same shape
- if (aParameterShape.IsSame(aShape)) {
- Handle(AIS_InteractiveObject) anOwnerPresentation =
- Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
- NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations =
- theShapesToBeSelected.Find(aParameterShape);
- if (aPresentations.Contains(anOwnerPresentation)) {
- theContext->AddOrRemoveSelected(anOwner);
- anOwner->SetSelected (Standard_True);
- }
+ const TopoDS_Shape& aParameterShape = aShapeIt.Key();
+ // isSame should be used here as it does not check orientation of shapes
+ // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is
+ // different for Edges shapes in model shape and owner even if this is the same shape
+ if (aParameterShape.IsSame(aShape)) {
+ Handle(AIS_InteractiveObject) anOwnerPresentation =
+ Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+ NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations =
+ theShapesToBeSelected.Find(aParameterShape);
+ if (aPresentations.Contains(anOwnerPresentation)) {
+ theContext->AddOrRemoveSelected(anOwner, Standard_False);
+ anOwner->SetSelected (Standard_True);
+ // collect selected presentations to do not select them if compsolid is selected
+ if (!aSelectedPresentations.Contains(anOwnerPresentation))
+ aSelectedPresentations.Add(anOwnerPresentation);
}
}
+ else if (!aCustomOwner.IsNull()) { // CompSolid processing #2219
+ // shape of owner is compound, but shape to be selected is compsolid, so
+ // we need to compare shape to AIS presentation of owner(rule of the owner creation)
+ Handle(AIS_Shape) anOwnerPresentation =
+ Handle(AIS_Shape)::DownCast(anOwner->Selectable());
+ const TopoDS_Shape& aPresentationShape = anOwnerPresentation->Shape();
+ if (aParameterShape.IsSame(anOwnerPresentation->Shape()) &&
+ !aCompsolidPresentations.Contains(anOwnerPresentation))
+ aCompsolidPresentations.Add(anOwnerPresentation);
+ }
}
}
}
+ // select CompSolid presentations if their owners was not selected yet
+ NCollection_Map<Handle(AIS_InteractiveObject)>::Iterator anIt (aCompsolidPresentations);
+ for (; anIt.More(); anIt.Next()) {
+ if (aSelectedPresentations.Contains(anIt.Value()))
+ continue;
+ theContext->AddOrRemoveSelected(anIt.Value(), Standard_False);
+ }
}