SketcherPrs.h
SketcherPrs_Coincident.h
SketcherPrs_Collinear.h
+ SketcherPrs_DimensionStyleListener.h
SketcherPrs_Factory.h
SketcherPrs_Parallel.h
SketcherPrs_Tools.h
SET(PROJECT_SOURCES
SketcherPrs_Coincident.cpp
SketcherPrs_Collinear.cpp
+ SketcherPrs_DimensionStyleListener.cpp
SketcherPrs_Factory.cpp
SketcherPrs_Parallel.cpp
SketcherPrs_Tools.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_DimensionStyleListener.cpp
+// Created: 31 March 2016
+// Author: Natalia ERMOLAEVA
+
+#include "SketcherPrs_DimensionStyleListener.h"
+#include "SketcherPrs_Tools.h"
+
+#include <Events_Error.h>
+#include <Events_Loop.h>
+
+SketcherPrs_DimensionStyleListener::SketcherPrs_DimensionStyleListener()
+{
+ Events_Loop* aLoop = Events_Loop::loop();
+ const Events_ID kDocCreatedEvent =
+ SketcherPrs_ParameterStyleMessage::eventId();
+ aLoop->registerListener(this, kDocCreatedEvent, NULL, false);
+}
+
+SketcherPrs_DimensionStyleListener::~SketcherPrs_DimensionStyleListener()
+{
+ Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->removeListener(this);
+}
+
+void SketcherPrs_DimensionStyleListener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+ const Events_ID kParameterStyleEvent = SketcherPrs_ParameterStyleMessage::eventId();
+ if (theMessage->eventID() == kParameterStyleEvent) {
+ std::shared_ptr<SketcherPrs_ParameterStyleMessage> aMessage = std::dynamic_pointer_cast<
+ SketcherPrs_ParameterStyleMessage>(theMessage);
+ myStyle = aMessage->style();
+ }
+}
+
+void SketcherPrs_DimensionStyleListener::updateDimensions(AIS_Dimension* theDimension,
+ const AttributeDoublePtr& theAttributeValue)
+{
+ if (!theDimension || !theAttributeValue.get())
+ return;
+
+ bool aHasParameters = theAttributeValue->usedParameters().size() > 0;
+ if (aHasParameters) {
+ bool isParameterValueStyle = myStyle == SketcherPrs_ParameterStyleMessage::ParameterValue;
+ SketcherPrs_Tools::setDisplaySpecialSymbol(theDimension, isParameterValueStyle);
+ SketcherPrs_Tools::setDisplayParameter(theDimension, theAttributeValue->text(), !isParameterValueStyle);
+ }
+ else {
+ SketcherPrs_Tools::setDisplaySpecialSymbol(theDimension, false);
+ SketcherPrs_Tools::setDisplayParameter(theDimension, theAttributeValue->text(), false);
+ }
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketcherPrs_DimensionStyleListener.h
+// Created: 31 March 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef SketcherPrs_DimensionStyleListener_H
+#define SketcherPrs_DimensionStyleListener_H
+
+#include <Events_Listener.h>
+
+#include <ModelAPI_AttributeDouble.h>
+
+#include "SketcherPrs_Tools.h"
+
+#include <Standard.hxx>
+
+/**
+* \ingroup GUI
+* A class for representation of linear dimension constraint.
+* It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
+*/
+class SketcherPrs_DimensionStyleListener : public Events_Listener
+{
+public:
+ /// Constructor
+ /// \param theConstraint a constraint feature
+ /// \param thePlane a coordinate plane of current sketch
+ Standard_EXPORT SketcherPrs_DimensionStyleListener();
+
+ /// Destructor
+ Standard_EXPORT ~SketcherPrs_DimensionStyleListener();
+
+ /// Process the ModelAPI_DocumentCreatedMessage to fulfill a document
+ /// from the message with origin and planes
+ virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+
+ /// Redefinition of virtual function
+ Standard_EXPORT void updateDimensions(AIS_Dimension* theDimension,
+ const AttributeDoublePtr& theAttributeValue);
+
+private:
+ /// Style how the parameter of dimension should be visualized
+ SketcherPrs_ParameterStyleMessage::ParameterStyle myStyle;
+};
+
+#endif
\ No newline at end of file
#include <SketchPlugin_Circle.h>
#include <SketcherPrs_Tools.h>
+#include <SketcherPrs_DimensionStyleListener.h>
#include <Events_Error.h>
#include <Events_Loop.h>
SetSelToleranceForText2d(SketcherPrs_Tools::getTextHeight());
SetDimensionAspect(myAspect);
- Events_Loop* aLoop = Events_Loop::loop();
- const Events_ID kDocCreatedEvent =
- SketcherPrs_ParameterStyleMessage::eventId();
- aLoop->registerListener(this, kDocCreatedEvent, NULL, false);
+ myStyleListener = new SketcherPrs_DimensionStyleListener();
}
SketcherPrs_LengthDimension::~SketcherPrs_LengthDimension()
{
- Events_Loop* aLoop = Events_Loop::loop();
- aLoop->removeListener(this);
-}
-
-void SketcherPrs_LengthDimension::processEvent(const std::shared_ptr<Events_Message>& theMessage)
-{
- const Events_ID kParameterStyleEvent = SketcherPrs_ParameterStyleMessage::eventId();
- if (theMessage->eventID() == kParameterStyleEvent) {
- std::shared_ptr<SketcherPrs_ParameterStyleMessage> aMessage = std::dynamic_pointer_cast<
- SketcherPrs_ParameterStyleMessage>(theMessage);
- myStyle = aMessage->style();
- }
+ delete myStyleListener;
}
bool SketcherPrs_LengthDimension::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
myAspect->TextAspect()->SetVerticalJustification(Graphic3d_VTA_CENTER);
AttributeDoublePtr aValue = myConstraint->data()->real(SketchPlugin_Constraint::VALUE());
- bool aHasParameters = aValue->usedParameters().size() > 0;
- if (aHasParameters) {
- bool isParameterValueStyle = myStyle == SketcherPrs_ParameterStyleMessage::ParameterValue;
- SketcherPrs_Tools::setDisplaySpecialSymbol(this, isParameterValueStyle);
- SketcherPrs_Tools::setDisplayParameter(this, aValue->text(), !isParameterValueStyle);
- }
- else {
- SketcherPrs_Tools::setDisplaySpecialSymbol(this, false);
- SketcherPrs_Tools::setDisplayParameter(this, aValue->text(), false);
- }
+
+ myStyleListener->updateDimensions(this, aValue);
+
AIS_LengthDimension::Compute(thePresentationManager, thePresentation, theMode);
}
#include <SketcherPrs_Tools.h>
-#include <Events_Listener.h>
-
+class SketcherPrs_DimensionStyleListener;
DEFINE_STANDARD_HANDLE(SketcherPrs_LengthDimension, AIS_LengthDimension)
* A class for representation of linear dimension constraint.
* It supports SketchPlugin_ConstraintLength and SketchPlugin_ConstraintDistance features.
*/
-class SketcherPrs_LengthDimension : public AIS_LengthDimension, public Events_Listener
+class SketcherPrs_LengthDimension : public AIS_LengthDimension
{
public:
/// Constructor
DEFINE_STANDARD_RTTI(SketcherPrs_LengthDimension)
- /// Process the ModelAPI_DocumentCreatedMessage to fulfill a document
- /// from the message with origin and planes
- virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
-
/// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
/// \param theConstraint a constraint feature
/// \param thePlane a coordinate plane of current sketch
Handle(Prs3d_DimensionAspect) myAspect;
- /// Style how the parameter of dimension should be visualized
- SketcherPrs_ParameterStyleMessage::ParameterStyle myStyle;
+ /// Listener to update dimension visualization style
+ SketcherPrs_DimensionStyleListener* myStyleListener;
};
#endif
\ No newline at end of file