]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Some improvements in GUI
authordbv <dbv@opencascade.com>
Wed, 27 Jun 2018 15:06:50 +0000 (18:06 +0300)
committerdbv <dbv@opencascade.com>
Wed, 27 Jun 2018 15:07:08 +0000 (18:07 +0300)
src/ConstructionAPI/ConstructionAPI_Point.cpp
src/ConstructionAPI/ConstructionAPI_Point.h
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.h
src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py
src/ConstructionPlugin/icons/point_by_projection_32x32.png [new file with mode: 0644]
src/ConstructionPlugin/icons/point_by_projection_on_edge_24x24.png [new file with mode: 0644]
src/ConstructionPlugin/icons/point_by_projection_on_face_24x24.png [new file with mode: 0644]
src/ConstructionPlugin/point_widget.xml

index 350c8857e8c483e6183390f2bd0b443d35c6b47b..fd6d468ec6f6c8392b011138c36ea968097604d5 100644 (file)
@@ -128,9 +128,11 @@ void ConstructionAPI_Point::setByOffsetOnEdge(const ModelHighAPI_Selection& theE
 void ConstructionAPI_Point::setByProjectionOnEdge(const ModelHighAPI_Selection& theVertex,
                                                   const ModelHighAPI_Selection& theEdge)
 {
-  fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION_ON_EDGE(),
+  fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION(),
                 mycreationMethod);
-  fillAttribute(theVertex, mypoinToProjectOnEdge);
+  fillAttribute(ConstructionPlugin_Point::PROJECTION_TYPE_ON_EDGE(),
+                myprojectionType);
+  fillAttribute(theVertex, mypoinToProject);
   fillAttribute(theEdge, myedgeForPointProjection);
 
   execute();
@@ -140,9 +142,11 @@ void ConstructionAPI_Point::setByProjectionOnEdge(const ModelHighAPI_Selection&
 void ConstructionAPI_Point::setByProjectionOnFace(const ModelHighAPI_Selection& theVertex,
                                                   const ModelHighAPI_Selection& theFace)
 {
-  fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION_ON_FACE(),
+  fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION(),
                 mycreationMethod);
-  fillAttribute(theVertex, mypoinToProjectOnFace);
+  fillAttribute(ConstructionPlugin_Point::PROJECTION_TYPE_ON_FACE(),
+                myprojectionType);
+  fillAttribute(theVertex, mypoinToProject);
   fillAttribute(theFace, myfaceForPointProjection);
 
   execute();
@@ -200,10 +204,13 @@ void ConstructionAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const
       theDumper << ratio() << ", " << true;
     }
     theDumper << ", " << reverse()->value();
-  } else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION_ON_EDGE()) {
-    theDumper << mypoinToProjectOnEdge << ", " << myedgeForPointProjection;
-  } else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION_ON_FACE()) {
-    theDumper << mypoinToProjectOnFace << ", " << myfaceForPointProjection;
+  } else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION()) {
+    theDumper << mypoinToProject << ", ";
+    if (projectionType()->value() == ConstructionPlugin_Point::PROJECTION_TYPE_ON_EDGE()) {
+      theDumper << myedgeForPointProjection;
+    } else {
+      theDumper << myfaceForPointProjection;
+    }
   }
 
   theDumper << ")" << std::endl;
index f028db1929174942ce4ccf0b157515549298c67e..a6145dc4774ae28cf55ad484b3c05afc67e7933c 100644 (file)
@@ -93,11 +93,11 @@ public:
                ModelAPI_AttributeDouble, /** Ratio */,
                reverse, ConstructionPlugin_Point::REVERSE(),
                ModelAPI_AttributeBoolean, /** Reverse */,
-               poinToProjectOnFace, ConstructionPlugin_Point::POINT_TO_PROJECT_ON_FACE(),
-               ModelAPI_AttributeSelection, /** Point to project on face */,
+               poinToProject, ConstructionPlugin_Point::POINT_TO_PROJECT(),
+               ModelAPI_AttributeSelection, /** Point to project*/,
+               projectionType, ConstructionPlugin_Point::PROJECTION_TYPE(),
+               ModelAPI_AttributeString, /** Type of the point projection */,
                faceForPointProjection, ConstructionPlugin_Point::FACE_FOR_POINT_PROJECTION(),
-               ModelAPI_AttributeSelection, /** Face for point projection */,
-               poinToProjectOnEdge, ConstructionPlugin_Point::POINT_TO_PROJECT_ON_EDGE(),
                ModelAPI_AttributeSelection, /** Point to project on edge */,
                edgeForPointProjection, ConstructionPlugin_Point::EDGE_FOR_POINT_PROJECTION(),
                ModelAPI_AttributeSelection, /** Edge for point projection */)
index 60b0af1c56b534fc677a4a609792c0215c320876..400824b7d4b78157c4615492d9fc37f6faca007a 100644 (file)
@@ -73,10 +73,9 @@ void ConstructionPlugin_Point::initAttributes()
   data()->addAttribute(RATIO(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(REVERSE(), ModelAPI_AttributeBoolean::typeId());
 
-  data()->addAttribute(POINT_TO_PROJECT_ON_EDGE(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(POINT_TO_PROJECT(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(PROJECTION_TYPE(), ModelAPI_AttributeString::typeId());
   data()->addAttribute(EDGE_FOR_POINT_PROJECTION(), ModelAPI_AttributeSelection::typeId());
-
-  data()->addAttribute(POINT_TO_PROJECT_ON_FACE(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(FACE_FOR_POINT_PROJECTION(), ModelAPI_AttributeSelection::typeId());
 }
 
@@ -93,10 +92,12 @@ void ConstructionPlugin_Point::execute()
     aShape = createByXYZ();
   } else if(aCreationMethod == CREATION_METHOD_BY_DISTANCE_ON_EDGE()) {
     aShape = createByDistanceOnEdge();
-  } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION_ON_EDGE()) {
-    aShape = createByProjectionOnEdge();
-  } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION_ON_FACE()) {
-    aShape = createByProjectionOnFace();
+  } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION()) {
+    if (string(PROJECTION_TYPE())->value() == PROJECTION_TYPE_ON_EDGE()) {
+      aShape = createByProjectionOnEdge();
+    } else {
+      aShape = createByProjectionOnFace();
+    }
   } /* else if(aCreationMethod == CREATION_METHOD_BY_LINES_INTERSECTION()) {
     aShape = createByLinesIntersection();
   } */ else if(aCreationMethod == CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()) {
@@ -178,7 +179,7 @@ std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByDistanceOnEdge
 std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjectionOnEdge()
 {
   // Get point.
-  AttributeSelectionPtr aPointSelection = selection(POINT_TO_PROJECT_ON_EDGE());
+  AttributeSelectionPtr aPointSelection = selection(POINT_TO_PROJECT());
   GeomShapePtr aPointShape = aPointSelection->value();
   if (!aPointShape.get()) {
     aPointShape = aPointSelection->context()->shape();
@@ -200,7 +201,7 @@ std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjectionOnEd
 std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjectionOnFace()
 {
   // Get point.
-  AttributeSelectionPtr aPointSelection = selection(POINT_TO_PROJECT_ON_FACE());
+  AttributeSelectionPtr aPointSelection = selection(POINT_TO_PROJECT());
   GeomShapePtr aPointShape = aPointSelection->value();
   if(!aPointShape.get()) {
     aPointShape = aPointSelection->context()->shape();
index 4be62ccde80539d8e505d540bd8aea1d6b89765b..0f4103b4948f54fd8988107ccccfd96d2f6974bb 100644 (file)
@@ -69,16 +69,9 @@ public:
   }
 
   /// Attribute name for creation method.
-  inline static const std::string& CREATION_METHOD_BY_PROJECTION_ON_EDGE()
+  inline static const std::string& CREATION_METHOD_BY_PROJECTION()
   {
-    static const std::string MY_CREATION_METHOD_ID("by_projection_on_edge");
-    return MY_CREATION_METHOD_ID;
-  }
-
-  /// Attribute name for creation method.
-  inline static const std::string& CREATION_METHOD_BY_PROJECTION_ON_FACE()
-  {
-    static const std::string MY_CREATION_METHOD_ID("by_projection_on_face");
+    static const std::string MY_CREATION_METHOD_ID("by_projection");
     return MY_CREATION_METHOD_ID;
   }
 
@@ -168,24 +161,38 @@ public:
     return ATTR_ID;
   }
 
-  /// Attribute name for point to project on edge.
-  inline static const std::string& POINT_TO_PROJECT_ON_EDGE()
+  /// Attribute name for point to projection.
+  inline static const std::string& POINT_TO_PROJECT()
   {
-    static const std::string ATTR_ID("point_to_project_on_edge");
+    static const std::string ATTR_ID("point_to_project");
     return ATTR_ID;
   }
 
-  /// Attribute name for edge for point projection.
-  inline static const std::string& EDGE_FOR_POINT_PROJECTION()
+  /// Attribute name for projection type.
+  inline static const std::string& PROJECTION_TYPE()
   {
-    static const std::string ATTR_ID("edge_for_point_projection");
+    static const std::string ATTR_ID("projection_type");
     return ATTR_ID;
   }
 
-  /// Attribute name for point to project on surface.
-  inline static const std::string& POINT_TO_PROJECT_ON_FACE()
+  /// Attribute name for projection type on edge.
+  inline static const std::string& PROJECTION_TYPE_ON_EDGE()
   {
-    static const std::string ATTR_ID("point_to_project_on_face");
+    static const std::string ATTR_ID("projection_type_on_edge");
+    return ATTR_ID;
+  }
+
+  /// Attribute name for projection type on face.
+  inline static const std::string& PROJECTION_TYPE_ON_FACE()
+  {
+    static const std::string ATTR_ID("projection_type_on_face");
+    return ATTR_ID;
+  }
+
+  /// Attribute name for edge for point projection.
+  inline static const std::string& EDGE_FOR_POINT_PROJECTION()
+  {
+    static const std::string ATTR_ID("edge_for_point_projection");
     return ATTR_ID;
   }
 
index 2cc5ecf09e3017fd9839ac1d621e1e0277978898..af44576ac973d54707d09c2608334c299f3f80c3 100644 (file)
@@ -45,6 +45,6 @@ assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape(
 
 assert (len(Point_3.results()) > 0)
 rightPosition = GeomAPI_Vertex(50, 50, 0)
-assert(rightPosition.isEqual(Point_4.results()[0].resultSubShapePair()[0].shape()))
+assert(rightPosition.isEqual(Point_3.results()[0].resultSubShapePair()[0].shape()))
 
 assert(model.checkPythonDump())
diff --git a/src/ConstructionPlugin/icons/point_by_projection_32x32.png b/src/ConstructionPlugin/icons/point_by_projection_32x32.png
new file mode 100644 (file)
index 0000000..2cc179d
Binary files /dev/null and b/src/ConstructionPlugin/icons/point_by_projection_32x32.png differ
diff --git a/src/ConstructionPlugin/icons/point_by_projection_on_edge_24x24.png b/src/ConstructionPlugin/icons/point_by_projection_on_edge_24x24.png
new file mode 100644 (file)
index 0000000..4364ed0
Binary files /dev/null and b/src/ConstructionPlugin/icons/point_by_projection_on_edge_24x24.png differ
diff --git a/src/ConstructionPlugin/icons/point_by_projection_on_face_24x24.png b/src/ConstructionPlugin/icons/point_by_projection_on_face_24x24.png
new file mode 100644 (file)
index 0000000..c16d2d0
Binary files /dev/null and b/src/ConstructionPlugin/icons/point_by_projection_on_face_24x24.png differ
index 55e09a75925b8449330977f818b1d9d0a5f334c7..8fb77b2a7388f853d96339bd51cdc3aff3895d17 100644 (file)
@@ -82,40 +82,41 @@ email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com
            tooltip="Distance from edge end point."
            default="false"/>
     </box>
-    <box id="by_projection_on_edge"
-         title="By projection on edge"
-         tooltip="Point on edge by projection selected point."
-         icon="icons/Construction/point_by_projection_on_edge_32x32.png">
-      <shape_selector id="point_to_project_on_edge"
+    <box id="by_projection"
+         title="By projection on edge or plane"
+         tooltip="Point on edge or plane by projection selected point."
+         icon="icons/Construction/point_by_projection_32x32.png">
+      <shape_selector id="point_to_project"
                       label="Point"
                       tooltip="Point for projection."
                       icon="icons/Construction/point.png"
                       shape_types="vertex">
       </shape_selector>
-      <shape_selector id="edge_for_point_projection"
-                      label="edge"
-                      tooltip="Edge for projection."
-                      icon="icons/Construction/edge.png"
-                      shape_types="edge">
-      </shape_selector>
-    </box>
-    <box id="by_projection_on_face"
-         title="By projection on face"
-         tooltip="Point on face surface by projection selected point."
-         icon="icons/Construction/point_by_projection_on_face_32x32.png">
-      <shape_selector id="point_to_project_on_face"
-                      label="Point"
-                      tooltip="Point for projection."
-                      icon="icons/Construction/point.png"
-                      shape_types="vertex">
-      </shape_selector>
-      <shape_selector id="face_for_point_projection"
-                      label="face"
-                      tooltip="Face for projection."
-                      icon="icons/Construction/face.png"
-                      shape_types="face">
-        <validator id="GeomValidators_Face" parameters="plane"/>
-      </shape_selector>
+      <toolbox id="projection_type">
+        <box id="projection_type_on_edge"
+             title="By projection on edge"
+             tooltip="Point on edge by projection selected point."
+             icon="icons/Construction/point_by_projection_on_edge_24x24.png">
+          <shape_selector id="edge_for_point_projection"
+                          label="edge"
+                          tooltip="Edge for projection."
+                          icon="icons/Construction/edge.png"
+                          shape_types="edge">
+          </shape_selector>
+        </box>
+        <box id="projection_type_on_face"
+             title="By projection on face"
+             tooltip="Point on face surface by projection selected point."
+             icon="icons/Construction/point_by_projection_on_face_24x24.png">
+          <shape_selector id="face_for_point_projection"
+                          label="face"
+                          tooltip="Face for projection."
+                          icon="icons/Construction/face.png"
+                          shape_types="face">
+            <validator id="GeomValidators_Face" parameters="plane"/>
+          </shape_selector>
+        </box>
+      </toolbox>
     </box>
 <!--
     <box id="by_lines_intersection"