From: mpv Date: Tue, 16 Sep 2014 07:04:29 +0000 (+0400) Subject: Fix for issue #134. Make common validator that checks OCC positive values X-Git-Tag: V_0.4.4~48^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0ea6242dd53cf845d8457921aa1613f546a68e44;p=modules%2Fshaper.git Fix for issue #134. Make common validator that checks OCC positive values --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a6134b22..7806682d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,7 @@ ADD_SUBDIRECTORY (src/PartSet) ADD_SUBDIRECTORY (src/XGUI) ADD_SUBDIRECTORY (src/GeomApp) ADD_SUBDIRECTORY (src/ExchangePlugin) +ADD_SUBDIRECTORY (src/GeomValidators) IF(${HAVE_SALOME}) ADD_SUBDIRECTORY (src/NewGeom) diff --git a/src/Config/plugins.xml b/src/Config/plugins.xml index 7d6b81b6f..396f565a9 100644 --- a/src/Config/plugins.xml +++ b/src/Config/plugins.xml @@ -5,5 +5,6 @@ + diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 6d4cd90fc..261b08746 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -10,12 +10,14 @@ SET(PROJECT_HEADERS 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 @@ -23,11 +25,9 @@ INCLUDE_DIRECTORIES( ../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) diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index c0069ca67..795db94f0 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -6,6 +6,8 @@ activate="true" shape_types="face" /> - + + + diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 26b230a25..41d7d8631 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -11,7 +11,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_PointBuilder.h GeomAlgoAPI_SketchBuilder.h GeomAlgoAPI_Extrusion.h - GeomAlgoAPI_Boolean.h + GeomAlgoAPI_Boolean.h ) SET(PROJECT_SOURCES @@ -21,7 +21,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_PointBuilder.cpp GeomAlgoAPI_SketchBuilder.cpp GeomAlgoAPI_Extrusion.cpp - GeomAlgoAPI_Boolean.cpp + GeomAlgoAPI_Boolean.cpp ) ADD_DEFINITIONS(-DGEOMALGOAPI_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/GeomValidators/CMakeLists.txt b/src/GeomValidators/CMakeLists.txt new file mode 100644 index 000000000..efb0b10e7 --- /dev/null +++ b/src/GeomValidators/CMakeLists.txt @@ -0,0 +1,28 @@ +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) diff --git a/src/GeomValidators/GeomValidators.h b/src/GeomValidators/GeomValidators.h new file mode 100644 index 000000000..0966a483d --- /dev/null +++ b/src/GeomValidators/GeomValidators.h @@ -0,0 +1,18 @@ +#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 diff --git a/src/GeomValidators/GeomValidators_Positive.cpp b/src/GeomValidators/GeomValidators_Positive.cpp new file mode 100644 index 000000000..935bce6b4 --- /dev/null +++ b/src/GeomValidators/GeomValidators_Positive.cpp @@ -0,0 +1,27 @@ +// File: GeomValidators_ValidatorPositive.cpp +// Created: 16 Sep 2014 +// Author: Mikhail PONIKAROV + +#include "GeomValidators_Positive.h" +#include +#include +#include + +/// 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& theArguments) const +{ + boost::shared_ptr aDouble = + boost::dynamic_pointer_cast(theAttribute); + return aDouble->isInitialized() && aDouble->value() > 1.e-5; +} diff --git a/src/GeomValidators/GeomValidators_Positive.h b/src/GeomValidators/GeomValidators_Positive.h new file mode 100644 index 000000000..f526999f6 --- /dev/null +++ b/src/GeomValidators/GeomValidators_Positive.h @@ -0,0 +1,27 @@ +// File: GeomValidators_ValidatorPositive.h +// Created: 16 Sep 2014 +// Author: Mikhail PONIKAROV + +#ifndef GeomValidators_ValidatorPositive_H +#define GeomValidators_ValidatorPositive_H + +#include +#include + +/** + * 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& theArguments) const; + +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 90f54d560..1b0730b76 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -29,8 +29,6 @@ SketchPlugin_Plugin::SketchPlugin_Plugin() 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); diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 14f5aaa9b..94e5676f5 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -43,11 +43,3 @@ bool SketchPlugin_DistanceAttrValidator::isValid( } return true; // it may be not reference attribute, in this case, it is OK } - -bool SketchPlugin_RadiusValidator::isValid( - const AttributePtr& theAttribute, const std::list& theArguments) const -{ - boost::shared_ptr aDouble = - boost::dynamic_pointer_cast(theAttribute); - return aDouble->isInitialized() && aDouble->value() > 1.e-5; -} diff --git a/src/SketchPlugin/SketchPlugin_Validators.h b/src/SketchPlugin/SketchPlugin_Validators.h index 8a5a82bb0..ece17e599 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.h +++ b/src/SketchPlugin/SketchPlugin_Validators.h @@ -22,18 +22,4 @@ class SketchPlugin_DistanceAttrValidator : public ModelAPI_RefAttrValidator }; -/** - * 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& theArguments) const; - -}; - #endif diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 422db1058..47b2ccbe3 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -15,7 +15,7 @@ - +