geom/src/BuildGUI/BuildGUI_EdgeDlg.cxx

524 lines
18 KiB
C++
Raw Normal View History

2011-06-06 13:23:11 +06:00
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
2004-01-07 20:46:21 +05:00
//
2011-06-06 13:23:11 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2004-01-07 20:46:21 +05:00
//
2011-06-06 13:23:11 +06:00
// 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.
2004-01-07 20:46:21 +05:00
//
2011-06-06 13:23:11 +06:00
// 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.
2009-02-13 17:16:39 +05:00
//
2011-06-06 13:23:11 +06:00
// 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
2009-02-13 17:16:39 +05:00
//
2010-05-14 21:15:28 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : BuildGUI_EdgeDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
2011-03-28 18:36:29 +06:00
2004-01-07 20:46:21 +05:00
#include "BuildGUI_EdgeDlg.h"
2009-02-13 17:16:39 +05:00
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
2004-06-16 21:24:55 +06:00
2009-02-13 17:16:39 +05:00
#include <GEOMImpl_Types.hxx>
2010-11-25 17:31:41 +05:00
#include <TColStd_IndexedMapOfInteger.hxx>
2004-01-07 20:46:21 +05:00
//=================================================================================
// class : BuildGUI_EdgeDlg()
2009-02-13 17:16:39 +05:00
// purpose : Constructs a BuildGUI_EdgeDlg which is a child of 'parent', with the
2004-01-07 20:46:21 +05:00
// 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.
//=================================================================================
2009-02-13 17:16:39 +05:00
BuildGUI_EdgeDlg::BuildGUI_EdgeDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
: GEOMBase_Skeleton(theGeometryGUI, parent)
2004-01-07 20:46:21 +05:00
{
2011-03-28 18:36:29 +06:00
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")));
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
setWindowTitle(tr("GEOM_EDGE_TITLE"));
2004-01-07 20:46:21 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
mainFrame()->GroupConstructors->setTitle(tr("GEOM_EDGE"));
2010-11-25 17:31:41 +05:00
mainFrame()->RadioButton1->setIcon(image1);
mainFrame()->RadioButton2->setIcon(image2);
2011-03-28 18:36:29 +06:00
mainFrame()->RadioButton3->setIcon(image3);
2009-02-13 17:16:39 +05:00
2010-11-25 17:31:41 +05:00
// two points
2004-01-07 20:46:21 +05:00
2010-11-25 17:31:41 +05:00
GroupPoints = new DlgRef_2Sel(centralWidget());
2004-01-07 20:46:21 +05:00
GroupPoints->GroupBox1->setTitle(tr("GEOM_POINTS"));
2009-02-13 17:16:39 +05:00
GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg(1));
GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg(2));
2010-11-25 17:31:41 +05:00
GroupPoints->PushButton1->setIcon(image0);
GroupPoints->PushButton2->setIcon(image0);
2009-02-13 17:16:39 +05:00
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
2010-11-25 17:31:41 +05:00
// 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);
2011-03-28 18:36:29 +06:00
GroupWire->TextLabel2->setText(tr("GEOM_LINEAR_TOLERANCE"));
GroupWire->TextLabel3->setText(tr("GEOM_ANGULAR_TOLERANCE"));
2010-11-25 17:31:41 +05:00
double SpecificStep = 0.0001;
double prec1 = Precision::Confusion();
double prec2 = Precision::Angular();
2011-03-28 18:36:29 +06:00
initSpinBox(GroupWire->SpinBox_DX, prec1, MAX_NUMBER, SpecificStep, "len_tol_precision");
initSpinBox(GroupWire->SpinBox_DY, prec2, MAX_NUMBER, SpecificStep, "ang_tol_precision");
2010-11-25 17:31:41 +05:00
GroupWire->SpinBox_DX->setValue(prec1);
GroupWire->SpinBox_DY->setValue(prec2);
2011-03-28 18:36:29 +06:00
// 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);
2010-11-25 17:31:41 +05:00
// layout
2009-02-13 17:16:39 +05:00
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
2010-11-25 17:31:41 +05:00
layout->addWidget(GroupWire);
2011-03-28 18:36:29 +06:00
layout->addWidget(GroupOnCurve);
2004-01-07 20:46:21 +05:00
/***************************************************************/
setHelpFileName("create_edge_page.html");
2010-11-25 17:31:41 +05:00
// initialisation
2004-01-07 20:46:21 +05:00
Init();
}
//=================================================================================
// function : ~BuildGUI_EdgeDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
BuildGUI_EdgeDlg::~BuildGUI_EdgeDlg()
{
2009-02-13 17:16:39 +05:00
// no need to delete child widgets, Qt does it all for us
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void BuildGUI_EdgeDlg::Init()
{
2009-02-13 17:16:39 +05:00
// init variables
myPoint1.nullify();
myPoint2.nullify();
myWire.nullify();
2011-03-28 18:36:29 +06:00
myCurve.nullify();
myStartPoint.nullify();
2010-11-25 17:31:41 +05:00
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton1->setDown(true);
globalSelection(); // close local contexts, if any
2011-03-28 18:36:29 +06:00
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
// signals and slots connections
2011-03-28 18:36:29 +06:00
connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
2010-11-25 17:31:41 +05:00
2011-03-28 18:36:29 +06:00
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
2010-11-25 17:31:41 +05:00
2009-02-13 17:16:39 +05:00
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
2004-01-07 20:46:21 +05:00
2011-03-28 18:36:29 +06:00
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(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
2004-01-07 20:46:21 +05:00
2011-03-28 18:36:29 +06:00
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
initName(tr("GEOM_EDGE"));
2004-01-07 20:46:21 +05:00
2011-03-28 18:36:29 +06:00
ConstructorsClicked(0);
2009-02-13 17:16:39 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void BuildGUI_EdgeDlg::ClickOnOk()
{
setIsApplyAndClose( true );
2009-02-13 17:16:39 +05:00
if (ClickOnApply())
2004-12-01 15:39:14 +05:00
ClickOnCancel();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
bool BuildGUI_EdgeDlg::ClickOnApply()
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
if (!onAccept())
2004-12-01 15:39:14 +05:00
return false;
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
initName();
2010-11-25 17:31:41 +05:00
2011-03-28 18:36:29 +06:00
myEditCurrentArgument->setText("");
ConstructorsClicked(getConstructorId());
2010-11-25 17:31:41 +05:00
2004-12-01 15:39:14 +05:00
return true;
2004-01-07 20:46:21 +05:00
}
2010-11-25 17:31:41 +05:00
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
2011-03-28 18:36:29 +06:00
void BuildGUI_EdgeDlg::ConstructorsClicked(int constructorId)
2010-11-25 17:31:41 +05:00
{
2011-03-28 18:36:29 +06:00
switch (constructorId) {
2010-11-25 17:31:41 +05:00
case 0:
{
globalSelection(); // close local contexts, if any
2011-03-28 18:36:29 +06:00
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
2010-11-25 17:31:41 +05:00
myEditCurrentArgument = GroupPoints->LineEdit1;
2011-03-28 18:36:29 +06:00
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myPoint1.nullify();
myPoint2.nullify();
2010-11-25 17:31:41 +05:00
GroupPoints->PushButton1->setDown(true);
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit1->setEnabled(true);
GroupPoints->LineEdit2->setEnabled(false);
GroupPoints->show();
GroupWire->hide();
2011-03-28 18:36:29 +06:00
GroupOnCurve->hide();
2010-11-25 17:31:41 +05:00
break;
}
case 1:
{
globalSelection(); // close local contexts, if any
2011-03-28 18:36:29 +06:00
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_WIRE);
2010-11-25 17:31:41 +05:00
myEditCurrentArgument = GroupWire->LineEdit1;
GroupWire->LineEdit1->setText("");
myWire.nullify();
2010-11-25 17:31:41 +05:00
GroupWire->PushButton1->setDown(true);
GroupWire->LineEdit1->setEnabled(true);
GroupPoints->hide();
2011-03-28 18:36:29 +06:00
GroupOnCurve->hide();
2010-11-25 17:31:41 +05:00
GroupWire->show();
break;
}
2011-03-28 18:36:29 +06:00
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;
}
2010-11-25 17:31:41 +05:00
}
qApp->processEvents();
updateGeometry();
2011-03-28 18:36:29 +06:00
resize(minimumSizeHint());
2010-11-25 17:31:41 +05:00
SelectionIntoArgument();
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : SelectionIntoArgument()
2009-02-13 17:16:39 +05:00
// purpose : Called when selection is changed or on dialog initialization or activation
2004-01-07 20:46:21 +05:00
//=================================================================================
void BuildGUI_EdgeDlg::SelectionIntoArgument()
{
2004-12-01 15:39:14 +05:00
erasePreview();
2004-01-07 20:46:21 +05:00
myEditCurrentArgument->setText("");
2009-02-13 17:16:39 +05:00
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) {
2011-03-28 18:36:29 +06:00
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);
2004-01-07 20:46:21 +05:00
return;
}
2009-02-13 17:16:39 +05:00
2011-03-28 18:36:29 +06:00
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;
2011-03-28 18:36:29 +06:00
if (aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) {
QString aName = GEOMBase::GetName(aSelectedObject.get());
myEditCurrentArgument->setText(aName);
2010-11-25 17:31:41 +05:00
globalSelection();
2011-03-28 18:36:29 +06:00
localSelection(GEOM::GEOM_Object::_nil(), aNeedType);
2010-11-25 17:31:41 +05:00
2011-03-28 18:36:29 +06:00
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
2010-11-25 17:31:41 +05:00
myPoint1 = aSelectedObject;
2011-03-28 18:36:29 +06:00
if (myPoint1 && !myPoint2)
2010-11-25 17:31:41 +05:00
GroupPoints->PushButton2->click();
}
2011-03-28 18:36:29 +06:00
else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
2010-11-25 17:31:41 +05:00
myPoint2 = aSelectedObject;
2011-03-28 18:36:29 +06:00
if (myPoint2 && !myPoint1)
2010-11-25 17:31:41 +05:00
GroupPoints->PushButton1->click();
}
2011-03-28 18:36:29 +06:00
else if (myEditCurrentArgument == GroupWire->LineEdit1) {
2010-11-25 17:31:41 +05:00
myWire = aSelectedObject;
}
2011-03-28 18:36:29 +06:00
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();
}
2004-01-07 20:46:21 +05:00
}
displayPreview(true);
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void BuildGUI_EdgeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
2009-02-13 17:16:39 +05:00
if (send == GroupPoints->PushButton1) {
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupPoints->LineEdit1;
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
else if (send == GroupPoints->PushButton2) {
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupPoints->LineEdit2;
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2010-11-25 17:31:41 +05:00
else if (send == GroupWire->PushButton1) {
myEditCurrentArgument = GroupWire->LineEdit1;
}
2011-03-28 18:36:29 +06:00
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);
}
2009-02-13 17:16:39 +05:00
// enable line edit
myEditCurrentArgument->setEnabled(true);
2004-12-01 15:39:14 +05:00
myEditCurrentArgument->setFocus();
2009-02-13 17:16:39 +05:00
send->setDown(true);
displayPreview(true);
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void BuildGUI_EdgeDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
2009-02-13 17:16:39 +05:00
2011-03-28 18:36:29 +06:00
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
2009-02-13 17:16:39 +05:00
2011-03-28 18:36:29 +06:00
ConstructorsClicked(getConstructorId());
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void BuildGUI_EdgeDlg::enterEvent (QEvent*)
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
if (!mainFrame()->GroupConstructors->isEnabled())
2004-12-01 15:39:14 +05:00
ActivateThisDialog();
2004-01-07 20:46:21 +05:00
}
2011-03-28 18:36:29 +06:00
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void BuildGUI_EdgeDlg::ValueChangedInSpinBox(double newValue)
{
displayPreview(true);
}
2004-12-01 15:39:14 +05:00
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr BuildGUI_EdgeDlg::createOperation()
{
2009-02-13 17:16:39 +05:00
return getGeomEngine()->GetIShapesOperations(getStudyId());
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : isValid
// purpose :
2004-01-07 20:46:21 +05:00
//=================================================================================
2010-11-25 17:31:41 +05:00
bool BuildGUI_EdgeDlg::isValid (QString& msg)
2004-01-07 20:46:21 +05:00
{
2010-11-25 17:31:41 +05:00
bool ok = false;
2011-03-28 18:36:29 +06:00
switch (getConstructorId()) {
case 0:
ok = myPoint1 && myPoint2;
break;
case 1:
2011-03-28 18:36:29 +06:00
ok = GroupWire->SpinBox_DX->isValid(msg, !IsPreview()) &&
GroupWire->SpinBox_DY->isValid(msg, !IsPreview()) &&
myWire;
break;
2011-03-28 18:36:29 +06:00
case 2:
ok = GroupOnCurve->SpinBox_DX->isValid(msg, !IsPreview()) &&
myCurve;
break;
default:
break;
2010-11-25 17:31:41 +05:00
}
return ok;
2004-12-01 15:39:14 +05:00
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
bool BuildGUI_EdgeDlg::execute (ObjectList& objects)
2004-12-01 15:39:14 +05:00
{
2010-11-25 17:31:41 +05:00
bool res = false;
GEOM::GEOM_Object_var anObj;
2011-03-28 18:36:29 +06:00
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow(getOperation());
2004-12-01 15:39:14 +05:00
2011-03-28 18:36:29 +06:00
switch (getConstructorId()) {
case 0:
2010-11-25 17:31:41 +05:00
{
2011-03-28 18:36:29 +06:00
anObj = anOper->MakeEdge(myPoint1.get(), myPoint2.get());
2010-11-25 17:31:41 +05:00
res = true;
break;
}
case 1:
{
double aLinearTolerance = GroupWire->SpinBox_DX->value();
double anAngularTolerance = GroupWire->SpinBox_DY->value();
2011-03-28 18:36:29 +06:00
2010-11-25 17:31:41 +05:00
QStringList aParameters;
aParameters << GroupWire->SpinBox_DX->text();
aParameters << GroupWire->SpinBox_DY->text();
2011-03-28 18:36:29 +06:00
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());
2010-11-25 17:31:41 +05:00
res = true;
break;
}
}
2004-12-01 15:39:14 +05:00
2011-03-28 18:36:29 +06:00
if (!anObj->_is_nil()) objects.push_back(anObj._retn());
2010-11-25 17:31:41 +05:00
return res;
}
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void BuildGUI_EdgeDlg::addSubshapesToStudy()
{
2011-03-28 18:36:29 +06:00
switch (getConstructorId()) {
case 0:
GEOMBase::PublishSubObject(myPoint1.get());
GEOMBase::PublishSubObject(myPoint2.get());
break;
case 1:
GEOMBase::PublishSubObject(myWire.get());
2010-11-25 17:31:41 +05:00
break;
2011-03-28 18:36:29 +06:00
case 2:
GEOMBase::PublishSubObject(myCurve.get());
GEOMBase::PublishSubObject(myStartPoint.get());
break;
default:
2010-11-25 17:31:41 +05:00
break;
}
2004-01-07 20:46:21 +05:00
}