ADD_SUBDIRECTORY (src/XGUI)
ADD_SUBDIRECTORY (src/GeomApp)
ADD_SUBDIRECTORY (src/ExchangePlugin)
+ADD_SUBDIRECTORY (src/GeomValidators)
IF(${HAVE_SALOME})
ADD_SUBDIRECTORY (src/NewGeom)
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
<plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
<plugin library="SketchSolver"/>
+ <plugin library="GeomValidators"/>
<plugin library="DFBrowser"/>
</plugins>
SET(PROJECT_SOURCES
FeaturesPlugin_Plugin.cpp
FeaturesPlugin_Extrusion.cpp
- FeaturesPlugin_Boolean.cpp
+ FeaturesPlugin_Boolean.cpp
)
-ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
-ADD_LIBRARY(FeaturesPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(FeaturesPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
+SET(XML_RESOURCES
+ plugin-Features.xml
+ extrusion_widget.xml
+ boolean_widget.xml
+)
INCLUDE_DIRECTORIES(
../ModelAPI
../GeomAlgoAPI
)
-SET(XML_RESOURCES
- plugin-Features.xml
- extrusion_widget.xml
- boolean_widget.xml
-)
+ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
+ADD_LIBRARY(FeaturesPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+TARGET_LINK_LIBRARIES(FeaturesPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
INSTALL(TARGETS FeaturesPlugin DESTINATION plugins)
INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
activate="true"
shape_types="face"
/>
- <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion"/>
+ <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
+ <validator id="GeomValidators_Positive"/>
+ </doublevalue>
<boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
</source>
GeomAlgoAPI_PointBuilder.h
GeomAlgoAPI_SketchBuilder.h
GeomAlgoAPI_Extrusion.h
- GeomAlgoAPI_Boolean.h
+ GeomAlgoAPI_Boolean.h
)
SET(PROJECT_SOURCES
GeomAlgoAPI_PointBuilder.cpp
GeomAlgoAPI_SketchBuilder.cpp
GeomAlgoAPI_Extrusion.cpp
- GeomAlgoAPI_Boolean.cpp
+ GeomAlgoAPI_Boolean.cpp
)
ADD_DEFINITIONS(-DGEOMALGOAPI_EXPORTS ${CAS_DEFINITIONS})
--- /dev/null
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+ GeomValidators.h
+ GeomValidators_Positive.h
+)
+
+SET(PROJECT_SOURCES
+ GeomValidators_Positive.cpp
+)
+
+SET(PROJECT_LIBRARIES
+ ModelAPI
+ Events
+)
+
+
+
+ADD_DEFINITIONS(-DGEOMVALIDATORS_EXPORTS ${BOOST_DEFINITIONS})
+ADD_LIBRARY(GeomValidators SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(GeomValidators ${PROJECT_LIBRARIES})
+
+INCLUDE_DIRECTORIES(
+ ../ModelAPI
+ ../Events
+)
+
+INSTALL(TARGETS GeomValidators DESTINATION plugins)
--- /dev/null
+#ifndef GEOMVALIDATORS_H
+#define GEOMVALIDATORS_H
+
+#if defined GEOMVALIDATORS_EXPORTS
+#if defined WIN32
+#define GEOMVALIDATORS_EXPORT __declspec( dllexport )
+#else
+#define GEOMVALIDATORS_EXPORT
+#endif
+#else
+#if defined WIN32
+#define GEOMVALIDATORS_EXPORT __declspec( dllimport )
+#else
+#define GEOMVALIDATORS_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+// File: GeomValidators_ValidatorPositive.cpp
+// Created: 16 Sep 2014
+// Author: Mikhail PONIKAROV
+
+#include "GeomValidators_Positive.h"
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+/// Global instance for validators factory
+GeomValidators_Positive MY_INSTANCE;
+
+GeomValidators_Positive::GeomValidators_Positive()
+{
+ // this validator is registered in the factory on this library loading
+ SessionPtr aMgr = ModelAPI_Session::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ aFactory->registerValidator("GeomValidators_Positive", &MY_INSTANCE);
+}
+
+bool GeomValidators_Positive::isValid(
+ const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
+{
+ boost::shared_ptr<ModelAPI_AttributeDouble> aDouble =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
+ return aDouble->isInitialized() && aDouble->value() > 1.e-5;
+}
--- /dev/null
+// File: GeomValidators_ValidatorPositive.h
+// Created: 16 Sep 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomValidators_ValidatorPositive_H
+#define GeomValidators_ValidatorPositive_H
+
+#include <GeomValidators.h>
+#include <ModelAPI_AttributeValidator.h>
+
+/**
+ * Validates that the double attribute is greater than 1.e-5
+ */
+class GeomValidators_Positive : public ModelAPI_AttributeValidator
+{
+public:
+ //! Constructor for only one instance per application: will register the validator
+ GeomValidators_Positive();
+ //! returns true if attribute is valid
+ //! \param theAttribute the checked attribute
+ //! \param theArguments arguments of the attribute
+ GEOMVALIDATORS_EXPORT virtual bool isValid(
+ const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const;
+
+};
+
+#endif
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
aFactory->registerValidator("SketchPlugin_DistanceAttrValidator",
new SketchPlugin_DistanceAttrValidator);
- aFactory->registerValidator("SketchPlugin_RadiusValidator",
- new SketchPlugin_RadiusValidator);
aFactory->registerValidator("SketchPlugin_ResultPointValidator", new SketchPlugin_ResultPointValidator);
aFactory->registerValidator("SketchPlugin_ResultLineValidator", new SketchPlugin_ResultLineValidator);
aFactory->registerValidator("SketchPlugin_ResultArcValidator", new SketchPlugin_ResultArcValidator);
}
return true; // it may be not reference attribute, in this case, it is OK
}
-
-bool SketchPlugin_RadiusValidator::isValid(
- const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const
-{
- boost::shared_ptr<ModelAPI_AttributeDouble> aDouble =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
- return aDouble->isInitialized() && aDouble->value() > 1.e-5;
-}
};
-/**
- * It must be bigger than 1.e-5
- */
-class SketchPlugin_RadiusValidator : public ModelAPI_AttributeValidator
-{
- public:
- //! returns true if attribute is valid
- //! \param theAttribute the checked attribute
- //! \param theArguments arguments of the attribute
- virtual bool isValid(
- const AttributePtr& theAttribute, const std::list<std::string>& theArguments) const;
-
-};
-
#endif
<feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon=":icons/circle.png">
<point_selector id="CircleCenter" title="Center" tooltip="Center of the circle"/>
<point2ddistance id="CircleRadius" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set Radius">
- <validator id="SketchPlugin_RadiusValidator"/>
+ <validator id="GeomValidators_Positive"/>
</point2ddistance>
</feature>
<feature id="SketchArc" title="Arc" tooltip="Create a new arc of a circle" icon=":icons/arc.png">