From: nds Date: Fri, 25 Mar 2016 16:20:11 +0000 (+0300) Subject: #1371 Using auxilliary Sketch elements in any Feature X-Git-Tag: V_2.3.0~322 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=28bbf47d23aa7fc8217e1cbf9ab089acef27cec3;p=modules%2Fshaper.git #1371 Using auxilliary Sketch elements in any Feature --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 4d89489a4..bf95e40c5 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -66,6 +66,11 @@ void ModuleBase_IModule::sendOperation(ModuleBase_Operation* theOperation) Events_Loop::loop()->send(aMessage); } +Handle(AIS_InteractiveObject) ModuleBase_IModule::createPresentation(const ResultPtr& theResult) +{ + return Handle(AIS_InteractiveObject)(); +} + QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature) { return ModelAPI_Tools::getFeatureError(theFeature).c_str(); diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 45d070997..8a25b2afb 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -228,6 +228,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \param theOperation the operation virtual void sendOperation(ModuleBase_Operation* theOperation); + /// Create specific for the module presentation + /// \param theResult an object for presentation + /// \return created presentation or NULL(default value) + virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult); + //! Returns data object by AIS virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0; diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index 4491b273a..0a278d93a 100755 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -28,13 +28,6 @@ #include #include -//#define DEBUG_WIRE - -#ifdef DEBUG_WIRE -#include -#include -#endif - IMPLEMENT_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner); IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner); @@ -48,18 +41,9 @@ IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape); ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult) - : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false) + : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult) { std::shared_ptr aShapePtr = ModelAPI_Tools::shape(theResult); - std::shared_ptr aWirePtr = - std::dynamic_pointer_cast(aShapePtr); - if (aWirePtr) { - if (aWirePtr->hasPlane() ) { - // If this is a wire with plane defined thin it is a sketch-like object - // It must have invisible faces - myIsSketchMode = true; - } - } TopoDS_Shape aShape = aShapePtr->impl(); Set(aShape); Handle(Prs3d_Drawer) aDrawer = Attributes(); @@ -96,17 +80,6 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t return; } - if (myIsSketchMode) { - myFacesList.clear(); - ResultConstructionPtr aConstruction = - std::dynamic_pointer_cast(myResult); - if (aConstruction.get()) { - int aFacesNum = aConstruction->facesNum(); - for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) { - myFacesList.push_back(aConstruction->face(aFaceIndex)); - } - } - } myOriginalShape = aShapePtr->impl(); if (!myOriginalShape.IsNull()) { Set(myOriginalShape); @@ -119,22 +92,6 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t Events_Error::throwException("An empty AIS presentation: ModuleBase_ResultPrs"); } -#ifdef DEBUG_WIRE -void debugInfo(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) -{ - TopTools_IndexedMapOfShape aSubShapes; - TopExp::MapShapes (theShape, theType, aSubShapes); - - Standard_Boolean isComesFromDecomposition = !((aSubShapes.Extent() == 1) && (theShape == aSubShapes (1))); - int anExtent = aSubShapes.Extent(); - for (Standard_Integer aShIndex = 1; aShIndex <= aSubShapes.Extent(); ++aShIndex) - { - const TopoDS_Shape& aSubShape = aSubShapes (aShIndex); - int aValue = 0; - } -} -#endif - void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) { @@ -142,37 +99,6 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a // In order to avoid using custom selection modes return; - if (myIsSketchMode) { - if (aMode == AIS_Shape::SelectionMode(TopAbs_FACE)) { -#ifdef DEBUG_WIRE - const TopoDS_Shape& aShape = Shape(); - debugInfo(aShape, TopAbs_VERTEX); // 24 - debugInfo(aShape, TopAbs_EDGE); // 12 - debugInfo(aShape, TopAbs_WIRE); // 0 - debugInfo(aShape, TopAbs_FACE); // 0 -#endif - BRep_Builder aBuilder; - TopoDS_Compound aComp; - aBuilder.MakeCompound(aComp); - aBuilder.Add(aComp, myOriginalShape); - std::list>::const_iterator aIt; - for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) { - TopoDS_Shape aFace = (*aIt)->impl(); - aBuilder.Add(aComp, aFace); - // for sketch presentation in the face mode wires should be selectable also - // accoring to #1343 Improvement of Extrusion and Revolution operations - appendWiresSelection(aSelection, aFace); - } -#ifdef DEBUG_WIRE - debugInfo(aComp, TopAbs_VERTEX); // 24 - debugInfo(aComp, TopAbs_EDGE); // 12 - debugInfo(aComp, TopAbs_WIRE); // 4 - debugInfo(aComp, TopAbs_FACE); // 2 -#endif - Set(aComp); - } else - Set(myOriginalShape); - } if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) { // Limit selection area only by actual object (Shape) ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult); @@ -200,24 +126,6 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a AIS_Shape::ComputeSelection(aSelection, aMode); } - -bool ModuleBase_ResultPrs::hasCompSolidSelectionMode() const -{ - if (!HasInteractiveContext()) - return false; - - Handle(AIS_InteractiveContext) aContext = GetContext(); - TColStd_ListOfInteger aModes; - aContext->ActivatedModes(this, aModes); - - TColStd_ListIteratorOfListOfInteger aIt(aModes); - for (; aIt.More(); aIt.Next()) { - if (aIt.Value() == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) - return true; - } - return false; -} - void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection, const TopoDS_Shape& theShape) { @@ -237,21 +145,6 @@ void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection } } -TopoDS_Shape ModuleBase_ResultPrs::getSelectionShape() const -{ - if (hasCompSolidSelectionMode()) { - // In case of CompSolid mode use shape from Parent for highlighting - ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult); - if (aCompSolid.get()) { - std::shared_ptr aShapePtr = ModelAPI_Tools::shape(aCompSolid); - if (aShapePtr.get()) - return aShapePtr->impl(); - } - } - return myOriginalShape; -} - - void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, const SelectMgr_SequenceOfOwner& theOwners) { diff --git a/src/ModuleBase/ModuleBase_ResultPrs.h b/src/ModuleBase/ModuleBase_ResultPrs.h index e6f2e3e7e..729d131aa 100644 --- a/src/ModuleBase/ModuleBase_ResultPrs.h +++ b/src/ModuleBase/ModuleBase_ResultPrs.h @@ -73,13 +73,7 @@ public: Standard_EXPORT ResultPtr getResult() const { return myResult; } /// Returns True if the presentation is in sketch mode - Standard_EXPORT bool isSketchMode() const { return myIsSketchMode; } - - /// Returns a list of faces - Standard_EXPORT const std::list >& facesList() { return myFacesList; } - - /// Returns true if the object is used in CompSolid selection mode - Standard_EXPORT bool hasCompSolidSelectionMode() const; + Standard_EXPORT bool isSketchMode() const { return false; } DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs) protected: @@ -97,21 +91,12 @@ private: /// \param theShape a shape void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection, const TopoDS_Shape& theShape); - /// Returns shape dependent on CompSolid selection mode - /// In case CompSolid selection mode it returns parent's compsolid shape - TopoDS_Shape getSelectionShape() const; /// Reference to result object ResultPtr myResult; - /// A sketch mode flag - bool myIsSketchMode; - /// Original shape of the result object TopoDS_Shape myOriginalShape; - - /// List of faces - std::list > myFacesList; }; diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 86da38c63..bb032d0d7 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -26,6 +26,7 @@ SET(PROJECT_HEADERS PartSet_WidgetFileSelector.h PartSet_Filters.h PartSet_FilterInfinite.h + PartSet_ResultSketchPrs.h PartSet_SketcherMgr.h PartSet_SketcherReetntrantMgr.h PartSet_MenuMgr.h @@ -54,6 +55,7 @@ SET(PROJECT_SOURCES PartSet_WidgetFileSelector.cpp PartSet_Filters.cpp PartSet_FilterInfinite.cpp + PartSet_ResultSketchPrs.cpp PartSet_SketcherMgr.cpp PartSet_SketcherReetntrantMgr.cpp PartSet_MenuMgr.cpp diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 701a5015f..6cb317832 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1015,6 +1015,11 @@ void PartSet_Module::onActiveDocPopup(const QPoint& thePnt) aMenu.exec(aHeader->mapToGlobal(thePnt)); } +Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ResultPtr& theResult) +{ + return mySketchMgr->createPresentation(theResult); +} + ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 0117e96b4..46392a361 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -249,6 +249,11 @@ public: /// Returns the viewer Z layer int getVisualLayerId() const { return myVisualLayerId; } + /// Create specific for the module presentation + /// \param theResult an object for presentation + /// \return created presentation or NULL(default value) + virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult); + //! Returns data object by AIS virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const; diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp new file mode 100755 index 000000000..956e60cd9 --- /dev/null +++ b/src/PartSet/PartSet_ResultSketchPrs.cpp @@ -0,0 +1,258 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PartSet_ResultSketchPrs.h +// Created: 25 March 2015 +// Author: Natalia ERMOLAEVA + +#include "PartSet_ResultSketchPrs.h" +#include "PartSet_Tools.h" +#include "ModuleBase_Tools.h" + +#include +#include +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEBUG_WIRE + +#ifdef DEBUG_WIRE +#include +#include +#endif + +//******************************************************************************************* + +IMPLEMENT_STANDARD_HANDLE(PartSet_ResultSketchPrs, ViewerData_AISShape); +IMPLEMENT_STANDARD_RTTIEXT(PartSet_ResultSketchPrs, ViewerData_AISShape); + +PartSet_ResultSketchPrs::PartSet_ResultSketchPrs(ResultPtr theResult) + : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult) +{ + std::shared_ptr aShapePtr = ModelAPI_Tools::shape(theResult); + + TopoDS_Shape aShape = aShapePtr->impl(); + Set(aShape); + Handle(Prs3d_Drawer) aDrawer = Attributes(); + if (aDrawer->HasOwnPointAspect()) + aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS); + else + aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.)); + + // Activate individual repaintng if this is a part of compsolid + ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult); + SetAutoHilight(aCompSolid.get() == NULL); +} + +bool PartSet_ResultSketchPrs::isValidShapeType(const TopAbs_ShapeEnum& theBaseType, + const TopAbs_ShapeEnum& theCheckedType) +{ + bool aValid = theBaseType == theCheckedType; + if (!aValid) { + // currently this functionality is for all, as we have no separate wire selection mode + // lately it should be corrected to have the following check only for sketch presentations + aValid = theBaseType == TopAbs_FACE && theCheckedType == TopAbs_WIRE; + } + return aValid; +} + + +void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode) +{ + std::shared_ptr aShapePtr = ModelAPI_Tools::shape(myResult); + if (!aShapePtr) { + Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs"); + return; + } + + myFacesList.clear(); + ResultConstructionPtr aConstruction = + std::dynamic_pointer_cast(myResult); + if (aConstruction.get()) { + int aFacesNum = aConstruction->facesNum(); + for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) { + myFacesList.push_back(aConstruction->face(aFaceIndex)); + } + } + + myOriginalShape = aShapePtr->impl(); + if (!myOriginalShape.IsNull()) { + Set(myOriginalShape); + + // change deviation coefficient to provide more precise circle + ModuleBase_Tools::setDefaultDeviationCoefficient(myOriginalShape, Attributes()); + AIS_Shape::Compute(thePresentationManager, thePresentation, theMode); + } + else + Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs"); + + + // create auxiliary shapes + FeaturePtr aResultFeature = ModelAPI_Feature::feature(myResult); + CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast + (aResultFeature); + std::list anAuxiliaryResults; + for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) { + FeaturePtr aFeature = aSketchFeature->subFeature(i); + if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) { + std::list aResults = aFeature->results(); + std::list::const_iterator aIt; + for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) { + ResultPtr aResult = *aIt; + if (aResult.get() && aResult->shape().get()) + anAuxiliaryResults.push_back(aResult); + } + } + } + if (anAuxiliaryResults.size() > 0) { + std::vector aColor; + aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color", + SKETCH_AUXILIARY_COLOR); + Standard_Real anAuxiliaryWidth = 1.; + Standard_Integer anAuxiliaryLineStyle = 3; + + SetColor(Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB)); + + //thePresentation->Clear(); + Handle(Prs3d_Drawer) aDrawer = Attributes(); + setWidth(aDrawer, anAuxiliaryWidth); + // set line style + Handle(Prs3d_LineAspect) aLineAspect; + + Aspect_TypeOfLine aType = (Aspect_TypeOfLine)anAuxiliaryLineStyle; + if (aDrawer->HasOwnLineAspect()) { + aLineAspect = aDrawer->LineAspect(); + } + if (aDrawer->HasOwnWireAspect()) { + aLineAspect = aDrawer->WireAspect(); + } + Quantity_Color aCurrentColor; + Aspect_TypeOfLine aCurrentType; + Standard_Real aCurrentWidth; + aLineAspect->Aspect()->Values(aCurrentColor, aCurrentType, aCurrentWidth); + bool isChanged = aType != aCurrentType; + if (isChanged) { + aLineAspect->SetTypeOfLine(aType); + } + // end of set line style + + BRep_Builder aBuilder; + TopoDS_Compound aComp; + aBuilder.MakeCompound(aComp); + + std::list::const_iterator anIt = anAuxiliaryResults.begin(), + aLast = anAuxiliaryResults.end(); + for (; anIt != aLast; anIt++) { + ResultPtr aResult = *anIt; + if (aResult.get()) { + GeomShapePtr aGeomShape = aResult->shape(); + if (aGeomShape.get()) { + const TopoDS_Shape& aShape = aGeomShape->impl(); + if (!aShape.IsNull()) + aBuilder.Add(aComp, aShape); + } + } + } + myAuxiliaryCompound = aComp; + StdPrs_WFDeflectionShape::Add(thePresentation, aComp, aDrawer); + } +} + +#ifdef DEBUG_WIRE +void debugInfo(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + TopTools_IndexedMapOfShape aSubShapes; + TopExp::MapShapes (theShape, theType, aSubShapes); + + Standard_Boolean isComesFromDecomposition = !((aSubShapes.Extent() == 1) && (theShape == aSubShapes (1))); + int anExtent = aSubShapes.Extent(); + for (Standard_Integer aShIndex = 1; aShIndex <= aSubShapes.Extent(); ++aShIndex) + { + const TopoDS_Shape& aSubShape = aSubShapes (aShIndex); + int aValue = 0; + } +} +#endif + +void PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer aMode) +{ + if (aMode > 8) + // In order to avoid using custom selection modes + return; + + if (aMode == AIS_Shape::SelectionMode(TopAbs_FACE)) { +#ifdef DEBUG_WIRE + const TopoDS_Shape& aShape = Shape(); + debugInfo(aShape, TopAbs_VERTEX); // 24 + debugInfo(aShape, TopAbs_EDGE); // 12 + debugInfo(aShape, TopAbs_WIRE); // 0 + debugInfo(aShape, TopAbs_FACE); // 0 +#endif + BRep_Builder aBuilder; + TopoDS_Compound aComp; + aBuilder.MakeCompound(aComp); + aBuilder.Add(aComp, myOriginalShape); + std::list>::const_iterator aIt; + for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) { + TopoDS_Shape aFace = (*aIt)->impl(); + aBuilder.Add(aComp, aFace); + // for sketch presentation in the face mode wires should be selectable also + // accoring to #1343 Improvement of Extrusion and Revolution operations + appendShapeSelection(aSelection, aFace, TopAbs_WIRE); + } +#ifdef DEBUG_WIRE + debugInfo(aComp, TopAbs_VERTEX); // 24 + debugInfo(aComp, TopAbs_EDGE); // 12 + debugInfo(aComp, TopAbs_WIRE); // 4 + debugInfo(aComp, TopAbs_FACE); // 2 +#endif + Set(aComp); + } else + Set(myOriginalShape); + + // append auxiliary compound to selection of edges/vertices + if (aMode == AIS_Shape::SelectionMode(TopAbs_EDGE) || + aMode == AIS_Shape::SelectionMode(TopAbs_VERTEX)) { + + bool isVertex = aMode == AIS_Shape::SelectionMode(TopAbs_VERTEX); + appendShapeSelection(aSelection, myAuxiliaryCompound, isVertex ? TopAbs_VERTEX : TopAbs_EDGE); + } + + AIS_Shape::ComputeSelection(aSelection, aMode); +} + +void PartSet_ResultSketchPrs::appendShapeSelection(const Handle(SelectMgr_Selection)& theSelection, + const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum& theTypeOfSelection) +{ + // POP protection against crash in low layers + Standard_Real aDeflection = Prs3d::GetDeflection(theShape, myDrawer); + try { + StdSelect_BRepSelectionTool::Load(theSelection, + this, + theShape, + theTypeOfSelection, + aDeflection, + myDrawer->HLRAngle(), + myDrawer->IsAutoTriangulation()); + } catch ( Standard_Failure ) { + } +} diff --git a/src/PartSet/PartSet_ResultSketchPrs.h b/src/PartSet/PartSet_ResultSketchPrs.h new file mode 100755 index 000000000..dc79c7c26 --- /dev/null +++ b/src/PartSet/PartSet_ResultSketchPrs.h @@ -0,0 +1,70 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PartSet_ResultSketchPrs.h +// Created: 25 March 2015 +// Author: Natalia ERMOLAEVA + +#ifndef PartSet_ResultSketchPrs_H +#define PartSet_ResultSketchPrs_H + +#include "ModuleBase.h" + +#include + +#include + +#include + +DEFINE_STANDARD_HANDLE(PartSet_ResultSketchPrs, ViewerData_AISShape) + +/** +* \ingroup GUI +* A redefinition of standard AIS Interactive Object in order to provide specific behaviour +* for wire presentations based in a one plane +*/ +class PartSet_ResultSketchPrs: public ViewerData_AISShape +{ +public: + /// Constructor + /// \param theResult a result object + Standard_EXPORT PartSet_ResultSketchPrs(ResultPtr theResult); + + /// Returns true if the checked type can be accepted for the base selection type + /// It returns true if they are coicide or if the base type is face and the checked type is wire + /// @return boolean result + static Standard_EXPORT bool isValidShapeType(const TopAbs_ShapeEnum& theBaseType, + const TopAbs_ShapeEnum& theCheckedType); + + DEFINE_STANDARD_RTTI(PartSet_ResultSketchPrs) +protected: + /// Redefinition of virtual function + Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0); + + /// Redefinition of virtual function + Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, + const Standard_Integer aMode) ; + +private: + /// Appens sensitive and owners for wires of the given shape into selection + /// \param theSelection a current filled selection + /// \param theShape a shape + /// \param theTypeOfSelection type of selection: VERTEX, EDGE, WIRE + void appendShapeSelection(const Handle(SelectMgr_Selection)& theSelection, + const TopoDS_Shape& theShape, const TopAbs_ShapeEnum& theTypeOfSelection); + + /// Reference to result object + ResultPtr myResult; + + /// Original shape of the result object + TopoDS_Shape myOriginalShape; + + /// Compound of auxiliary shapes + TopoDS_Compound myAuxiliaryCompound; + + /// List of faces + std::list > myFacesList; +}; + + +#endif \ No newline at end of file diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 1817bc3aa..06fbec26c 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -12,6 +12,7 @@ #include "PartSet_Tools.h" #include "PartSet_WidgetSketchLabel.h" #include "PartSet_WidgetEditor.h" +#include "PartSet_ResultSketchPrs.h" #include #include @@ -612,8 +613,7 @@ void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMo QList aWidgets = aPanel->modelWidgets(); // Find corresponded widget to activate value editing foreach (ModuleBase_ModelWidget* aWgt, aWidgets) { - if (aWgt->attributeID() == "ConstraintValue" || - aWgt->attributeID() == "AngleValue") { + if (aWgt->attributeID() == "ConstraintValue") { PartSet_WidgetEditor* anEditor = dynamic_cast(aWgt); if (anEditor) anEditor->showPopupEditor(); @@ -786,6 +786,17 @@ void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes) theModes.append(TopAbs_EDGE); } +Handle(AIS_InteractiveObject) PartSet_SketcherMgr::createPresentation(const ResultPtr& theResult) +{ + Handle(AIS_InteractiveObject) aPrs; + + FeaturePtr aFeature = ModelAPI_Feature::feature(theResult); + if (aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID()) { + aPrs = new PartSet_ResultSketchPrs(theResult); + } + return aPrs; +} + bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation) { return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID(); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index aa99353aa..06edf86e1 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -238,6 +238,11 @@ public: /// \param theModes a list of modes static void sketchSelectionModes(QIntList& theModes); + /// Create specific for the module presentation + /// \param theResult an object for presentation + /// \return created presentation or NULL(default value) + virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult); + /// Connects or disconnects to the value changed signal of the property panel widgets /// \param theWidget a property contol widget /// \param isToConnect a boolean value whether connect or disconnect diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 6d46988ea..0616192d9 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -942,3 +942,18 @@ void PartSet_Tools::sendSubFeaturesEvent(const CompositeFeaturePtr& theComposite } Events_Loop::loop()->flush(theEventId); } + +bool PartSet_Tools::isAuxiliarySketchEntity(const ObjectPtr& theObject) +{ + bool isAuxiliaryFeature = false; + + FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject); + std::string anAuxiliaryAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID(); + AttributeBooleanPtr anAuxiliaryAttr = std::dynamic_pointer_cast( + anObjectFeature->data()->attribute(anAuxiliaryAttribute)); + if (anAuxiliaryAttr.get()) + isAuxiliaryFeature = anAuxiliaryAttr->value(); + + + return isAuxiliaryFeature; +} diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 8db945e80..fe133ede0 100755 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -256,6 +256,13 @@ public: /// Sends redisplay event for all sub-features of the composite. Flush it. static void sendSubFeaturesEvent(const CompositeFeaturePtr& theComposite, const Events_ID theId); + + /** + * Returns true if the object is a sketch entity, where auxiliary attribute has true vlaue + * \param theObject a result or feature + * \return boolean result + */ + static bool isAuxiliarySketchEntity(const ObjectPtr& theObject); }; #endif diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 004fd0d3c..11f698ad1 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -513,13 +513,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous setPoint(aX, aY); } setValueState(Stored); // in case of edge selection, Apply state should also be updated - - FeaturePtr anObjectFeature = ModelAPI_Feature::feature(aObject); - std::string anAuxiliaryAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID(); - AttributeBooleanPtr anAuxiliaryAttr = std::dynamic_pointer_cast( - anObjectFeature->data()->attribute(anAuxiliaryAttribute)); - if (anAuxiliaryAttr.get()) - isAuxiliaryFeature = anAuxiliaryAttr->value(); + isAuxiliaryFeature = PartSet_Tools::isAuxiliarySketchEntity(aObject); } // it is important to perform updateObject() in order to the current value is // processed by Sketch Solver. Test case: line is created from a previous point diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 7833d748c..27798a128 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -161,7 +161,10 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer) std::shared_ptr aShapePtr = ModelAPI_Tools::shape(aResult); if (aShapePtr.get() != NULL) { anAIS = AISObjectPtr(new GeomAPI_AISObject()); - anAIS->setImpl(new Handle(AIS_InteractiveObject)(new ModuleBase_ResultPrs(aResult))); + Handle(AIS_InteractiveObject) anAISPrs = myWorkshop->module()->createPresentation(aResult); + if (anAISPrs.IsNull()) + anAISPrs = new ModuleBase_ResultPrs(aResult); + anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs)); //anAIS->createShape(aShapePtr); isShading = true; }