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();
/// \param theOperation the operation\r
virtual void sendOperation(ModuleBase_Operation* theOperation);\r
\r
+ /// Create specific for the module presentation\r
+ /// \param theResult an object for presentation\r
+ /// \return created presentation or NULL(default value)\r
+ virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult);\r
+\r
//! Returns data object by AIS\r
virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;\r
\r
#include <AIS_Selection.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
-//#define DEBUG_WIRE
-
-#ifdef DEBUG_WIRE
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopExp.hxx>
-#endif
-
IMPLEMENT_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner);
IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner);
ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
- : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false)
+ : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult)
{
std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
- std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr =
- std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(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<TopoDS_Shape>();
Set(aShape);
Handle(Prs3d_Drawer) aDrawer = Attributes();
return;
}
- if (myIsSketchMode) {
- myFacesList.clear();
- ResultConstructionPtr aConstruction =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
- if (aConstruction.get()) {
- int aFacesNum = aConstruction->facesNum();
- for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
- myFacesList.push_back(aConstruction->face(aFaceIndex));
- }
- }
- }
myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
if (!myOriginalShape.IsNull()) {
Set(myOriginalShape);
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)
{
// 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<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
- for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
- TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
- 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);
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)
{
}
}
-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<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aCompSolid);
- if (aShapePtr.get())
- return aShapePtr->impl<TopoDS_Shape>();
- }
- }
- return myOriginalShape;
-}
-
-
void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM,
const SelectMgr_SequenceOfOwner& theOwners)
{
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<std::shared_ptr<GeomAPI_Shape> >& 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:
/// \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<std::shared_ptr<GeomAPI_Shape> > myFacesList;
};
PartSet_WidgetFileSelector.h
PartSet_Filters.h
PartSet_FilterInfinite.h
+ PartSet_ResultSketchPrs.h
PartSet_SketcherMgr.h
PartSet_SketcherReetntrantMgr.h
PartSet_MenuMgr.h
PartSet_WidgetFileSelector.cpp
PartSet_Filters.cpp
PartSet_FilterInfinite.cpp
+ PartSet_ResultSketchPrs.cpp
PartSet_SketcherMgr.cpp
PartSet_SketcherReetntrantMgr.cpp
PartSet_MenuMgr.cpp
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
{
/// 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;
--- /dev/null
+// 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 <ModelAPI_Tools.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <GeomAPI_PlanarEdges.h>
+
+#include <Events_Error.h>
+
+#include <SketchPlugin_SketchEntity.h>
+
+#include <Config_PropManager.h>
+
+#include <BRep_Builder.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <TopoDS_Builder.hxx>
+#include <SelectMgr_SelectionManager.hxx>
+#include <StdPrs_WFDeflectionShape.hxx>
+#include <StdSelect_BRepSelectionTool.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_LineAspect.hxx>
+
+#define DEBUG_WIRE
+
+#ifdef DEBUG_WIRE
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#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<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
+
+ TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
+ 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<GeomAPI_Shape> 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<ModelAPI_ResultConstruction>(myResult);
+ if (aConstruction.get()) {
+ int aFacesNum = aConstruction->facesNum();
+ for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
+ myFacesList.push_back(aConstruction->face(aFaceIndex));
+ }
+ }
+
+ myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
+ 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<ModelAPI_CompositeFeature>
+ (aResultFeature);
+ std::list<ResultPtr> anAuxiliaryResults;
+ for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) {
+ FeaturePtr aFeature = aSketchFeature->subFeature(i);
+ if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) {
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::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<int> 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<ResultPtr>::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<TopoDS_Shape>();
+ 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<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
+ for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
+ TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
+ 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 ) {
+ }
+}
--- /dev/null
+// 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 <ModelAPI_Result.h>
+
+#include <ViewerData_AISShape.hxx>
+
+#include <TopoDS_Compound.hxx>
+
+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<std::shared_ptr<GeomAPI_Shape> > myFacesList;
+};
+
+
+#endif
\ No newline at end of file
#include "PartSet_Tools.h"
#include "PartSet_WidgetSketchLabel.h"
#include "PartSet_WidgetEditor.h"
+#include "PartSet_ResultSketchPrs.h"
#include <XGUI_ModuleConnector.h>
#include <XGUI_Displayer.h>
QList<ModuleBase_ModelWidget*> 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<PartSet_WidgetEditor*>(aWgt);
if (anEditor)
anEditor->showPopupEditor();
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();
/// \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
}
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<ModelAPI_AttributeBoolean>(
+ anObjectFeature->data()->attribute(anAuxiliaryAttribute));
+ if (anAuxiliaryAttr.get())
+ isAuxiliaryFeature = anAuxiliaryAttr->value();
+
+
+ return isAuxiliaryFeature;
+}
/// 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
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<ModelAPI_AttributeBoolean>(
- 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
std::shared_ptr<GeomAPI_Shape> 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;
}