]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix #20389
authorJérôme <jerome.lucas@cesgenslab.fr>
Thu, 26 Nov 2020 20:01:26 +0000 (21:01 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Thu, 26 Nov 2020 20:01:26 +0000 (21:01 +0100)
src/FeaturesAPI/FeaturesAPI_PointCoordinates.cpp
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.cpp
src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.h
src/FeaturesPlugin/doc/TUI_point_coordinates.rst [new file with mode: 0644]
src/FeaturesPlugin/doc/examples/point_coordinates.py [new file with mode: 0644]
src/FeaturesPlugin/doc/pointCoordinatesFeature.rst
src/FeaturesPlugin/plugin-Features.xml
src/FeaturesPlugin/point_coordinates_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/pointcoordinates_widget.xml [deleted file]
src/ModelAPI/CMakeLists.txt

index f4805ac22be129b98c2254a01077a4440ec19817..8898319f7110645facee0ca30066070884537df4 100644 (file)
 #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));
index ada07caa6fd25fc439e151959e626e8a24cc52a1..43ce7484f2eb93d1dfb92687d384bf4675891916 100644 (file)
@@ -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
index eae9d32010c27584f7767a96e5a81babb50a821d..6a6daa9c52ea2a905bca970d7ab95caf7e6fb5a5 100644 (file)
@@ -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() );
   }
 
 }
index 74b5b8c60d86fbd98780bd4cb433d930dadf6ae3..0e4451018c63f36e4d96f8adda2b11ea615b509f 100644 (file)
@@ -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 (file)
index 0000000..abc6e00
--- /dev/null
@@ -0,0 +1,12 @@
+
+  .. _tui_point_coordinates:
+
+Get point coordinates
+=====================
+
+.. literalinclude:: examples/point_coordinates.py 
+    :linenos:
+    :language: python
+
+:download:`Download this script <examples/point_coordinates.py>`
+   
diff --git a/src/FeaturesPlugin/doc/examples/point_coordinates.py b/src/FeaturesPlugin/doc/examples/point_coordinates.py
new file mode 100644 (file)
index 0000000..d7e0e0e
--- /dev/null
@@ -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()
index b90a21044ca0d352d54ab1417c2d0709302ee4ca..84717d1aad3554c5247e9ce7bb5193ac8ee0758e 100644 (file)
@@ -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
index b1b745c1ae6a71bd4a94feeb89bb5df5f24be086..926f4cfe2c221036ad16800d0d53ba2f29b54dfb 100644 (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">
diff --git a/src/FeaturesPlugin/point_coordinates_widget.xml b/src/FeaturesPlugin/point_coordinates_widget.xml
new file mode 100644 (file)
index 0000000..7e5aa11
--- /dev/null
@@ -0,0 +1,13 @@
+<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>
diff --git a/src/FeaturesPlugin/pointcoordinates_widget.xml b/src/FeaturesPlugin/pointcoordinates_widget.xml
deleted file mode 100644 (file)
index 7e5aa11..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<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>
index 7b7876165946fb970b92faf8a221c3f33b3e7693..0a49da69553130978aa63bbfcbe5e6a4f4eff73d 100644 (file)
@@ -117,7 +117,6 @@ SET(PROJECT_SOURCES
 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)
@@ -131,10 +130,6 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Config
                     ${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}
 )