X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Displayer.cpp;h=2652ae0ed1753caa9e7f863862942f59b2ba4247;hb=00a3c1675ca0ead43040cafa3a99f984e1d8177b;hp=26672b4726b4cf94ac9210dfb0d184d1c9f02d34;hpb=e2b09ef7ae7fae77e1a8dd4e5a7725da23081f1f;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 26672b472..2652ae0ed 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -1,15 +1,30 @@ -// 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 +// +#include "XGUI_CustomPrs.h" #include "XGUI_Displayer.h" -#include "XGUI_Workshop.h" -#include "XGUI_ViewerProxy.h" -#include "XGUI_SelectionMgr.h" +#include "XGUI_FacesPanel.h" #include "XGUI_Selection.h" -#include "XGUI_CustomPrs.h" +#include "XGUI_SelectionMgr.h" +#include "XGUI_ViewerProxy.h" +#include "XGUI_Workshop.h" #ifndef HAVE_SALOME #include @@ -22,11 +37,12 @@ #include #include +#include +#include +#include #include #include -#include #include -#include #include #include @@ -60,7 +76,7 @@ #include #ifdef TINSPECTOR -#include +#include #endif #include @@ -1057,13 +1073,13 @@ Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter() } 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(); 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 @@ -1351,7 +1367,6 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, return isActivationChanged; } -//#define DEBUG_FULLY_CONSTRAINED bool XGUI_Displayer::customizeObject(ObjectPtr theObject) { AISObjectPtr anAISObj = getAISObject(theObject); @@ -1374,10 +1389,13 @@ bool XGUI_Displayer::customizeObject(ObjectPtr theObject) } bool isCustomized = aCustomPrs.get() && aCustomPrs->customisePresentation(aResult, anAISObj, myCustomPrs); -#ifdef DEBUG_FULLY_CONSTRAINED isCustomized = myWorkshop->module()->afterCustomisePresentation(aResult, anAISObj, myCustomPrs) || isCustomized; -#endif + + // update presentation state if faces panel is active + if (anAISObj.get() && myWorkshop->facesPanel()) + isCustomized = myWorkshop->facesPanel()->customizeObject(theObject, anAISObj) || isCustomized; + return isCustomized; } @@ -1434,6 +1452,14 @@ void XGUI_Displayer::getPresentations(const ObjectPtr& theObject, ResultPtr aResult = std::dynamic_pointer_cast(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(aResult); + if (aCompSolid.get() && aCompSolid->numberOfSubs() > 0) { + aAISObj = getAISObject(aCompSolid->subResult(0)); + } + } if (aAISObj.get() != NULL) { Handle(AIS_InteractiveObject) anAIS = aAISObj->impl(); if (!anAIS.IsNull() && !thePresentations.Contains(anAIS)) @@ -1499,7 +1525,7 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const } else { deactivateTrihedron(false); - aContext->Erase(aTrihedron); + aContext->Erase(aTrihedron, Standard_True); #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Remove(aTrihedron); #endif @@ -1522,6 +1548,9 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th const NCollection_DataMap>& theShapesToBeSelected) { + NCollection_Map aCompsolidPresentations; + NCollection_Map aSelectedPresentations; + NCollection_List anActiveOwners; theContext->MainSelector()->ActiveOwners(anActiveOwners); NCollection_List::Iterator anOwnersIt (anActiveOwners); @@ -1545,26 +1574,46 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th if (aShape.IsNull()) continue; + Handle(ModuleBase_BRepOwner) aCustomOwner = Handle(ModuleBase_BRepOwner)::DownCast(anOwner); + NCollection_DataMap > ::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 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 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::Iterator anIt (aCompsolidPresentations); + for (; anIt.More(); anIt.Next()) { + if (aSelectedPresentations.Contains(anIt.Value())) + continue; + theContext->AddOrRemoveSelected(anIt.Value(), Standard_False); + } }