From: vsv Date: Thu, 11 Dec 2014 16:56:46 +0000 (+0300) Subject: Removed not used function SimpleAISobject X-Git-Tag: before_slalome_7.5.1~19^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=07bc7fd1c59cbe7a2d916654edf77409670f215b;p=modules%2Fshaper.git Removed not used function SimpleAISobject Provided customization of sketch objects presentations --- diff --git a/src/GeomAPI/CMakeLists.txt b/src/GeomAPI/CMakeLists.txt index e08c67fc1..eec0e4d2c 100644 --- a/src/GeomAPI/CMakeLists.txt +++ b/src/GeomAPI/CMakeLists.txt @@ -27,6 +27,7 @@ SET(PROJECT_HEADERS GeomAPI_IPresentable.h GeomAPI_Curve.h GeomAPI_DataMapOfShapeShape.h + GeomAPI_ICustomPrs.h ) SET(PROJECT_SOURCES diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index f1534e2af..1e6566c09 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -26,6 +26,7 @@ #include #include #include +#include const double tolerance = 1e-7; @@ -296,3 +297,31 @@ bool GeomAPI_AISObject::empty() const return false; } +int GeomAPI_AISObject::getShapeType() const +{ + Handle(AIS_InteractiveObject) anAIS = const_cast(this) + ->impl(); + if (!anAIS.IsNull()) { + Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anAIS); + if (!aAISShape.IsNull()) { + return aAISShape->Shape().ShapeType(); + } + } + return -1; +} + +void GeomAPI_AISObject::setPointMarker(int theType, double theScale) +{ + Handle(AIS_InteractiveObject) anAIS = impl(); + if (!anAIS.IsNull()) { + Handle(AIS_Drawer) aDrawer = anAIS->Attributes(); + if (aDrawer->HasPointAspect()) { + Handle(Prs3d_PointAspect) aPA = aDrawer->PointAspect(); + aPA->SetTypeOfMarker((Aspect_TypeOfMarker)theType); + aPA->SetScale(theScale); + } else { + Quantity_NameOfColor aCol = Quantity_NOC_YELLOW; + aDrawer->SetPointAspect(new Prs3d_PointAspect((Aspect_TypeOfMarker)theType, aCol, theScale)); + } + } +} diff --git a/src/GeomAPI/GeomAPI_AISObject.h b/src/GeomAPI/GeomAPI_AISObject.h index 48e3d6fa0..1477c5a13 100644 --- a/src/GeomAPI/GeomAPI_AISObject.h +++ b/src/GeomAPI/GeomAPI_AISObject.h @@ -95,6 +95,14 @@ class GEOMAPI_EXPORT GeomAPI_AISObject : public GeomAPI_Interface /// \brief Checks if the object is empty bool empty() const; + + /// Return shape type according to TopAbs_ShapeEnum if the AIS is AIS_Shape + /// Otherwise returns -1 + int getShapeType() const; + + /// Sets marker type for vertex. + /// The type has to be defined according to Acpect_TypeOfMarker + void setPointMarker(int theType, double theScale); }; //! Pointer on attribute object diff --git a/src/GeomAPI/GeomAPI_ICustomPrs.h b/src/GeomAPI/GeomAPI_ICustomPrs.h new file mode 100644 index 000000000..c398a33bc --- /dev/null +++ b/src/GeomAPI/GeomAPI_ICustomPrs.h @@ -0,0 +1,24 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAPI_ICustomPrs.hxx +// Created: 11 Dec 2014 +// Author: Vitaly SMETANNIKOV + +#ifndef GeomAPI_ICustomPrs_H +#define GeomAPI_ICustomPrs_H + +#include "GeomAPI_AISObject.h" + +/** +* Interface of a class which can provide specific customization of +* object presentation +*/ +class GeomAPI_ICustomPrs +{ +public: + virtual void customisePresentation(AISObjectPtr thePrs) = 0; +}; + +typedef std::shared_ptr GeomCustomPrsPtr; + +#endif \ No newline at end of file diff --git a/src/SketchPlugin/SketchPlugin_Circle.h b/src/SketchPlugin/SketchPlugin_Circle.h index ab56e8ed8..76bac7887 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.h +++ b/src/SketchPlugin/SketchPlugin_Circle.h @@ -16,7 +16,7 @@ * \ingroup DataModel * \brief Feature for creation of the new circle in PartSet. */ -class SketchPlugin_Circle : public SketchPlugin_Feature //, public GeomAPI_IPresentable +class SketchPlugin_Circle : public SketchPlugin_Feature { public: /// Circle feature kind @@ -56,12 +56,6 @@ class SketchPlugin_Circle : public SketchPlugin_Feature //, public GeomAPI_IPre /// Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); - /// Returns the AIS preview - virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious) - { - return simpleAISObject(firstResult(), thePrevious); - } - /// Adds sub-feature of the higher level feature (sub-element of the sketch) /// \param theFeature sub-feature SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature) diff --git a/src/SketchPlugin/SketchPlugin_Feature.cpp b/src/SketchPlugin/SketchPlugin_Feature.cpp index 9916b78e5..dcd2f9847 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.cpp +++ b/src/SketchPlugin/SketchPlugin_Feature.cpp @@ -31,19 +31,13 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch() return mySketch; } -AISObjectPtr SketchPlugin_Feature::simpleAISObject(std::shared_ptr theRes, - AISObjectPtr thePrevious) -{ - std::shared_ptr aConstr = std::dynamic_pointer_cast< - ModelAPI_ResultConstruction>(theRes); - - std::shared_ptr aPreview; - if (aConstr) - aPreview = aConstr->shape(); - AISObjectPtr aResult = thePrevious; - if (!aResult) - aResult = AISObjectPtr(new GeomAPI_AISObject()); - aResult->createShape(aPreview); - return aResult; -} +void SketchPlugin_Feature::customisePresentation(AISObjectPtr thePrs) +{ + // if this is an edge + if (thePrs->getShapeType() == 6) + thePrs->setWidth(3); + // if this is a vertex + else if (thePrs->getShapeType() == 7) + thePrs->setPointMarker(6, 2.); +} \ No newline at end of file diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index 01b9d88ee..7ca0eb6d3 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -13,6 +13,7 @@ #include #include #include +#include class SketchPlugin_Sketch; class GeomAPI_Pnt2d; @@ -23,13 +24,9 @@ class Handle_AIS_InteractiveObject; * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give * an interface to create the sketch feature preview. */ -class SketchPlugin_Feature : public ModelAPI_Feature +class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs { public: - /// Simple creation of interactive object by the result of the object - static AISObjectPtr simpleAISObject(std::shared_ptr theRes, - AISObjectPtr thePrevious); - /// Reference to the external edge or vertex as a AttributeSelection inline static const std::string& EXTERNAL_ID() { @@ -66,6 +63,9 @@ class SketchPlugin_Feature : public ModelAPI_Feature return false; } + /// Customize presentation of the feature + virtual void customisePresentation(AISObjectPtr thePrs); + /// Returns the sketch of this feature SketchPlugin_Sketch* sketch(); protected: diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index e31dfb59d..50d8f438f 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -116,3 +116,4 @@ void SketchPlugin_Line::attributeChanged(const std::string& theID) { } } } + diff --git a/src/SketchPlugin/SketchPlugin_Line.h b/src/SketchPlugin/SketchPlugin_Line.h index 46161cf74..be5fadaad 100644 --- a/src/SketchPlugin/SketchPlugin_Line.h +++ b/src/SketchPlugin/SketchPlugin_Line.h @@ -54,12 +54,6 @@ class SketchPlugin_Line : public SketchPlugin_Feature /// Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); - /// Returns the AIS preview - SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious) - { - return simpleAISObject(firstResult(), thePrevious); - } - /// Moves the feature /// \param theDeltaX the delta for X coordinate is moved /// \param theDeltaY the delta for Y coordinate is moved diff --git a/src/SketchPlugin/SketchPlugin_Point.h b/src/SketchPlugin/SketchPlugin_Point.h index 4d2845c1c..a60f9beba 100644 --- a/src/SketchPlugin/SketchPlugin_Point.h +++ b/src/SketchPlugin/SketchPlugin_Point.h @@ -47,12 +47,6 @@ class SketchPlugin_Point : public SketchPlugin_Feature /// Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); - /// Returns the AIS preview - virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious) - { - return simpleAISObject(firstResult(), thePrevious); - } - /// Moves the feature /// \param theDeltaX the delta for X coordinate is moved /// \param theDeltaY the delta for Y coordinate is moved diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index a0fe6a50f..3a530c2f4 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -87,6 +88,12 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!anAISIO.IsNull()) { myResult2AISObjectMap[theObject] = theAIS; + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + if (aFeature.get() != NULL) { + GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast(aFeature); + if (aCustPrs.get() != NULL) + aCustPrs->customisePresentation(theAIS); + } aContext->Display(anAISIO, false); aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, isUpdateViewer); if (aContext->HasOpenedContext()) {