ModuleBase_ParamSpinBox.h
ModuleBase_Preferences.h
ModuleBase_ResultPrs.h
- ModuleBase_ArrowPrs.h
ModuleBase_SelectionValidator.h
ModuleBase_ToolBox.h
ModuleBase_Tools.h
ModuleBase_ParamSpinBox.cpp
ModuleBase_Preferences.cpp
ModuleBase_ResultPrs.cpp
- ModuleBase_ArrowPrs.cpp
ModuleBase_ToolBox.cpp
ModuleBase_Tools.cpp
ModuleBase_ViewerFilters.cpp
#include <StdPrs_ShadedShape.hxx>
#include <StdSelect_BRepSelectionTool.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Builder.hxx>
#include <TopoDS_Edge.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <Standard_Version.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <TopExp.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
#if OCC_VERSION_HEX > 0x070400
#include <StdPrs_ToolTriangulatedShape.hxx>
// change deviation coefficient to provide more precise circle
try {
AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
- AddRemoveEdgesDir(GetContext()->CurrentViewer());
}
catch (...) {
return;
}
+ if (myResult.get() && ModelAPI_Tools::isShowEdgesDirection(myResult))
+ {
+ TopExp_Explorer Exp(myshape, TopAbs_EDGE);
+ for (; Exp.More(); Exp.Next()) {
+ TopoDS_Edge anEdgeE = TopoDS::Edge(Exp.Current());
+ if (anEdgeE.IsNull())
+ continue;
+
+ // draw curve direction (issue 0021087)
+ anEdgeE.Orientation(TopAbs_FORWARD);
+
+ TopoDS_Vertex aV1, aV2;
+ 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()) continue;
+
+ 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;
+
+ Prs3d_Arrow::Draw(thePresentation->CurrentGroup(), aP2, aDir, M_PI / 180.*5., aDist / 10.);
+ }
+ }
+ }
// visualize hidden sub-shapes transparent
if (myResult.get()) {
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<GeomShapePtr> 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<TopoDS_Edge>();
- 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();
-}
#include "ModuleBase.h"
-#include "ModuleBase_ArrowPrs.h"
-
#include <ModelAPI_Result.h>
#include <ModelAPI_ResultField.h>
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:
Handle(Prs3d_IsoAspect) myUIsoAspect;
Handle(Prs3d_IsoAspect) myVIsoAspect;
-
-
- EdgesDirectionMap myEdgesDirection;
};
aDesktop);
addAction("WIREFRAME_CMD", anAction);
- anAction = ModuleBase_Tools::createAction(QIcon(":pictures/iso_lines.png"), tr("Define Isos..."),
+ anAction = ModuleBase_Tools::createAction(QIcon(":pictures/edges_dir.png"), tr("Show edges direction"),
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(":pictures/iso_lines.png"), tr("Define Isos..."),
+ aDesktop);
+ addAction("ISOLINES_CMD", anAction);
+
anAction = ModuleBase_Tools::createAction(QIcon(), tr("Show Isos"), aDesktop);
anAction->setCheckable(true);
addAction("SHOW_ISOLINES_CMD", anAction);
}
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);
if (aPrsList.size() == 1) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(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));
+
+ action("SHOW_EDGES_DIRECTION_CMD")->setEnabled(true);
+ action("SHOW_EDGES_DIRECTION_CMD")->setChecked(
+ ModelAPI_Tools::isShowEdgesDirection(aResult));
}
}
}
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"));
// 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();
QList<ModuleBase_ViewerPrsPtr> aPresentations;
QList<ModuleBase_ViewerPrsPtr> 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);
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<Handle(AIS_InteractiveObject)>());
- aResPrs->UpdateEdgesDir();
+
if (!thePresentations.contains(aPrs)) // TODO: check whether the presentation in a list
thePresentations.append(aPrs);
}
setDisplayMode(anObjects, XGUI_Displayer::Shading);
else if (theId == "WIREFRAME_CMD")
setDisplayMode(anObjects, XGUI_Displayer::Wireframe);
+ else if (theId == "SHOW_EDGES_DIRECTION_CMD")
+ toggleEdgesDirection(anObjects);
else if (theId == "HIDEALL_CMD") {
QObjectPtrList aList = myDisplayer->displayedObjects();
foreach (ObjectPtr aObj, aList) {
} 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<ModelAPI_Result>(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<Model_Session> aSession =
myDisplayer->updateViewer();
}
+//**************************************************************
+void XGUI_Workshop::toggleEdgesDirection(const QObjectPtrList& theList)
+{
+ foreach(ObjectPtr anObj, theList) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
+ if (aResult.get() != NULL)
+ {
+ bool aToShow = !ModelAPI_Tools::isShowEdgesDirection(aResult);
+ ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
+ if (aBodyResult.get() != NULL) { // change property for all sub-solids
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allSubs(aBodyResult, allRes);
+ std::list<ResultPtr>::iterator aRes;
+ for (aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ ModelAPI_Tools::showEdgesDirection(*aRes, aToShow);
+ myDisplayer->redisplay(*aRes, false);
+ }
+ }
+ ModelAPI_Tools::showEdgesDirection(aResult, aToShow);
+ myDisplayer->redisplay(anObj, false);
+ }
+ }
+ if (theList.size() > 0)
+ myDisplayer->updateViewer();
+}
+
//**************************************************************
void XGUI_Workshop::closeDocument()
{
/// \param theMode a mode to set (see \ref XGUI_Displayer)
void setDisplayMode(const QObjectPtrList& theList, int theMode);
+ /// Toggle visualisation of edges direction
+ void toggleEdgesDirection(const QObjectPtrList& theList);
+
/// Set selection mode in viewer. If theMode=-1 then activate default mode
/// \param theMode the selection mode (according to TopAbs_ShapeEnum)
void setViewerSelectionMode(int theMode);
<file>pictures/CrossCursor.png</file>
<file>pictures/HandCursor.png</file>
<file>pictures/iso_lines.png</file>
+ <file>pictures/edges_dir.png</file>
</qresource>
</RCC>