From 0544d26769c6fdddb255469d1a8188fbc3d2d3ef Mon Sep 17 00:00:00 2001 From: Alexey Kondratyev Date: Wed, 27 Apr 2022 11:51:19 +0300 Subject: [PATCH] [bos #29479] Show edges directions Add algorithm to show direction of edges. --- doc/gui/General/Introduction.rst | 7 ++ src/Model/Model_Data.cpp | 3 +- src/ModelAPI/ModelAPI_Result.cpp | 2 + src/ModelAPI/ModelAPI_Result.h | 8 ++ src/ModelAPI/ModelAPI_Tools.cpp | 25 ++++++ src/ModelAPI/ModelAPI_Tools.h | 8 ++ src/ModuleBase/CMakeLists.txt | 2 + src/ModuleBase/ModuleBase_ArrowPrs.cpp | 113 ++++++++++++++++++++++++ src/ModuleBase/ModuleBase_ArrowPrs.h | 72 +++++++++++++++ src/ModuleBase/ModuleBase_ResultPrs.cpp | 48 ++++++++++ src/ModuleBase/ModuleBase_ResultPrs.h | 9 ++ src/XGUI/XGUI_ContextMenuMgr.cpp | 13 +++ src/XGUI/XGUI_Displayer.cpp | 4 +- src/XGUI/XGUI_Selection.cpp | 16 +++- src/XGUI/XGUI_Workshop.cpp | 9 ++ src/XGUI/XGUI_msg_fr.ts | 4 + 16 files changed, 340 insertions(+), 3 deletions(-) create mode 100644 src/ModuleBase/ModuleBase_ArrowPrs.cpp create mode 100644 src/ModuleBase/ModuleBase_ArrowPrs.h diff --git a/doc/gui/General/Introduction.rst b/doc/gui/General/Introduction.rst index b691bdf2a..8da63702f 100644 --- a/doc/gui/General/Introduction.rst +++ b/doc/gui/General/Introduction.rst @@ -394,6 +394,13 @@ This point of view can be modified using viewer commands: **Panning**, **Zooming Two view windows +The viewer is able to show direction of edges of objects. + +.. figure:: /images/edges_directions.png + :align: center + + Showing the edges direction + The description of OCC 3D Viewer architecture and functionality is provided in GUI module user's guide in chapter **OCC 3D Viewer**. .. _parameter_usage: diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 058b326e6..00e6defd2 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -465,7 +465,8 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) // trim: need to redisplay or set color in the python script if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color" || theAttr->id() == "Transparency" || theAttr->id() == "Deflection" || - theAttr->id() == "Iso_lines" || theAttr->id() == "Show_Iso_lines")) { + theAttr->id() == "Iso_lines" || theAttr->id() == "Show_Iso_lines" || + theAttr->id() == "Show_Edges_direction")) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); } diff --git a/src/ModelAPI/ModelAPI_Result.cpp b/src/ModelAPI/ModelAPI_Result.cpp index ec27cbf82..a225fe950 100644 --- a/src/ModelAPI/ModelAPI_Result.cpp +++ b/src/ModelAPI/ModelAPI_Result.cpp @@ -41,6 +41,8 @@ void ModelAPI_Result::initAttributes() aData->addAttribute(ISO_LINES_ID(), ModelAPI_AttributeIntArray::typeId())->setIsArgument(false); aData->addAttribute(SHOW_ISO_LINES_ID(), ModelAPI_AttributeBoolean::typeId())-> setIsArgument(false); + aData->addAttribute(SHOW_EDGES_DIRECTION_ID(), ModelAPI_AttributeBoolean::typeId())-> + setIsArgument(false); } bool ModelAPI_Result::setDisabled(std::shared_ptr theThis, const bool theFlag) diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h index df12ecaf6..778529c22 100644 --- a/src/ModelAPI/ModelAPI_Result.h +++ b/src/ModelAPI/ModelAPI_Result.h @@ -79,6 +79,14 @@ class ModelAPI_Result : public ModelAPI_Object return MY_SHOW_ISO_LINES_ID; } + /// Reference to the transparency of the result. + /// The double value is used. The value is in [0, 1] range + inline static const std::string& SHOW_EDGES_DIRECTION_ID() + { + static const std::string MY_SHOW_EDGES_DIRECTION_ID("Show_Edges_direction"); + return MY_SHOW_EDGES_DIRECTION_ID; + } + /// Returns true if the result is concealed from the data tree (referenced by other objects) MODELAPI_EXPORT virtual bool isConcealed(); diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index dda65e007..5c927a6a9 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -1169,6 +1169,31 @@ bool isShownIsoLines(std::shared_ptr theResult) return false; } +//****************************************************** +void showEdgesDirection(std::shared_ptr theResult, bool theShow) +{ + if (!theResult.get()) + return; + + AttributeBooleanPtr aAttr = theResult->data()->boolean(ModelAPI_Result::SHOW_EDGES_DIRECTION_ID()); + if (aAttr.get() != NULL) { + aAttr->setValue(theShow); + } +} + +//****************************************************** +bool isShowEdgesDirection(std::shared_ptr theResult) +{ + if (!theResult.get()) + return false; + + AttributeBooleanPtr aAttr = theResult->data()->boolean(ModelAPI_Result::SHOW_EDGES_DIRECTION_ID()); + if (aAttr.get() != NULL) { + return aAttr->value(); + } + return false; +} + //************************************************************** void setTransparency(ResultPtr theResult, double theTransparency) { diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index 6f61423e8..1e5ea7380 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -304,6 +304,14 @@ MODELAPI_EXPORT void showIsoLines(std::shared_ptr theResult, bo MODELAPI_EXPORT bool isShownIsoLines(std::shared_ptr theResult); +/*! Set visibility of edges direction +* \param[in] theResult a result object +* \param[in] theShow is a visibility flag +*/ +MODELAPI_EXPORT void showEdgesDirection(std::shared_ptr theResult, bool theShow); + +MODELAPI_EXPORT bool isShowEdgesDirection(std::shared_ptr theResult); + /*! Returns current transparency in the given result * \param theResult a result object * \return a transparency value or -1 if it was not defined diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index e4161f97b..84bf06cd3 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -65,6 +65,7 @@ SET(PROJECT_HEADERS ModuleBase_ParamSpinBox.h ModuleBase_Preferences.h ModuleBase_ResultPrs.h + ModuleBase_ArrowPrs.h ModuleBase_SelectionValidator.h ModuleBase_ToolBox.h ModuleBase_Tools.h @@ -190,6 +191,7 @@ SET(PROJECT_SOURCES ModuleBase_ParamSpinBox.cpp ModuleBase_Preferences.cpp ModuleBase_ResultPrs.cpp + ModuleBase_ArrowPrs.cpp ModuleBase_ToolBox.cpp ModuleBase_Tools.cpp ModuleBase_ViewerFilters.cpp diff --git a/src/ModuleBase/ModuleBase_ArrowPrs.cpp b/src/ModuleBase/ModuleBase_ArrowPrs.cpp new file mode 100644 index 000000000..da02554e6 --- /dev/null +++ b/src/ModuleBase/ModuleBase_ArrowPrs.cpp @@ -0,0 +1,113 @@ +// Copyright (C) 2014-2022 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 "ModuleBase_ArrowPrs.h" + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ArrowPrs, AIS_InteractiveContext) + + +ModuleBase_ArrowPrs::ModuleBase_ArrowPrs(const Handle(V3d_Viewer)& theViewer, + const GeomEdgePtr& theEdge) + : AIS_InteractiveContext(theViewer), + myEdge(theEdge) +{ +} + +//******************************************************************** +void ModuleBase_ArrowPrs::DrawArrow(const Handle(Prs3d_Presentation)& thePrs, + Quantity_Color theColor) +{ + Handle(Prs3d_Drawer) aDrawer = myDefaultDrawer; + Handle(Prs3d_ArrowAspect) anArrowAspect = aDrawer->ArrowAspect(); + + Handle(Graphic3d_AspectLine3d) PtA = anArrowAspect->Aspect(); + PtA->SetColor(theColor); + + Handle(Graphic3d_Group) TheGroup = thePrs->CurrentGroup(); + TheGroup->SetPrimitivesAspect(PtA); + + TopoDS_Vertex aV1, aV2; + TopoDS_Edge anEdgeE = myEdge->impl(); + anEdgeE.Orientation(TopAbs_FORWARD); + if (anEdgeE.IsNull()) return; + + TopExp::Vertices(anEdgeE, aV1, aV2); + gp_Pnt aP1 = BRep_Tool::Pnt(aV1); + gp_Pnt aP2 = BRep_Tool::Pnt(aV2); + + double fp, lp; + gp_Vec aDirVec; + Handle(Geom_Curve) C = BRep_Tool::Curve(anEdgeE, fp, lp); + + if (C.IsNull()) return; + + if (anEdgeE.Orientation() == TopAbs_FORWARD) + C->D1(lp, aP2, aDirVec); + else { + C->D1(fp, aP1, aDirVec); + aP2 = aP1; + } + + GeomAdaptor_Curve aAdC; + aAdC.Load(C, fp, lp); + Standard_Real aDist = GCPnts_AbscissaPoint::Length(aAdC, fp, lp); + + if (aDist > gp::Resolution()) { + gp_Dir aDir; + if (anEdgeE.Orientation() == TopAbs_FORWARD) + aDir = aDirVec; + else + aDir = -aDirVec; + + TopoDS_Vertex aVertex; + BRep_Builder aB; + aB.MakeVertex(aVertex, aP2, Precision::Confusion()); + Prs3d_Arrow::Draw(TheGroup, aP2, aDir, M_PI / 180. * 5., aDist / 10.); + } +} + +//******************************************************************** +bool ModuleBase_ArrowPrs::Comparator::operator()(const std::shared_ptr& theEdge1, + const std::shared_ptr& theEdge2) const +{ + const TopoDS_Edge& aShape1 = theEdge1->impl(); + const TopoDS_Edge& aShape2 = theEdge2->impl(); + bool isLess = aShape1.TShape() < aShape2.TShape(); + if (aShape1.TShape() == aShape2.TShape()) { + Standard_Integer aHash1 = aShape1.Location().HashCode(IntegerLast()); + Standard_Integer aHash2 = aShape2.Location().HashCode(IntegerLast()); + isLess = aHash1 < aHash2; + } + return isLess; +} diff --git a/src/ModuleBase/ModuleBase_ArrowPrs.h b/src/ModuleBase/ModuleBase_ArrowPrs.h new file mode 100644 index 000000000..238bca1d0 --- /dev/null +++ b/src/ModuleBase/ModuleBase_ArrowPrs.h @@ -0,0 +1,72 @@ +// Copyright (C) 2014-2022 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 +// + +#ifndef ModuleBase_ArrowPrs_H +#define ModuleBase_ArrowPrs_H + +#include +#include +#include + +#include + +DEFINE_STANDARD_HANDLE(ModuleBase_ArrowPrs, AIS_InteractiveContext) + +/** +* \ingroup GUI +* A presentation class for displaying a direction of edge +*/ + +class ModuleBase_ArrowPrs : public AIS_InteractiveContext +{ +public: + /// Constructor + /// \param theViewer a viewer which theEdge is displaying. + /// \param theEdge an edge whose direction to display. + Standard_EXPORT ModuleBase_ArrowPrs(const Handle(V3d_Viewer)& theViewer, + const GeomEdgePtr& theEdge); + + /// Returns an edge shape + GeomEdgePtr Edge() const { return myEdge; } + + /// Draw arrow that represent direction of the edge. + Standard_EXPORT void DrawArrow(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor); + + /// \brief Compare addresses of edges + class Comparator + { + public: + /// Return \c true if the address of the first edge is less than the address of the second + MODULEBASE_EXPORT + bool operator ()(const std::shared_ptr& theEdge1, + const std::shared_ptr& theEdge2) const; + }; + + DEFINE_STANDARD_RTTIEXT(ModuleBase_ArrowPrs, AIS_InteractiveContext) + +private: + + /// The edge whose direction to display. + GeomEdgePtr myEdge; +}; + +typedef std::pair EdgeDirection; +typedef std::map EdgesDirectionMap; + +#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index c9cf04473..81f55c806 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -296,6 +297,7 @@ void ModuleBase_ResultPrs::Compute( // change deviation coefficient to provide more precise circle try { AIS_Shape::Compute(thePresentationManager, thePresentation, theMode); + AddRemoveEdgesDir(GetContext()->CurrentViewer()); } catch (...) { return; @@ -538,3 +540,49 @@ void ModuleBase_ResultPrs::updateIsoLines() myUIsoAspect->SetNumber(aIsoValues[0]); myVIsoAspect->SetNumber(aIsoValues[1]); } + +bool ModuleBase_ResultPrs::AddRemoveEdgesDir(const Handle(V3d_Viewer)& theViewer) +{ + bool isShow = ModelAPI_Tools::isShowEdgesDirection(myResult); + if (isShow) { + std::list aSubEdges = myResult->shape()->subShapes(GeomAPI_Shape::EDGE); + + for (auto anEdgeIter = aSubEdges.begin(); anEdgeIter != aSubEdges.end(); ++anEdgeIter) { + GeomEdgePtr anEdgePtr = (*anEdgeIter)->edge(); + if (myEdgesDirection.find(anEdgePtr) != myEdgesDirection.end()) { + myEdgesDirection.at(anEdgePtr)->DrawArrow(Presentation(), Quantity_NOC_BLACK); + } + else { + Handle(ModuleBase_ArrowPrs) anArrowPrs = new ModuleBase_ArrowPrs(theViewer, anEdgePtr); + myEdgesDirection.insert(EdgeDirection(anEdgePtr, anArrowPrs)); + anArrowPrs->DrawArrow(Presentation(), Quantity_NOC_BLACK); + } + } + } + else + myEdgesDirection.clear(); + + GetContext()->UpdateCurrentViewer(); + return isShow; +} + +Standard_EXPORT void ModuleBase_ResultPrs::UpdateEdgesDir() +{ + TopoDS_Shape aSelectedShape = GetContext()->SelectedShape(); + for (auto anEdgeDir = myEdgesDirection.begin(); anEdgeDir != myEdgesDirection.end(); ++anEdgeDir) { + TopoDS_Edge anEdge = anEdgeDir->first->impl(); + bool isSelect = false; + TopExp_Explorer Exp(aSelectedShape, TopAbs_EDGE); + for (; Exp.More(); Exp.Next()) { + if (TopoDS::Edge(Exp.Current()).IsSame(anEdge)) { + isSelect = true; + break; + } + } + if(isSelect) + anEdgeDir->second->DrawArrow(Presentation(), Quantity_NOC_WHITE); + else + anEdgeDir->second->DrawArrow(Presentation(), Quantity_NOC_BLACK); + } + GetContext()->UpdateCurrentViewer(); +} diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h index 5607c2bb0..5eddec23c 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.h +++ b/src/ModuleBase/ModuleBase_ResultPrs.h @@ -22,6 +22,8 @@ #include "ModuleBase.h" +#include "ModuleBase_ArrowPrs.h" + #include #include @@ -121,6 +123,10 @@ public: Standard_EXPORT void updateIsoLines(); + Standard_EXPORT bool AddRemoveEdgesDir(const Handle(V3d_Viewer)& theViewer); + + Standard_EXPORT void UpdateEdgesDir(); + DEFINE_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape) protected: @@ -178,6 +184,9 @@ private: Handle(Prs3d_IsoAspect) myUIsoAspect; Handle(Prs3d_IsoAspect) myVIsoAspect; + + + EdgesDirectionMap myEdgesDirection; }; diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 64c590e66..97e58c22f 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -161,6 +161,10 @@ void XGUI_ContextMenuMgr::createActions() aDesktop); addAction("ISOLINES_CMD", anAction); + anAction = ModuleBase_Tools::createAction(QIcon(), tr("Show edges direction"), aDesktop); + anAction->setCheckable(true); + addAction("SHOW_EDGES_DIRECTION_CMD", anAction); + anAction = ModuleBase_Tools::createAction(QIcon(), tr("Show Isos"), aDesktop); anAction->setCheckable(true); addAction("SHOW_ISOLINES_CMD", anAction); @@ -340,6 +344,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("WIREFRAME_CMD")->setEnabled(true); action("SHADING_CMD")->setEnabled(true); } + action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true); + action("SHOW_EDGES_DIRECTION_CMD")->setChecked(ModelAPI_Tools::isShowEdgesDirection(aResult)); action("SHOW_ISOLINES_CMD")->setEnabled(true); action("SHOW_ISOLINES_CMD")->setChecked(ModelAPI_Tools::isShownIsoLines(aResult)); action("ISOLINES_CMD")->setEnabled(true); @@ -396,6 +402,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("SHOW_ONLY_CMD")->setEnabled(true); action("SHADING_CMD")->setEnabled(true); action("WIREFRAME_CMD")->setEnabled(true); + action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true); action("SHOW_ISOLINES_CMD")->setEnabled(true); action("ISOLINES_CMD")->setEnabled(true); } @@ -588,6 +595,9 @@ void XGUI_ContextMenuMgr::updateViewerMenu() if (aPrsList.size() == 1) { ResultPtr aResult = std::dynamic_pointer_cast(aObject); if (aResult.get()) { + action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true); + action("SHOW_EDGES_DIRECTION_CMD")->setChecked( + ModelAPI_Tools::isShowEdgesDirection(aResult)); action("SHOW_ISOLINES_CMD")->setEnabled(true); action("SHOW_ISOLINES_CMD")->setChecked(ModelAPI_Tools::isShownIsoLines(aResult)); } @@ -696,6 +706,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.clear(); aList.append(action("WIREFRAME_CMD")); aList.append(action("SHADING_CMD")); + aList.append(action("SHOW_EDGES_DIRECTION_CMD")); aList.append(mySeparator1); // this separator is not shown as this action is added after show only // qt list container contains only one instance of the same action aList.append(action("SHOW_CMD")); @@ -801,6 +812,7 @@ void XGUI_ContextMenuMgr::buildViewerMenu() aList.clear(); aList.append(action("WIREFRAME_CMD")); aList.append(action("SHADING_CMD")); + aList.append(action("SHOW_EDGES_DIRECTION_CMD")); aList.append(mySeparator2); aList.append(action("COLOR_CMD")); aList.append(action("DEFLECTION_CMD")); @@ -845,6 +857,7 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const } else if (aSelected > 1) { anActions.append(action("WIREFRAME_CMD")); anActions.append(action("SHADING_CMD")); + anActions.append(action("SHOW_EDGES_DIRECTION_CMD")); anActions.append(mySeparator1); anActions.append(action("SHOW_CMD")); anActions.append(action("HIDE_CMD")); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b9be6db91..87bc8aae2 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -327,8 +327,10 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) // Set Iso-Lines Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(aAISIO); - if (!aResPrs.IsNull()) + if (!aResPrs.IsNull()) { aResPrs->updateIsoLines(); + aResPrs->AddRemoveEdgesDir(AISContext()->CurrentViewer()); + } } //myWorkshop->module()->storeSelection(); diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 5eb5498fa..af8a65e48 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -72,6 +72,17 @@ QList XGUI_Selection::getSelected(const SelectionPlace& QList aPresentations; QList aToRemove; + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + if (!aContext.IsNull()) { + AIS_ListOfInteractive aListOfObjects; + aContext->DisplayedObjects(aListOfObjects); + for (auto anObject = aListOfObjects.begin(); anObject != aListOfObjects.end(); ++anObject) { + Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(*anObject); + if(aResPrs.get()) + aResPrs->UpdateEdgesDir(); + } + } + switch (thePlace) { case Browser: getSelectedInBrowser(aPresentations); @@ -173,7 +184,10 @@ void XGUI_Selection::getSelectedInViewer(QList& thePres aSelectedIds.append((size_t)anOwner.get()); fillPresentation(aPrs, anOwner); - + AISObjectPtr anAISObject = myWorkshop->displayer()->getAISObject(aPrs->object()); + Handle(ModuleBase_ResultPrs) aResPrs = Handle(ModuleBase_ResultPrs)::DownCast(anAISObject-> + impl()); + aResPrs->UpdateEdgesDir(); if (!thePresentations.contains(aPrs)) // TODO: check whether the presentation in a list thePresentations.append(aPrs); } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 624f64422..694283601 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1866,6 +1866,15 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) } else if (theId == "SET_VIEW_INVERTEDNORMAL_CMD") { setNormalView(true); } + else if (theId == "SHOW_EDGES_DIRECTION_CMD") { + foreach(ObjectPtr aObj, anObjects) { + ResultPtr aResult = std::dynamic_pointer_cast(aObj); + if (aResult.get()) + ModelAPI_Tools::showEdgesDirection(aResult, !ModelAPI_Tools::isShowEdgesDirection(aResult)); + } + mySelector->clearSelection(); + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + } #ifdef TINSPECTOR else if (theId == "TINSPECTOR_VIEW") { std::shared_ptr aSession = diff --git a/src/XGUI/XGUI_msg_fr.ts b/src/XGUI/XGUI_msg_fr.ts index 2e320d15e..1d7ec9610 100644 --- a/src/XGUI/XGUI_msg_fr.ts +++ b/src/XGUI/XGUI_msg_fr.ts @@ -216,6 +216,10 @@ Recover Récupérer + + Show edges direction + Afficher la direction des bords + XGUI_DataTree -- 2.39.2