Salome HOME
0023115: [CEA 1545] Regression on KindOfShape method
[modules/geom.git] / src / BuildGUI / BuildGUI_EdgeDlg.cxx
index 6403242ce9d5177c7d356531f0e2d3a668037c87..b96feeeae7a604f2626c2e94fcbe848fe2d3a9b7 100644 (file)
-//  GEOM GEOMGUI : GUI for Geometry component
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  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. 
-// 
-//  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
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
 //
-//  File   : BuildGUI_EdgeDlg.cxx
-//  Author : Lucien PIGNOLONI
-//  Module : GEOM
-//  $Header$
 
-#include "BuildGUI_EdgeDlg.h"
+// GEOM GEOMGUI : GUI for Geometry component
+// File   : BuildGUI_EdgeDlg.cxx
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
 
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <Precision.hxx>
+#include "BuildGUI_EdgeDlg.h"
 
-#include "utilities.h"
-#include "GEOMImpl_Types.hxx"
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
 
-#include "SUIT_Session.h"
-#include "SalomeApp_Application.h"
-#include "LightApp_SelectionMgr.h"
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
 
-#include <qlabel.h>
+#include <GEOMImpl_Types.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
 
 //=================================================================================
 // class    : BuildGUI_EdgeDlg()
-// purpose  : Constructs a BuildGUI_EdgeDlg which is a child of 'parent', with the 
+// purpose  : Constructs a BuildGUI_EdgeDlg which is a child of 'parent', with the
 //            name 'name' and widget flags set to 'f'.
 //            The dialog will by default be modeless, unless you set 'modal' to
 //            TRUE to construct a modal dialog.
 //=================================================================================
-BuildGUI_EdgeDlg::BuildGUI_EdgeDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
-                                   const char* name, bool modal, WFlags fl)
-  :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
-                     WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+BuildGUI_EdgeDlg::BuildGUI_EdgeDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
+  : GEOMBase_Skeleton(theGeometryGUI, parent)
 {
-  QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_BUILD_EDGE")));
-  QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
+  QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE")));
+  QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE_WIRE")));
+  QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE_CURVE")));
 
-  setCaption(tr("GEOM_EDGE_TITLE"));
+  setWindowTitle(tr("GEOM_EDGE_TITLE"));
 
   /***************************************************************/
-  GroupConstructors->setTitle(tr("GEOM_EDGE"));
-  RadioButton1->setPixmap(image0);
-  RadioButton2->close(TRUE);
-  RadioButton3->close(TRUE);
+  mainFrame()->GroupConstructors->setTitle(tr("GEOM_EDGE"));
+  mainFrame()->RadioButton1->setIcon(image1);
+  mainFrame()->RadioButton2->setIcon(image2);
+  mainFrame()->RadioButton3->setIcon(image3);
 
-  GroupPoints = new DlgRef_2Sel_QTD(this, "GroupPoints");
+  // two points
+
+  GroupPoints = new DlgRef_2Sel(centralWidget());
   GroupPoints->GroupBox1->setTitle(tr("GEOM_POINTS"));
-  GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg("1"));
-  GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("2"));
-  GroupPoints->PushButton1->setPixmap(image1);
-  GroupPoints->PushButton2->setPixmap(image1);
-  
-  GroupPoints->LineEdit1->setReadOnly( true );
-  GroupPoints->LineEdit2->setReadOnly( true );
-
-  Layout1->addWidget(GroupPoints, 2, 0);
+  GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg(1));
+  GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg(2));
+  GroupPoints->PushButton1->setIcon(image0);
+  GroupPoints->PushButton2->setIcon(image0);
+  GroupPoints->LineEdit1->setReadOnly(true);
+  GroupPoints->LineEdit2->setReadOnly(true);
+
+  // wire
+
+  GroupWire = new DlgRef_1Sel2Spin(centralWidget());
+  GroupWire->GroupBox1->setTitle(tr("GEOM_WIRE"));
+  GroupWire->TextLabel1->setText(tr("GEOM_WIRE"));
+  GroupWire->PushButton1->setIcon(image0);
+  GroupWire->LineEdit1->setReadOnly(true);
+  GroupWire->TextLabel2->setText(tr("GEOM_LINEAR_TOLERANCE"));
+  GroupWire->TextLabel3->setText(tr("GEOM_ANGULAR_TOLERANCE"));
+  double SpecificStep = 0.0001;
+  double prec1 = Precision::Confusion();
+  double prec2 = Precision::Angular();
+  initSpinBox(GroupWire->SpinBox_DX, prec1, MAX_NUMBER, SpecificStep, "len_tol_precision");
+  initSpinBox(GroupWire->SpinBox_DY, prec2, MAX_NUMBER, SpecificStep, "ang_tol_precision");
+  GroupWire->SpinBox_DX->setValue(prec1);
+  GroupWire->SpinBox_DY->setValue(prec2);
+
+  // on curve
+
+  GroupOnCurve = new DlgRef_2Sel1Spin(centralWidget());
+  GroupOnCurve->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+  GroupOnCurve->TextLabel1->setText(tr("GEOM_EDGE"));
+  GroupOnCurve->PushButton1->setIcon(image0);
+  GroupOnCurve->LineEdit1->setReadOnly(true);
+  GroupOnCurve->TextLabel2->setText(tr("GEOM_START_POINT"));
+  GroupOnCurve->PushButton2->setIcon(image0);
+  GroupOnCurve->LineEdit2->setReadOnly(true);
+  GroupOnCurve->TextLabel3->setText(tr("GEOM_LENGTH"));
+  double step = aResMgr->doubleValue("Geometry", "SettingsGeomStep", 100.0);
+  initSpinBox(GroupOnCurve->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
+  GroupOnCurve->SpinBox_DX->setValue(step);
+
+  // layout
+
+  QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+  layout->setMargin(0); layout->setSpacing(6);
+  layout->addWidget(GroupPoints);
+  layout->addWidget(GroupWire);
+  layout->addWidget(GroupOnCurve);
   /***************************************************************/
 
   setHelpFileName("create_edge_page.html");
 
-  /* Initialisations */
+  // initialisation
   Init();
 }
 
-
 //=================================================================================
 // function : ~BuildGUI_EdgeDlg()
 // purpose  : Destroys the object and frees any allocated resources
 //=================================================================================
 BuildGUI_EdgeDlg::~BuildGUI_EdgeDlg()
 {
-    // no need to delete child widgets, Qt does it all for us
+  // no need to delete child widgets, Qt does it all for us
 }
 
-
 //=================================================================================
 // function : Init()
 // purpose  :
 //=================================================================================
 void BuildGUI_EdgeDlg::Init()
 {
-  /* init variables */
+  // init variables
+  myPoint1.nullify();
+  myPoint2.nullify();
+  myWire.nullify();
+  myCurve.nullify();
+  myStartPoint.nullify();
+
   myEditCurrentArgument = GroupPoints->LineEdit1;
-  GroupPoints->LineEdit1->setReadOnly( true );
-  GroupPoints->LineEdit2->setReadOnly( true );
+  GroupPoints->PushButton1->setDown(true);
+  globalSelection(); // close local contexts, if any
+  localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
 
-  myOkPoint1 = myOkPoint2 = false;
+  // signals and slots connections
+  connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
+  connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()),        this, SLOT(ClickOnCancel()));
 
-  globalSelection( GEOM_POINT );
+  connect(this,      SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
 
-  /* signals and slots connections */
-  connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
-  connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+  connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+  connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
 
-  connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(GroupPoints->PushButton1,  SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(GroupPoints->PushButton2,  SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(GroupWire->PushButton1,    SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(GroupOnCurve->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
 
-  connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-  connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-  
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
+  connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
 
-  initName( tr( "GEOM_EDGE") );
-}
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+           this, SLOT(SelectionIntoArgument()));
+
+  initName(tr("GEOM_EDGE"));
 
+  ConstructorsClicked(0);
+}
 
 //=================================================================================
 // function : ClickOnOk()
@@ -131,78 +178,159 @@ void BuildGUI_EdgeDlg::Init()
 //=================================================================================
 void BuildGUI_EdgeDlg::ClickOnOk()
 {
-  if ( ClickOnApply() )
+  setIsApplyAndClose( true );
+  if (ClickOnApply())
     ClickOnCancel();
 }
 
-
 //=================================================================================
 // function : ClickOnApply()
 // purpose  :
 //=================================================================================
 bool BuildGUI_EdgeDlg::ClickOnApply()
 {
-  if ( !onAccept() )
+  if (!onAccept())
     return false;
 
   initName();
+
+  myEditCurrentArgument->setText("");
+  ConstructorsClicked(getConstructorId());
+
   return true;
 }
 
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose  : Radio button management
+//=================================================================================
+void BuildGUI_EdgeDlg::ConstructorsClicked(int constructorId)
+{
+  switch (constructorId) {
+  case 0:
+    {
+      globalSelection(); // close local contexts, if any
+      localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
+
+      myEditCurrentArgument = GroupPoints->LineEdit1;
+      GroupPoints->LineEdit1->setText("");
+      GroupPoints->LineEdit2->setText("");
+      myPoint1.nullify();
+      myPoint2.nullify();
+      GroupPoints->PushButton1->setDown(true);
+      GroupPoints->PushButton2->setDown(false);
+      GroupPoints->LineEdit1->setEnabled(true);
+      GroupPoints->LineEdit2->setEnabled(false);
+      GroupPoints->show();
+      GroupWire->hide();
+      GroupOnCurve->hide();
+      break;
+    }
+  case 1:
+    {
+      globalSelection(); // close local contexts, if any
+      localSelection(GEOM::GEOM_Object::_nil(), TopAbs_WIRE);
+
+      myEditCurrentArgument = GroupWire->LineEdit1;
+      GroupWire->LineEdit1->setText("");
+      myWire.nullify();
+      GroupWire->PushButton1->setDown(true);
+      GroupWire->LineEdit1->setEnabled(true);
+      GroupPoints->hide();
+      GroupOnCurve->hide();
+      GroupWire->show();
+      break;
+    }
+  case 2:
+    {
+      globalSelection(); // close local contexts, if any
+      localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
+
+      myEditCurrentArgument = GroupOnCurve->LineEdit1;
+      GroupOnCurve->LineEdit1->setText("");
+      GroupOnCurve->LineEdit2->setText("");
+      myCurve.nullify();
+      myStartPoint.nullify();
+      GroupOnCurve->PushButton1->setDown(true);
+      GroupOnCurve->PushButton2->setDown(false);
+      GroupOnCurve->LineEdit1->setEnabled(true);
+      GroupOnCurve->LineEdit2->setEnabled(false);
+      GroupPoints->hide();
+      GroupWire->hide();
+      GroupOnCurve->show();
+      break;
+    }
+  }
+
+  qApp->processEvents();
+  updateGeometry();
+  resize(minimumSizeHint());
+  SelectionIntoArgument();
+}
 
 //=================================================================================
 // function : SelectionIntoArgument()
-// purpose  : Called when selection as changed or other case
+// purpose  : Called when selection is changed or on dialog initialization or activation
 //=================================================================================
 void BuildGUI_EdgeDlg::SelectionIntoArgument()
 {
   erasePreview();
   myEditCurrentArgument->setText("");
-  
-  if(IObjectCount() != 1) {
-    if(myEditCurrentArgument == GroupPoints->LineEdit1)
-      myOkPoint1 = false;
-    else if(myEditCurrentArgument == GroupPoints->LineEdit2)
-      myOkPoint2 = false;
+
+  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+  SALOME_ListIO aSelList;
+  aSelMgr->selectedObjects(aSelList);
+
+  if (aSelList.Extent() != 1) {
+    if      (myEditCurrentArgument == GroupPoints->LineEdit1)  myPoint1.nullify();
+    else if (myEditCurrentArgument == GroupPoints->LineEdit2)  myPoint2.nullify();
+    else if (myEditCurrentArgument == GroupWire->LineEdit1)    myWire.nullify();
+    else if (myEditCurrentArgument == GroupOnCurve->LineEdit1) myCurve.nullify();
+    else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) myStartPoint.nullify();
+    displayPreview(true);
     return;
   }
-  
-  // nbSel == 1
-  Standard_Boolean testResult = Standard_False;
-  GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult );
-  
-  if(!testResult)
-    return;
 
-  if(myEditCurrentArgument == GroupPoints->LineEdit1) {
-    myPoint1 = aSelectedObject;
-    myOkPoint1 = true;
-  }
-  else if(myEditCurrentArgument == GroupPoints->LineEdit2) {
-    myPoint2 = aSelectedObject;
-    myOkPoint2 = true;
-  }
-  
-  myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
-  
-  displayPreview();
-}
+  TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
+  if (myEditCurrentArgument == GroupWire->LineEdit1) aNeedType = TopAbs_WIRE;
+  else if (myEditCurrentArgument == GroupOnCurve->LineEdit1) aNeedType = TopAbs_EDGE;
+  GEOM::GeomObjPtr aSelectedObject = getSelected(aNeedType);
 
+  TopoDS_Shape aShape;
+  if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) {
+    QString aName = GEOMBase::GetName(aSelectedObject.get());
+    myEditCurrentArgument->setText(aName);
 
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose  :
-//=================================================================================
-void BuildGUI_EdgeDlg::LineEditReturnPressed()
-{
-  QLineEdit* send = (QLineEdit*)sender();
-  if(send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2)
-    {
-      myEditCurrentArgument = send;
-      GEOMBase_Skeleton::LineEditReturnPressed();
+    globalSelection();
+    localSelection(GEOM::GEOM_Object::_nil(), aNeedType);
+
+    if (myEditCurrentArgument == GroupPoints->LineEdit1) {
+      myPoint1 = aSelectedObject;
+      if (myPoint1 && !myPoint2)
+        GroupPoints->PushButton2->click();
     }
-}
+    else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
+      myPoint2 = aSelectedObject;
+      if (myPoint2 && !myPoint1)
+        GroupPoints->PushButton1->click();
+    }
+    else if (myEditCurrentArgument == GroupWire->LineEdit1) {
+      myWire = aSelectedObject;
+    }
+    else if (myEditCurrentArgument == GroupOnCurve->LineEdit1) {
+      myCurve = aSelectedObject;
+      if (myCurve && !myStartPoint)
+        GroupOnCurve->PushButton2->click();
+    }
+    else if (myEditCurrentArgument == GroupOnCurve->LineEdit2) {
+      myStartPoint = aSelectedObject;
+      if (myStartPoint && !myCurve)
+        GroupOnCurve->PushButton1->click();
+    }
+  }
 
+  displayPreview(true);
+}
 
 //=================================================================================
 // function : SetEditCurrentArgument()
@@ -210,24 +338,45 @@ void BuildGUI_EdgeDlg::LineEditReturnPressed()
 //=================================================================================
 void BuildGUI_EdgeDlg::SetEditCurrentArgument()
 {
-  
   QPushButton* send = (QPushButton*)sender();
-  globalSelection();
 
-  if(send == GroupPoints->PushButton1) {
+  if (send == GroupPoints->PushButton1) {
     myEditCurrentArgument = GroupPoints->LineEdit1;
-    globalSelection( GEOM_POINT );
+    GroupPoints->PushButton2->setDown(false);
+    GroupPoints->LineEdit2->setEnabled(false);
   }
-  else if(send == GroupPoints->PushButton2) {
+  else if (send == GroupPoints->PushButton2) {
     myEditCurrentArgument = GroupPoints->LineEdit2;
-    globalSelection( GEOM_POINT );
+    GroupPoints->PushButton1->setDown(false);
+    GroupPoints->LineEdit1->setEnabled(false);
+  }
+  else if (send == GroupWire->PushButton1) {
+    myEditCurrentArgument = GroupWire->LineEdit1;
+  }
+  else if (send == GroupOnCurve->PushButton1) {
+    myEditCurrentArgument = GroupOnCurve->LineEdit1;
+    GroupOnCurve->PushButton2->setDown(false);
+    GroupOnCurve->LineEdit2->setEnabled(false);
+
+    globalSelection(); // close local contexts, if any
+    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
+  }
+  else if (send == GroupOnCurve->PushButton2) {
+    myEditCurrentArgument = GroupOnCurve->LineEdit2;
+    GroupOnCurve->PushButton1->setDown(false);
+    GroupOnCurve->LineEdit1->setEnabled(false);
+
+    globalSelection(); // close local contexts, if any
+    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
   }
-  
+
+  // enable line edit
+  myEditCurrentArgument->setEnabled(true);
   myEditCurrentArgument->setFocus();
-  SelectionIntoArgument();
+  send->setDown(true);
+  displayPreview(true);
 }
 
-
 //=================================================================================
 // function : ActivateThisDialog()
 // purpose  :
@@ -235,53 +384,151 @@ void BuildGUI_EdgeDlg::SetEditCurrentArgument()
 void BuildGUI_EdgeDlg::ActivateThisDialog()
 {
   GEOMBase_Skeleton::ActivateThisDialog();
-  connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 
-         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
-  globalSelection( GEOM_POINT );
-  displayPreview();
-}
 
+  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+          this, SLOT(SelectionIntoArgument()));
+
+  ConstructorsClicked(getConstructorId());
+}
 
 //=================================================================================
 // function : enterEvent()
 // purpose  :
 //=================================================================================
-void BuildGUI_EdgeDlg::enterEvent(QEvent* e)
+void BuildGUI_EdgeDlg::enterEvent (QEvent*)
 {
-  if ( !GroupConstructors->isEnabled() )
+  if (!mainFrame()->GroupConstructors->isEnabled())
     ActivateThisDialog();
 }
 
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose  :
+//=================================================================================
+void BuildGUI_EdgeDlg::ValueChangedInSpinBox(double newValue)
+{
+  displayPreview(true);
+}
+
 //=================================================================================
 // function : createOperation
 // purpose  :
 //=================================================================================
 GEOM::GEOM_IOperations_ptr BuildGUI_EdgeDlg::createOperation()
 {
-  return getGeomEngine()->GetIShapesOperations( getStudyId() );
+  return getGeomEngine()->GetIShapesOperations(getStudyId());
 }
 
 //=================================================================================
 // function : isValid
 // purpose  :
 //=================================================================================
-bool BuildGUI_EdgeDlg::isValid( QString& )
+bool BuildGUI_EdgeDlg::isValid (QString& msg)
 {
-  return myOkPoint1 && myOkPoint2;
+  bool ok = false;
+  switch (getConstructorId()) {
+  case 0:
+    ok = myPoint1 && myPoint2;
+    break;
+  case 1:
+    ok = GroupWire->SpinBox_DX->isValid(msg, !IsPreview()) &&
+         GroupWire->SpinBox_DY->isValid(msg, !IsPreview()) &&
+         myWire;
+    break;
+  case 2:
+    ok = GroupOnCurve->SpinBox_DX->isValid(msg, !IsPreview()) &&
+         myCurve;
+    break;
+  default:
+    break;
+  }
+  return ok;
 }
 
 //=================================================================================
 // function : execute
 // purpose  :
 //=================================================================================
-bool BuildGUI_EdgeDlg::execute( ObjectList& objects )
+bool BuildGUI_EdgeDlg::execute (ObjectList& objects)
 {
+  bool res = false;
   GEOM::GEOM_Object_var anObj;
 
-  anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeEdge( myPoint1, myPoint2 );
+  GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
 
-  if ( !anObj->_is_nil() )
-    objects.push_back( anObj._retn() );
+  switch (getConstructorId()) {
+  case 0:
+    {
+      anObj = anOper->MakeEdge(myPoint1.get(), myPoint2.get());
+      res = true;
+      break;
+    }
+  case 1:
+    {
+      double aLinearTolerance   = GroupWire->SpinBox_DX->value();
+      double anAngularTolerance = GroupWire->SpinBox_DY->value();
 
-  return true;
+      QStringList aParameters;
+      aParameters << GroupWire->SpinBox_DX->text();
+      aParameters << GroupWire->SpinBox_DY->text();
+
+      anObj = anOper->MakeEdgeWire(myWire.get(), aLinearTolerance, anAngularTolerance);
+
+      if (!anObj->_is_nil() && !IsPreview())
+        anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+
+      res = true;
+      break;
+    }
+  case 2:
+    {
+      double aLength = GroupOnCurve->SpinBox_DX->value();
+
+      anObj = anOper->MakeEdgeOnCurveByLength(myCurve.get(), aLength, myStartPoint.get());
+
+      if (!anObj->_is_nil() && !IsPreview())
+        anObj->SetParameters(GroupOnCurve->SpinBox_DX->text().toLatin1().constData());
+
+      res = true;
+      break;
+    }
+  }
+
+  if (!anObj->_is_nil()) objects.push_back(anObj._retn());
+
+  return res;
+}
+
+//=================================================================================
+// function : addSubshapeToStudy
+// purpose  : virtual method to add new SubObjects if local selection
+//=================================================================================
+void BuildGUI_EdgeDlg::addSubshapesToStudy()
+{
+  switch (getConstructorId()) {
+  case 0:
+    GEOMBase::PublishSubObject(myPoint1.get());
+    GEOMBase::PublishSubObject(myPoint2.get());
+    break;
+  case 1:
+    GEOMBase::PublishSubObject(myWire.get());
+    break;
+  case 2:
+    GEOMBase::PublishSubObject(myCurve.get());
+    GEOMBase::PublishSubObject(myStartPoint.get());
+    break;
+  default:
+    break;
+  }
+}
+
+//=================================================================================
+// function : getSourceObjects
+// purpose  : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> BuildGUI_EdgeDlg::getSourceObjects()
+{
+  QList<GEOM::GeomObjPtr> res;
+  res << myPoint1 << myPoint2 << myWire << myCurve << myStartPoint;
+  return res;
 }