2004-06-16 21:24:55 +06:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2008-03-07 12:45:34 +05:00
|
|
|
// 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
|
2004-06-16 21:24:55 +06:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : EntityGUI_SketcherDlg.cxx
|
|
|
|
// Author : Damien COQUERET
|
|
|
|
// Module : GEOM
|
2008-03-07 12:45:34 +05:00
|
|
|
// $Header$
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
#include "EntityGUI_SketcherDlg.h"
|
|
|
|
#include "Sketcher_Profile.hxx"
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GEOM_Displayer.h"
|
2006-05-06 14:44:32 +06:00
|
|
|
#include "GEOMBase.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
#include "SUIT_Desktop.h"
|
|
|
|
#include "SUIT_Session.h"
|
|
|
|
#include "SUIT_MessageBox.h"
|
|
|
|
#include "SUIT_ResourceMgr.h"
|
|
|
|
#include "SalomeApp_Application.h"
|
2006-05-06 14:44:32 +06:00
|
|
|
#include "LightApp_Application.h"
|
2005-11-03 13:30:14 +05:00
|
|
|
#include "LightApp_SelectionMgr.h"
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
#include <qpushbutton.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <qlabel.h>
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
#include <BRep_Tool.hxx>
|
|
|
|
#include <TopExp.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TopExp_Explorer.hxx>
|
2004-06-16 21:24:55 +06:00
|
|
|
#include <TopoDS_Vertex.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TopoDS.hxx>
|
|
|
|
#include <BRepBuilderAPI_Transform.hxx>
|
|
|
|
#include <BRepBuilderAPI_MakeWire.hxx>
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GEOMImpl_Types.hxx"
|
|
|
|
|
|
|
|
#include "utilities.h"
|
|
|
|
|
|
|
|
using namespace std;
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : EntityGUI_SketcherDlg()
|
2008-03-07 12:45:34 +05:00
|
|
|
// purpose : Constructs a EntityGUI_SketcherDlg which is a child of 'parent', with the
|
2004-06-16 21:24:55 +06: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.
|
|
|
|
//=================================================================================
|
2006-05-06 14:44:32 +06:00
|
|
|
EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(GeometryGUI* GUI, QWidget* parent,
|
2008-03-07 12:45:34 +05:00
|
|
|
const char* name, bool modal, WFlags fl,
|
|
|
|
const double lineWidth)
|
2006-05-06 14:44:32 +06:00
|
|
|
:EntityGUI_Skeleton_QTD(parent, name, modal, WStyle_Customize |
|
|
|
|
WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
|
|
|
|
myIsAllAdded( false ),
|
2005-08-02 18:45:47 +06:00
|
|
|
GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ),
|
2008-03-07 12:45:34 +05:00
|
|
|
myGeometryGUI( GUI ),
|
|
|
|
myLineWidth( lineWidth )
|
2004-06-16 21:24:55 +06:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
myGeometryGUI->SetActiveDialogBox(this);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
if ( !name ) setName("EntityGUI_SketcherDlg");
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
buttonCancel->setText(tr("GEOM_BUT_CANCEL"));
|
|
|
|
buttonEnd->setText(tr("GEOM_BUT_END_SKETCH"));
|
|
|
|
buttonClose->setText(tr("GEOM_BUT_CLOSE_SKETCH"));
|
2006-05-06 14:44:32 +06:00
|
|
|
buttonHelp->setText(tr("GEOM_BUT_HELP"));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
|
|
|
|
QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_UNDO")));
|
|
|
|
QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_REDO")));
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
setCaption(tr("GEOM_SKETCHER_TITLE"));
|
|
|
|
|
|
|
|
GroupConstructors->setTitle(tr("GEOM_SKETCHER_EL"));
|
|
|
|
RadioButton1->setText(tr("GEOM_SKETCHER_SEGMENT"));
|
|
|
|
RadioButton2->setText(tr("GEOM_SKETCHER_ARC"));
|
|
|
|
GroupDest->setTitle(tr("GEOM_SKETCHER_DEST"));
|
|
|
|
GroupDest1->setTitle(tr("GEOM_SKETCHER_TYPE"));
|
|
|
|
RB_Dest1->setText(tr("GEOM_SKETCHER_POINT"));
|
|
|
|
RB_Dest2->setText(tr("GEOM_SKETCHER_DIR"));
|
|
|
|
|
|
|
|
/***************************************************************/
|
|
|
|
GroupPt = new EntityGUI_Point_QTD(GroupDest, "GroupPt");
|
|
|
|
GroupPt->GroupPoint->setTitle(tr("GEOM_SKETCHER_POINT"));
|
|
|
|
GroupPt->RB_Point1->setText(tr("GEOM_SKETCHER_ABS"));
|
|
|
|
GroupPt->RB_Point2->setText(tr("GEOM_SKETCHER_REL"));
|
|
|
|
GroupPt->RB_Point3->setText(tr("GEOM_SKETCHER_SEL"));
|
|
|
|
|
|
|
|
GroupD1 = new EntityGUI_Dir1_QTD(GroupDest, "GroupD1");
|
|
|
|
GroupD1->GroupDir1->setTitle(tr("GEOM_SKETCHER_DIR"));
|
|
|
|
GroupD1->RB_Dir11->setText(tr("GEOM_SKETCHER_ANGLE"));
|
|
|
|
GroupD1->RB_Dir12->setText(tr("GEOM_SKETCHER_PER"));
|
|
|
|
GroupD1->RB_Dir13->setText(tr("GEOM_SKETCHER_TAN"));
|
|
|
|
GroupD1->RB_Dir14->setText(tr("GEOM_SKETCHER_VXVY"));
|
|
|
|
|
|
|
|
GroupD2 = new EntityGUI_Dir2_QTD(GroupDest, "GroupD2");
|
|
|
|
GroupD2->GroupDir2->setTitle(tr("GEOM_SKETCHER_DIR"));
|
|
|
|
GroupD2->RB_Dir21->setText(tr("GEOM_SKETCHER_LENGTH"));
|
|
|
|
GroupD2->RB_Dir22->setText(tr("GEOM_SKETCHER_X"));
|
|
|
|
GroupD2->RB_Dir23->setText(tr("GEOM_SKETCHER_Y"));
|
|
|
|
|
|
|
|
Group1Sel = new EntityGUI_1Sel_QTD(this, "Group1Sel");
|
|
|
|
Group1Sel->TextLabel1->setText(tr("GEOM_SKETCHER_POINT2"));
|
|
|
|
Group1Sel->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
|
|
|
|
Group1Sel->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
|
|
|
|
Group1Sel->PushButton1->setPixmap(image0);
|
2004-12-01 15:39:14 +05:00
|
|
|
Group1Sel->buttonUndo->setPixmap(image1);
|
|
|
|
Group1Sel->buttonRedo->setPixmap(image2);
|
|
|
|
Group1Sel->LineEdit1->setReadOnly( true );
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
Group1Spin = new EntityGUI_1Spin(this, "Group1Spin");
|
|
|
|
Group1Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
|
|
|
|
Group1Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
|
2004-12-01 15:39:14 +05:00
|
|
|
Group1Spin->buttonUndo->setPixmap(image1);
|
|
|
|
Group1Spin->buttonRedo->setPixmap(image2);
|
2008-03-07 12:45:34 +05:00
|
|
|
QWidget::setTabOrder(Group1Spin->SpinBox_DX , Group1Spin->buttonApply);
|
|
|
|
QWidget::setTabOrder(Group1Spin->buttonApply, Group1Spin->buttonUndo);
|
|
|
|
QWidget::setTabOrder(Group1Spin->buttonUndo , Group1Spin->buttonRedo);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
Group2Spin = new EntityGUI_2Spin(this, "Group2Spin");
|
|
|
|
Group2Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
|
|
|
|
Group2Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
|
2004-12-01 15:39:14 +05:00
|
|
|
Group2Spin->buttonUndo->setPixmap(image1);
|
|
|
|
Group2Spin->buttonRedo->setPixmap(image2);
|
2008-03-07 12:45:34 +05:00
|
|
|
QWidget::setTabOrder(Group2Spin->SpinBox_DX , Group2Spin->SpinBox_DY);
|
|
|
|
QWidget::setTabOrder(Group2Spin->SpinBox_DY , Group2Spin->buttonApply);
|
|
|
|
QWidget::setTabOrder(Group2Spin->buttonApply, Group2Spin->buttonUndo);
|
|
|
|
QWidget::setTabOrder(Group2Spin->buttonUndo , Group2Spin->buttonRedo);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
Group3Spin = new EntityGUI_3Spin(this, "Group3Spin");
|
|
|
|
Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
|
|
|
|
Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
|
2004-12-01 15:39:14 +05:00
|
|
|
Group3Spin->buttonUndo->setPixmap(image1);
|
|
|
|
Group3Spin->buttonRedo->setPixmap(image2);
|
2008-03-07 12:45:34 +05:00
|
|
|
QWidget::setTabOrder(Group3Spin->SpinBox_DX , Group3Spin->SpinBox_DY);
|
|
|
|
QWidget::setTabOrder(Group3Spin->SpinBox_DY , Group3Spin->SpinBox_DZ);
|
|
|
|
QWidget::setTabOrder(Group3Spin->SpinBox_DZ , Group3Spin->buttonApply);
|
|
|
|
QWidget::setTabOrder(Group3Spin->buttonApply, Group3Spin->buttonUndo);
|
|
|
|
QWidget::setTabOrder(Group3Spin->buttonUndo , Group3Spin->buttonRedo);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
Group4Spin = new EntityGUI_4Spin(this, "Group4Spin");
|
|
|
|
Group4Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
|
|
|
|
Group4Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
|
2004-12-01 15:39:14 +05:00
|
|
|
Group4Spin->buttonUndo->setPixmap(image1);
|
|
|
|
Group4Spin->buttonRedo->setPixmap(image2);
|
2008-03-07 12:45:34 +05:00
|
|
|
QWidget::setTabOrder(Group4Spin->SpinBox_DX , Group4Spin->SpinBox_DY);
|
|
|
|
QWidget::setTabOrder(Group4Spin->SpinBox_DY , Group4Spin->SpinBox_DZ);
|
|
|
|
QWidget::setTabOrder(Group4Spin->SpinBox_DZ , Group4Spin->SpinBox_DS);
|
|
|
|
QWidget::setTabOrder(Group4Spin->SpinBox_DS , Group4Spin->buttonApply);
|
|
|
|
QWidget::setTabOrder(Group4Spin->buttonApply, Group4Spin->buttonUndo);
|
|
|
|
QWidget::setTabOrder(Group4Spin->buttonUndo , Group4Spin->buttonRedo);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1);
|
|
|
|
Layout5->addWidget(GroupD1, 1, 0);
|
|
|
|
Layout5->addWidget(GroupD2, 1, 1);
|
|
|
|
|
|
|
|
Layout1->addWidget(Group1Sel, 2, 0);
|
|
|
|
Layout1->addWidget(Group1Spin, 2, 0);
|
|
|
|
Layout1->addWidget(Group2Spin, 2, 0);
|
|
|
|
Layout1->addWidget(Group3Spin, 2, 0);
|
|
|
|
Layout1->addWidget(Group4Spin, 2, 0);
|
|
|
|
/***************************************************************/
|
|
|
|
|
|
|
|
/* signals and slots connections */
|
|
|
|
connect(buttonEnd, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
|
2004-12-01 15:39:14 +05:00
|
|
|
connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnEnd()));
|
2004-06-16 21:24:55 +06:00
|
|
|
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
|
2006-05-06 14:44:32 +06:00
|
|
|
connect(buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp()));
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
connect(Group1Sel->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
|
|
|
connect(Group1Sel->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
|
2004-12-01 15:39:14 +05:00
|
|
|
connect(Group1Sel->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
|
2004-06-16 21:24:55 +06:00
|
|
|
connect(Group1Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
|
|
|
connect(Group1Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
|
2004-12-01 15:39:14 +05:00
|
|
|
connect(Group1Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
|
2004-06-16 21:24:55 +06:00
|
|
|
connect(Group2Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
|
|
|
connect(Group2Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
|
2004-12-01 15:39:14 +05:00
|
|
|
connect(Group2Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
|
2004-06-16 21:24:55 +06:00
|
|
|
connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
|
|
|
connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
|
2004-12-01 15:39:14 +05:00
|
|
|
connect(Group3Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
|
2004-06-16 21:24:55 +06:00
|
|
|
connect(Group4Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
|
|
|
connect(Group4Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
|
2004-12-01 15:39:14 +05:00
|
|
|
connect(Group4Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo()));
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(TypeClicked(int)));
|
|
|
|
connect(GroupDest1, SIGNAL(clicked(int)), this, SLOT(DestClicked(int)));
|
|
|
|
connect(GroupPt->GroupPoint, SIGNAL(clicked(int)), this, SLOT(PointClicked(int)));
|
|
|
|
connect(GroupD1->GroupDir1, SIGNAL(clicked(int)), this, SLOT(Dir1Clicked(int)));
|
|
|
|
connect(GroupD2->GroupDir2, SIGNAL(clicked(int)), this, SLOT(Dir2Clicked(int)));
|
|
|
|
|
|
|
|
connect(Group1Sel->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
|
|
|
|
connect(Group1Sel->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
|
|
|
|
|
|
|
connect(Group1Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group2Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group2Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group4Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group4Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group4Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
connect(Group4Spin->SpinBox_DS, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double)));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double)));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
connect(myGeometryGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
|
|
|
|
connect(myGeometryGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
// install event filter on spin-boxes to provide Apply action on Return pressed
|
|
|
|
Group1Spin->SpinBox_DX->installEventFilter(this);
|
|
|
|
Group2Spin->SpinBox_DX->installEventFilter(this);
|
|
|
|
Group2Spin->SpinBox_DY->installEventFilter(this);
|
|
|
|
Group3Spin->SpinBox_DX->installEventFilter(this);
|
|
|
|
Group3Spin->SpinBox_DY->installEventFilter(this);
|
|
|
|
Group3Spin->SpinBox_DZ->installEventFilter(this);
|
|
|
|
Group4Spin->SpinBox_DX->installEventFilter(this);
|
|
|
|
Group4Spin->SpinBox_DY->installEventFilter(this);
|
|
|
|
Group4Spin->SpinBox_DZ->installEventFilter(this);
|
|
|
|
Group4Spin->SpinBox_DS->installEventFilter(this);
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
Init();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~EntityGUI_SketcherDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
|
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
myGeometryGUI->SetActiveDialogBox( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : eventFilter()
|
|
|
|
// purpose : event filter for spin-boxes to provide Apply action on Return pressed
|
|
|
|
//=================================================================================
|
|
|
|
bool EntityGUI_SketcherDlg::eventFilter (QObject* object, QEvent* event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::KeyPress) {
|
|
|
|
QKeyEvent* ke = (QKeyEvent*)event;
|
|
|
|
if (ke->key() == Key_Return) {
|
|
|
|
if (object == Group1Spin->SpinBox_DX) {
|
|
|
|
Group1Spin->buttonApply->animateClick();
|
|
|
|
return true;
|
|
|
|
} else if (object == Group2Spin->SpinBox_DX ||
|
|
|
|
object == Group2Spin->SpinBox_DY) {
|
|
|
|
Group2Spin->buttonApply->animateClick();
|
|
|
|
return true;
|
|
|
|
} else if (object == Group3Spin->SpinBox_DX ||
|
|
|
|
object == Group3Spin->SpinBox_DY ||
|
|
|
|
object == Group3Spin->SpinBox_DZ) {
|
|
|
|
Group3Spin->buttonApply->animateClick();
|
|
|
|
return true;
|
|
|
|
} else if (object == Group4Spin->SpinBox_DX ||
|
|
|
|
object == Group4Spin->SpinBox_DY ||
|
|
|
|
object == Group4Spin->SpinBox_DZ ||
|
|
|
|
object == Group4Spin->SpinBox_DS) {
|
|
|
|
Group4Spin->buttonApply->animateClick();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event->type() == QEvent::KeyRelease) {
|
|
|
|
// NPAL16010 (Sketcher Apply non available if only one line is modified)
|
|
|
|
// To have Apply active as soon as value text changed
|
|
|
|
QString s = ((QtxDblSpinBox*) object)->text();
|
|
|
|
bool ok;
|
|
|
|
double newVal = s.toDouble( &ok );
|
|
|
|
if ( ok )
|
|
|
|
ValueChangedInSpinBox( newVal );
|
|
|
|
}
|
|
|
|
|
|
|
|
return EntityGUI_Skeleton_QTD::eventFilter(object, event);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::Init()
|
|
|
|
{
|
|
|
|
/* init variables */
|
|
|
|
myEditCurrentArgument = Group1Sel->LineEdit1;
|
2004-12-01 15:39:14 +05:00
|
|
|
myCommand.append( "Sketcher" );
|
|
|
|
myUndoCommand.append( "Sketcher" );
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
mySketchState = FIRST_POINT;
|
|
|
|
globalSelection( GEOM_POINT );
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
myLastX1 = 0.0;
|
|
|
|
myLastY1 = 0.0;
|
|
|
|
myLastX2 = 0.0;
|
|
|
|
myLastY2 = 0.0;
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
myHelpFileName = "create_sketcher_page.html";
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
/* Get setting of step value from file configuration */
|
2005-06-02 13:17:09 +06:00
|
|
|
double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
/* min, max, step and decimals for spin boxes */
|
2008-03-07 12:45:34 +05:00
|
|
|
Group1Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group3Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group3Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group3Spin->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group4Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, DBL_DIGITS_DISPLAY);
|
|
|
|
Group4Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, DBL_DIGITS_DISPLAY);
|
|
|
|
Group4Spin->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group4Spin->SpinBox_DS->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., DBL_DIGITS_DISPLAY);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
/* displays Dialog */
|
|
|
|
GroupConstructors->setEnabled(false);
|
|
|
|
GroupDest1->setEnabled(false);
|
|
|
|
setEnabledUndo(false);
|
|
|
|
setEnabledRedo(false);
|
|
|
|
|
|
|
|
RadioButton1->setChecked(true);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
resize( 0, 0 );
|
|
|
|
TypeClicked(0);
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : InitClick()
|
2004-12-01 15:39:14 +05:00
|
|
|
// purpose :
|
2004-06-16 21:24:55 +06:00
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::InitClick()
|
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
disconnect(myGeometryGUI->getApp()->selectionMgr(), 0, this, 0);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
Group1Sel->hide();
|
|
|
|
Group1Spin->hide();
|
|
|
|
Group2Spin->hide();
|
|
|
|
Group3Spin->hide();
|
|
|
|
Group4Spin->hide();
|
|
|
|
|
|
|
|
resize(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : TypeClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::TypeClicked(int constructorId)
|
|
|
|
{
|
|
|
|
myConstructorId = constructorId;
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( myConstructorId == 0 ) // SEGMENT
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
GroupD2->setEnabled(true);
|
|
|
|
RB_Dest1->setEnabled(true);
|
|
|
|
RB_Dest1->setChecked(true);
|
2004-12-01 15:39:14 +05:00
|
|
|
DestClicked(1);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorId == 1 ) // ARC
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
GroupD2->setEnabled(false);
|
|
|
|
RB_Dest1->setEnabled(false);
|
|
|
|
RB_Dest2->setChecked(true);
|
2004-12-01 15:39:14 +05:00
|
|
|
DestClicked(0);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DestClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void EntityGUI_SketcherDlg::DestClicked( int constructorId )
|
2004-06-16 21:24:55 +06:00
|
|
|
{
|
|
|
|
GroupPt->hide();
|
|
|
|
GroupD1->hide();
|
|
|
|
GroupD2->hide();
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( constructorId == 1 )
|
|
|
|
{ // Point
|
2004-06-16 21:24:55 +06:00
|
|
|
GroupPt->RB_Point1->setChecked(true);
|
|
|
|
GroupPt->show();
|
2004-12-01 15:39:14 +05:00
|
|
|
PointClicked(1); // XY
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 0 )
|
|
|
|
{ // Direction
|
2004-06-16 21:24:55 +06:00
|
|
|
GroupD1->RB_Dir11->setChecked(true);
|
|
|
|
GroupD1->show();
|
|
|
|
GroupD2->show();
|
2004-12-01 15:39:14 +05:00
|
|
|
Dir1Clicked(2); // Angle
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : PointClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::PointClicked(int constructorId)
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
InitClick();
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Get setting of step value from file configuration
|
|
|
|
double step = SUIT_Session::session()->resourceMgr()->doubleValue("Geometry", "SettingsGeomStep", 100.0);
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( myConstructorId == 0 )
|
|
|
|
{ // SEGMENT
|
|
|
|
if ( constructorId == 1 )
|
|
|
|
{ // XY
|
2004-06-16 21:24:55 +06:00
|
|
|
mySketchType = PT_ABS;
|
2008-03-07 12:45:34 +05:00
|
|
|
Group2Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
2004-06-16 21:24:55 +06:00
|
|
|
Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
|
|
|
|
Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
|
|
|
|
myX = 0.0;
|
|
|
|
Group2Spin->SpinBox_DX->SetValue(myX);
|
|
|
|
myY = 0.0;
|
|
|
|
Group2Spin->SpinBox_DY->SetValue(myY);
|
|
|
|
Group2Spin->show();
|
|
|
|
Group2Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 0 )
|
|
|
|
{ // DXDY
|
2004-06-16 21:24:55 +06:00
|
|
|
mySketchType = PT_RELATIVE;
|
2008-03-07 12:45:34 +05:00
|
|
|
Group2Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
2004-06-16 21:24:55 +06:00
|
|
|
Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
|
|
|
|
Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
|
|
|
|
myDX = 0.0;
|
|
|
|
Group2Spin->SpinBox_DX->SetValue(myDX);
|
|
|
|
myDY = 0.0;
|
|
|
|
Group2Spin->SpinBox_DY->SetValue(myDY);
|
|
|
|
Group2Spin->show();
|
|
|
|
Group2Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 2 )
|
|
|
|
{ // Selection
|
2004-06-16 21:24:55 +06:00
|
|
|
mySketchType = PT_SEL;
|
|
|
|
myEditCurrentArgument = Group1Sel->LineEdit1;
|
2008-03-07 12:45:34 +05:00
|
|
|
connect(myGeometryGUI->getApp()->selectionMgr(),
|
|
|
|
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
2004-06-16 21:24:55 +06:00
|
|
|
Group1Sel->show();
|
|
|
|
Group1Sel->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
SelectionIntoArgument();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Dir1Clicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId)
|
|
|
|
{
|
|
|
|
myConstructorDirId = constructorId;
|
|
|
|
GroupD2->RB_Dir21->setChecked(true);
|
2004-12-01 15:39:14 +05:00
|
|
|
Dir2Clicked(2);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Dir2Clicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId)
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
InitClick();
|
2004-06-16 21:24:55 +06:00
|
|
|
myAngle = 0.0;
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Get setting of step value from file configuration
|
|
|
|
double step = SUIT_Session::session()->resourceMgr()->doubleValue("Geometry", "SettingsGeomStep", 100.0);
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( myConstructorId == 0 )
|
|
|
|
{ // SEGMENT
|
2004-06-16 21:24:55 +06:00
|
|
|
myX = 0.0;
|
|
|
|
myY = 0.0;
|
|
|
|
myLength = 100.0;
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( myConstructorDirId == 2 )
|
|
|
|
{ // Angle
|
2008-03-07 12:45:34 +05:00
|
|
|
Group2Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
2004-06-16 21:24:55 +06:00
|
|
|
Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
|
|
|
|
Group2Spin->SpinBox_DX->SetValue(myAngle);
|
|
|
|
Group2Spin->buttonApply->setFocus();
|
|
|
|
Group2Spin->show();
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( constructorId == 2 )
|
|
|
|
{ // Length
|
|
|
|
mySketchType = DIR_ANGLE_LENGTH;
|
|
|
|
Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2"));
|
|
|
|
Group2Spin->SpinBox_DY->SetValue(myLength);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 0 )
|
|
|
|
{ // X
|
|
|
|
mySketchType = DIR_ANGLE_X;
|
|
|
|
Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3"));
|
|
|
|
Group2Spin->SpinBox_DY->SetValue(myX);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 1 )
|
|
|
|
{ // Y
|
|
|
|
mySketchType = DIR_ANGLE_Y;
|
|
|
|
Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3"));
|
|
|
|
Group2Spin->SpinBox_DY->SetValue(myY);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorDirId == 0 )
|
|
|
|
{ // Perpendicular
|
2004-06-16 21:24:55 +06:00
|
|
|
Group1Spin->show();
|
|
|
|
Group1Spin->buttonApply->setFocus();
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( constructorId == 2 )
|
|
|
|
{ // Length
|
|
|
|
mySketchType = DIR_PER_LENGTH;
|
|
|
|
Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
|
|
|
|
Group1Spin->SpinBox_DX->SetValue(myLength);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 0 )
|
|
|
|
{ // X
|
|
|
|
mySketchType = DIR_PER_X;
|
|
|
|
Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
|
|
|
|
Group1Spin->SpinBox_DX->SetValue(myX);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 1 )
|
|
|
|
{ // Y
|
|
|
|
mySketchType = DIR_PER_Y;
|
|
|
|
Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
|
|
|
|
Group1Spin->SpinBox_DX->SetValue(myY);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorDirId == 1 )
|
|
|
|
{ // Tangent
|
2004-06-16 21:24:55 +06:00
|
|
|
Group1Spin->show();
|
|
|
|
Group1Spin->buttonApply->setFocus();
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( constructorId == 2 )
|
|
|
|
{ // Length
|
|
|
|
mySketchType = DIR_TAN_LENGTH;
|
|
|
|
Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2"));
|
|
|
|
Group1Spin->SpinBox_DX->SetValue(myLength);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 0 )
|
|
|
|
{ // X
|
|
|
|
mySketchType = DIR_TAN_X;
|
|
|
|
Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3"));
|
|
|
|
Group1Spin->SpinBox_DX->SetValue(myX);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 1 )
|
|
|
|
{ // Y
|
|
|
|
mySketchType = DIR_TAN_Y;
|
|
|
|
Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3"));
|
|
|
|
Group1Spin->SpinBox_DX->SetValue(myY);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorDirId == 3 )
|
|
|
|
{ // DXDY
|
2008-03-07 12:45:34 +05:00
|
|
|
Group3Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, DBL_DIGITS_DISPLAY);
|
|
|
|
Group3Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 0.1, DBL_DIGITS_DISPLAY);
|
|
|
|
Group3Spin->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
2004-06-16 21:24:55 +06:00
|
|
|
Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
|
|
|
|
Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
|
|
|
|
myDX = 0.0;
|
|
|
|
Group3Spin->SpinBox_DX->SetValue(myDX);
|
|
|
|
myDY = 0.0;
|
|
|
|
Group3Spin->SpinBox_DY->SetValue(myDY);
|
|
|
|
Group3Spin->show();
|
|
|
|
Group3Spin->buttonApply->setFocus();
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( constructorId == 2 )
|
|
|
|
{ // Length
|
|
|
|
mySketchType = DIR_DXDY_LENGTH;
|
|
|
|
Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2"));
|
|
|
|
Group3Spin->SpinBox_DZ->SetValue(myLength);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 0 )
|
|
|
|
{ // X
|
|
|
|
mySketchType = DIR_DXDY_X;
|
|
|
|
Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3"));
|
|
|
|
Group3Spin->SpinBox_DZ->SetValue(myX);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( constructorId == 1 )
|
|
|
|
{ // Y
|
|
|
|
mySketchType = DIR_DXDY_Y;
|
|
|
|
Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3"));
|
|
|
|
Group3Spin->SpinBox_DZ->SetValue(myY);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorId == 1 )
|
|
|
|
{ // ARC
|
|
|
|
if ( myConstructorDirId == 2 )
|
|
|
|
{ // Angle
|
|
|
|
if ( constructorId == 2 )
|
|
|
|
{ // Length
|
2008-03-07 12:45:34 +05:00
|
|
|
mySketchType = DIR_ANGLE_LENGTH;
|
|
|
|
Group3Spin->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., DBL_DIGITS_DISPLAY);
|
|
|
|
Group3Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group3Spin->SpinBox_DZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., DBL_DIGITS_DISPLAY);
|
|
|
|
Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2"));
|
|
|
|
Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2"));
|
|
|
|
Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2"));
|
|
|
|
Group3Spin->SpinBox_DX->SetValue(myAngle);
|
|
|
|
myRadius = 100.0;
|
|
|
|
Group3Spin->SpinBox_DY->SetValue(myRadius);
|
|
|
|
myLength = 30.0;
|
|
|
|
Group3Spin->SpinBox_DZ->SetValue(myLength);
|
|
|
|
Group3Spin->show();
|
|
|
|
Group3Spin->buttonApply->setFocus();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorDirId == 0 )
|
|
|
|
{ // Perpendicular
|
|
|
|
if ( constructorId == 2 )
|
|
|
|
{ // Length
|
2008-03-07 12:45:34 +05:00
|
|
|
mySketchType = DIR_PER_LENGTH;
|
|
|
|
Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
|
|
|
|
Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
|
|
|
|
myRadius = 100.0;
|
|
|
|
Group2Spin->SpinBox_DX->SetValue(myRadius);
|
|
|
|
myLength = 30.0;
|
|
|
|
Group2Spin->SpinBox_DY->SetValue(myLength);
|
|
|
|
Group2Spin->show();
|
|
|
|
Group2Spin->buttonApply->setFocus();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorDirId == 1 )
|
|
|
|
{ // Tangent
|
|
|
|
if ( constructorId == 2 )
|
|
|
|
{ // Length
|
2008-03-07 12:45:34 +05:00
|
|
|
mySketchType = DIR_TAN_LENGTH;
|
|
|
|
Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 5., DBL_DIGITS_DISPLAY);
|
|
|
|
Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2"));
|
|
|
|
Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2"));
|
|
|
|
myRadius = 100.0;
|
|
|
|
Group2Spin->SpinBox_DX->SetValue(myRadius);
|
|
|
|
myLength = 30.0;
|
|
|
|
Group2Spin->SpinBox_DY->SetValue(myLength);
|
|
|
|
Group2Spin->show();
|
|
|
|
Group2Spin->buttonApply->setFocus();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorDirId == 3 )
|
|
|
|
{ // DXDY
|
|
|
|
if ( constructorId == 2 )
|
|
|
|
{ // Length
|
|
|
|
mySketchType = DIR_DXDY_LENGTH;
|
|
|
|
Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2"));
|
|
|
|
Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2"));
|
|
|
|
Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2"));
|
|
|
|
Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2"));
|
|
|
|
myDX = 0.0;
|
|
|
|
Group4Spin->SpinBox_DX->SetValue(myDX);
|
|
|
|
myDY = 0.0;
|
|
|
|
Group4Spin->SpinBox_DY->SetValue(myDY);
|
|
|
|
myRadius = 100.0;
|
|
|
|
Group4Spin->SpinBox_DZ->SetValue(myRadius);
|
|
|
|
myLength = 30.0;
|
|
|
|
Group4Spin->SpinBox_DS->SetValue(myLength);
|
|
|
|
Group4Spin->show();
|
|
|
|
Group4Spin->buttonApply->setFocus();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnCancel()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::ClickOnCancel()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
close();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnEnd()
|
2004-12-01 15:39:14 +05:00
|
|
|
// purpose : connected to buttonEnd AND buttonClose
|
2004-06-16 21:24:55 +06:00
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::ClickOnEnd()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( sender() == buttonClose )
|
|
|
|
{
|
|
|
|
// Verify validity of commands
|
|
|
|
if ( myCommand.count() <= 2 )
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_MessageBox::error1( SUIT_Session::session()->activeApplication()->desktop(),
|
|
|
|
tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
return;
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
QString Command = myCommand.join( "" ) + GetNewCommand();
|
|
|
|
Sketcher_Profile aProfile (Command.ascii());
|
|
|
|
|
|
|
|
Command = myCommand.join( "" );
|
|
|
|
aProfile = Sketcher_Profile(Command.ascii());
|
|
|
|
TopoDS_Shape myShape;
|
|
|
|
if ( aProfile.IsDone() )
|
|
|
|
myShape = aProfile.GetShape();
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if(myShape.ShapeType() != TopAbs_VERTEX)
|
|
|
|
myCommand.append( ":WW" );
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// PAL16008 (Sketcher Validation should be equal to Apply&Close)
|
|
|
|
if (Group1Spin->buttonApply->isEnabled() && Group1Spin->isVisible() ||
|
|
|
|
Group2Spin->buttonApply->isEnabled() && Group2Spin->isVisible() ||
|
|
|
|
Group3Spin->buttonApply->isEnabled() && Group3Spin->isVisible() ||
|
|
|
|
Group4Spin->buttonApply->isEnabled() && Group4Spin->isVisible() ||
|
|
|
|
Group1Sel ->buttonApply->isEnabled() && Group1Sel->isVisible() )
|
|
|
|
{
|
|
|
|
ClickOnApply();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
myIsAllAdded = true;
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if( myCommand.size() > 2 )
|
|
|
|
if( !onAccept() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
close();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool EntityGUI_SketcherDlg::ClickOnApply()
|
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
if (sender() && sender()->inherits("QPushButton"))
|
|
|
|
((QPushButton*)sender())->setFocus(); // to update value of currently edited spin-box (PAL11948)
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
myCommand.append( GetNewCommand() );
|
|
|
|
mySketchState = NEXT_POINT;
|
|
|
|
|
|
|
|
myUndoCommand.clear();
|
|
|
|
myUndoCommand.append( "Sketcher" );
|
|
|
|
|
|
|
|
GroupConstructors->setEnabled(true);
|
|
|
|
GroupDest1->setEnabled(true);
|
|
|
|
setEnabledUndo(true);
|
|
|
|
setEnabledRedo(false);
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
|
|
|
|
|
|
|
// Set focus to SpinBox_DX
|
|
|
|
if (sender() == Group1Spin->buttonApply) {
|
|
|
|
(Group1Spin->SpinBox_DX)->setFocus();
|
|
|
|
(Group1Spin->SpinBox_DX)->selectAll();
|
|
|
|
}
|
|
|
|
else if (sender() == Group2Spin->buttonApply) {
|
|
|
|
(Group2Spin->SpinBox_DX)->setFocus();
|
|
|
|
(Group2Spin->SpinBox_DX)->selectAll();
|
|
|
|
}
|
|
|
|
else if (sender() == Group3Spin->buttonApply) {
|
|
|
|
(Group3Spin->SpinBox_DX)->setFocus();
|
|
|
|
(Group3Spin->SpinBox_DX)->selectAll();
|
|
|
|
}
|
|
|
|
else if (sender() == Group4Spin->buttonApply) {
|
|
|
|
(Group4Spin->SpinBox_DX)->setFocus();
|
|
|
|
(Group4Spin->SpinBox_DX)->selectAll();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2006-05-06 14:44:32 +06:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnHelp()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::ClickOnHelp()
|
|
|
|
{
|
|
|
|
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
|
2008-03-07 12:45:34 +05:00
|
|
|
if (app)
|
2006-05-06 14:44:32 +06:00
|
|
|
app->onHelpContextModule(myGeometryGUI ? app->moduleName(myGeometryGUI->moduleName()) : QString(""), myHelpFileName);
|
|
|
|
else {
|
2008-03-07 12:45:34 +05:00
|
|
|
QString platform;
|
|
|
|
#ifdef WIN32
|
|
|
|
platform = "winapplication";
|
|
|
|
#else
|
|
|
|
platform = "application";
|
|
|
|
#endif
|
|
|
|
|
2006-05-06 14:44:32 +06:00
|
|
|
SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
|
|
|
|
QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
|
2008-03-07 12:45:34 +05:00
|
|
|
arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
|
2006-05-06 14:44:32 +06:00
|
|
|
QObject::tr("BUT_OK"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : ClickOnUndo()
|
2004-06-16 21:24:55 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void EntityGUI_SketcherDlg::ClickOnUndo()
|
2004-06-16 21:24:55 +06:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
myUndoCommand.append( myCommand.last() );
|
|
|
|
myCommand.pop_back();
|
|
|
|
|
|
|
|
if(myCommand.count() == 1) {
|
|
|
|
mySketchState = FIRST_POINT;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
RadioButton1->setChecked(true);
|
|
|
|
TypeClicked(0);
|
|
|
|
|
|
|
|
GroupConstructors->setEnabled(false);
|
|
|
|
GroupDest1->setEnabled(false);
|
|
|
|
setEnabledUndo(false);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
setEnabledRedo(true);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : ClickOnRedo()
|
2004-06-16 21:24:55 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void EntityGUI_SketcherDlg::ClickOnRedo()
|
2004-06-16 21:24:55 +06:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
myCommand.append( myUndoCommand.last() );
|
|
|
|
myUndoCommand.pop_back();
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
mySketchState = NEXT_POINT;
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
GroupConstructors->setEnabled(true);
|
|
|
|
GroupDest1->setEnabled(true);
|
|
|
|
setEnabledUndo(true);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if(myUndoCommand.count() == 1)
|
|
|
|
setEnabledRedo(false);
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : setEnabledUndo()
|
2004-06-16 21:24:55 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void EntityGUI_SketcherDlg::setEnabledUndo(bool value)
|
2004-06-16 21:24:55 +06:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
Group1Sel->buttonUndo->setEnabled(value);
|
|
|
|
Group1Spin->buttonUndo->setEnabled(value);
|
|
|
|
Group2Spin->buttonUndo->setEnabled(value);
|
|
|
|
Group3Spin->buttonUndo->setEnabled(value);
|
|
|
|
Group4Spin->buttonUndo->setEnabled(value);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : setEnabledRedo()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::setEnabledRedo(bool value)
|
|
|
|
{
|
|
|
|
Group1Sel->buttonRedo->setEnabled(value);
|
|
|
|
Group1Spin->buttonRedo->setEnabled(value);
|
|
|
|
Group2Spin->buttonRedo->setEnabled(value);
|
|
|
|
Group3Spin->buttonRedo->setEnabled(value);
|
|
|
|
Group4Spin->buttonRedo->setEnabled(value);
|
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection as changed
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::SelectionIntoArgument()
|
|
|
|
{
|
|
|
|
myEditCurrentArgument->setText("");
|
2004-12-01 15:39:14 +05:00
|
|
|
myX = myLastX1;
|
|
|
|
myY = myLastY1;
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
int nbSel = IObjectCount();
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1 )
|
|
|
|
{
|
|
|
|
Standard_Boolean aRes = Standard_False;
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
|
|
|
|
TopoDS_Shape aShape;
|
|
|
|
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_VERTEX ) ) {
|
|
|
|
gp_Trsf aTrans;
|
2005-06-02 13:17:09 +06:00
|
|
|
gp_Ax3 aWPlane = myGeometryGUI->GetWorkingPlane();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
aTrans.SetTransformation(aWPlane);
|
|
|
|
BRepBuilderAPI_Transform aTransformation(aShape, aTrans, Standard_False);
|
|
|
|
aShape = aTransformation.Shape();
|
|
|
|
|
|
|
|
gp_Pnt aPnt;
|
|
|
|
if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
|
|
|
|
myX = aPnt.X();
|
|
|
|
myY = aPnt.Y();
|
|
|
|
Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::SetEditCurrentArgument()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( sender() == Group1Sel->PushButton1 )
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myEditCurrentArgument = Group1Sel->LineEdit1;
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument->setFocus();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
SelectionIntoArgument();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : LineEditReturnPressed()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::LineEditReturnPressed()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( sender() == Group1Sel->LineEdit1 )
|
|
|
|
{
|
|
|
|
myEditCurrentArgument = Group1Sel->LineEdit1;
|
|
|
|
|
|
|
|
/* User name of object input management */
|
|
|
|
/* If successfull the selection is changed and signal emitted... */
|
|
|
|
/* so SelectionIntoArgument() is automatically called. */
|
|
|
|
const QString objectUserName = myEditCurrentArgument->text();
|
|
|
|
QWidget* thisWidget = (QWidget*)this;
|
2005-06-02 13:17:09 +06:00
|
|
|
if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, selectedIO()))
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument->setText(objectUserName);
|
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : DeactivateActiveDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::DeactivateActiveDialog()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
//myGeometryGUI->SetState( -1 );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
setEnabled( false );
|
|
|
|
globalSelection();
|
2008-03-07 12:45:34 +05:00
|
|
|
disconnect(myGeometryGUI->getApp()->selectionMgr(), 0, this, 0);
|
2005-06-02 13:17:09 +06:00
|
|
|
myGeometryGUI->SetActiveDialogBox(0);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::ActivateThisDialog()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
myGeometryGUI->EmitSignalDeactivateDialog();
|
2004-12-01 15:39:14 +05:00
|
|
|
setEnabled(true);
|
2005-06-02 13:17:09 +06:00
|
|
|
myGeometryGUI->SetActiveDialogBox((QDialog*)this);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
connect(myGeometryGUI->getApp()->selectionMgr(),
|
|
|
|
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
//myGeometryGUI->SetState( 0 );
|
2004-12-01 15:39:14 +05:00
|
|
|
globalSelection( GEOM_POINT );
|
|
|
|
|
|
|
|
myEditCurrentArgument = Group1Sel->LineEdit1;
|
|
|
|
myEditCurrentArgument->setFocus();
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent [REDEFINED]
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::enterEvent(QEvent* e)
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( !GroupConstructors->isEnabled())
|
|
|
|
ActivateThisDialog();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : closeEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e)
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
//myGeometryGUI->SetState( -1 );
|
2008-03-07 12:45:34 +05:00
|
|
|
disconnect(myGeometryGUI->getApp()->selectionMgr(), 0, this, 0);
|
2004-12-01 15:39:14 +05:00
|
|
|
QDialog::closeEvent( e );
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ValueChangedInSpinBox()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue)
|
|
|
|
{
|
|
|
|
QObject* send = (QObject*)sender();
|
|
|
|
Standard_Real vx, vy, vz, vs;
|
|
|
|
vx = vy = vz = vs = 0.0;
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( send == Group1Spin->SpinBox_DX)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = newValue;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group2Spin->SpinBox_DX )
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = newValue;
|
|
|
|
vy = Group2Spin->SpinBox_DY->GetValue();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group2Spin->SpinBox_DY)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = Group2Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = newValue;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group3Spin->SpinBox_DX)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = newValue;
|
|
|
|
vy = Group3Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = Group3Spin->SpinBox_DZ->GetValue();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group3Spin->SpinBox_DY)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = Group3Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = newValue;
|
|
|
|
vz = Group3Spin->SpinBox_DZ->GetValue();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group3Spin->SpinBox_DZ)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = Group3Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = Group3Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = newValue;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group4Spin->SpinBox_DX)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = newValue;
|
|
|
|
vy = Group4Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = Group4Spin->SpinBox_DZ->GetValue();
|
|
|
|
vs = Group4Spin->SpinBox_DS->GetValue();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group4Spin->SpinBox_DY)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = Group4Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = newValue;
|
|
|
|
vz = Group4Spin->SpinBox_DZ->GetValue();
|
|
|
|
vs = Group4Spin->SpinBox_DS->GetValue();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group4Spin->SpinBox_DZ)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = Group4Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = Group4Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = newValue;
|
|
|
|
vs = Group4Spin->SpinBox_DS->GetValue();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( send == Group4Spin->SpinBox_DS)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
vx = Group4Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = Group4Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = Group4Spin->SpinBox_DZ->GetValue();
|
|
|
|
vs = newValue;
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
// NPAL16010 (Sketcher Apply non available if only one line is modified)
|
|
|
|
// if ValueChangedInSpinBox() called from eventFilter()
|
|
|
|
else if ( Group1Spin->SpinBox_DX->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = newValue;
|
|
|
|
}
|
|
|
|
else if ( Group2Spin->SpinBox_DX ->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = newValue;
|
|
|
|
vy = Group2Spin->SpinBox_DY->GetValue();
|
|
|
|
}
|
|
|
|
else if ( Group2Spin->SpinBox_DY->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = Group2Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = newValue;
|
|
|
|
}
|
|
|
|
else if ( Group3Spin->SpinBox_DX->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = newValue;
|
|
|
|
vy = Group3Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = Group3Spin->SpinBox_DZ->GetValue();
|
|
|
|
}
|
|
|
|
else if ( Group3Spin->SpinBox_DY->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = Group3Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = newValue;
|
|
|
|
vz = Group3Spin->SpinBox_DZ->GetValue();
|
|
|
|
}
|
|
|
|
else if ( Group3Spin->SpinBox_DZ->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = Group3Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = Group3Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = newValue;
|
|
|
|
}
|
|
|
|
else if ( Group4Spin->SpinBox_DX->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = newValue;
|
|
|
|
vy = Group4Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = Group4Spin->SpinBox_DZ->GetValue();
|
|
|
|
vs = Group4Spin->SpinBox_DS->GetValue();
|
|
|
|
}
|
|
|
|
else if ( Group4Spin->SpinBox_DY->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = Group4Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = newValue;
|
|
|
|
vz = Group4Spin->SpinBox_DZ->GetValue();
|
|
|
|
vs = Group4Spin->SpinBox_DS->GetValue();
|
|
|
|
}
|
|
|
|
else if ( Group4Spin->SpinBox_DZ->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = Group4Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = Group4Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = newValue;
|
|
|
|
vs = Group4Spin->SpinBox_DS->GetValue();
|
|
|
|
}
|
|
|
|
else if ( Group4Spin->SpinBox_DS->hasFocus() )
|
|
|
|
{
|
|
|
|
vx = Group4Spin->SpinBox_DX->GetValue();
|
|
|
|
vy = Group4Spin->SpinBox_DY->GetValue();
|
|
|
|
vz = Group4Spin->SpinBox_DZ->GetValue();
|
|
|
|
vs = newValue;
|
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( myConstructorId == 0 )
|
|
|
|
{ // SEGMENT
|
|
|
|
if ( mySketchType == PT_ABS)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myX = vx;
|
|
|
|
myY = vy;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == PT_RELATIVE)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myDX = vx;
|
|
|
|
myDY = vy;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_ANGLE_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myAngle = vx;
|
|
|
|
myLength = vy;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_ANGLE_X)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myAngle = vx;
|
|
|
|
myX = vy;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_ANGLE_Y)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myAngle = vx;
|
|
|
|
myY = vy;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_PER_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myLength = vx;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_PER_X)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myX = vx;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_PER_Y)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myY = vx;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_TAN_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myLength = vx;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_TAN_X)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myX = vx;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_TAN_Y)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myY = vx;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_DXDY_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myDX = vx;
|
|
|
|
myDY = vy;
|
|
|
|
myLength = vz;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_DXDY_X)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myDX = vx;
|
|
|
|
myDY = vy;
|
|
|
|
myX = vz;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_DXDY_Y)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myDX = vx;
|
|
|
|
myDY = vy;
|
|
|
|
myY = vz;
|
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorId == 1 )
|
|
|
|
{ // ARC
|
|
|
|
if ( mySketchType == DIR_ANGLE_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myAngle = vx;
|
|
|
|
myRadius = vy;
|
|
|
|
myLength = vz;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_PER_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myRadius = vx;
|
|
|
|
myLength = vy;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_TAN_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myRadius = vx;
|
|
|
|
myLength = vy;
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mySketchType == DIR_DXDY_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myDX = vx;
|
|
|
|
myDY = vy;
|
|
|
|
myRadius = vz;
|
|
|
|
myLength = vs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOMBase_Helper::displayPreview(false, true, true, myLineWidth);
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : GetNewCommand()
|
2004-12-01 15:39:14 +05:00
|
|
|
// purpose : Build the new command with context
|
2004-06-16 21:24:55 +06:00
|
|
|
//=================================================================================
|
|
|
|
QString EntityGUI_SketcherDlg::GetNewCommand()
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
QString myNewCommand = ":";
|
|
|
|
if ( mySketchState == FIRST_POINT ) {
|
|
|
|
if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
|
|
|
|
myNewCommand = myNewCommand + "F " + QString::number(myX) + " " + QString::number(myY);
|
|
|
|
if ( mySketchType == PT_RELATIVE)
|
|
|
|
myNewCommand = myNewCommand + "F " + QString::number(myDX) + " " + QString::number(myDY);
|
2004-06-16 21:24:55 +06:00
|
|
|
return myNewCommand;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( myConstructorId == 0 )
|
|
|
|
{ // SEGMENT
|
|
|
|
if ( mySketchType == PT_ABS || mySketchType == PT_SEL)
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY);
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == PT_RELATIVE)
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY);
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_ANGLE_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "R " + QString::number(myAngle);
|
|
|
|
myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_ANGLE_X)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "R " + QString::number(myAngle);
|
|
|
|
myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_ANGLE_Y)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "R " + QString::number(myAngle);
|
|
|
|
myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_PER_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "R " + QString::number(90.0);
|
|
|
|
myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_PER_X)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "R " + QString::number(90.0);
|
|
|
|
myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_PER_Y)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "R " + QString::number(90.0);
|
|
|
|
myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_TAN_LENGTH)
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "L " + QString::number(myLength);
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_TAN_X)
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "IX " + QString::number(myX);
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_TAN_Y)
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "IY " + QString::number(myY);
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_DXDY_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
|
|
|
|
myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_DXDY_X)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
|
|
|
|
myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_DXDY_Y)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
|
|
|
|
myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY);
|
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( myConstructorId == 1 )
|
|
|
|
{ // ARC
|
|
|
|
if ( mySketchType == DIR_ANGLE_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "R " + QString::number(myAngle);
|
|
|
|
myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_PER_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "R " + QString::number(90.0);
|
|
|
|
myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_TAN_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( mySketchType == DIR_DXDY_LENGTH)
|
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY);
|
|
|
|
myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return myNewCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : createOperation
|
2004-06-16 21:24:55 +06:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation()
|
2004-06-16 21:24:55 +06:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
return getGeomEngine()->GetICurvesOperations( getStudyId() );
|
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : isValid
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool EntityGUI_SketcherDlg::isValid( QString& msg )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : execute
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
|
|
|
|
{
|
|
|
|
if(mySketchState == FIRST_POINT) {
|
|
|
|
myLastX2 = myX;
|
|
|
|
myLastY2 = myY;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//Test if the current point is the same as the last one
|
|
|
|
TopoDS_Shape myShape1, myShape2;
|
|
|
|
|
|
|
|
//Last Shape
|
|
|
|
QString Command1 = myCommand.join( "" );
|
|
|
|
Sketcher_Profile aProfile1 (Command1.ascii());
|
|
|
|
if(aProfile1.IsDone())
|
|
|
|
myShape1 = aProfile1.GetShape();
|
|
|
|
|
|
|
|
//Current Shape
|
|
|
|
QString Command2 = Command1 + GetNewCommand();
|
|
|
|
Sketcher_Profile aProfile2 (Command2.ascii());
|
|
|
|
if(aProfile2.IsDone())
|
|
|
|
myShape2 = aProfile2.GetShape();
|
|
|
|
|
|
|
|
if(myShape2.IsNull()) {
|
|
|
|
//the current point is the same as the last one
|
|
|
|
myLastX2 = myLastX1;
|
|
|
|
myLastY2 = myLastY1;
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else {
|
|
|
|
TopoDS_Vertex V1, V2;
|
|
|
|
gp_Pnt pt;
|
|
|
|
if(myShape1.ShapeType() == TopAbs_VERTEX) {
|
|
|
|
//the last shape is the first point
|
|
|
|
pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape1));
|
2004-06-16 21:24:55 +06:00
|
|
|
myLastX1 = pt.X();
|
|
|
|
myLastY1 = pt.Y();
|
|
|
|
}
|
|
|
|
else {
|
2004-12-01 15:39:14 +05:00
|
|
|
TopExp::Vertices(TopoDS::Wire(myShape1), V1, V2);
|
|
|
|
pt = BRep_Tool::Pnt(V2);
|
2004-06-16 21:24:55 +06:00
|
|
|
myLastX1 = pt.X();
|
|
|
|
myLastY1 = pt.Y();
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
TopExp::Vertices(TopoDS::Wire(myShape2), V1, V2);
|
|
|
|
pt = BRep_Tool::Pnt(V2);
|
|
|
|
myLastX2 = pt.X();
|
|
|
|
myLastY2 = pt.Y();
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
QString cmd;
|
2008-03-07 12:45:34 +05:00
|
|
|
if( ( mySketchState != FIRST_POINT &&
|
|
|
|
myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
cmd = myCommand.join( "" );
|
|
|
|
|
|
|
|
if ( Group1Sel->isVisible() ) {
|
|
|
|
Group1Sel->buttonApply->setEnabled(false);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group1Sel->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
if ( Group1Spin->isVisible() ) {
|
|
|
|
Group1Spin->buttonApply->setEnabled(false);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group1Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
if ( Group2Spin->isVisible() ) {
|
|
|
|
Group2Spin->buttonApply->setEnabled(false);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group2Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
if ( Group3Spin->isVisible() ) {
|
|
|
|
Group3Spin->buttonApply->setEnabled(false);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group3Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
if ( Group4Spin->isVisible() ) {
|
|
|
|
Group4Spin->buttonApply->setEnabled(false);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group4Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else {
|
|
|
|
cmd = myCommand.join( "" ) + GetNewCommand();
|
|
|
|
|
|
|
|
if ( Group1Sel->isVisible() ) {
|
|
|
|
Group1Sel->buttonApply->setEnabled(true);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group1Sel->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
if ( Group1Spin->isVisible() ) {
|
|
|
|
Group1Spin->buttonApply->setEnabled(true);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group1Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
if ( Group2Spin->isVisible() ) {
|
|
|
|
Group2Spin->buttonApply->setEnabled(true);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group2Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
if ( Group3Spin->isVisible() ) {
|
|
|
|
Group3Spin->buttonApply->setEnabled(true);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group3Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
if ( Group4Spin->isVisible() ) {
|
|
|
|
Group4Spin->buttonApply->setEnabled(true);
|
2008-03-07 12:45:34 +05:00
|
|
|
//Group4Spin->buttonApply->setFocus();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
gp_Ax3 myWPlane = myGeometryGUI->GetWorkingPlane();
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
|
|
|
|
WPlane->length(9);
|
|
|
|
WPlane[0] = myWPlane.Location().X();
|
|
|
|
WPlane[1] = myWPlane.Location().Y();
|
|
|
|
WPlane[2] = myWPlane.Location().Z();
|
|
|
|
|
|
|
|
WPlane[3] = myWPlane.Direction().X();
|
|
|
|
WPlane[4] = myWPlane.Direction().Y();
|
|
|
|
WPlane[5] = myWPlane.Direction().Z();
|
|
|
|
|
|
|
|
WPlane[6] = myWPlane.XDirection().X();
|
|
|
|
WPlane[7] = myWPlane.XDirection().Y();
|
|
|
|
WPlane[8] = myWPlane.XDirection().Z();
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOM::GEOM_Object_var anObj =
|
|
|
|
GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSketcher( cmd.latin1(), WPlane );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
if ( !anObj->_is_nil() )
|
|
|
|
objects.push_back( anObj._retn() );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//================================================================
|
|
|
|
// Function : displayPreview
|
|
|
|
// Purpose : Method for displaying preview of resulting shape
|
|
|
|
// Redefined from GEOMBase_Helper.
|
|
|
|
//================================================================
|
|
|
|
void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
|
|
|
|
const bool append,
|
|
|
|
const bool activate,
|
|
|
|
const bool update,
|
|
|
|
const double lineWidth )
|
|
|
|
{
|
|
|
|
// Set color for preview shape
|
|
|
|
getDisplayer()->SetColor( Quantity_NOC_RED );
|
|
|
|
|
|
|
|
// set width of displayed shape
|
2008-03-07 12:45:34 +05:00
|
|
|
getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Disable activation of selection
|
|
|
|
getDisplayer()->SetToActivate( activate );
|
|
|
|
|
|
|
|
// Make a reference to GEOM_Object
|
2008-03-07 12:45:34 +05:00
|
|
|
CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
|
|
|
|
getDisplayer()->SetName( objStr.in() );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Create wire from applayed object
|
|
|
|
TopoDS_Shape anApplyedWire, aLastSegment;
|
|
|
|
if ( !createShapes( object, anApplyedWire, aLastSegment ) )
|
2004-06-16 21:24:55 +06:00
|
|
|
return;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Build prs
|
|
|
|
SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
|
|
|
|
if ( aPrs != 0 && !aPrs->IsNull() )
|
|
|
|
GEOMBase_Helper::displayPreview( aPrs, append, update );
|
|
|
|
|
|
|
|
getDisplayer()->SetColor( Quantity_NOC_VIOLET );
|
|
|
|
aPrs = getDisplayer()->BuildPrs( aLastSegment );
|
|
|
|
if ( aPrs != 0 && !aPrs->IsNull() )
|
|
|
|
GEOMBase_Helper::displayPreview( aPrs, append, update );
|
|
|
|
|
|
|
|
getDisplayer()->UnsetName();
|
|
|
|
|
|
|
|
// Enable activation of displayed objects
|
|
|
|
getDisplayer()->SetToActivate( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
//================================================================
|
|
|
|
// Function : createShapes
|
|
|
|
// Purpose : Create applyed wire, and last segment from entry object
|
|
|
|
//================================================================
|
|
|
|
bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
|
|
|
|
TopoDS_Shape& theApplyedWire,
|
|
|
|
TopoDS_Shape& theLastSegment )
|
|
|
|
{
|
|
|
|
TopoDS_Shape aShape;
|
|
|
|
if ( !GEOMBase::GetShape( theObject, aShape ) ||
|
|
|
|
aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() ||
|
|
|
|
Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() ||
|
|
|
|
Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() ||
|
|
|
|
Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() ||
|
|
|
|
Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() )
|
|
|
|
{
|
|
|
|
theApplyedWire = aShape;
|
|
|
|
return true;
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
BRepBuilderAPI_MakeWire aBuilder;
|
|
|
|
TopExp_Explorer anExp( aShape, TopAbs_EDGE );
|
|
|
|
while( 1 )
|
|
|
|
{
|
|
|
|
TopoDS_Shape anEdge = anExp.Current();
|
|
|
|
anExp.Next();
|
|
|
|
if ( anExp.More() ) // i.e. non-last edge
|
|
|
|
aBuilder.Add( TopoDS::Edge( anEdge ) );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
theLastSegment = anEdge;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( aBuilder.IsDone() )
|
|
|
|
theApplyedWire = aBuilder.Shape();
|
|
|
|
|
|
|
|
return true;
|
2004-06-16 21:24:55 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : keyPressEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void EntityGUI_SketcherDlg::keyPressEvent( QKeyEvent* e )
|
|
|
|
{
|
|
|
|
QDialog::keyPressEvent( e );
|
|
|
|
if ( e->isAccepted() )
|
|
|
|
return;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
if ( e->key() == Key_F1 )
|
|
|
|
{
|
|
|
|
e->accept();
|
|
|
|
ClickOnHelp();
|
|
|
|
}
|
|
|
|
}
|