Salome HOME
22755: [EDF] Improvement of Projection operation
authoreap <eap@opencascade.com>
Fri, 21 Nov 2014 17:25:48 +0000 (20:25 +0300)
committereap <eap@opencascade.com>
Fri, 21 Nov 2014 17:25:48 +0000 (20:25 +0300)
18 files changed:
doc/salome/examples/transformation_operations_ex07.py
doc/salome/gui/GEOM/images/projection_dlg.png
doc/salome/gui/GEOM/images/projection_dlg1.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/projection_dlg2.png [new file with mode: 0644]
doc/salome/gui/GEOM/input/extension_operation.doc
doc/salome/gui/GEOM/input/projection_operation.doc
idl/GEOM_Gen.idl
resources/CMakeLists.txt
resources/projection_on_edge.png [new file with mode: 0644]
resources/projection_on_wire.png [new file with mode: 0644]
src/GEOM/GEOM_PythonDump.cxx
src/GEOMBase/GEOMBase_Helper.cxx
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMImpl/GEOMImpl_ITransformOperations.cxx
src/GEOM_SWIG/geomBuilder.py
src/TransformationGUI/TransformationGUI_ProjectionDlg.cxx
src/TransformationGUI/TransformationGUI_ProjectionDlg.h

index 0b324a10158db07ce12184a0502137959e2e07f2..f76bd9036434bf1640e1aa9b05a937fe7cf097b7 100644 (file)
@@ -2,7 +2,6 @@
 
 import salome
 salome.salome_init()
-import GEOM
 from salome.geom import geomBuilder
 geompy = geomBuilder.New(salome.myStudy)
 
@@ -25,24 +24,17 @@ projection = geompy.MakeProjection(curve, face_cyl)
 # add objects in the study
 geompy.addToStudy(cylinder, "cylinder")
 geompy.addToStudyInFather(cylinder, face_cyl, "face_cyl")
-geompy.addToStudy(p1, "p1")
-geompy.addToStudy(p2, "p2")
-geompy.addToStudy(p3, "p3")
-geompy.addToStudy(p4, "p4")
-geompy.addToStudy(p5, "p5")
 geompy.addToStudy(curve, "curve")
 geompy.addToStudy(projection, "projection")
 
-#projection of point on wire.
+#projection of point on wire
 e1 = geompy.MakeLineTwoPnt(p1, p2)
 e2 = geompy.MakeLineTwoPnt(p2, p3)
 
 w1 = geompy.MakeWire([e1, e2], 1.e-7)
 v1 = geompy.MakeVertex(300, 40, 100)
 
-prj = geompy.MakeProjectionOnWire(v1, w1)
-geompy.addToStudy(e1, "e1")
-geompy.addToStudy(e2, "e2")
+prj = geompy.MakeProjection(v1, w1)
 geompy.addToStudy(w1, "w1")
 geompy.addToStudy(v1, "v1")
-geompy.addToStudy(prj[1], "projOnWire")
+geompy.addToStudy(prj, "projOnWire")
index ac912b9a8ec362dbbe2842fd2e0801f4baff2790..561ca30f3a32b853052f4522e3c157891b9e477c 100644 (file)
Binary files a/doc/salome/gui/GEOM/images/projection_dlg.png and b/doc/salome/gui/GEOM/images/projection_dlg.png differ
diff --git a/doc/salome/gui/GEOM/images/projection_dlg1.png b/doc/salome/gui/GEOM/images/projection_dlg1.png
new file mode 100644 (file)
index 0000000..342e762
Binary files /dev/null and b/doc/salome/gui/GEOM/images/projection_dlg1.png differ
diff --git a/doc/salome/gui/GEOM/images/projection_dlg2.png b/doc/salome/gui/GEOM/images/projection_dlg2.png
new file mode 100644 (file)
index 0000000..1c0ab27
Binary files /dev/null and b/doc/salome/gui/GEOM/images/projection_dlg2.png differ
index 417577adb09e30cd58ae70aed2b864ba0b13fb83..605ff176f3d52d8c5fa901276202905f7645c55d 100644 (file)
@@ -27,7 +27,7 @@ parameter value, \em theMax the maximal parameter value.
 \note The input Edge parameters range is [0, 1]. If \b theMin parameter is
       negative, the input Edge is extended, otherwise it is shrinked by
       \b theMin parameter. If \b theMax is greater than 1, the Edge is
-      extended, otherwise it is shrinked by \btheMax parameter.
+      extended, otherwise it is shrinked by \b theMax parameter.
 
 Secondly it is possible to resize a \b Face.
 \n <b>TUI Command:</b> <em>geompy.ExtendFace(theFace, theUMin, theUMax,
index 6f7e8b4eb3fb085af1e9cab4339fef7c53408944..b90373be893c47ba32a47445d31eba21fe85b785 100644 (file)
@@ -1,23 +1,34 @@
 /*!
 
-\page projection_operation_page Projection on a Face
+\page projection_operation_page Projection
 
 \n To produce a <b>Projection</b> in the <b>Main Menu</b> select
 <b>Operations - > Transformation - > Projection</b>
 
-\n This operation makes normal projection of a <b>Source vertex, edge
-   or wire</b> on a given <b>Target face</b>.
-\ref restore_presentation_parameters_page "Advanced options".
+\n This operation makes normal projection of one shape to another.
+\n There are 3 types of projection different by types of operands.
+
+Firstly, you can project <b>Source vertex, edge or wire</b> on a given <b>Target face</b>.
 
 \image html projection_dlg.png
 
+Secondly, you can project <b>Source vertex</b> on a given <b>Target wire</b>.
+
+\image html projection_dlg1.png
+
+Thirdly, you can project <b>Source vertex</b> on a given <b>Target edge</b>.
+
+\image html projection_dlg2.png
+
+\ref restore_presentation_parameters_page "Advanced options".
+
 \n <b>Example:</b>
 
 \image html projection_preview.png "The curve (in red) and its projection on the cylindric surface"
 
 \n <b>TUI Command:</b> <em>geompy.MakeProjection(Source, Target),</em>
    where \em Source is a shape which has to be projected, \em Target
-   is a face, on which the \em Source shape will be projected. The \em
+   is a shape, on which the \em Source shape will be projected. The \em
    Result will be a \em GEOM_Object.
 
 Our <b>TUI Scripts</b> provide you with useful examples of the use of
index 0b24f8c7db960482f54bee875d1c09b6435723a9..83faa46bb4cdf7783fe6d5a471be272331de08c6 100644 (file)
@@ -3860,8 +3860,8 @@ module GEOM
     GEOM_Object MakeCopy (in GEOM_Object theOriginal);
 
     /*!
-     *  \brief Deprecated method. Use Export<FormatName> (from the
-     *  corresponding plugin) instead; here <FormatName> is a name of format.
+     *  \brief Deprecated method. Use Export\<FormatName\> (from the
+     *  corresponding plugin) instead; here \<FormatName\> is a name of format.
      *
      *  \brief Export the given shape into a file with given name.
      *  \param theObject Shape to be stored in the file.
@@ -3871,8 +3871,8 @@ module GEOM
     void Export (in GEOM_Object theObject, in string theFileName, in string theFormatName);
 
     /*!
-     *  \brief Deprecated method. Use Import<FormatName> (from the
-     *  corresponding plugin) instead; here <FormatName> is a name of format.
+     *  \brief Deprecated method. Use Import\<FormatName\> (from the
+     *  corresponding plugin) instead; here \<FormatName\> is a name of format.
      *
      *  \brief Import a shape from the STL, BREP, IGES or STEP file
      *  (depends on given format) with given name.
index d841d3612df8768bcc51674b7b47ada207b6a243..49a7e5362b44198414cd352382d421cf7015e402 100755 (executable)
@@ -131,6 +131,8 @@ SET( _res_files
   normale.png
   offset.png
   projection.png
+  projection_on_edge.png
+  projection_on_wire.png
   origin_and_vectors.png
   partition.png
   partitionkeep.png
diff --git a/resources/projection_on_edge.png b/resources/projection_on_edge.png
new file mode 100644 (file)
index 0000000..b1f65ad
Binary files /dev/null and b/resources/projection_on_edge.png differ
diff --git a/resources/projection_on_wire.png b/resources/projection_on_wire.png
new file mode 100644 (file)
index 0000000..a182d8f
Binary files /dev/null and b/resources/projection_on_wire.png differ
index 07aaa0e339f043c501fe5d6f2ba2998f628bf113..107203a407625586b0d77b7edcb7801dbfeed76e 100644 (file)
@@ -44,11 +44,11 @@ namespace GEOM
   {
     if (--myCounter == 0) {
       TCollection_AsciiString aDescr;
-      if ( myAppend ) {
+      if ( myAppend )
         aDescr = myFunction->GetDescription();
-        if ( !aDescr.IsEmpty() ) aDescr += "\n\t";
-      }
       std::string aString = myStream.str();
+      if ( !aDescr.IsEmpty() && !aString.empty())
+        aDescr += "\n\t";
       aDescr += (char *)aString.c_str();
       myFunction->SetDescription( aDescr );
     }
index 93c4c2da6e68edfbf92cda0bc3f6f3a2101310a7..42ab59c1b0fde2abf95e05756c05dd6884e3404c 100755 (executable)
@@ -407,12 +407,12 @@ void GEOMBase_Helper::erasePreview( const bool update )
     {
       SUIT_ViewManager* aViewManager = myViewWindow->getViewManager();
       if ( aViewManager->getType() == OCCViewer_Viewer::Type() ||
-          aViewManager->getType() == SVTK_Viewer::Type() )
+           aViewManager->getType() == SVTK_Viewer::Type() )
       {
-       SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
-       SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
-       if (aView)
-         aView->Erase( getDisplayer(), *anIter, true );
+        SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
+        SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
+        if (aView)
+          aView->Erase( getDisplayer(), *anIter, true );
       }
     }
     delete *anIter;
@@ -843,21 +843,21 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b
             QString aName = getObjectName(obj);
             if (aName.isEmpty()) {
               aName = getNewObjectName(currObj);
-                   if ( nbObjs > 1 ) {
-                           if (aName.isEmpty())
-                             aName = getPrefix(obj);
-                             if (nbObjs <= 30) {
-                               // Try to find a unique name
-                               aName = GEOMBase::GetDefaultName(aName, extractPrefix());
-                             } else {
-                               // Don't check name uniqueness in case of numerous objects
-                               aName = aName + "_" + QString::number(aNumber++);
-                             }
-                   } else {
-                           // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
-                           if ( aName.isEmpty() )
-                             aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
-                   }
+                    if ( nbObjs > 1 ) {
+                            if (aName.isEmpty())
+                              aName = getPrefix(obj);
+                              if (nbObjs <= 30) {
+                                // Try to find a unique name
+                                aName = GEOMBase::GetDefaultName(aName, extractPrefix());
+                              } else {
+                                // Don't check name uniqueness in case of numerous objects
+                                aName = aName + "_" + QString::number(aNumber++);
+                              }
+                    } else {
+                            // PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
+                            if ( aName.isEmpty() )
+                              aName = GEOMBase::GetDefaultName( getPrefix( obj ) );
+                    }
             }
             anEntryList << addInStudy( obj, aName.toLatin1().constData() );
             // updateView=false
@@ -1137,10 +1137,10 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr
         if ( !CORBA::is_nil( cobject ) ) {
           GEOM::ListOfLong_var indices = cobject->GetSubShapeIndices();
           int length = indices->length();
-         // VSR 18/03/2014: we need only sub-shapes with single sub-shape index (to exclude groups, etc)
-         if ( length == 1 && indices[0] == theIndex ) {
-           object = cobject;
-           break;
+          // VSR 18/03/2014: we need only sub-shapes with single sub-shape index (to exclude groups, etc)
+          if ( length == 1 && indices[0] == theIndex ) {
+            object = cobject;
+            break;
           }
         }
       }
index c8c70c1630892b6d741788a88e0aab38e15f5a73..14cf841bc6ce0d84d5430fff357e33d2c013588b 100644 (file)
             <translation>offset.png</translation>
         </message>
         <message>
-            <source>ICON_DLG_PROJECTION</source>
+            <source>ICON_DLG_PROJECTION_ON_FACE</source>
             <translation>projection.png</translation>
         </message>
+        <message>
+            <source>ICON_DLG_PROJECTION_ON_WIRE</source>
+            <translation>projection_on_wire.png</translation>
+        </message>
+        <message>
+            <source>ICON_DLG_PROJECTION_ON_EDGE</source>
+            <translation>projection_on_edge.png</translation>
+        </message>
         <message>
             <source>ICON_DLG_EXTEND_EDGE</source>
             <translation>edgeextension.png</translation>
index 27690e1f57ec00e79b576a8f5555853120e65f18..1630caf5a93ac776932428cd963ed89c46fe21d8 100644 (file)
@@ -1213,17 +1213,45 @@ Please, select face, shell or solid and try again</translation>
         <translation>Division pattern</translation>
     </message>
     <message>
-        <source>GEOM_PROJECTION</source>
-        <translation>Projection</translation>
+        <source>GEOM_PROJECTION_ON_FACE</source>
+        <translation>Projection on Face</translation>
+    </message>
+    <message>
+        <source>GEOM_PROJECTION_ON_WIRE</source>
+        <translation>Projection on Wire</translation>
+    </message>
+    <message>
+        <source>GEOM_PROJECTION_ON_EDGE</source>
+        <translation>Projection on Edge</translation>
     </message>
     <message>
         <source>GEOM_PROJECTION_TITLE</source>
-        <translation>Projection on Face</translation>
+        <translation>Projection</translation>
     </message>
     <message>
-        <source>GEOM_SOURCE_OBJECT</source>
+        <source>GEOM_PROJ_ON_FACE_SOURCE</source>
         <translation>Source vertex, edge or wire</translation>
     </message>
+    <message>
+        <source>GEOM_PROJ_ON_FACE_TARGET</source>
+        <translation>Target face</translation>
+    </message>
+    <message>
+        <source>GEOM_PROJ_ON_WIRE_SOURCE</source>
+        <translation>Source vertex</translation>
+    </message>
+    <message>
+        <source>GEOM_PROJ_ON_WIRE_TARGET</source>
+        <translation>Target wire</translation>
+    </message>
+    <message>
+        <source>GEOM_PROJ_ON_EDGE_SOURCE</source>
+        <translation>Source vertex</translation>
+    </message>
+    <message>
+        <source>GEOM_PROJ_ON_EDGE_TARGET</source>
+        <translation>Target edge</translation>
+    </message>
     <message>
         <source>GEOM_SOLUTION</source>
         <translation>Solution :</translation>
@@ -1232,10 +1260,6 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_SOLUTION_I</source>
         <translation>Solution %1</translation>
     </message>
-    <message>
-        <source>GEOM_TARGET_OBJECT</source>
-        <translation>Target face</translation>
-    </message>
     <message>
         <source>GEOM_WITH_CONTACT</source>
         <translation>With contact</translation>
index 8e04e15ec2ef1cb75d4385f96a81c5c2a4e34be7..012d9982d1d816a748d65db1391ea584d972a3ab 100644 (file)
@@ -1155,8 +1155,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
  *  ProjectShapeCopy
  */
 //=============================================================================
-Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy
-       (Handle(GEOM_Object) theSource, Handle(GEOM_Object) theTarget)
+Handle(GEOM_Object)
+GEOMImpl_ITransformOperations::ProjectShapeCopy (Handle(GEOM_Object) theSource,
+                                                 Handle(GEOM_Object) theTarget)
 {
   SetErrorCode(KO);
 
@@ -1165,35 +1166,54 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy
   Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction();
   if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected
 
-  //Add a new Projection object
-  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
+  Handle(GEOM_Object) aCopy;
 
-  //Add a Projection function
-  Handle(GEOM_Function) aFunction =
-    aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
+  TopoDS_Shape aTarget = theTarget->GetValue();
+  if ( aTarget.IsNull() ) return NULL;
+  if ( aTarget.ShapeType() == TopAbs_EDGE ||
+       aTarget.ShapeType() == TopAbs_WIRE )
+  {
+    // a TPythonDump prevents dumping ProjectPointOnWire(),
+    // dump of MakeProjection() is done at the end of this function
+    GEOM::TPythonDump preventDump(aLastFunction, /*append=*/true);
+    Standard_Integer dummy;
+    ProjectPointOnWire( theSource, theTarget, aCopy, dummy );
+    if ( aCopy.IsNull() || !IsDone() )
+      return NULL;
+  }
+  else
+  {
+    //Add a new Projection object
+    aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
 
-  //Check if the function is set correctly
-  if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
+    //Add a Projection function
+    Handle(GEOM_Function) aFunction =
+      aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
 
-  GEOMImpl_IMirror aTI (aFunction);
-  aTI.SetPlane(theTarget->GetLastFunction());
-  aTI.SetOriginal(aLastFunction);
+    //Check if the function is set correctly
+    if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
 
-  //Compute the Projection
-  try {
-    OCC_CATCH_SIGNALS;
-    if (!GetSolver()->ComputeFunction(aFunction)) {
-      SetErrorCode("Projection driver failed");
+    GEOMImpl_IMirror aTI (aFunction);
+    aTI.SetPlane(theTarget->GetLastFunction());
+    aTI.SetOriginal(aLastFunction);
+
+    //Compute the Projection
+    try {
+      OCC_CATCH_SIGNALS;
+      if (!GetSolver()->ComputeFunction(aFunction)) {
+        SetErrorCode("Projection driver failed");
+        return NULL;
+      }
+    }
+    catch (Standard_Failure) {
+      Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+      SetErrorCode(aFail->GetMessageString());
       return NULL;
     }
   }
-  catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    SetErrorCode(aFail->GetMessageString());
-    return NULL;
-  }
 
   //Make a Python command
+  Handle(GEOM_Function) aFunction = aCopy->GetLastFunction();
   GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
                                << theSource << ", " << theTarget << ")";
 
index c3eead5dd0845632d2dd93d455a35da420d3cf70..83c2e34b0759ff591499de81ffc03e03f70ec8fd 100644 (file)
@@ -8785,9 +8785,10 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "offset")
             return anObj
 
-        ## Create new object as projection of the given one on a 2D surface.
+        ## Create new object as projection of the given one on another.
         #  @param theSource The source object for the projection. It can be a point, edge or wire.
-        #  @param theTarget The target object. It can be planar or cylindrical face.
+        #         Edge and wire are acceptable if @a theTarget is a face.
+        #  @param theTarget The target object. It can be planar or cylindrical face, edge or wire.
         #  @param theName Object name; when specified, this parameter is used
         #         for result publication in the study. Otherwise, if automatic
         #         publication is switched on, default value is used for result name.
@@ -8798,11 +8799,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         @ManageTransactions("TrsfOp")
         def MakeProjection(self, theSource, theTarget, theName=None):
             """
-            Create new object as projection of the given one on a 2D surface.
+            Create new object as projection of the given one on another.
 
             Parameters:
                 theSource The source object for the projection. It can be a point, edge or wire.
-                theTarget The target object. It can be planar or cylindrical face.
+                          Edge and wire are acceptable if theTarget is a face.
+                theTarget The target object. It can be planar or cylindrical face, edge or wire.
                 theName Object name; when specified, this parameter is used
                         for result publication in the study. Otherwise, if automatic
                         publication is switched on, default value is used for result name.
index be7d741bf43a91aad16303166b3c88ea1ffe066e..73b2c528baf56aa568d99af6c34fd6fad8d56ec0 100644 (file)
 
 #include <TColStd_MapOfInteger.hxx>
 
+namespace
+{
+  enum EOperationType { PROJ_ON_FACE = 0, PROJ_ON_WIRE, PROJ_ON_EDGE };
+}
+
 //=================================================================================
 // class    : TransformationGUI_ProjectionDlg()
 // purpose  : Constructs a TransformationGUI_ProjectionDlg which is a child of 'parent', with the
@@ -49,23 +54,20 @@ TransformationGUI_ProjectionDlg::TransformationGUI_ProjectionDlg (GeometryGUI* t
                                       QWidget* parent, bool modal, Qt::WindowFlags fl)
   : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
 {
-  QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION")));
   QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
+  QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION_ON_FACE")));
+  QPixmap image3 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION_ON_WIRE")));
+  QPixmap image4 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PROJECTION_ON_EDGE")));
 
   setWindowTitle(tr("GEOM_PROJECTION_TITLE"));
 
-  mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION"));
-  mainFrame()->RadioButton1->setIcon(image0);
-  mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
-  mainFrame()->RadioButton2->close();
-  mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
-  mainFrame()->RadioButton3->close();
+  mainFrame()->RadioButton1->setIcon(image2);
+  mainFrame()->RadioButton2->setIcon(image3);
+  mainFrame()->RadioButton3->setIcon(image4);
 
   myGroup = new DlgRef_2Sel (centralWidget());
 
   myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
-  myGroup->TextLabel1->setText(tr("GEOM_SOURCE_OBJECT"));
-  myGroup->TextLabel2->setText(tr("GEOM_TARGET_OBJECT"));
   myGroup->PushButton1->setIcon(image1);
   myGroup->PushButton2->setIcon(image1);
   myGroup->LineEdit1->setReadOnly(true);
@@ -108,6 +110,8 @@ void TransformationGUI_ProjectionDlg::Init()
   showOnlyPreviewControl();
  
   // signals and slots connections
+  connect(this, SIGNAL( constructorsClicked( int )),
+          this, SLOT  ( ConstructorsClicked( int )));
   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
 
@@ -115,20 +119,17 @@ void TransformationGUI_ProjectionDlg::Init()
   connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
 
   connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
-           SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
 
-  initName(mainFrame()->GroupConstructors->title());
+  initName( windowTitle() );
 
   setTabOrder(mainFrame()->GroupConstructors, mainFrame()->GroupBoxName);
   setTabOrder(mainFrame()->GroupBoxName, mainFrame()->GroupMedium);
   setTabOrder(mainFrame()->GroupMedium, mainFrame()->GroupButtons);
 
-  mainFrame()->RadioButton1->setFocus();
+  //mainFrame()->RadioButton1->setFocus();
+  ConstructorsClicked( 0 );
 
-  globalSelection(GEOM_ALLSHAPES);
-
-  myGroup->PushButton1->click();
-  SelectionIntoArgument();
   resize(100,100);
 }
 
@@ -153,8 +154,8 @@ bool TransformationGUI_ProjectionDlg::ClickOnApply()
     return false;
 
   initName();
-  // activate selection and connect selection manager
-  myGroup->PushButton1->click();
+  ConstructorsClicked( getConstructorId() );
+
   return true;
 }
 
@@ -166,9 +167,25 @@ void TransformationGUI_ProjectionDlg::SelectionIntoArgument()
 {
   myEditCurrentArgument->setText("");
 
-  GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_SHAPE);
+  GEOM::GeomObjPtr aSelectedObject;
+  if ( myEditCurrentArgument == myGroup->LineEdit1 ) // what to project
+    switch(  getConstructorId() ) {
+    case PROJ_ON_FACE: aSelectedObject = getSelected(TopAbs_SHAPE); break;
+    case PROJ_ON_WIRE:
+    case PROJ_ON_EDGE: aSelectedObject = getSelected(TopAbs_VERTEX); break;
+    default:;
+    }
+  else
+    switch(  getConstructorId() ) { // where to project
+    case PROJ_ON_FACE: aSelectedObject = getSelected(TopAbs_FACE); break;
+    case PROJ_ON_WIRE: aSelectedObject = getSelected(TopAbs_WIRE); break;
+    case PROJ_ON_EDGE: aSelectedObject = getSelected(TopAbs_EDGE); break;
+    default:;
+    }
+
   TopoDS_Shape aShape;
-  if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) {
+  if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull())
+  {
     QString aName = GEOMBase::GetName(aSelectedObject.get());
     myEditCurrentArgument->setText(aName);
 
@@ -193,6 +210,7 @@ void TransformationGUI_ProjectionDlg::SelectionIntoArgument()
     if      (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
     else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
   }
+  processPreview();
 }
 
 //=================================================================================
@@ -203,25 +221,45 @@ void TransformationGUI_ProjectionDlg::SetEditCurrentArgument()
 {
   QPushButton* send = (QPushButton*)sender();
 
-  if (send == myGroup->PushButton1) {
+  globalSelection(); // close local contexts, if any
+
+  if (send == myGroup->PushButton1) // what to project
+  {
     myEditCurrentArgument = myGroup->LineEdit1;
 
     myGroup->PushButton2->setDown(false);
     myGroup->LineEdit2->setEnabled(false);
 
-    TColStd_MapOfInteger aMap;
-    aMap.Add( GEOM_POINT );
-    aMap.Add( GEOM_EDGE );
-    aMap.Add( GEOM_WIRE );
-    globalSelection( aMap );
+    switch ( getConstructorId() ) {
+    case PROJ_ON_FACE: {
+      TColStd_MapOfInteger aMap;
+      aMap.Add( GEOM_POINT );
+      aMap.Add( GEOM_EDGE );
+      aMap.Add( GEOM_WIRE );
+      globalSelection( aMap );
+      break;
+    }
+    case PROJ_ON_WIRE:
+    case PROJ_ON_EDGE: {
+      localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
+      break;
+    }
+    default:;
+    }
   }
-  else if (send == myGroup->PushButton2) {
+  else if (send == myGroup->PushButton2) // where to project
+  {
     myEditCurrentArgument = myGroup->LineEdit2;
 
     myGroup->PushButton1->setDown(false);
     myGroup->LineEdit1->setEnabled(false);
 
-    globalSelection( GEOM_FACE );
+    switch ( getConstructorId() ) {
+    case PROJ_ON_FACE: localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE); break;
+    case PROJ_ON_WIRE: localSelection(GEOM::GEOM_Object::_nil(), TopAbs_WIRE); break;
+    case PROJ_ON_EDGE: localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); break;
+    default:;
+    }
   }
 
   // enable line edit
@@ -229,6 +267,8 @@ void TransformationGUI_ProjectionDlg::SetEditCurrentArgument()
   myEditCurrentArgument->setFocus();
   // after setFocus(), because it will be setDown(false) when loses focus
   send->setDown(true);
+
+  SelectionIntoArgument();
 }
 
 //=================================================================================
@@ -281,9 +321,51 @@ bool TransformationGUI_ProjectionDlg::execute (ObjectList& objects)
   GEOM::GEOM_Object_var anObj;
 
   GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
-  anObj = anOper->ProjectShapeCopy(myObject1.get(), myObject2.get());
+  anObj = anOper->ProjectShapeCopy( myObject1.get(), myObject2.get() );
   if (!anObj->_is_nil())
     objects.push_back(anObj._retn());
 
   return true;
 }
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose  : Radio button management
+//=================================================================================
+void TransformationGUI_ProjectionDlg::ConstructorsClicked( int constructorId )
+{
+  myObject1.nullify();
+  myObject2.nullify();
+  myGroup->LineEdit1->setText( "" );
+  myGroup->LineEdit2->setText( "" );
+
+  switch ( constructorId ) {
+  case PROJ_ON_FACE:
+    mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION_ON_FACE"));
+    myGroup->TextLabel1->setText(tr("GEOM_PROJ_ON_FACE_SOURCE"));
+    myGroup->TextLabel2->setText(tr("GEOM_PROJ_ON_FACE_TARGET"));
+    break;
+  case PROJ_ON_EDGE:
+    mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION_ON_EDGE"));
+    myGroup->TextLabel1->setText(tr("GEOM_PROJ_ON_EDGE_SOURCE"));
+    myGroup->TextLabel2->setText(tr("GEOM_PROJ_ON_EDGE_TARGET"));
+    break;
+  case PROJ_ON_WIRE:
+    mainFrame()->GroupConstructors->setTitle(tr("GEOM_PROJECTION_ON_WIRE"));
+    myGroup->TextLabel1->setText(tr("GEOM_PROJ_ON_WIRE_SOURCE"));
+    myGroup->TextLabel2->setText(tr("GEOM_PROJ_ON_WIRE_TARGET"));
+    break;
+  default:;
+  }
+  myGroup->PushButton1->click();
+}
+
+//=================================================================================
+// function : addSubshapeToStudy
+// purpose  : virtual method to add new SubObjects if local selection
+//=================================================================================
+void TransformationGUI_ProjectionDlg::addSubshapesToStudy()
+{
+  GEOMBase::PublishSubObject( myObject1.get() );
+  GEOMBase::PublishSubObject( myObject2.get() );
+}
index b20e110c8d961ea64d5a78fa68ce5a50d3558e76..3b09bba84b5933f0b86deda77efb2b73dd7e49f6 100644 (file)
@@ -49,6 +49,7 @@ protected:
   virtual GEOM::GEOM_IOperations_ptr createOperation();
   virtual bool                       isValid (QString&);
   virtual bool                       execute (ObjectList&);
+  virtual void                       addSubshapesToStudy();
 
 private:
   void                               Init();
@@ -66,6 +67,7 @@ private slots:
   void                               SetEditCurrentArgument();
   void                               SelectionIntoArgument();
   void                               ActivateThisDialog();
+  void                               ConstructorsClicked( int constructorId );
 };
 
 #endif // TRANSFORMATIONGUI_PROJECTIONDLG_H