From: Jérôme Date: Thu, 26 Nov 2020 20:01:26 +0000 (+0100) Subject: Fix #20389 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=51cc0c8484462da00b834e951cad2884756ebef6;p=modules%2Fshaper.git Fix #20389 --- diff --git a/src/FeaturesAPI/FeaturesAPI_PointCoordinates.cpp b/src/FeaturesAPI/FeaturesAPI_PointCoordinates.cpp index f4805ac22..8898319f7 100644 --- a/src/FeaturesAPI/FeaturesAPI_PointCoordinates.cpp +++ b/src/FeaturesAPI/FeaturesAPI_PointCoordinates.cpp @@ -24,18 +24,18 @@ #include #include -std::list getPointCoordinates(const std::shared_ptr& thePart, - const ModelHighAPI_Selection& thePoint) +std::list getPointCoordinates(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& thePoint) { - FeaturePtr aPointCoodFeat = thePart->addFeature(FeaturesPlugin_PointCoordinates::ID()); + FeaturePtr aPointCoordFeat = thePart->addFeature(FeaturesPlugin_PointCoordinates::ID()); - fillAttribute(thePoint, aPointCoodFeat + fillAttribute(thePoint, aPointCoordFeat ->selection(FeaturesPlugin_PointCoordinates::POINT_SELECTED_ID())); std::list res; // obtain result AttributeDoubleArrayPtr aResult = std::dynamic_pointer_cast( - aPointCoodFeat->attribute(FeaturesPlugin_PointCoordinates::RESULT_VALUES_ID())); + aPointCoordFeat->attribute(FeaturesPlugin_PointCoordinates::RESULT_VALUES_ID())); for ( int i : {0, 1, 2}) res.push_back( aResult->value(i)); diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index ada07caa6..43ce7484f 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -24,7 +24,6 @@ INCLUDE(UseQtExt) # additional include directories INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GeomDataAPI ${PROJECT_SOURCE_DIR}/src/Locale - ${PROJECT_SOURCE_DIR}/src/PrimitivesPlugin ${QT_INCLUDES}) # additional preprocessor / compiler flags @@ -157,7 +156,7 @@ SET(XML_RESOURCES fillet_widget.xml fillet1d_widget.xml measurement_widget.xml - pointcoordinates_widget.xml + point_coordinates_widget.xml fusion_faces_widget.xml chamfer_widget.xml copy_widget.xml diff --git a/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.cpp b/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.cpp index eae9d3201..6a6daa9c5 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.cpp @@ -46,9 +46,9 @@ void FeaturesPlugin_PointCoordinates::initAttributes() // attribute for point selected data()->addAttribute(POINT_SELECTED_ID(), ModelAPI_AttributeSelection::typeId()); // attributes for result message and values - data()->addAttribute(X_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Y_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Z_COOD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(X_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Y_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Z_COORD_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(RESULT_VALUES_ID(), ModelAPI_AttributeDoubleArray::typeId()); @@ -77,8 +77,7 @@ void FeaturesPlugin_PointCoordinates::attributeChanged(const std::string& theID) if (!aShape && aSelection->context()) aShape = aSelection->context()->shape(); } - if (aShape){ - + if (aShape) { aPoint = GeomAlgoAPI_PointBuilder::point(aShape); streamx << std::setprecision(14) << aPoint->x(); aValues->setValue(0, aPoint->x()); @@ -88,9 +87,9 @@ void FeaturesPlugin_PointCoordinates::attributeChanged(const std::string& theID) aValues->setValue(2, aPoint->z()); } - string(X_COOD_ID() )->setValue( "X = " + streamx.str() ); - string(Y_COOD_ID() )->setValue( "Y = " + streamy.str() ); - string(Z_COOD_ID() )->setValue( "Z = " + streamz.str() ); + string(X_COORD_ID() )->setValue( "X = " + streamx.str() ); + string(Y_COORD_ID() )->setValue( "Y = " + streamy.str() ); + string(Z_COORD_ID() )->setValue( "Z = " + streamz.str() ); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.h b/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.h index 74b5b8c60..0e4451018 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.h +++ b/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.h @@ -52,25 +52,25 @@ public: return MY_POINT_SELECTED_ID; } - /// Attribute name for x coodinate. - inline static const std::string& X_COOD_ID() + /// Attribute name for x coordinate. + inline static const std::string& X_COORD_ID() { - static const std::string MY_X_COOOD_ID("xcoordinate"); - return MY_X_COOOD_ID; + static const std::string MY_X_COORD_ID("xcoordinate"); + return MY_X_COORD_ID; } - /// Attribute name for y coodinate. - inline static const std::string& Y_COOD_ID() + /// Attribute name for y coordinate. + inline static const std::string& Y_COORD_ID() { - static const std::string MY_Y_COOOD_ID("ycoordinate"); - return MY_Y_COOOD_ID; + static const std::string MY_Y_COORD_ID("ycoordinate"); + return MY_Y_COORD_ID; } - /// Attribute name for z coodinate. - inline static const std::string& Z_COOD_ID() + /// Attribute name for z coordinate. + inline static const std::string& Z_COORD_ID() { - static const std::string MY_Z_COOOD_ID("zcoordinate"); - return MY_Z_COOOD_ID; + static const std::string MY_Z_COORD_ID("zcoordinate"); + return MY_Z_COORD_ID; } /// Attribute name for values of result. diff --git a/src/FeaturesPlugin/doc/TUI_point_coordinates.rst b/src/FeaturesPlugin/doc/TUI_point_coordinates.rst new file mode 100644 index 000000000..abc6e003a --- /dev/null +++ b/src/FeaturesPlugin/doc/TUI_point_coordinates.rst @@ -0,0 +1,12 @@ + + .. _tui_point_coordinates: + +Get point coordinates +===================== + +.. literalinclude:: examples/point_coordinates.py + :linenos: + :language: python + +:download:`Download this script ` + diff --git a/src/FeaturesPlugin/doc/examples/point_coordinates.py b/src/FeaturesPlugin/doc/examples/point_coordinates.py new file mode 100644 index 000000000..d7e0e0eee --- /dev/null +++ b/src/FeaturesPlugin/doc/examples/point_coordinates.py @@ -0,0 +1,13 @@ +import os +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +coordinates = model.getPointCoordinates(Part_1_doc,model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]")) +print(" x: ", coordinates[0]) +print(" y: ", coordinates[1]) +print(" z: ", coordinates[2]) +model.end() diff --git a/src/FeaturesPlugin/doc/pointCoordinatesFeature.rst b/src/FeaturesPlugin/doc/pointCoordinatesFeature.rst index b90a21044..84717d1aa 100644 --- a/src/FeaturesPlugin/doc/pointCoordinatesFeature.rst +++ b/src/FeaturesPlugin/doc/pointCoordinatesFeature.rst @@ -26,3 +26,13 @@ Input fields: - Input field contains a point selected in 3D OCC viewer or object browser. Note, the coordinates displayed can be selected. + +**TUI Command**: + +.. py:function:: model.getPointCoordinates(Part_doc, point) + + :param part: The current part object. + :param object: A point in format *model.selection("VERTEX", shape)*. + :return: list of coordinates. + +**See Also** a sample TUI Script of :ref:`tui_point_coordinates` operation. \ No newline at end of file diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index b1b745c1a..926f4cfe2 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -175,7 +175,7 @@ - + diff --git a/src/FeaturesPlugin/point_coordinates_widget.xml b/src/FeaturesPlugin/point_coordinates_widget.xml new file mode 100644 index 000000000..7e5aa1151 --- /dev/null +++ b/src/FeaturesPlugin/point_coordinates_widget.xml @@ -0,0 +1,13 @@ + + + + +