From 481c77d3cff0c7580fca0967926d2378120f6a98 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 27 Jun 2018 18:06:50 +0300 Subject: [PATCH] Some improvements in GUI --- src/ConstructionAPI/ConstructionAPI_Point.cpp | 23 ++++--- src/ConstructionAPI/ConstructionAPI_Point.h | 8 +-- .../ConstructionPlugin_Point.cpp | 19 +++--- .../ConstructionPlugin_Point.h | 43 +++++++------ .../Test/TestPoint_ProjectOnEdge.py | 2 +- .../icons/point_by_projection_32x32.png | Bin 0 -> 617 bytes .../point_by_projection_on_edge_24x24.png | Bin 0 -> 773 bytes .../point_by_projection_on_face_24x24.png | Bin 0 -> 949 bytes src/ConstructionPlugin/point_widget.xml | 59 +++++++++--------- 9 files changed, 85 insertions(+), 69 deletions(-) create mode 100644 src/ConstructionPlugin/icons/point_by_projection_32x32.png create mode 100644 src/ConstructionPlugin/icons/point_by_projection_on_edge_24x24.png create mode 100644 src/ConstructionPlugin/icons/point_by_projection_on_face_24x24.png diff --git a/src/ConstructionAPI/ConstructionAPI_Point.cpp b/src/ConstructionAPI/ConstructionAPI_Point.cpp index 350c8857e..fd6d468ec 100644 --- a/src/ConstructionAPI/ConstructionAPI_Point.cpp +++ b/src/ConstructionAPI/ConstructionAPI_Point.cpp @@ -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; diff --git a/src/ConstructionAPI/ConstructionAPI_Point.h b/src/ConstructionAPI/ConstructionAPI_Point.h index f028db192..a6145dc47 100644 --- a/src/ConstructionAPI/ConstructionAPI_Point.h +++ b/src/ConstructionAPI/ConstructionAPI_Point.h @@ -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 */) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index 60b0af1c5..400824b7d 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -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 ConstructionPlugin_Point::createByDistanceOnEdge std::shared_ptr 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 ConstructionPlugin_Point::createByProjectionOnEd std::shared_ptr 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(); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.h b/src/ConstructionPlugin/ConstructionPlugin_Point.h index 4be62ccde..0f4103b49 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.h @@ -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; } diff --git a/src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py b/src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py index 2cc5ecf09..af44576ac 100644 --- a/src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py +++ b/src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py @@ -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 index 0000000000000000000000000000000000000000..2cc179da641eece987e49026e4eaad0b4ae39c7e GIT binary patch literal 617 zcmV-v0+#)WP)4gdfE8FWQhbW?9;ba!ELWdLwtX>N2bZe?^J zG%heMF*(%MvSa`N0p>|WK~z{r?Up-B13?sp*Jxp7;v>89QCL{1rHzHKW+z%`+?isn z#Zqi+1hGjcf|ZpBg5VR4*8T`vL97HjMgPKjCOAzvn;8ogAs0TvIeRzv&d$v4cxjq` zn_?8t6otI>g{(J-ovoiN%3YG$Dyw-<(8MmIMw9I5_5$Rnd&pk@|m;H*?x zN>F591O0^Gd!vK0D#JTx_hvy&2BHIx_|%W$H9c|-7T+@pKNzjo#E&(g!JprFwOY>T z<|*hEN#3u>W20T5W)>K+1e-=TH=w6spt3Y&vwK)?n}~K8`QL+17E&8ir;}pmg5RFT^I_h11PT7z#F^n3N>B$(+0AF z<=UX;Z$eEQ_zbsC#SPtjAZee9+o$68srVnBic{|saqe4gdfE8FWQhbW?9;ba!ELWdLwtX>N2bZe?^J zG%heMF*(%MvSa`N0)k0IK~zXftyN2C6G0f>L`CW=joF#qmZBiy!Dq! zc4lINR>VV*-n^(qt6~(2c<^x&D)=}mUPKRGMX&0?gZMaE6+sI=z#Bb;IWf2i-f;1>VxO_~7`h{zvo2!haXMtKRkr7ch3i+1#2i2s@^g49^5i9+PMxLj( z_BeN-5jF;ZQrdyW!1IkM) zV9hwXe03V3dAmZOcp(+HbVS^5%0{FmfO_kkqTs|C*)y_+$xW&LCPb6 zVrN~hCL#XF%NBcWYHOe(I$=Jdc_vI=qM^PC&)*Xf-7|&jN$mjLj?u8V2lkwv9zi*U z&R_dXS8zXW(^^IXosPkdL3Di|EBIkX(dE$@pQ-Jb_hUA%b)d^3BJ??keL{h8tl*&G zF|K=Y@UePQJAmLmbpM?&bpv({ds)pqrgsq@4V!&n)0#(5f4KwVM=^@uV9Q-h&N2bZe?^J zG%heMF*(%MvSa`N12RcOK~zXfwN+_I6;T*{S`kqZVKY`_6bb%lBie0w_GaG8LT5>z zdt#;LR+_jx%Y0cbX_|(Hlp(FQkUdedh^UBYp~5!EXtnxL7C{6;l%BqscNOhd#CYH^ zbI;uS-EY3{%v{qy!)_nuwOaCPWsNN+(Z=0!E0NydUR+qDvXBD$DlEWEAO(VQq>;YFp4NruD2%U>F+ zm5Pmx#grvWM)6kp1~1CTm}D$i4~EdDiHRe4QA*$~vci-h0BvG2JBPE8vGBIWkc*Tn z^s8uOlCjVnr1gLk)n+Cc4v$IZpb6te`#3iKA2>ZZo9s^?QxYerDLO4`Drb@06qPic zg1kkisAh43lFeD<9AYj#b9f6%9$9%i#n?gD3>Mf8E>M|43!nLg#$n-xtyn}{yfGbq zA#s=+os3Dg5KIe>#LVz`%!*9F@}w-RNXo{_&fu6mV@zGn)aN_oJ zq}3enpV!B;4_;wGTv{)cs6{h|9^XrpBq~jplv|=_FmOS5;eMnaJPA3k6uwF<=EWpK z-M$xvjcrJ(ZWuK8eEVC7>G{3Xi`SI>Yzpl`{#JR~?Iyi`?y`Q>mu`9P)U zgu0^)nTO8kWjXio4N_{3_0MbT_>B09!qug5ca@1mzTAerzhpmaSSv zSZFuM>vbezqHWzEYT7_j8GETuzlcBSt-E=v@`IB5PWm^>`YT;KIBW1S3OV4+Hktka XM3>thsgM}d00000NkvXXu0mjf%&xo@ literal 0 HcmV?d00001 diff --git a/src/ConstructionPlugin/point_widget.xml b/src/ConstructionPlugin/point_widget.xml index 55e09a759..8fb77b2a7 100644 --- a/src/ConstructionPlugin/point_widget.xml +++ b/src/ConstructionPlugin/point_widget.xml @@ -82,40 +82,41 @@ email : webmaster.salome@opencascade.com - - + - - - - - - - - - + + + + + + + + + + +