From 8bc0ecf3493230331bfa21dc66a72b1a590bf42d Mon Sep 17 00:00:00 2001 From: rraphael Date: Fri, 26 Feb 2021 11:56:27 +0100 Subject: [PATCH] fix coding style --- .../CollectionPlugin_GroupAddition.h | 2 +- .../CollectionPlugin_GroupMerge.cpp | 2 +- .../CollectionPlugin_GroupMerge.h | 2 +- .../CollectionPlugin_GroupShape.cpp | 2 +- .../CollectionPlugin_GroupShape.h | 2 +- .../ConstructionPlugin_Point.cpp | 5 ++- src/ExchangeAPI/ExchangeAPI_Import.cpp | 3 +- src/ExchangePlugin/ExchangePlugin_Import.cpp | 7 +-- src/ExchangePlugin/ExchangePlugin_Import.h | 2 +- .../ExchangePlugin_ImportFeature.cpp | 5 +-- .../ExchangePlugin_ImportFeature.h | 2 +- .../FeaturesPlugin_Symmetry.cpp | 3 +- src/FeaturesPlugin/FeaturesPlugin_Tools.cpp | 5 ++- src/GeomAlgoAPI/GeomAlgoAPI_ImageImport.cpp | 5 ++- src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp | 3 +- src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h | 3 +- src/ModuleBase/ModuleBase_WidgetValidated.cpp | 6 ++- src/PartSet/PartSet_Module.cpp | 9 ++-- src/SketchAPI/SketchAPI_MacroRectangle.cpp | 34 +++++++++------ src/SketchAPI/SketchAPI_MacroRectangle.h | 3 +- src/SketchAPI/SketchAPI_Rectangle.cpp | 17 +++++--- src/SketchAPI/SketchAPI_Rectangle.h | 21 ++++++--- src/SketchAPI/SketchAPI_Sketch.cpp | 6 ++- .../SketchPlugin_MacroRectangle.cpp | 36 ++++++++++------ src/SketchPlugin/SketchPlugin_Rectangle.cpp | 43 ++++++++++++------- src/SketchPlugin/SketchPlugin_Rectangle.h | 4 +- 26 files changed, 142 insertions(+), 90 deletions(-) diff --git a/src/CollectionPlugin/CollectionPlugin_GroupAddition.h b/src/CollectionPlugin/CollectionPlugin_GroupAddition.h index d52da423b..0af701120 100644 --- a/src/CollectionPlugin/CollectionPlugin_GroupAddition.h +++ b/src/CollectionPlugin/CollectionPlugin_GroupAddition.h @@ -36,7 +36,7 @@ public: { static const std::string MY_GROUP_ID("GroupAddition"); return MY_GROUP_ID; - } + } /// Returns the kind of a feature COLLECTIONPLUGIN_EXPORT virtual const std::string& getKind() diff --git a/src/CollectionPlugin/CollectionPlugin_GroupMerge.cpp b/src/CollectionPlugin/CollectionPlugin_GroupMerge.cpp index cfef811bb..7307d4b74 100644 --- a/src/CollectionPlugin/CollectionPlugin_GroupMerge.cpp +++ b/src/CollectionPlugin/CollectionPlugin_GroupMerge.cpp @@ -80,5 +80,5 @@ void CollectionPlugin_GroupMerge::execute(ResultGroupPtr & aGroup) aGroup->store(aCompound); // update the type of selection - updateGroupType(LIST_ID()); + updateGroupType(LIST_ID()); } diff --git a/src/CollectionPlugin/CollectionPlugin_GroupMerge.h b/src/CollectionPlugin/CollectionPlugin_GroupMerge.h index e56f40fdb..8a7c2c437 100644 --- a/src/CollectionPlugin/CollectionPlugin_GroupMerge.h +++ b/src/CollectionPlugin/CollectionPlugin_GroupMerge.h @@ -31,7 +31,7 @@ */ class CollectionPlugin_GroupMerge: public CollectionPlugin_GroupOperation { -public: +public: /// attribute name of selected entities list inline static const std::string& LIST_ID() { diff --git a/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp b/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp index 0a0f90d25..037380041 100644 --- a/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp +++ b/src/CollectionPlugin/CollectionPlugin_GroupShape.cpp @@ -23,7 +23,7 @@ #include void CollectionPlugin_GroupShape::execute() -{ +{ ResultGroupPtr aGroup; CollectionPlugin_GroupMerge::execute(aGroup); GeomShapePtr aCompound = aGroup->shape(); diff --git a/src/CollectionPlugin/CollectionPlugin_GroupShape.h b/src/CollectionPlugin/CollectionPlugin_GroupShape.h index a69a7a2ba..162b43c81 100644 --- a/src/CollectionPlugin/CollectionPlugin_GroupShape.h +++ b/src/CollectionPlugin/CollectionPlugin_GroupShape.h @@ -36,7 +36,7 @@ public: { static const std::string MY_GROUP_ID("GroupShape"); return MY_GROUP_ID; - } + } /// Returns the kind of a feature COLLECTIONPLUGIN_EXPORT virtual const std::string& getKind() diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index 0129d391e..91392151b 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -144,9 +144,10 @@ void ConstructionPlugin_Point::execute() removeResults(1); // for case the point type was switched from multi-results type std::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setInfinite(true); - aConstr->setShape(aShape); + aConstr->setShape(aShape); + /// set point color aConstr->setColor(ModelAPI_ResultConstruction::ModelApi_PointColor::DEFAULT_COLOR(), - ModelAPI_ResultConstruction::ModelApi_PointColor::COLOR_CONFIG_NAME()); /// set point color + ModelAPI_ResultConstruction::ModelApi_PointColor::COLOR_CONFIG_NAME()); setResult(aConstr); } diff --git a/src/ExchangeAPI/ExchangeAPI_Import.cpp b/src/ExchangeAPI/ExchangeAPI_Import.cpp index d17f3bfa8..eee356406 100644 --- a/src/ExchangeAPI/ExchangeAPI_Import.cpp +++ b/src/ExchangeAPI/ExchangeAPI_Import.cpp @@ -244,7 +244,8 @@ void ExchangeAPI_Import_Image::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); std::string aPartName = theDumper.name(aBase->document()); - std::string aFilePath = aBase->string(ExchangePlugin_Import_ImageFeature::FILE_PATH_ID())->value(); + std::string aFilePath = + aBase->string(ExchangePlugin_Import_ImageFeature::FILE_PATH_ID())->value(); theDumper << aBase << " = model.addImportImage(" << aPartName << ", \"" << aFilePath << "\")" << std::endl; diff --git a/src/ExchangePlugin/ExchangePlugin_Import.cpp b/src/ExchangePlugin/ExchangePlugin_Import.cpp index 6157782b1..a166c9431 100644 --- a/src/ExchangePlugin/ExchangePlugin_Import.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Import.cpp @@ -74,7 +74,7 @@ void ExchangePlugin_ImportBase::initAttributes() { data()->addAttribute(FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(TARGET_PART_ID(), ModelAPI_AttributeInteger::typeId()); - data()->addAttribute(TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId()); + data()->addAttribute(TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId()); } void ExchangePlugin_Import::initAttributes() @@ -82,7 +82,7 @@ void ExchangePlugin_Import::initAttributes() ExchangePlugin_ImportBase::initAttributes(); data()->addAttribute(STEP_FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(STEP_TARGET_PART_ID(), ModelAPI_AttributeInteger::typeId()); data()->addAttribute(STEP_TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId()); data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId()); @@ -173,7 +173,8 @@ void ExchangePlugin_Import_Image::execute() if (aDoc.get()) { FeaturePtr aImportFeature = aDoc->addFeature(ExchangePlugin_Import_ImageFeature::ID()); DataPtr aData = aImportFeature->data(); - AttributeStringPtr aPathAttr = aData->string(ExchangePlugin_Import_ImageFeature::FILE_PATH_ID()); + AttributeStringPtr aPathAttr = + aData->string(ExchangePlugin_Import_ImageFeature::FILE_PATH_ID()); aPathAttr->setValue(aFilePathAttr->value()); aImportFeature->execute(); } diff --git a/src/ExchangePlugin/ExchangePlugin_Import.h b/src/ExchangePlugin/ExchangePlugin_Import.h index 7bb292894..e018bedc2 100644 --- a/src/ExchangePlugin/ExchangePlugin_Import.h +++ b/src/ExchangePlugin/ExchangePlugin_Import.h @@ -38,7 +38,7 @@ */ class ExchangePlugin_ImportBase : public ModelAPI_Feature { - public: + public: /// attribute name of file path inline static const std::string& FILE_PATH_ID() { diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index dd87d800c..e6bd0d82f 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -85,13 +85,13 @@ void ExchangePlugin_ImportFeatureBase::initAttributes() void ExchangePlugin_ImportFeature::initAttributes() { ExchangePlugin_ImportFeatureBase::initAttributes(); - + data()->addAttribute(STEP_FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId()); data()->addAttribute(STEP_COLORS_ID(), ModelAPI_AttributeBoolean::typeId()); data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId()); - + ModelAPI_Session::get()->validators()->registerNotObligatory( getKind(), ExchangePlugin_ImportFeature::STEP_COLORS_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory( @@ -206,7 +206,6 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) } // Pass the results into the model - loadNamingDS(aGeomShape, aResult); // create color group diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.h b/src/ExchangePlugin/ExchangePlugin_ImportFeature.h index fa4ac0f7f..37376e198 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.h +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.h @@ -168,7 +168,7 @@ protected: /// Performs the import of XAO file EXCHANGEPLUGIN_EXPORT void importXAO(const std::string& theFileName); -private: +private: /// Set groups of color void setColorGroups(std::shared_ptr theResultBody); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp index 6dce5b6c8..57effe32d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp @@ -203,7 +203,8 @@ GeomTrsfPtr FeaturesPlugin_Symmetry::symmetryByPlane() void FeaturesPlugin_Symmetry::buildResult( const std::shared_ptr& theAlgo, const std::list >& theOriginalShapes, - std::shared_ptr theTargetShape, int& theResultIndex, std::string & theTextureFile) + std::shared_ptr theTargetShape, int& theResultIndex, + std::string & theTextureFile) { // Store and name the result. ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp index 29654258c..e8a1af8c4 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp @@ -259,7 +259,8 @@ bool FeaturesPlugin_Tools::getShape(const AttributeSelectionListPtr theSelection } //================================================================================================== -bool FeaturesPlugin_Tools::shapesFromSelectionList(const std::shared_ptr theSelectionList, +bool FeaturesPlugin_Tools::shapesFromSelectionList( + const std::shared_ptr theSelectionList, const bool theStoreFullHierarchy, GeomAPI_ShapeHierarchy& theHierarchy, std::list& theParts, std::string &theTextureFile) @@ -270,7 +271,7 @@ bool FeaturesPlugin_Tools::shapesFromSelectionList(const std::shared_ptrvalue(0); if(anObjectAttr.get()) { - FeaturePtr aFeature = anObjectAttr->contextFeature(); + FeaturePtr aFeature = anObjectAttr->contextFeature(); if(aFeature.get() && aFeature->results().size() == 1) { theTextureFile = aFeature->firstResult()->getTextureFile(); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ImageImport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ImageImport.cpp index a95bf2b41..1f73aeef1 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ImageImport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ImageImport.cpp @@ -61,7 +61,8 @@ std::shared_ptr ImageImport(const std::string& theFileName, aTriVertexes[2] = BRepBuilderAPI_MakeVertex (aPnt3); aTriVertexes[3] = BRepBuilderAPI_MakeVertex (aPnt4); - aWire = BRepBuilderAPI_MakePolygon (aTriVertexes[0], aTriVertexes[1], aTriVertexes[2], aTriVertexes[3], Standard_True); + aWire = BRepBuilderAPI_MakePolygon (aTriVertexes[0], aTriVertexes[1], aTriVertexes[2], + aTriVertexes[3], Standard_True); BRepBuilderAPI_Sewing aSewingTool; aSewingTool.Init (1.0e-06, Standard_True); @@ -93,7 +94,7 @@ std::shared_ptr ImageImport(const std::string& theFileName, } std::shared_ptr aGeomShape(new GeomAPI_Shape); - aGeomShape->setImpl(new TopoDS_Shape(aResShape)); + aGeomShape->setImpl(new TopoDS_Shape(aResShape)); return aGeomShape; } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index 4fad7e251..a6cbafc02 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -226,7 +226,8 @@ double GeomAlgoAPI_ShapeTools::minimalDistance(const GeomShapePtr& theShape1, } double GeomAlgoAPI_ShapeTools::minimalDistance(const GeomShapePtr& theShape1, - const GeomShapePtr& theShape2, std::array & fromShape1To2) + const GeomShapePtr& theShape2, + std::array & fromShape1To2) { BRepExtrema_DistShapeShape aDist = getExtemaDistShape(theShape1, theShape2); const auto & pt1 = aDist.PointOnShape1(1); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h index 5ad2e78ac..94ee16de5 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h @@ -68,7 +68,8 @@ public: GEOMALGOAPI_EXPORT static double minimalDistance(const GeomShapePtr& theShape1, const GeomShapePtr& theShape2); GEOMALGOAPI_EXPORT static double minimalDistance(const GeomShapePtr& theShape1, - const GeomShapePtr& theShape2, std::array & fromShape1To2); + const GeomShapePtr& theShape2, + std::array & fromShape1To2); /// \brief Combines faces with common edges to shells, or solids to compsolids. /// \param[in] theCompound compound of shapes. diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index a02d2589e..90436988e 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -504,7 +504,8 @@ QList ModuleBase_WidgetValidated::getFilteredSelected() std::vector aRemove; - if (myFeatureId == BuildPlugin_Face::ID() && shapeTypes.find(GeomAPI_Shape::FACE) != shapeTypes.end()) + if (myFeatureId == BuildPlugin_Face::ID() && shapeTypes.find(GeomAPI_Shape::FACE) + != shapeTypes.end()) { for(auto aSelection: aSelected){ auto aType = aSelection->shape()->shapeType(); @@ -512,7 +513,8 @@ QList ModuleBase_WidgetValidated::getFilteredSelected() aRemove.push_back(aSelection); } } - else if (myFeatureId == BuildPlugin_Wire::ID() && shapeTypes.find(GeomAPI_Shape::WIRE) != shapeTypes.end()) + else if (myFeatureId == BuildPlugin_Wire::ID() && shapeTypes.find(GeomAPI_Shape::WIRE) + != shapeTypes.end()) { for(auto aSelection: aSelected){ auto aType = aSelection->shape()->shapeType(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 5b8075e7a..5135f7161 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -210,10 +210,11 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) "Construction color", Config_Prop::Color, ModelAPI_ResultConstruction::DEFAULT_COLOR()); - Config_PropManager::registerProp("Visualization", - ModelAPI_ResultConstruction::ModelApi_PointColor::COLOR_CONFIG_NAME(), - "Construction point color", Config_Prop::Color, - ModelAPI_ResultConstruction::ModelApi_PointColor::DEFAULT_COLOR()); + Config_PropManager::registerProp( + "Visualization", + ModelAPI_ResultConstruction::ModelApi_PointColor::COLOR_CONFIG_NAME(), + "Construction point color", Config_Prop::Color, + ModelAPI_ResultConstruction::ModelApi_PointColor::DEFAULT_COLOR()); Config_PropManager::registerProp("Visualization", "result_part_color", "Part color", diff --git a/src/SketchAPI/SketchAPI_MacroRectangle.cpp b/src/SketchAPI/SketchAPI_MacroRectangle.cpp index a619aefd2..b143c1e64 100644 --- a/src/SketchAPI/SketchAPI_MacroRectangle.cpp +++ b/src/SketchAPI/SketchAPI_MacroRectangle.cpp @@ -28,18 +28,21 @@ #include //================================================================================================== -SketchAPI_MacroRectangle::SketchAPI_MacroRectangle(const std::shared_ptr& theFeature) +SketchAPI_MacroRectangle::SketchAPI_MacroRectangle( + const std::shared_ptr& theFeature) : SketchAPI_SketchEntity(theFeature) { initialize(); } //================================================================================================== -SketchAPI_MacroRectangle::SketchAPI_MacroRectangle(const std::shared_ptr& theFeature, - double theStartX, - double theStartY, - double theSecondX, - double theSecondY, bool isFirstPointCenter): +SketchAPI_MacroRectangle::SketchAPI_MacroRectangle( + const std::shared_ptr& theFeature, + double theStartX, + double theStartY, + double theSecondX, + double theSecondY, + bool isFirstPointCenter): SketchAPI_SketchEntity(theFeature) { if(initialize()) { @@ -51,9 +54,10 @@ SketchAPI_MacroRectangle::SketchAPI_MacroRectangle(const std::shared_ptr& theFeature, - const std::shared_ptr& theStartPoint, - const std::shared_ptr& theSecondPoint, bool isFirstPointCenter): +SketchAPI_MacroRectangle::SketchAPI_MacroRectangle( + const std::shared_ptr& theFeature, + const std::shared_ptr& theStartPoint, + const std::shared_ptr& theSecondPoint, bool isFirstPointCenter): SketchAPI_SketchEntity(theFeature) { if(initialize()) { @@ -80,8 +84,9 @@ void SketchAPI_MacroRectangle::setByStartAndEndPoints(double theStartX, double t } //================================================================================================== -void SketchAPI_MacroRectangle::setByStartAndEndPoints(const std::shared_ptr& theStartPoint, - const std::shared_ptr& theEndPoint) +void SketchAPI_MacroRectangle::setByStartAndEndPoints( + const std::shared_ptr& theStartPoint, + const std::shared_ptr& theEndPoint) { fillAttribute(SketchPlugin_MacroRectangle::START_END_POINT_TYPE_ID(), rectangleType()); fillAttribute(theStartPoint, startPoint1()); @@ -91,7 +96,8 @@ void SketchAPI_MacroRectangle::setByStartAndEndPoints(const std::shared_ptr& theCenterPoint, const std::shared_ptr& theEndPoint){ +void SketchAPI_MacroRectangle::setByCenterAndEndPoints( + const std::shared_ptr& theCenterPoint, + const std::shared_ptr& theEndPoint){ fillAttribute(SketchPlugin_MacroRectangle::CENTER_END_POINT_TYPE_ID(), rectangleType()); fillAttribute(theEndPoint, endPoint2()); fillAttribute(theCenterPoint, centerPoint()); diff --git a/src/SketchAPI/SketchAPI_MacroRectangle.h b/src/SketchAPI/SketchAPI_MacroRectangle.h index c7d2c165e..dc271f3bc 100644 --- a/src/SketchAPI/SketchAPI_MacroRectangle.h +++ b/src/SketchAPI/SketchAPI_MacroRectangle.h @@ -48,7 +48,8 @@ public: SKETCHAPI_EXPORT SketchAPI_MacroRectangle(const std::shared_ptr& theFeature, const std::shared_ptr& theStartPoint, - const std::shared_ptr& theSecondPoint, bool isFirstPointCenter = false); + const std::shared_ptr& theSecondPoint, + bool isFirstPointCenter = false); /// Destructor. diff --git a/src/SketchAPI/SketchAPI_Rectangle.cpp b/src/SketchAPI/SketchAPI_Rectangle.cpp index e40b501d2..af0b62a83 100644 --- a/src/SketchAPI/SketchAPI_Rectangle.cpp +++ b/src/SketchAPI/SketchAPI_Rectangle.cpp @@ -34,7 +34,8 @@ SketchAPI_Rectangle::SketchAPI_Rectangle( } SketchAPI_Rectangle::SketchAPI_Rectangle(const std::shared_ptr & theFeature, - double theX1, double theY1, double theX2, double theY2, bool isFirstPointCenter) + double theX1, double theY1, double theX2, double theY2, + bool isFirstPointCenter) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -44,7 +45,8 @@ SketchAPI_Rectangle::SketchAPI_Rectangle(const std::shared_ptr SketchAPI_Rectangle::SketchAPI_Rectangle(const std::shared_ptr & theFeature, const std::shared_ptr & theFirstPoint, - const std::shared_ptr & theEndPoint, bool isFirstPointCenter) + const std::shared_ptr & theEndPoint, + bool isFirstPointCenter) : SketchAPI_SketchEntity(theFeature) { if (initialize()) { @@ -59,7 +61,7 @@ SketchAPI_Rectangle::~SketchAPI_Rectangle() //-------------------------------------------------------------------------------------- void SketchAPI_Rectangle::setByCoordinates( double theX1, double theY1, double theX2, double theY2, bool isFirstPointCenter) -{ +{ if(isFirstPointCenter){ fillAttribute(centerPoint(), theX1, theY1); double xStart = 2.0*theX1 - theX2; @@ -74,7 +76,8 @@ void SketchAPI_Rectangle::setByCoordinates( } void SketchAPI_Rectangle::setByPoints(const std::shared_ptr & theFirstPoint, - const std::shared_ptr & theSecondPoint, bool isFirstPointCenter) + const std::shared_ptr & theSecondPoint, + bool isFirstPointCenter) { if(isFirstPointCenter){ fillAttribute(theFirstPoint, centerPoint()); @@ -112,7 +115,8 @@ void SketchAPI_Rectangle::dump(ModelHighAPI_Dumper& theDumper) const /// do not dump sub-features eg: lines and lines constraints AttributeRefListPtr noToDumpList = aBase->reflist(SketchPlugin_Rectangle::NOT_TO_DUMP_LIST_ID()); for( int i = 0; i < noToDumpList->size(); i++){ - theDumper.doNotDumpFeature(std::dynamic_pointer_cast(noToDumpList->object(i))); + theDumper.doNotDumpFeature( + std::dynamic_pointer_cast(noToDumpList->object(i))); } if (isCopy()) @@ -120,7 +124,8 @@ void SketchAPI_Rectangle::dump(ModelHighAPI_Dumper& theDumper) const const std::string& aSketchName = theDumper.parentName(aBase); - FeaturePtr aCenterPointFeature = std::dynamic_pointer_cast(aBase->refattr(SketchPlugin_Rectangle::CENTER_REF_ID())->object()); + FeaturePtr aCenterPointFeature = std::dynamic_pointer_cast( + aBase->refattr(SketchPlugin_Rectangle::CENTER_REF_ID())->object()); if(aCenterPointFeature){ // rectangle has center theDumper << aBase << " = " << aSketchName << ".addRectangle(" diff --git a/src/SketchAPI/SketchAPI_Rectangle.h b/src/SketchAPI/SketchAPI_Rectangle.h index b2fd70670..2ef409332 100644 --- a/src/SketchAPI/SketchAPI_Rectangle.h +++ b/src/SketchAPI/SketchAPI_Rectangle.h @@ -42,26 +42,33 @@ public: /// Constructor with values SKETCHAPI_EXPORT SketchAPI_Rectangle(const std::shared_ptr & theFeature, - double theX1, double theY1, double theX2, double theY2, bool isFirstPointCenter = false); + double theX1, double theY1, double theX2, double theY2, + bool isFirstPointCenter = false); /// Constructor with values SKETCHAPI_EXPORT SketchAPI_Rectangle(const std::shared_ptr & theFeature, const std::shared_ptr & theFirstPoint, - const std::shared_ptr & theEndPoint, bool isFirstPointCenter = false); + const std::shared_ptr & theEndPoint, + bool isFirstPointCenter = false); /// Destructor SKETCHAPI_EXPORT virtual ~SketchAPI_Rectangle(); INTERFACE_4(SketchPlugin_Rectangle::ID(), - startPoint, SketchPlugin_Rectangle::START_ID(), GeomDataAPI_Point2D, /** Start point */, - endPoint, SketchPlugin_Rectangle::END_ID(), GeomDataAPI_Point2D, /** End point */, - centerPoint, SketchPlugin_Rectangle::CENTER_ID(), GeomDataAPI_Point2D, /** Center point */, - linesList, SketchPlugin_Rectangle::LINES_LIST_ID(), ModelAPI_AttributeRefList, /** Lines list */ + startPoint, SketchPlugin_Rectangle::START_ID(), GeomDataAPI_Point2D, + /** Start point */, + endPoint, SketchPlugin_Rectangle::END_ID(), GeomDataAPI_Point2D, + /** End point */, + centerPoint, SketchPlugin_Rectangle::CENTER_ID(), GeomDataAPI_Point2D, + /** Center point */, + linesList, SketchPlugin_Rectangle::LINES_LIST_ID(), ModelAPI_AttributeRefList, + /** Lines list */ ) /// Set by coordinates SKETCHAPI_EXPORT - void setByCoordinates(double theX1, double theY1, double theX2, double theY2, bool isFirstPointCenter); + void setByCoordinates(double theX1, double theY1, double theX2, double theY2, + bool isFirstPointCenter); /// Set by points SKETCHAPI_EXPORT diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp index cd9851de2..de5799715 100644 --- a/src/SketchAPI/SketchAPI_Sketch.cpp +++ b/src/SketchAPI/SketchAPI_Sketch.cpp @@ -430,7 +430,8 @@ std::shared_ptr SketchAPI_Sketch::addRectangle( { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID()); - return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1, theX2, theY2, isFirstPointCenter)); + return RectanglePtr(new SketchAPI_Rectangle(aFeature, theX1, theY1, + theX2, theY2, isFirstPointCenter)); } std::shared_ptr SketchAPI_Sketch::addRectangle( const std::shared_ptr & theFirstPoint, @@ -438,7 +439,8 @@ std::shared_ptr SketchAPI_Sketch::addRectangle( { std::shared_ptr aFeature = compositeFeature()->addFeature(SketchAPI_Rectangle::ID()); - return RectanglePtr(new SketchAPI_Rectangle(aFeature, theFirstPoint, theEndPoint, isFirstPointCenter)); + return RectanglePtr(new SketchAPI_Rectangle(aFeature, theFirstPoint, theEndPoint, + isFirstPointCenter)); } std::shared_ptr SketchAPI_Sketch::addRectangleCentered( diff --git a/src/SketchPlugin/SketchPlugin_MacroRectangle.cpp b/src/SketchPlugin/SketchPlugin_MacroRectangle.cpp index ff1c97321..1541f8433 100644 --- a/src/SketchPlugin/SketchPlugin_MacroRectangle.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroRectangle.cpp @@ -47,8 +47,7 @@ const double tolerance = 1e-7; SketchPlugin_MacroRectangle::SketchPlugin_MacroRectangle() : SketchPlugin_SketchEntity(), myHasCenterPoint(false) -{ -} +{} void SketchPlugin_MacroRectangle::initAttributes() { @@ -139,32 +138,41 @@ void SketchPlugin_MacroRectangle::execute() if(myHasCenterPoint){ std::dynamic_pointer_cast( - myRectangleFeature->attribute(SketchPlugin_Rectangle::CENTER_ID()))->setValue(myCenterPoint->x(), - myCenterPoint->y()); + myRectangleFeature->attribute( + SketchPlugin_Rectangle::CENTER_ID()))->setValue(myCenterPoint->x(), + myCenterPoint->y()); } std::dynamic_pointer_cast( - myRectangleFeature->attribute(SketchPlugin_Rectangle::START_ID()))->setValue(myStartPoint->x(), - myStartPoint->y()); + myRectangleFeature->attribute( + SketchPlugin_Rectangle::START_ID()))->setValue(myStartPoint->x(), + myStartPoint->y()); std::dynamic_pointer_cast( - myRectangleFeature->attribute(SketchPlugin_Rectangle::END_ID()))->setValue(myEndPoint->x(), - myEndPoint->y()); + myRectangleFeature->attribute( + SketchPlugin_Rectangle::END_ID()))->setValue(myEndPoint->x(), + myEndPoint->y()); myRectangleFeature->boolean(SketchPlugin_Rectangle::AUXILIARY_ID()) ->setValue(boolean(AUXILIARY_ID())->value()); myRectangleFeature->execute(); /// create coincidences with rectangle start/center and end points - AttributeRefListPtr aLinesList = myRectangleFeature->reflist(SketchPlugin_Rectangle::LINES_LIST_ID()); - FeaturePtr aRectangleStartLineFeature = std::dynamic_pointer_cast(aLinesList->object(0)); - FeaturePtr aRectangleEndLineFeature = std::dynamic_pointer_cast(aLinesList->object(2)); + AttributeRefListPtr aLinesList = + myRectangleFeature->reflist(SketchPlugin_Rectangle::LINES_LIST_ID()); + FeaturePtr aRectangleStartLineFeature = + std::dynamic_pointer_cast(aLinesList->object(0)); + FeaturePtr aRectangleEndLineFeature = + std::dynamic_pointer_cast(aLinesList->object(2)); std::shared_ptr aRectanglePointEndAttr = - std::dynamic_pointer_cast(aRectangleEndLineFeature->attribute(SketchPlugin_Line::END_ID())); + std::dynamic_pointer_cast( + aRectangleEndLineFeature->attribute(SketchPlugin_Line::END_ID())); std::shared_ptr aRectanglePointStartAttr = - std::dynamic_pointer_cast(aRectangleStartLineFeature->attribute(SketchPlugin_Line::END_ID())); + std::dynamic_pointer_cast( + aRectangleStartLineFeature->attribute(SketchPlugin_Line::END_ID())); if(myHasCenterPoint){ - FeaturePtr aCenterPointFeature = std::dynamic_pointer_cast(myRectangleFeature->refattr(CENTER_REF_ID())->object()); + FeaturePtr aCenterPointFeature = std::dynamic_pointer_cast( + myRectangleFeature->refattr(CENTER_REF_ID())->object()); SketchPlugin_Tools::createCoincidenceOrTangency( this, CENTER_REF_ID(), AttributePtr(), aCenterPointFeature, false); SketchPlugin_Tools::createCoincidenceOrTangency( diff --git a/src/SketchPlugin/SketchPlugin_Rectangle.cpp b/src/SketchPlugin/SketchPlugin_Rectangle.cpp index 22feb52a8..b598158b3 100644 --- a/src/SketchPlugin/SketchPlugin_Rectangle.cpp +++ b/src/SketchPlugin/SketchPlugin_Rectangle.cpp @@ -102,9 +102,11 @@ void SketchPlugin_Rectangle::updateLines() { FeaturePtr aLine = std::dynamic_pointer_cast(aLinesList->object(i)); std::shared_ptr aLineStart = - std::dynamic_pointer_cast(aLine->attribute(SketchPlugin_Line::START_ID())); + std::dynamic_pointer_cast( + aLine->attribute(SketchPlugin_Line::START_ID())); std::shared_ptr aLineEnd = - std::dynamic_pointer_cast(aLine->attribute(SketchPlugin_Line::END_ID())); + std::dynamic_pointer_cast( + aLine->attribute(SketchPlugin_Line::END_ID())); aLineStart->setValue(aX[(i+3)%4], aY[(i+3)%4]); aLineEnd->setValue(aX[i], aY[i]); aLine->data()->boolean(AUXILIARY_ID())->setValue(anAuxiliary); @@ -112,8 +114,10 @@ void SketchPlugin_Rectangle::updateLines() if(aDiagonalList->size()) { auto aDiagonalPoint = cornerToDiagonalLinePoints[i]; - FeaturePtr aDiagonal = std::dynamic_pointer_cast(aDiagonalList->object(aDiagonalPoint.first)); - std::dynamic_pointer_cast(aDiagonal->attribute(aDiagonalPoint.second))->setValue(aX[(i+3)%4], aY[(i+3)%4]); + FeaturePtr aDiagonal = std::dynamic_pointer_cast( + aDiagonalList->object(aDiagonalPoint.first)); + std::dynamic_pointer_cast( + aDiagonal->attribute(aDiagonalPoint.second))->setValue(aX[(i+3)%4], aY[(i+3)%4]); } } } @@ -134,7 +138,8 @@ void SketchPlugin_Rectangle::updateStartPoint() { FeaturePtr aLine = std::dynamic_pointer_cast(aLinesList->object(i)); std::shared_ptr aLineStart = - std::dynamic_pointer_cast(aLine->attribute(SketchPlugin_Line::END_ID())); + std::dynamic_pointer_cast( + aLine->attribute(SketchPlugin_Line::END_ID())); aLineStart->setValue(aXStart, aYStart); } } @@ -194,9 +199,11 @@ void SketchPlugin_Rectangle::execute() for(int i = 0; i < 2; i++) { - FeaturePtr aDiagonal = std::dynamic_pointer_cast(aDiagonalList->object(i)); - FeaturePtr aConstraint = SketchPlugin_Tools::createConstraintAttrObject(aSketch, SketchPlugin_ConstraintCoincidence::ID(), - aCoord, aDiagonal); + FeaturePtr aDiagonal = std::dynamic_pointer_cast( + aDiagonalList->object(i)); + FeaturePtr aConstraint = SketchPlugin_Tools::createConstraintAttrObject( + aSketch, SketchPlugin_ConstraintCoincidence::ID(), + aCoord, aDiagonal); aNotToDumpList->append(aConstraint); } } @@ -208,19 +215,22 @@ void SketchPlugin_Rectangle::execute() /// connect neighbor lines by coincidence unsigned iPrev = (i+3)%4; FeaturePtr aPrevLine = std::dynamic_pointer_cast(aLinesList->object(iPrev)); - FeaturePtr aConstraint = SketchPlugin_Tools::createConstraintAttrAttr(aSketch, SketchPlugin_ConstraintCoincidence::ID(), - aPrevLine->attribute(SketchPlugin_Line::END_ID()), - aLine->attribute(SketchPlugin_Line::START_ID())); + FeaturePtr aConstraint = SketchPlugin_Tools::createConstraintAttrAttr( + aSketch, SketchPlugin_ConstraintCoincidence::ID(), + aPrevLine->attribute(SketchPlugin_Line::END_ID()), + aLine->attribute(SketchPlugin_Line::START_ID())); aNotToDumpList->append(aConstraint); /// case of rectangle created from its center if(aDiagonalList->size()) { auto aDiagonalPoint = cornerToDiagonalLinePoints[i]; - FeaturePtr aDiagonal = std::dynamic_pointer_cast(aDiagonalList->object(aDiagonalPoint.first)); - FeaturePtr aConstraint = SketchPlugin_Tools::createConstraintAttrAttr(aSketch, SketchPlugin_ConstraintCoincidence::ID(), - aDiagonal->attribute(aDiagonalPoint.second), - aLine->attribute(SketchPlugin_Line::START_ID())); + FeaturePtr aDiagonal = std::dynamic_pointer_cast( + aDiagonalList->object(aDiagonalPoint.first)); + FeaturePtr aConstraint = SketchPlugin_Tools::createConstraintAttrAttr( + aSketch, SketchPlugin_ConstraintCoincidence::ID(), + aDiagonal->attribute(aDiagonalPoint.second), + aLine->attribute(SketchPlugin_Line::START_ID())); aNotToDumpList->append(aConstraint); } } @@ -283,7 +293,8 @@ void SketchPlugin_Rectangle::execute() aSubs.push_back(aDiagonalResult->shape()); } - FeaturePtr aCenterPointFeature = std::dynamic_pointer_cast(refattr(CENTER_REF_ID())->object()); + FeaturePtr aCenterPointFeature = std::dynamic_pointer_cast( + refattr(CENTER_REF_ID())->object()); if(aCenterPointFeature) { ResultPtr aCenterResult = aCenterPointFeature->lastResult(); diff --git a/src/SketchPlugin/SketchPlugin_Rectangle.h b/src/SketchPlugin/SketchPlugin_Rectangle.h index 72bef0d6a..a39621729 100644 --- a/src/SketchPlugin/SketchPlugin_Rectangle.h +++ b/src/SketchPlugin/SketchPlugin_Rectangle.h @@ -116,8 +116,8 @@ protected: private: /// \brief updateLines crates lines from start and en points - void updateLines(); - void updateStartPoint(); + void updateLines(); + void updateStartPoint(); }; -- 2.30.2