#include <ModelHighAPI_Services.h>
#include <ModelHighAPI_Tools.h>
-std::list<double> getPointCoordinates(const std::shared_ptr<ModelAPI_Document>& thePart,
- const ModelHighAPI_Selection& thePoint)
+std::list<double> getPointCoordinates(const std::shared_ptr<ModelAPI_Document>& 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<double> res;
// obtain result
AttributeDoubleArrayPtr aResult = std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(
- 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));
# 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
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
// 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());
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());
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() );
}
}
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.
--- /dev/null
+
+ .. _tui_point_coordinates:
+
+Get point coordinates
+=====================
+
+.. literalinclude:: examples/point_coordinates.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/point_coordinates.py>`
+
--- /dev/null
+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()
- 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
<group id="PointCoordinates">
<feature id="PointCoordinates" title="Point coordinates" tooltip="View point coordinate"
icon="icons/Features/point_coord.png" helpfile="pointCoordinatesFeature.html" abort_confirmation="false">
- <source path="pointcoordinates_widget.xml"/>
+ <source path="point_coordinates_widget.xml"/>
</feature>
</group>
<group id="Calculation">
--- /dev/null
+<source>
+ <shape_selector id="point_selected"
+ icon="icons/Features/point.png"
+ label="Edge"
+ tooltip="Select a point"
+ shape_types="vertex"
+ default="">
+ <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+ </shape_selector>
+ <label id="xcoordinate" isSelectable = "true"/>
+ <label id="ycoordinate" isSelectable = "true"/>
+ <label id="zcoordinate" isSelectable = "true"/>
+</source>
+++ /dev/null
-<source>
- <shape_selector id="point_selected"
- icon="icons/Features/point.png"
- label="Edge"
- tooltip="Select a point"
- shape_types="vertex"
- default="">
- <validator id="GeomValidators_ShapeType" parameters="vertex"/>
- </shape_selector>
- <label id="xcoordinate" isSelectable = "true"/>
- <label id="ycoordinate" isSelectable = "true"/>
- <label id="zcoordinate" isSelectable = "true"/>
-</source>
SET(PROJECT_LIBRARIES
Config
GeomAPI
- ${OpenCASCADE_ApplicationFramework_LIBRARIES}
)
SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473)
ADD_DEFINITIONS(-DMODELAPI_EXPORTS)
${PROJECT_SOURCE_DIR}/src/GeomAPI
${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
${PROJECT_SOURCE_DIR}/src/Locale
- ${OpenCASCADE_INCLUDE_DIR}
- ${OpenCASCADE_DataExchange_LIBRARIES}
- ${OpenCASCADE_ModelingAlgorithms_LIBRARIES}
- ${OpenCASCADE_ApplicationFramework_LIBRARIES}
)