From 2eaafb182129c24c711adcc75ecacd74ce917141 Mon Sep 17 00:00:00 2001 From: spo Date: Tue, 3 Nov 2015 17:00:04 +0300 Subject: [PATCH] Remove linking to GeomValidators. --- src/GeomValidators/GeomValidators_Tools.cpp | 26 --------- src/GeomValidators/GeomValidators_Tools.h | 4 -- src/ModuleBase/CMakeLists.txt | 2 - src/ModuleBase/ModuleBase_Tools.cpp | 58 ++++++++++++++++++- src/ModuleBase/ModuleBase_Tools.h | 12 ++++ .../ModuleBase_WidgetMultiSelector.h | 1 - src/ModuleBase/ModuleBase_WidgetSelector.cpp | 5 +- .../ModuleBase_WidgetShapeSelector.cpp | 7 +-- .../ModuleBase_WidgetShapeSelector.h | 1 - src/PartSet/CMakeLists.txt | 2 - src/PartSet/PartSet_CustomPrs.cpp | 2 - src/PartSet/PartSet_OperationPrs.cpp | 2 - src/PartSet/PartSet_Validators.cpp | 1 - src/SketchPlugin/CMakeLists.txt | 2 - src/SketchPlugin/SketchPlugin_Validators.cpp | 4 +- 15 files changed, 73 insertions(+), 56 deletions(-) diff --git a/src/GeomValidators/GeomValidators_Tools.cpp b/src/GeomValidators/GeomValidators_Tools.cpp index 7f16f0814..ef49c197d 100644 --- a/src/GeomValidators/GeomValidators_Tools.cpp +++ b/src/GeomValidators/GeomValidators_Tools.cpp @@ -36,30 +36,4 @@ namespace GeomValidators_Tools { return anObject; } - TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape) - { - TopAbs_ShapeEnum aShapeType = theShape.ShapeType(); - - // for compounds check sub-shapes: it may be compound of needed type: - // Booleans may produce compounds of Solids - if (aShapeType == TopAbs_COMPOUND) { - for(TopoDS_Iterator aSubs(theShape); aSubs.More(); aSubs.Next()) { - if (!aSubs.Value().IsNull()) { - TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType(); - if (aSubType == TopAbs_COMPOUND) { // compound of compound(s) - aShapeType = TopAbs_COMPOUND; - break; - } - if (aShapeType == TopAbs_COMPOUND) { - aShapeType = aSubType; - } else if (aShapeType != aSubType) { // compound of shapes of different types - aShapeType = TopAbs_COMPOUND; - break; - } - } - } - } - return aShapeType; - } - } diff --git a/src/GeomValidators/GeomValidators_Tools.h b/src/GeomValidators/GeomValidators_Tools.h index 83a2c3f66..3912db484 100644 --- a/src/GeomValidators/GeomValidators_Tools.h +++ b/src/GeomValidators/GeomValidators_Tools.h @@ -20,10 +20,6 @@ namespace GeomValidators_Tools /// \param theObj an object GEOMVALIDATORS_EXPORT ObjectPtr getObject(const AttributePtr& theAttribute); - // Returns the object from the attribute - /// \param theObj an object - GEOMVALIDATORS_EXPORT TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape); - }; #endif diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 3bd1fba4f..5d6e49ef8 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -113,7 +113,6 @@ SET(PROJECT_LIBRARIES GeomAPI GeomDataAPI GeomAlgoAPI - GeomValidators ${QT_LIBRARIES} ${CAS_VIEWER} ${CAS_KERNEL} @@ -141,7 +140,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/src/GeomDataAPI ${CMAKE_SOURCE_DIR}/src/GeomAPI ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI - ${CMAKE_SOURCE_DIR}/src/GeomValidators ${SUIT_INCLUDE} ) diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index d2009ac41..5d3643ab7 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -7,14 +7,18 @@ #include "ModuleBase_Tools.h" #include -#include -#include #include #include -#include +#include +#include +#include +#include #include +#include #include +#include + #include #include @@ -266,6 +270,54 @@ Quantity_Color color(const std::string& theSection, return Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB); } +ObjectPtr getObject(const AttributePtr& theAttribute) +{ + ObjectPtr anObject; + std::string anAttrType = theAttribute->attributeType(); + if (anAttrType == ModelAPI_AttributeRefAttr::typeId()) { + AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttribute); + if (anAttr != NULL && anAttr->isObject()) + anObject = anAttr->object(); + } + if (anAttrType == ModelAPI_AttributeSelection::typeId()) { + AttributeSelectionPtr anAttr = std::dynamic_pointer_cast(theAttribute); + if (anAttr != NULL) + anObject = anAttr->context(); + } + if (anAttrType == ModelAPI_AttributeReference::typeId()) { + AttributeReferencePtr anAttr = std::dynamic_pointer_cast(theAttribute); + if (anAttr.get() != NULL) + anObject = anAttr->value(); + } + return anObject; +} + +TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape) +{ + TopAbs_ShapeEnum aShapeType = theShape.ShapeType(); + + // for compounds check sub-shapes: it may be compound of needed type: + // Booleans may produce compounds of Solids + if (aShapeType == TopAbs_COMPOUND) { + for(TopoDS_Iterator aSubs(theShape); aSubs.More(); aSubs.Next()) { + if (!aSubs.Value().IsNull()) { + TopAbs_ShapeEnum aSubType = aSubs.Value().ShapeType(); + if (aSubType == TopAbs_COMPOUND) { // compound of compound(s) + aShapeType = TopAbs_COMPOUND; + break; + } + if (aShapeType == TopAbs_COMPOUND) { + aShapeType = aSubType; + } else if (aShapeType != aSubType) { // compound of shapes of different types + aShapeType = TopAbs_COMPOUND; + break; + } + } + } + } + return aShapeType; } +} // namespace ModuleBase_Tools + diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 600a5334f..f78e9b755 100755 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -10,7 +10,9 @@ #include "ModuleBase.h" #include "ModuleBase_Definitions.h" +#include #include + #include #include #include @@ -120,6 +122,16 @@ MODULEBASE_EXPORT void setDefaultDeviationCoefficient(const TopoDS_Shape& theSha MODULEBASE_EXPORT Quantity_Color color(const std::string& theSection, const std::string& theName, const std::string& theDefault); + + +// Returns the object from the attribute +/// \param theObj an object +MODULEBASE_EXPORT ObjectPtr getObject(const AttributePtr& theAttribute); + +// Returns the object from the attribute +/// \param theObj an object +MODULEBASE_EXPORT TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape); + } #endif diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index d3a9b8a09..d8df98aa3 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -29,7 +29,6 @@ class QWidget; class QListWidget; class QComboBox; class ModuleBase_IWorkshop; -class GeomValidators_ShapeType; class QAction; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 130079870..061635320 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -8,11 +8,10 @@ #include #include +#include #include -#include - #include ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent, @@ -90,7 +89,7 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape, // for compounds check sub-shapes: it may be compound of needed type: // Booleans may produce compounds of Solids if (aShapeType == TopAbs_COMPOUND) { - aShapeType = GeomValidators_Tools::getCompoundSubType(aTopoShape); + aShapeType = ModuleBase_Tools::getCompoundSubType(aTopoShape); } } diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 1e60ec404..47fc4b44c 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -141,7 +140,7 @@ QList ModuleBase_WidgetShapeSelector::getAttributeSelectio DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); - ObjectPtr anObject = GeomValidators_Tools::getObject(anAttribute); + ObjectPtr anObject = ModuleBase_Tools::getObject(anAttribute); TopoDS_Shape aShape; std::shared_ptr aShapePtr = getShape(); if (aShapePtr.get()) { @@ -222,7 +221,7 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() isNameUpdated = true; } if (!isNameUpdated) { - ObjectPtr anObject = GeomValidators_Tools::getObject(myFeature->attribute(attributeID())); + ObjectPtr anObject = ModuleBase_Tools::getObject(myFeature->attribute(attributeID())); if (anObject.get() != NULL) { std::string aName = anObject->data()->name(); myTextLine->setText(QString::fromStdString(aName)); @@ -252,7 +251,7 @@ void ModuleBase_WidgetShapeSelector::storeAttributeValue() DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); - myObject = GeomValidators_Tools::getObject(anAttribute); + myObject = ModuleBase_Tools::getObject(anAttribute); myShape = getShape(); myRefAttribute = AttributePtr(); myIsObject = false; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index 650d5b1e1..2c8a10363 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -27,7 +27,6 @@ class QLineEdit; class QToolButton; class ModuleBase_IWorkshop; class ModelAPI_Validator; -class GeomValidators_ShapeType; /** * \ingroup GUI diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 39ff91869..31ba5f79e 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -66,7 +66,6 @@ SET(PROJECT_LIBRARIES ModuleBase Config GeomAPI - GeomValidators GeomDataAPI SketcherPrs ${QT_LIBRARIES} @@ -104,7 +103,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI ${CMAKE_SOURCE_DIR}/src/FeaturesPlugin ${CMAKE_SOURCE_DIR}/src/PartSetPlugin ${CMAKE_SOURCE_DIR}/src/GeomAPI - ${CMAKE_SOURCE_DIR}/src/GeomValidators ${CMAKE_SOURCE_DIR}/src/AppElements ${CAS_INCLUDE_DIRS} ${SUIT_INCLUDE} diff --git a/src/PartSet/PartSet_CustomPrs.cpp b/src/PartSet/PartSet_CustomPrs.cpp index ab7a858fb..ab96e5538 100755 --- a/src/PartSet/PartSet_CustomPrs.cpp +++ b/src/PartSet/PartSet_CustomPrs.cpp @@ -15,8 +15,6 @@ #include #include -#include - #include #include diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index 58b5a53f5..9f52a502d 100755 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -25,8 +25,6 @@ #include #include -#include - #include #include diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index cc80fc8c8..a53eb3596 100755 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 508a74049..2ef3a06b4 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -72,7 +72,6 @@ SET(PROJECT_LIBRARIES Config GeomAPI GeomAlgoAPI - GeomValidators ModelAPI SketcherPrs GeomDataAPI @@ -93,7 +92,6 @@ INCLUDE_DIRECTORIES( ../GeomAPI ../GeomAlgoAPI ../GeomDataAPI - ../GeomValidators ../SketcherPrs ) diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index ee7121371..a432becda 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -27,8 +27,6 @@ #include #include -#include - #include @@ -56,7 +54,7 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribut ObjectPtr anObject = aRefAttr->object(); const ModelAPI_AttributeValidator* aShapeValidator = - dynamic_cast(aFactory->validator("GeomValidators_ShapeType")); + dynamic_cast(aFactory->validator("GeomValidators_ShapeType")); std::list anArguments; anArguments.push_back("circle"); std::string aCircleError; -- 2.30.2