Salome HOME
CEA : Lot2 - Point coordinates
authorcg246364 <clarisse.genrault@cea.fr>
Sun, 3 Jan 2021 14:03:52 +0000 (15:03 +0100)
committercg246364 <clarisse.genrault@cea.fr>
Wed, 20 Jan 2021 14:22:42 +0000 (15:22 +0100)
24 files changed:
src/Config/Config_Keywords.h
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_PointCoordinates.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_PointCoordinates.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_swig.h
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts
src/FeaturesPlugin/Test/TestPointCoordinates.py [new file with mode: 0644]
src/FeaturesPlugin/doc/FeaturesPlugin.rst
src/FeaturesPlugin/doc/TUI_pointCoordinates.rst [new file with mode: 0644]
src/FeaturesPlugin/doc/examples/point_coordinates.py [new file with mode: 0644]
src/FeaturesPlugin/doc/images/pointCoordinatesPropertyPanel.png [new file with mode: 0644]
src/FeaturesPlugin/doc/images/point_coord.png [new file with mode: 0644]
src/FeaturesPlugin/doc/pointCoordinatesFeature.rst [new file with mode: 0644]
src/FeaturesPlugin/icons/point_coord.png [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/FeaturesPlugin/point_coordinates_widget.xml [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetLabel.cpp
src/PythonAPI/model/features/__init__.py
src/SHAPERGUI/SHAPERGUI.cpp

index 5be23a997a8cb03ab9d4c04c8b75030c191fa77e..28783fd69c7ae2bd501418e968a6b6a36716c001 100644 (file)
@@ -100,6 +100,7 @@ MAYBE_UNUSED const static char* ATTR_TOOLTIP = FEATURE_TOOLTIP;
 MAYBE_UNUSED const static char* ATTR_ICON = FEATURE_ICON;
 MAYBE_UNUSED const static char* ATTR_LABEL = "label";
 MAYBE_UNUSED const static char* ATTR_STYLE_SHEET = "styleSheet";
+MAYBE_UNUSED const static char* ATTR_IS_SELECTABLE = "isSelectable";
 MAYBE_UNUSED const static char* ATTR_HTML_STYLE = "isHTML";
 MAYBE_UNUSED const static char* ATTR_DEFAULT = "default";
 MAYBE_UNUSED const static char* ATTR_INTERNAL = "internal";
index 0b8e3055ceea2574236c565de5a95816d09e0a8c..78b18e83f76aecf08c3cdbe1df0eff60321d33f0 100644 (file)
@@ -51,6 +51,7 @@ SET(PROJECT_HEADERS
   FeaturesAPI_Copy.h
   FeaturesAPI_ImportResult.h
   FeaturesAPI_Defeaturing.h
+  FeaturesAPI_PointCoordinates.h
 )
 
 SET(PROJECT_SOURCES
@@ -84,6 +85,7 @@ SET(PROJECT_SOURCES
   FeaturesAPI_Copy.cpp
   FeaturesAPI_ImportResult.cpp
   FeaturesAPI_Defeaturing.cpp
+  FeaturesAPI_PointCoordinates.cpp
 )
 
 SET(PROJECT_LIBRARIES
index b76fd2dc433da48ec55917f838656249d29c963a..5324158dc0eb9bc1cb596f9ee185e73684381d90 100644 (file)
 %include "FeaturesAPI_RemoveResults.h"
 %include "FeaturesAPI_Copy.h"
 %include "FeaturesAPI_ImportResult.h"
+%include "FeaturesAPI_PointCoordinates.h"
diff --git a/src/FeaturesAPI/FeaturesAPI_PointCoordinates.cpp b/src/FeaturesAPI/FeaturesAPI_PointCoordinates.cpp
new file mode 100644 (file)
index 0000000..8898319
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2018-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "FeaturesAPI_PointCoordinates.h"
+
+#include <FeaturesPlugin_PointCoordinates.h>
+#include <ModelAPI_AttributeDoubleArray.h>
+#include <ModelHighAPI_Services.h>
+#include <ModelHighAPI_Tools.h>
+
+std::list<double> getPointCoordinates(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                      const ModelHighAPI_Selection& thePoint)
+{
+  FeaturePtr aPointCoordFeat = thePart->addFeature(FeaturesPlugin_PointCoordinates::ID());
+
+  fillAttribute(thePoint, aPointCoordFeat
+                      ->selection(FeaturesPlugin_PointCoordinates::POINT_SELECTED_ID()));
+  std::list<double> res;
+
+  // obtain result
+  AttributeDoubleArrayPtr aResult = std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(
+      aPointCoordFeat->attribute(FeaturesPlugin_PointCoordinates::RESULT_VALUES_ID()));
+
+  for ( int i : {0, 1, 2})
+    res.push_back( aResult->value(i));
+
+  return res;
+}
+
diff --git a/src/FeaturesAPI/FeaturesAPI_PointCoordinates.h b/src/FeaturesAPI/FeaturesAPI_PointCoordinates.h
new file mode 100644 (file)
index 0000000..b6d502d
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2018-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef FeaturesAPI_PointCoordinates_H_
+#define FeaturesAPI_PointCoordinates_H_
+
+#include "FeaturesAPI.h"
+
+#include <list>
+#include <memory>
+
+class ModelAPI_Document;
+class ModelHighAPI_Selection;
+
+/// \ingroup CPPHighAPI
+/// \brief  Get the point coordinates.
+FEATURESAPI_EXPORT
+std::list<double> getPointCoordinates(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                      const ModelHighAPI_Selection& thePoint);
+
+#endif // FeaturesAPI_PointCoordinates_H_
index 17ada7187e7c42fda139cd4ebb47fea682fc0974..c2a5c5a83a21d1fc3aad0b6cf99f57afb3f79aa7 100644 (file)
@@ -53,5 +53,6 @@
   #include "FeaturesAPI_RemoveResults.h"
   #include "FeaturesAPI_Copy.h"
   #include "FeaturesAPI_ImportResult.h"
+  #include "FeaturesAPI_PointCoordinates.h"
 
 #endif // FeaturesAPI_swig_H_
index 1dce791a91c48cc0b07a8e657e6e0f197598d6e1..ce50f9d33bb76f37947513331613656a64bdf99a 100644 (file)
@@ -20,6 +20,7 @@
 INCLUDE(Common)
 INCLUDE(UnitTest)
 
+
 SET(PROJECT_HEADERS
     FeaturesPlugin.h
     FeaturesPlugin_Plugin.h
@@ -66,6 +67,7 @@ SET(PROJECT_HEADERS
     FeaturesPlugin_ImportResult.h
     FeaturesPlugin_Defeaturing.h
     FeaturesPlugin_VersionedChFi.h
+    FeaturesPlugin_PointCoordinates.h
 )
 
 SET(PROJECT_SOURCES
@@ -113,6 +115,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_ImportResult.cpp
     FeaturesPlugin_Defeaturing.cpp
     FeaturesPlugin_VersionedChFi.cpp
+    FeaturesPlugin_PointCoordinates.cpp
 )
 
 SET(XML_RESOURCES
@@ -149,6 +152,7 @@ SET(XML_RESOURCES
   copy_widget.xml
   import_result_widget.xml
   defeaturing_widget.xml
+  point_coordinates_widget.xml
 )
 
 SET(TEXT_RESOURCES
@@ -166,6 +170,7 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
   ../GeomAlgoAPI
   ../GeomValidators
+  ../ModuleBase
   ../Events
   ../Config
   ${OpenCASCADE_INCLUDE_DIR}
@@ -688,4 +693,5 @@ ADD_UNIT_TESTS(TestExtrusion.py
                Test20245_2.py
                Test20245_3.py
                Test20247.py
+               TestPointCoordinates.py
 )
index 0d49dfe08d1da9ca019628b9784e630e8b5331f9..fdd2beeea9194fc972b94bf6cb6da6f3152bc5f9 100644 (file)
@@ -33,6 +33,7 @@
 #include <FeaturesPlugin_Fillet1D.h>
 #include <FeaturesPlugin_Intersection.h>
 #include <FeaturesPlugin_Measurement.h>
+#include <FeaturesPlugin_PointCoordinates.h>
 #include <FeaturesPlugin_MultiRotation.h>
 #include <FeaturesPlugin_MultiTranslation.h>
 #include <FeaturesPlugin_Partition.h>
@@ -197,6 +198,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new FeaturesPlugin_ImportResult);
   } else if (theFeatureID == FeaturesPlugin_Defeaturing::ID()) {
     return FeaturePtr(new FeaturesPlugin_Defeaturing);
+  } else if (theFeatureID == FeaturesPlugin_PointCoordinates::ID()) {
+    return FeaturePtr(new FeaturesPlugin_PointCoordinates);
   }
 
 
diff --git a/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.cpp b/src/FeaturesPlugin/FeaturesPlugin_PointCoordinates.cpp
new file mode 100644 (file)
index 0000000..a3aed98
--- /dev/null
@@ -0,0 +1,96 @@
+// Copyright (C) 2018-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "FeaturesPlugin_PointCoordinates.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeDoubleArray.h>
+
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Session.h>
+
+#include <Config_PropManager.h>
+
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Vertex.h>
+
+#include <GeomAlgoAPI_PointBuilder.h>
+
+#include <iomanip>
+#include <sstream>
+
+FeaturesPlugin_PointCoordinates::FeaturesPlugin_PointCoordinates()
+{
+}
+
+void FeaturesPlugin_PointCoordinates::initAttributes()
+{
+  // attribute for point selected
+  data()->addAttribute(POINT_SELECTED_ID(), ModelAPI_AttributeSelection::typeId());
+
+  // attribute for x, y and z coordinates
+  data()->addAttribute(X_COORD_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(Y_COORD_ID(), ModelAPI_AttributeString::typeId());
+  data()->addAttribute(Z_COORD_ID(), ModelAPI_AttributeString::typeId());
+
+  // attributes for result message and values
+  data()->addAttribute(RESULT_VALUES_ID(), ModelAPI_AttributeDoubleArray::typeId());
+  data()->realArray(RESULT_VALUES_ID())->setSize(3);
+}
+
+void FeaturesPlugin_PointCoordinates::execute()
+{
+}
+
+void FeaturesPlugin_PointCoordinates::attributeChanged(const std::string& theID)
+{
+  if (theID == POINT_SELECTED_ID()) {
+    AttributeSelectionPtr aSelection = selection(POINT_SELECTED_ID());
+    GeomShapePtr aShape;
+    GeomPointPtr aPoint;
+    if (aSelection && aSelection->isInitialized()) {
+      aShape = aSelection->value();
+      if (!aShape && aSelection->context())
+        aShape = aSelection->context()->shape();
+    }
+
+    AttributeDoubleArrayPtr aValues =
+      std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(attribute(RESULT_VALUES_ID()));
+    std::stringstream streamx;
+    std::stringstream streamy;
+    std::stringstream streamz;
+    if (aShape) {
+      aPoint = GeomAlgoAPI_PointBuilder::point(aShape);
+      streamx << std::setprecision(14) << aPoint->x();
+      aValues->setValue(0, aPoint->x());
+      streamy << std::setprecision(14) << aPoint->y();
+      aValues->setValue(1, aPoint->y());
+      streamz << std::setprecision(14) << aPoint->z();
+      aValues->setValue(2, aPoint->z());
+    }
+
+    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
new file mode 100644 (file)
index 0000000..5578c15
--- /dev/null
@@ -0,0 +1,101 @@
+// Copyright (C) 2018-2020  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef FeaturesPlugin_PointCoordinates_H_
+#define FeaturesPlugin_PointCoordinates_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+
+#include <GeomAPI_IPresentable.h>
+#include <GeomAPI_IScreenParams.h>
+
+/// \class FeaturesPlugin_PointCoordinates
+/// \ingroup Plugins
+/// \brief Feature to view point coordinates.
+
+class FeaturesPlugin_PointCoordinates : public ModelAPI_Feature
+{
+public:
+  inline static const std::string& ID()
+  {
+    static const std::string MY_ID("PointCoordinates");
+    return MY_ID;
+  }
+
+  /// Attribute name for point selected.
+  inline static const std::string& POINT_SELECTED_ID()
+  {
+    static const std::string MY_POINT_SELECTED_ID("point_selected");
+    return MY_POINT_SELECTED_ID;
+  }
+
+  /// Attribute name for x coordinate.
+  inline static const std::string& X_COORD_ID()
+  {
+    static const std::string MY_X_COORD_ID("xcoordinate");
+    return MY_X_COORD_ID;
+  }
+
+  /// Attribute name for y coordinate.
+  inline static const std::string& Y_COORD_ID()
+  {
+    static const std::string MY_Y_COORD_ID("ycoordinate");
+    return MY_Y_COORD_ID;
+  }
+
+  /// Attribute name for z coordinate.
+  inline static const std::string& Z_COORD_ID()
+  {
+    static const std::string MY_Z_COORD_ID("zcoordinate");
+    return MY_Z_COORD_ID;
+  }
+
+  /// Attribute name for values of result.
+  inline static const std::string& RESULT_VALUES_ID()
+  {
+    static const std::string MY_RESULT_VALUES_ID("result_values");
+    return MY_RESULT_VALUES_ID;
+  }
+
+  /// \return the kind of a feature.
+  virtual const std::string& getKind()
+  {
+    return ID();
+  }
+
+  /// Performs the algorithm and stores results it in the data structure.
+  FEATURESPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
+  /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
+  FEATURESPLUGIN_EXPORT virtual bool isMacro() const { return true; }
+
+  /// Use plugin manager for features creation
+  FeaturesPlugin_PointCoordinates();
+
+};
+
+#endif
index 66977d71fa36ba56200345b4638c1787c42a4dce..798f86a53b27fe961019663d100d9b4939af442d 100644 (file)
       <source>Measurement</source>
       <translation>Mesure</translation>
     </message>
+    <message>
+      <source>Point coordinates</source>
+      <translation>Coordonnées d'un point</translation>
+    </message>
     <message>
       <source>Placement</source>
       <translation>Placement</translation>
       <translation>Deuxième direction</translation>
     </message>
   </context>
-
+  <!-- PointCoordinates -->
+  <context>
+    <name>PointCoordinates</name>
+    <message>
+      <source>Point coordinates</source>
+      <translation>Coordonnées d'un point</translation>
+    </message>
+  </context>
   <!-- Measurement -->
   <context>
     <name>Measurement</name>
diff --git a/src/FeaturesPlugin/Test/TestPointCoordinates.py b/src/FeaturesPlugin/Test/TestPointCoordinates.py
new file mode 100644 (file)
index 0000000..8b5c5b9
--- /dev/null
@@ -0,0 +1,73 @@
+# Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+      Unit test of ...
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+import os
+import math
+
+from salome.shaper import model
+
+__updated__ = "2020-11-12"
+
+#=========================================================================
+# test get point coordinates
+#=========================================================================
+def test_point_coordinates():
+
+    model.begin()
+    file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Brep","box1.brep")
+    partSet = model.moduleDocument()
+    Part_1 = model.addPart(partSet)
+    Part_1_doc = Part_1.document()
+    Import_1 = model.addImport(Part_1_doc,file_path)
+    model.do()
+    
+    myDelta = 1e-6
+    coordinates = model.getPointCoordinates(Part_1_doc,model.selection("VERTEX", "[box1_1/Shape_2][box1_1/Shape_3][box1_1/Shape_6]"))
+
+    print(" x: ", coordinates[0])
+    print(" y: ", coordinates[1])
+    print(" z: ", coordinates[2]) 
+
+    aRef = 200
+    aRes = coordinates[0]
+    assert (math.fabs(aRes - aRef) < myDelta), "The coordinate X is wrong: expected = {0}, real = {1}".format(aRef, aRes)
+
+    aRef = 0
+    aRes= coordinates[1]
+    assert (math.fabs(aRes - aRef) < myDelta), "The coordinate Y is wrong: expected = {0}, real = {1}".format(aRef, aRes)
+
+    aRef = 200
+    aRes = coordinates[2]
+    assert (math.fabs(aRes - aRef) < myDelta), "The coordinate Z is wrong: expected = {0}, real = {1}".format(aRef, aRes)
+
+    
+if __name__ == '__main__':
+
+    test_point_coordinates()
+        
+    #=========================================================================
+    # End of test
+    #=========================================================================
index d3d384b68dfcb98c8a447aa83a8c018a6686a89c..dd4f0810729acfc35b72f3c9f0da264b016d05f1 100644 (file)
@@ -18,14 +18,15 @@ Features plug-in provides a set of common topological operations. It implements
    extrusionCutFeature.rst
    extrusionFeature.rst
    extrusionFuseFeature.rst
-   filletFeature.rst
    fillet1dFeature.rst
+   filletFeature.rst
    fuseFeatureFaces.rst
    importResultFeature.rst
    linearCopyFeature.rst
    measurementFeature.rst
    pipeFeature.rst
    placementFeature.rst
+   pointCoordinatesFeature.rst
    recoverFeature.rst
    removeSubShapesFeature.rst
    revolutionCutFeature.rst
diff --git a/src/FeaturesPlugin/doc/TUI_pointCoordinates.rst b/src/FeaturesPlugin/doc/TUI_pointCoordinates.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()
diff --git a/src/FeaturesPlugin/doc/images/pointCoordinatesPropertyPanel.png b/src/FeaturesPlugin/doc/images/pointCoordinatesPropertyPanel.png
new file mode 100644 (file)
index 0000000..4eabd78
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/pointCoordinatesPropertyPanel.png differ
diff --git a/src/FeaturesPlugin/doc/images/point_coord.png b/src/FeaturesPlugin/doc/images/point_coord.png
new file mode 100644 (file)
index 0000000..a3fe457
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/point_coord.png differ
diff --git a/src/FeaturesPlugin/doc/pointCoordinatesFeature.rst b/src/FeaturesPlugin/doc/pointCoordinatesFeature.rst
new file mode 100644 (file)
index 0000000..84717d1
--- /dev/null
@@ -0,0 +1,38 @@
+.. |point_coord.icon|    image:: images/point_coord.png
+
+Point Coordinates
+=================
+
+The **Points coordinates** feature displays the coordinates of a selected point.
+
+The coordinates are displayed in the property panel.
+
+**Apply** button does not generate any result and has the same effect as **Cancel** for this feature.  
+
+To display Point coordinates in the active part:
+
+#. select in the Main Menu *Inspection - > Point coordinates* item  or
+#. click |point_coord.icon| **Points coordinates** button in the toolbar
+
+The coordinates can be displayed for a selected point in the property panel : 
+
+.. figure:: images/pointCoordinatesPropertyPanel.png
+   :align: center
+
+   Point coordinates
+
+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/icons/point_coord.png b/src/FeaturesPlugin/icons/point_coord.png
new file mode 100644 (file)
index 0000000..a3fe457
Binary files /dev/null and b/src/FeaturesPlugin/icons/point_coord.png differ
index 08c08b775d79c7aaf9fa5ea31cc8103dbe6f65bf..a45dbce5d4ff64df6c9202d4e81498c246ecee8f 100644 (file)
     </group>
   </workbench>
   <workbench id="Inspection">
-    <group id="Measurement">
+    <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="point_coordinates_widget.xml"/>
+      </feature>
+    </group>
+    <group id="Calculation">
       <feature id="Measurement" title="Measurement" tooltip="Calculate properties of objects"
                icon="icons/Features/measurement.png" helpfile="measurementFeature.html" abort_confirmation="false">
         <source path="measurement_widget.xml"/>
diff --git a/src/FeaturesPlugin/point_coordinates_widget.xml b/src/FeaturesPlugin/point_coordinates_widget.xml
new file mode 100644 (file)
index 0000000..8ab89ae
--- /dev/null
@@ -0,0 +1,14 @@
+<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"/>
+        <validator id="GeomValidators_ConstructionComposite"/>
+  </shape_selector>
+  <label id="xcoordinate" isSelectable="true"/>
+  <label id="ycoordinate" isSelectable="true"/>
+  <label id="zcoordinate" isSelectable="true"/>
+</source>
index 7a47835c8a1b984de1fdc6aa9939ef5db144f1f2..7e3f86de0ab80bdf75d1b2397dfeb846dd64de43 100644 (file)
@@ -61,6 +61,10 @@ ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
   std::string aStyleSheet = theData->getProperty(ATTR_STYLE_SHEET);
   if (!aStyleSheet.empty())
     myLabel->setStyleSheet(QString("QLabel {%1}").arg(aStyleSheet.c_str()));
+
+  aStyleSheet = theData->getProperty(ATTR_IS_SELECTABLE);
+  if ( aStyleSheet == "true")
+    myLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
 }
 
 ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel()
index 772dc05c219e2fa9c563ea82796013ef67860cca..41f3e1e8e66bd2d0042284791c782cff13284a20 100644 (file)
@@ -30,6 +30,7 @@ from FeaturesAPI import addRecover
 from FeaturesAPI import addFillet, addChamfer
 from FeaturesAPI import addFusionFaces
 from FeaturesAPI import measureLength, measureDistance, measureRadius, measureAngle
+from FeaturesAPI import getPointCoordinates
 from FeaturesAPI import addRemoveResults
 from FeaturesAPI import addCopy, addImportResult
 from FeaturesAPI import addDefeaturing
index f92d89f69d7bcc8891d76cf276a29844632f8d7d..c0633ccc8777146db09ebd5761262069eea558d1 100644 (file)
@@ -174,7 +174,6 @@ void SHAPERGUI::initialize(CAM_Application* theApp)
   }
 
   int aMenu = createMenu(tr("Inspection"), -1, -1, 30);
-  int aSubMenu = createMenu(tr("Information"), aMenu, -1, -1, 0);
 
   int aId = getNextCommandId();
   myActionsList.append(aId);
@@ -184,7 +183,7 @@ void SHAPERGUI::initialize(CAM_Application* theApp)
     aTip, QKeySequence(), aDesk, true, this, SLOT(onWhatIs(bool)));
   myWhatIsAction->setStatusTip(aTip);
   myWhatIsAction->setData("INSPECTION_CMD");
-  createMenu(aId, aSubMenu, 0);
+  createMenu(aId, aMenu, 0);
 
   QString aToolName = tr("Inspection");
   int aTool = createTool(aToolName);
@@ -690,7 +689,12 @@ QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theTBNam
 #ifdef _DEBUG
   int aItemId =
 #endif
-    createMenu(aId, aWBMenu);
+
+  if( theId == "PointCoordinates" )
+    createMenu(separator(), aWBMenu);
+
+  createMenu(aId, aWBMenu);
+
   if (isAddSeparator)
     createMenu(separator(), aWBMenu);