2016-03-15 17:26:56 +05:00
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2004-06-16 21:24:55 +06:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2008-03-07 12:45:34 +05:00
//
2012-08-09 13:58:02 +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
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2008-03-07 12:45:34 +05:00
//
2012-08-09 13:58:02 +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.
2008-03-07 12:45:34 +05:00
//
2012-08-09 13:58:02 +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
2008-03-07 12:45:34 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2004-06-16 21:24:55 +06:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : EntityGUI_SketcherDlg.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
2004-06-16 21:24:55 +06:00
//
# include "EntityGUI_SketcherDlg.h"
2009-02-13 17:16:39 +05:00
# include "EntityGUI_Widgets.h"
2012-08-09 13:58:02 +06:00
# include <SalomeApp_DoubleSpinBox.h>
# include <OCCViewer_ViewPort3d.h>
# include <OCCViewer_ViewWindow.h>
# include <OCCViewer_ViewSketcher.h>
2005-06-02 13:17:09 +06:00
2009-02-13 17:16:39 +05:00
# include <GEOMBase.h>
# include <GeometryGUI.h>
# include <GEOMImpl_Types.hxx>
2012-08-09 13:58:02 +06:00
# include <Geom_Surface.hxx>
# include <Geom_Plane.hxx>
# include <GeomLib_IsPlanarSurface.hxx>
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
# include <SUIT_Desktop.h>
# include <SUIT_Session.h>
# include <SUIT_MessageBox.h>
# include <SUIT_ResourceMgr.h>
# include <SalomeApp_Application.h>
# include <LightApp_Application.h>
# include <LightApp_SelectionMgr.h>
2015-02-09 21:50:36 +05:00
# include "utilities.h"
2009-02-13 17:16:39 +05:00
2012-08-09 13:58:02 +06:00
# include <DlgRef.h>
2009-02-13 17:16:39 +05:00
# include <QKeyEvent>
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>
2012-08-09 13:58:02 +06:00
# include <BRepBuilderAPI_MakeVertex.hxx>
2009-02-13 17:16:39 +05:00
# include <Sketcher_Profile.hxx>
2004-06-16 21:24:55 +06:00
2012-08-09 13:58:02 +06:00
# include <SalomeApp_Study.h>
# include <SalomeApp_Tools.h>
2014-11-19 20:45:44 +05:00
# include "utilities.h"
2012-08-09 13:58:02 +06:00
# include <gp_Pln.hxx>
# include <Basics_Utils.hxx>
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.
//=================================================================================
2009-02-13 17:16:39 +05:00
EntityGUI_SketcherDlg : : EntityGUI_SketcherDlg ( GeometryGUI * GUI , QWidget * parent ,
2012-08-09 13:58:02 +06:00
bool modal , Qt : : WindowFlags fl ,
const double lineWidth )
2009-02-13 17:16:39 +05:00
: QDialog ( parent , fl ) ,
myIsAllAdded ( false ) ,
myIsApply ( false ) ,
GEOMBase_Helper ( dynamic_cast < SUIT_Desktop * > ( parent ) ) ,
myGeometryGUI ( GUI ) ,
myLineWidth ( lineWidth )
2004-06-16 21:24:55 +06:00
{
2012-08-09 13:58:02 +06:00
SUIT_ResourceMgr * aResMgr = SUIT_Session : : session ( ) - > resourceMgr ( ) ;
2009-02-13 17:16:39 +05:00
setModal ( modal ) ;
setAttribute ( Qt : : WA_DeleteOnClose ) ;
2012-08-09 13:58:02 +06:00
// Disable rectangular selection
// SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
// ((OCCViewer_ViewWindow*)theViewWindow)->setEnabledDrawMode( false );
// MESSAGE("((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode();"<<((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode())
// OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
// vp->setSketchingEnabled( false );
// MESSAGE("vp->isSketchingEnabled()"<<vp->isSketchingEnabled())
// ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(true);
// OCCViewer_ViewSketcher* aViewSketcher = ((OCCViewer_ViewWindow*)theViewWindow)->getSketcher( OCCViewer_ViewWindow::Rect );
// aViewSketcher->deactivate()
// aViewSketcher->setVisible(false);
// this->setMouseTracking(false);
2005-06-02 13:17:09 +06:00
myGeometryGUI - > SetActiveDialogBox ( this ) ;
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
MainWidget = new EntityGUI_Skeleton ( this ) ;
QVBoxLayout * topLayout = new QVBoxLayout ( this ) ;
topLayout - > setMargin ( 9 ) ; topLayout - > setSpacing ( 6 ) ;
2004-06-16 21:24:55 +06:00
2009-02-13 17:16:39 +05:00
MainWidget - > buttonCancel - > setText ( tr ( " GEOM_BUT_CANCEL " ) ) ;
2012-08-09 13:58:02 +06:00
MainWidget - > buttonEnd - > setText ( tr ( " GEOM_BUT_CLOSE " ) ) ;
2009-02-13 17:16:39 +05:00
MainWidget - > buttonClose - > setText ( tr ( " GEOM_BUT_CLOSE_SKETCH " ) ) ;
MainWidget - > buttonHelp - > setText ( tr ( " GEOM_BUT_HELP " ) ) ;
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
QPixmap image0 ( aResMgr - > loadPixmap ( " GEOM " , tr ( " ICON_SELECT " ) ) ) ;
QPixmap image1 ( aResMgr - > loadPixmap ( " GEOM " , tr ( " ICON_DLG_UNDO " ) ) ) ;
QPixmap image2 ( aResMgr - > loadPixmap ( " GEOM " , tr ( " ICON_DLG_REDO " ) ) ) ;
QPixmap image3 ( aResMgr - > loadPixmap ( " GEOM " , tr ( " ICON_DLG_LINE_2P " ) ) ) ;
QPixmap image4 ( aResMgr - > loadPixmap ( " GEOM " , tr ( " ICON_DLG_ARC " ) ) ) ;
QPixmap image5 ( aResMgr - > loadPixmap ( " GEOM " , tr ( " ICON_SELECT " ) ) ) ;
QPixmap image6 ( aResMgr - > loadPixmap ( " GEOM " , tr ( " ICON_DLG_RECTANGLE " ) ) ) ;
2004-06-16 21:24:55 +06:00
2009-02-13 17:16:39 +05:00
setWindowTitle ( tr ( " GEOM_SKETCHER_TITLE " ) ) ;
2004-06-16 21:24:55 +06:00
2009-02-13 17:16:39 +05:00
MainWidget - > GroupConstructors - > setTitle ( tr ( " GEOM_SKETCHER_EL " ) ) ;
2012-08-09 13:58:02 +06:00
MainWidget - > RadioButton1 - > setText ( " " ) ;
MainWidget - > RadioButton1 - > setIcon ( image3 ) ;
MainWidget - > RadioButton2 - > setText ( " " ) ;
MainWidget - > RadioButton2 - > setIcon ( image4 ) ;
MainWidget - > RadioButton3 - > setText ( " " ) ;
MainWidget - > RadioButton3 - > setIcon ( image6 ) ;
2009-02-13 17:16:39 +05:00
MainWidget - > GroupDest - > setTitle ( tr ( " GEOM_SKETCHER_DEST " ) ) ;
MainWidget - > GroupDest1 - > setTitle ( tr ( " GEOM_SKETCHER_TYPE " ) ) ;
MainWidget - > RB_Dest1 - > setText ( tr ( " GEOM_SKETCHER_POINT " ) ) ;
MainWidget - > RB_Dest2 - > setText ( tr ( " GEOM_SKETCHER_DIR " ) ) ;
2004-06-16 21:24:55 +06:00
/***************************************************************/
2012-08-09 13:58:02 +06:00
GroupBox1 = new QGroupBox ( tr ( " GEOM_CS " ) , this ) ;
QGridLayout * planeLayout = new QGridLayout ( GroupBox1 ) ;
planeLayout - > setSpacing ( 6 ) ;
planeLayout - > setMargin ( 11 ) ;
ComboBox1 = new QComboBox ( GroupBox1 ) ;
planeLayout - > addWidget ( ComboBox1 , 0 , 0 , 1 , 2 ) ;
planeButton = new QPushButton ( GroupBox1 ) ;
planeButton - > setText ( tr ( " GEOM_SKETCHER_RESTORE " ) ) ;
planeLayout - > addWidget ( planeButton , 0 , 2 ) ;
selButton = new QPushButton ( GroupBox1 ) ;
selButton - > setIcon ( image5 ) ;
planeLayout - > addWidget ( selButton , 1 , 0 ) ;
WPlaneLineEdit = new QLineEdit ( GroupBox1 ) ;
WPlaneLineEdit - > setReadOnly ( true ) ;
planeLayout - > addWidget ( WPlaneLineEdit , 1 , 1 , 1 , 2 ) ;
planeLayout - > setColumnStretch ( 1 , 1 ) ;
topLayout - > addWidget ( GroupBox1 ) ;
topLayout - > addWidget ( MainWidget ) ;
topLayout - > setStretch ( 1 , 1 ) ;
2009-02-13 17:16:39 +05:00
GroupPt = new EntityGUI_Point ( MainWidget - > DestCnt ) ;
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 " ) ) ;
2012-08-09 13:58:02 +06:00
GroupPt2 = new EntityGUI_Point ( MainWidget - > DestCnt ) ;
GroupPt2 - > GroupPoint - > setTitle ( tr ( " GEOM_SKETCHER_ADD_PARAMS " ) ) ;
GroupPt2 - > RB_Point1 - > setText ( tr ( " GEOM_SKETCHER_NONE " ) ) ;
GroupPt2 - > RB_Point2 - > setText ( tr ( " GEOM_SKETCHER_RADIUS " ) ) ;
GroupPt2 - > RB_Point3 - > setText ( tr ( " GEOM_SKETCHER_CENTER " ) ) ;
2009-02-13 17:16:39 +05:00
GroupD1 = new EntityGUI_Dir1 ( MainWidget - > DestCnt ) ;
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 ( MainWidget - > DestCnt ) ;
2012-08-09 13:58:02 +06:00
GroupD2 - > GroupDir2 - > setTitle ( tr ( " GEOM_SKETCHER_DIST " ) ) ;
2009-02-13 17:16:39 +05:00
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 ( MainWidget - > SkeletonCnt ) ;
Group1Sel - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_POINT2 " ) ) ;
Group1Sel - > GroupBox1 - > setTitle ( tr ( " GEOM_SKETCHER_VALUES " ) ) ;
Group1Sel - > buttonApply - > setText ( tr ( " GEOM_SKETCHER_APPLY " ) ) ;
Group1Sel - > PushButton1 - > setIcon ( image0 ) ;
Group1Sel - > buttonUndo - > setIcon ( image1 ) ;
Group1Sel - > buttonRedo - > setIcon ( image2 ) ;
2004-12-01 15:39:14 +05:00
Group1Sel - > LineEdit1 - > setReadOnly ( true ) ;
2004-06-16 21:24:55 +06:00
2012-08-09 13:58:02 +06:00
Group2Sel = new EntityGUI_2Sel1Check ( MainWidget - > SkeletonCnt ) ;
Group2Sel - > GroupBox1 - > setTitle ( tr ( " GEOM_SKETCHER_VALUES " ) ) ;
Group2Sel - > buttonApply - > setText ( tr ( " GEOM_SKETCHER_APPLY " ) ) ;
Group2Sel - > checkBox - > setText ( tr ( " GEOM_REVERSE " ) ) ;
Group2Sel - > PushButton1 - > setIcon ( image0 ) ;
Group2Sel - > PushButton2 - > setIcon ( image0 ) ;
Group2Sel - > buttonUndo - > setIcon ( image1 ) ;
Group2Sel - > buttonRedo - > setIcon ( image2 ) ;
Group2Sel - > LineEdit1 - > setReadOnly ( true ) ;
Group2Sel - > LineEdit2 - > setReadOnly ( true ) ;
Group1Sel1Spin = new EntityGUI_1Sel1Spin1Check ( MainWidget - > SkeletonCnt ) ;
Group1Sel1Spin - > GroupBox1 - > setTitle ( tr ( " GEOM_SKETCHER_VALUES " ) ) ;
Group1Sel1Spin - > buttonApply - > setText ( tr ( " GEOM_SKETCHER_APPLY " ) ) ;
Group1Sel1Spin - > checkBox - > setText ( tr ( " GEOM_REVERSE " ) ) ;
Group1Sel1Spin - > PushButton1 - > setIcon ( image0 ) ;
Group1Sel1Spin - > buttonUndo - > setIcon ( image1 ) ;
Group1Sel1Spin - > buttonRedo - > setIcon ( image2 ) ;
Group1Sel1Spin - > LineEdit1 - > setReadOnly ( true ) ;
2009-02-13 17:16:39 +05:00
Group1Spin = new EntityGUI_1Spin ( MainWidget - > SkeletonCnt ) ;
Group1Spin - > GroupBox1 - > setTitle ( tr ( " GEOM_SKETCHER_VALUES " ) ) ;
Group1Spin - > buttonApply - > setText ( tr ( " GEOM_SKETCHER_APPLY " ) ) ;
Group1Spin - > buttonUndo - > setIcon ( image1 ) ;
Group1Spin - > buttonRedo - > setIcon ( image2 ) ;
Group2Spin = new EntityGUI_2Spin ( MainWidget - > SkeletonCnt ) ;
Group2Spin - > GroupBox1 - > setTitle ( tr ( " GEOM_SKETCHER_VALUES " ) ) ;
Group2Spin - > buttonApply - > setText ( tr ( " GEOM_SKETCHER_APPLY " ) ) ;
Group2Spin - > buttonUndo - > setIcon ( image1 ) ;
Group2Spin - > buttonRedo - > setIcon ( image2 ) ;
2012-08-09 13:58:02 +06:00
Group3Spin = new EntityGUI_3Spin1Check ( MainWidget - > SkeletonCnt ) ;
2009-02-13 17:16:39 +05:00
Group3Spin - > GroupBox1 - > setTitle ( tr ( " GEOM_SKETCHER_VALUES " ) ) ;
Group3Spin - > buttonApply - > setText ( tr ( " GEOM_SKETCHER_APPLY " ) ) ;
2012-08-09 13:58:02 +06:00
Group3Spin - > checkBox - > setText ( tr ( " GEOM_REVERSE " ) ) ;
2009-02-13 17:16:39 +05:00
Group3Spin - > buttonUndo - > setIcon ( image1 ) ;
Group3Spin - > buttonRedo - > setIcon ( image2 ) ;
2012-08-09 13:58:02 +06:00
Group4Spin = new EntityGUI_4Spin1Check ( MainWidget - > SkeletonCnt ) ;
2009-02-13 17:16:39 +05:00
Group4Spin - > GroupBox1 - > setTitle ( tr ( " GEOM_SKETCHER_VALUES " ) ) ;
Group4Spin - > buttonApply - > setText ( tr ( " GEOM_SKETCHER_APPLY " ) ) ;
2012-08-09 13:58:02 +06:00
Group4Spin - > checkBox - > setText ( tr ( " GEOM_REVERSE " ) ) ;
2009-02-13 17:16:39 +05:00
Group4Spin - > buttonUndo - > setIcon ( image1 ) ;
Group4Spin - > buttonRedo - > setIcon ( image2 ) ;
2012-08-09 13:58:02 +06:00
GroupRect = new DlgRef_4Spin ( MainWidget - > SkeletonCnt ) ;
GroupRect - > GroupBox1 - > setTitle ( tr ( " GEOM_SKETCHER_VALUES " ) ) ;
GroupRect - > TextLabel1 - > setText ( " X1: " ) ;
GroupRect - > TextLabel2 - > setText ( " Y1: " ) ;
GroupRect - > TextLabel3 - > setText ( " X2: " ) ;
GroupRect - > TextLabel4 - > setText ( " Y2: " ) ;
// Defines a palette for the error message on Group4Spin and Group2Sel
QPalette palette ;
QColor color ( " red " ) ;
palette . setColor ( Group4Spin - > label - > foregroundRole ( ) , color ) ;
Group4Spin - > label - > setPalette ( palette ) ;
palette . setColor ( Group2Sel - > label - > foregroundRole ( ) , color ) ;
Group2Sel - > label - > setPalette ( palette ) ;
2009-02-13 17:16:39 +05:00
QGridLayout * DestCntLayout = new QGridLayout ( MainWidget - > DestCnt ) ;
DestCntLayout - > setMargin ( 0 ) ; DestCntLayout - > setSpacing ( 6 ) ;
2012-08-09 13:58:02 +06:00
DestCntLayout - > addWidget ( GroupPt , 0 , 0 ) ;
DestCntLayout - > addWidget ( GroupPt2 , 0 , 1 ) ;
DestCntLayout - > addWidget ( GroupD1 , 0 , 0 ) ;
DestCntLayout - > addWidget ( GroupD2 , 0 , 1 ) ;
2009-02-13 17:16:39 +05:00
QVBoxLayout * SkeletonCntlayout = new QVBoxLayout ( MainWidget - > SkeletonCnt ) ;
SkeletonCntlayout - > setMargin ( 0 ) ; SkeletonCntlayout - > setSpacing ( 6 ) ;
SkeletonCntlayout - > addWidget ( Group1Sel , 0 , 0 ) ;
2012-08-09 13:58:02 +06:00
SkeletonCntlayout - > addWidget ( Group2Sel , 0 , 0 ) ;
SkeletonCntlayout - > addWidget ( Group1Sel1Spin , 0 , 0 ) ;
2009-02-13 17:16:39 +05:00
SkeletonCntlayout - > addWidget ( Group1Spin , 0 , 0 ) ;
SkeletonCntlayout - > addWidget ( Group2Spin , 0 , 0 ) ;
SkeletonCntlayout - > addWidget ( Group3Spin , 0 , 0 ) ;
SkeletonCntlayout - > addWidget ( Group4Spin , 0 , 0 ) ;
2012-08-09 13:58:02 +06:00
SkeletonCntlayout - > addWidget ( GroupRect , 0 , 0 ) ;
//SkeletonCntlayout->setStretch( 0, 1);
2004-06-16 21:24:55 +06:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
QButtonGroup * ButtonGroup = new QButtonGroup ( this ) ;
ButtonGroup - > addButton ( MainWidget - > RB_Dest1 , 1 ) ;
ButtonGroup - > addButton ( MainWidget - > RB_Dest2 , 0 ) ;
2008-03-07 12:45:34 +05:00
2009-02-13 17:16:39 +05:00
/* signals and slots connections */
2012-08-09 13:58:02 +06:00
connect ( MainWidget - > buttonEnd , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnEnd ( ) ) ) ;
connect ( MainWidget - > buttonClose , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnEnd ( ) ) ) ;
connect ( MainWidget - > buttonCancel , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnCancel ( ) ) ) ;
connect ( MainWidget - > buttonHelp , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnHelp ( ) ) ) ;
connect ( Group1Sel - > buttonApply , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnApply ( ) ) ) ;
connect ( Group1Sel - > buttonUndo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnUndo ( ) ) ) ;
connect ( Group1Sel - > buttonRedo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnRedo ( ) ) ) ;
connect ( Group2Sel - > buttonApply , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnApply ( ) ) ) ;
connect ( Group2Sel - > buttonUndo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnUndo ( ) ) ) ;
connect ( Group2Sel - > buttonRedo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnRedo ( ) ) ) ;
connect ( Group1Sel1Spin - > buttonApply , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnApply ( ) ) ) ;
connect ( Group1Sel1Spin - > buttonUndo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnUndo ( ) ) ) ;
connect ( Group1Sel1Spin - > buttonRedo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnRedo ( ) ) ) ;
connect ( Group1Spin - > buttonApply , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnApply ( ) ) ) ;
connect ( Group1Spin - > buttonUndo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnUndo ( ) ) ) ;
connect ( Group1Spin - > buttonRedo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnRedo ( ) ) ) ;
connect ( Group2Spin - > buttonApply , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnApply ( ) ) ) ;
connect ( Group2Spin - > buttonUndo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnUndo ( ) ) ) ;
connect ( Group2Spin - > buttonRedo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnRedo ( ) ) ) ;
connect ( Group3Spin - > buttonApply , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnApply ( ) ) ) ;
connect ( Group3Spin - > buttonUndo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnUndo ( ) ) ) ;
connect ( Group3Spin - > buttonRedo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnRedo ( ) ) ) ;
connect ( Group4Spin - > buttonApply , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnApply ( ) ) ) ;
connect ( Group4Spin - > buttonUndo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnUndo ( ) ) ) ;
connect ( Group4Spin - > buttonRedo , SIGNAL ( clicked ( ) ) , this , SLOT ( ClickOnRedo ( ) ) ) ;
connect ( MainWidget - > ButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( TypeClicked ( int ) ) ) ;
connect ( ButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( DestClicked ( int ) ) ) ;
connect ( GroupPt - > ButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( PointClicked ( int ) ) ) ;
connect ( GroupPt2 - > ButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( Point2Clicked ( int ) ) ) ;
connect ( GroupD1 - > ButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( Dir1Clicked ( int ) ) ) ;
connect ( GroupD2 - > ButtonGroup , SIGNAL ( buttonClicked ( int ) ) , this , SLOT ( Dir2Clicked ( int ) ) ) ;
connect ( Group1Sel - > LineEdit1 , SIGNAL ( returnPressed ( ) ) , this , SLOT ( LineEditReturnPressed ( ) ) ) ;
connect ( Group1Sel - > PushButton1 , SIGNAL ( clicked ( ) ) , this , SLOT ( SetEditCurrentArgument ( ) ) ) ;
connect ( Group2Sel - > LineEdit1 , SIGNAL ( returnPressed ( ) ) , this , SLOT ( LineEditReturnPressed ( ) ) ) ;
connect ( Group2Sel - > LineEdit2 , SIGNAL ( returnPressed ( ) ) , this , SLOT ( LineEditReturnPressed ( ) ) ) ;
connect ( Group2Sel - > PushButton1 , SIGNAL ( clicked ( ) ) , this , SLOT ( SetEditCurrentArgument ( ) ) ) ;
connect ( Group2Sel - > PushButton2 , SIGNAL ( clicked ( ) ) , this , SLOT ( SetEditCurrentArgument ( ) ) ) ;
connect ( Group1Sel1Spin - > LineEdit1 , SIGNAL ( returnPressed ( ) ) , this , SLOT ( LineEditReturnPressed ( ) ) ) ;
connect ( Group1Sel1Spin - > PushButton1 , SIGNAL ( clicked ( ) ) , this , SLOT ( SetEditCurrentArgument ( ) ) ) ;
connect ( Group1Sel1Spin - > SpinBox_DX , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
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 ) ) ) ;
connect ( GroupRect - > SpinBox_DX1 , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
connect ( GroupRect - > SpinBox_DX2 , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
connect ( GroupRect - > SpinBox_DY1 , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
connect ( GroupRect - > SpinBox_DY2 , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
connect ( Group3Spin - > checkBox , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( CheckBoxClicked ( int ) ) ) ;
connect ( Group4Spin - > checkBox , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( CheckBoxClicked ( int ) ) ) ;
connect ( Group2Sel - > checkBox , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( CheckBoxClicked ( int ) ) ) ;
connect ( Group1Sel1Spin - > checkBox , SIGNAL ( stateChanged ( int ) ) , this , SLOT ( CheckBoxClicked ( int ) ) ) ;
connect ( ComboBox1 , SIGNAL ( activated ( int ) ) , this , SLOT ( ActivateLocalCS ( ) ) ) ;
connect ( planeButton , SIGNAL ( clicked ( ) ) , this , SLOT ( ActivateLocalCS ( ) ) ) ;
connect ( selButton , SIGNAL ( clicked ( ) ) , this , SLOT ( SetEditCurrentArgument ( ) ) ) ;
connect ( myGeometryGUI , SIGNAL ( SignalDefaultStepValueChanged ( double ) ) , this , SLOT ( SetDoubleSpinBoxStep ( double ) ) ) ;
connect ( myGeometryGUI , SIGNAL ( SignalDeactivateActiveDialog ( ) ) , this , SLOT ( DeactivateActiveDialog ( ) ) ) ;
connect ( myGeometryGUI , SIGNAL ( SignalCloseAllDialogs ( ) ) , this , SLOT ( ClickOnCancel ( ) ) ) ;
2009-02-13 17:16:39 +05:00
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 ) ;
2012-08-09 13:58:02 +06:00
Group1Sel1Spin - > SpinBox_DX - > installEventFilter ( this ) ;
2008-03-07 12:45:34 +05:00
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
}
2009-02-13 17:16:39 +05:00
2004-06-16 21:24:55 +06:00
//=================================================================================
// function : ~EntityGUI_SketcherDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
EntityGUI_SketcherDlg : : ~ EntityGUI_SketcherDlg ( )
{
2012-08-09 13:58:02 +06:00
// SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
2008-03-07 12:45:34 +05:00
myGeometryGUI - > SetActiveDialogBox ( 0 ) ;
2012-08-09 13:58:02 +06:00
// ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(false);
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
2008-03-07 12:45:34 +05:00
//=================================================================================
// 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 ;
2012-08-09 13:58:02 +06:00
if ( ke - > key ( ) = = Qt : : Key_Return | | ke - > key ( ) = = Qt : : Key_Enter ) {
2008-03-07 12:45:34 +05:00
if ( object = = Group1Spin - > SpinBox_DX ) {
2012-08-09 13:58:02 +06:00
Group1Spin - > buttonApply - > click ( ) ;
return true ;
} else if ( object = = Group1Sel1Spin - > SpinBox_DX ) {
Group1Sel1Spin - > buttonApply - > click ( ) ;
2008-03-07 12:45:34 +05:00
return true ;
} else if ( object = = Group2Spin - > SpinBox_DX | |
object = = Group2Spin - > SpinBox_DY ) {
2012-08-09 13:58:02 +06:00
Group2Spin - > buttonApply - > click ( ) ;
2008-03-07 12:45:34 +05:00
return true ;
} else if ( object = = Group3Spin - > SpinBox_DX | |
object = = Group3Spin - > SpinBox_DY | |
object = = Group3Spin - > SpinBox_DZ ) {
2012-08-09 13:58:02 +06:00
Group3Spin - > buttonApply - > click ( ) ;
2008-03-07 12:45:34 +05:00
return true ;
} else if ( object = = Group4Spin - > SpinBox_DX | |
object = = Group4Spin - > SpinBox_DY | |
object = = Group4Spin - > SpinBox_DZ | |
object = = Group4Spin - > SpinBox_DS ) {
2012-08-09 13:58:02 +06:00
Group4Spin - > buttonApply - > click ( ) ;
2008-03-07 12:45:34 +05:00
return true ;
}
}
}
2009-02-13 17:16:39 +05:00
// Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
2008-03-07 12:45:34 +05:00
2009-02-13 17:16:39 +05:00
return QDialog : : eventFilter ( object , event ) ;
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void EntityGUI_SketcherDlg : : Init ( )
{
/* init variables */
2012-08-09 13:58:02 +06:00
autoApply = false ;
myEditCurrentArgument = WPlaneLineEdit ; // Initiate the parameters selection with the first WPlaneLineEdit
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 ;
2012-08-09 13:58:02 +06:00
globalSelection ( GEOM_FACE ) ;
myCheckFlag = 0 ;
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 " ;
2012-08-09 13:58:02 +06:00
GEOM : : GEOM_IBasicOperations_var aBasicOp = getGeomEngine ( ) - > GetIBasicOperations ( getStudyId ( ) ) ;
myGlobalCS = aBasicOp - > MakeMarker ( 0 , 0 , 0 ,
1 , 0 , 0 ,
0 , 1 , 0 ) ;
myWPlane = myGlobalCS ;
myLCSList . push_back ( WPlaneToLCS ( myGlobalCS ) ) ;
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 */
2012-08-09 13:58:02 +06:00
initSpinBox ( Group1Sel1Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group1Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group2Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
// san: Note specific step values below!
initSpinBox ( Group4Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , 0.1 , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , 0.1 , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DS , COORD_MIN , COORD_MAX , 5. , " length_precision " ) ;
initSpinBox ( GroupRect - > SpinBox_DX1 , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( GroupRect - > SpinBox_DY1 , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( GroupRect - > SpinBox_DX2 , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( GroupRect - > SpinBox_DY2 , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
2004-12-01 15:39:14 +05:00
/* displays Dialog */
2012-08-09 13:58:02 +06:00
// MainWidget->RadioButton1->setEnabled( false );
// MainWidget->RadioButton2->setEnabled( false );
// MainWidget->RadioButton3->setEnabled( true );
// MainWidget->GroupDest1->setEnabled( false );
2009-02-13 17:16:39 +05:00
setEnabledUndo ( false ) ;
setEnabledRedo ( false ) ;
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
MainWidget - > RadioButton1 - > setChecked ( true ) ;
2004-06-16 21:24:55 +06:00
2012-08-09 13:58:02 +06:00
FindLocalCS ( ) ;
2009-02-13 17:16:39 +05:00
TypeClicked ( 0 ) ;
2012-08-09 13:58:02 +06:00
// If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
// that should be filled with the possibly selected face
OnFirstPoint ( ) ;
SelectionIntoArgument ( ) ;
resize ( 100 , 100 ) ;
setPrefix ( tr ( " GEOM_SKETCH " ) ) ;
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
ActivateLocalCS ( ) ;
setIsWaitCursorEnabled ( false ) ;
GEOMBase_Helper : : displayPreview ( true , 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 ( )
{
2012-08-09 13:58:02 +06:00
MESSAGE ( " EntityGUI_SketcherDlg::InitClick() " )
2009-02-13 17:16:39 +05:00
disconnect ( myGeometryGUI - > getApp ( ) - > selectionMgr ( ) , 0 , this , 0 ) ;
2012-08-09 13:58:02 +06:00
myCheckFlag = 0 ;
2004-06-16 21:24:55 +06:00
Group1Sel - > hide ( ) ;
2012-08-09 13:58:02 +06:00
Group2Sel - > hide ( ) ;
Group1Sel1Spin - > hide ( ) ;
2004-06-16 21:24:55 +06:00
Group1Spin - > hide ( ) ;
Group2Spin - > hide ( ) ;
Group3Spin - > hide ( ) ;
Group4Spin - > hide ( ) ;
2012-08-09 13:58:02 +06:00
GroupRect - > hide ( ) ;
globalSelection ( ) ; // close local selection to clear it
2015-09-24 17:01:40 +05:00
localSelection ( TopAbs_VERTEX ) ;
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : TypeClicked()
// purpose : Radio button management
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : TypeClicked ( int constructorId )
2004-06-16 21:24:55 +06:00
{
myConstructorId = constructorId ;
2012-08-09 13:58:02 +06:00
MainWidget - > buttonEnd - > setText ( tr ( " GEOM_BUT_CLOSE " ) ) ;
MainWidget - > buttonClose - > setEnabled ( true ) ;
2009-02-13 17:16:39 +05:00
if ( myConstructorId = = 0 ) { // SEGMENT
2012-08-09 13:58:02 +06:00
GroupPt2 - > RB_Point1 - > setChecked ( true ) ;
GroupPt - > setEnabled ( true ) ;
GroupPt2 - > setEnabled ( false ) ;
GroupD1 - > setEnabled ( true ) ;
2009-02-13 17:16:39 +05:00
GroupD2 - > setEnabled ( true ) ;
MainWidget - > RB_Dest1 - > setEnabled ( true ) ;
MainWidget - > RB_Dest1 - > setChecked ( true ) ;
2012-08-09 13:58:02 +06:00
MainWidget - > GroupDest - > setEnabled ( true ) ;
MainWidget - > GroupDest1 - > setEnabled ( true ) ;
MainWidget - > GroupDest - > show ( ) ;
MainWidget - > GroupDest1 - > show ( ) ;
2009-02-13 17:16:39 +05:00
DestClicked ( 1 ) ;
2012-08-09 13:58:02 +06:00
if ( mySketchState = = FIRST_POINT )
{
OnFirstPoint ( ) ;
}
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorId = = 1 ) { // ARC
2012-08-09 13:58:02 +06:00
GroupPt - > setEnabled ( true ) ;
GroupPt2 - > setEnabled ( true ) ;
GroupD2 - > RB_Dir21 - > setChecked ( true ) ;
GroupD1 - > setEnabled ( true ) ;
2009-02-13 17:16:39 +05:00
GroupD2 - > setEnabled ( false ) ;
2012-08-09 13:58:02 +06:00
MainWidget - > RB_Dest1 - > setEnabled ( true ) ;
MainWidget - > RB_Dest1 - > setChecked ( true ) ;
MainWidget - > GroupDest - > setEnabled ( true ) ;
MainWidget - > GroupDest1 - > setEnabled ( true ) ;
MainWidget - > GroupDest - > show ( ) ;
MainWidget - > GroupDest1 - > show ( ) ;
DestClicked ( 1 ) ;
if ( mySketchState = = FIRST_POINT )
{
OnFirstPoint ( ) ;
}
2004-06-16 21:24:55 +06:00
}
2012-08-09 13:58:02 +06:00
else if ( myConstructorId = = 2 ) { // RECTANGLE
GroupPt - > setEnabled ( false ) ;
GroupPt2 - > setEnabled ( false ) ;
GroupD1 - > setEnabled ( false ) ;
GroupD2 - > setEnabled ( false ) ;
MainWidget - > GroupDest - > setEnabled ( false ) ;
MainWidget - > GroupDest1 - > setEnabled ( false ) ;
GroupPt - > hide ( ) ;
GroupPt2 - > hide ( ) ;
GroupD1 - > hide ( ) ;
GroupD2 - > hide ( ) ;
MainWidget - > GroupDest - > hide ( ) ;
MainWidget - > GroupDest1 - > hide ( ) ;
MainWidget - > buttonEnd - > setText ( tr ( " Apply and Close " ) ) ;
MainWidget - > buttonClose - > setEnabled ( false ) ;
GroupRect - > setEnabled ( true ) ;
MainWidget - > RadioButton1 - > setEnabled ( true ) ;
MainWidget - > RadioButton2 - > setEnabled ( true ) ;
RectClicked ( ) ;
}
}
//=================================================================================
// function : RectClicked()
// purpose : Radio button management
//=================================================================================
void EntityGUI_SketcherDlg : : RectClicked ( )
{
InitClick ( ) ;
// Connect the selction manager (disconnected in InitClick())
connect ( myGeometryGUI - > getApp ( ) - > selectionMgr ( ) ,
SIGNAL ( currentSelectionChanged ( ) ) , this , SLOT ( SelectionIntoArgument ( ) ) ) ;
GroupRect - > show ( ) ;
2015-05-08 17:48:37 +05:00
2012-08-09 13:58:02 +06:00
myX1 = 0 ;
GroupRect - > SpinBox_DX1 - > setValue ( myX1 ) ;
2015-05-08 17:48:37 +05:00
myY1 = 0 ;
2012-08-09 13:58:02 +06:00
GroupRect - > SpinBox_DY1 - > setValue ( myY1 ) ;
2015-05-08 17:48:37 +05:00
myX2 = 10 ;
2012-08-09 13:58:02 +06:00
GroupRect - > SpinBox_DX2 - > setValue ( myX2 ) ;
2015-05-08 17:48:37 +05:00
myY2 = 10 ;
2012-08-09 13:58:02 +06:00
GroupRect - > SpinBox_DY2 - > setValue ( myY2 ) ;
resize ( minimumSizeHint ( ) ) ;
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
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 ( ) ;
2012-08-09 13:58:02 +06:00
GroupPt2 - > hide ( ) ;
2004-06-16 21:24:55 +06:00
GroupD1 - > hide ( ) ;
GroupD2 - > hide ( ) ;
2009-02-13 17:16:39 +05:00
if ( constructorId = = 1 ) {
// Point
GroupPt - > RB_Point1 - > setChecked ( true ) ;
2004-06-16 21:24:55 +06:00
GroupPt - > show ( ) ;
2012-08-09 13:58:02 +06:00
GroupPt2 - > show ( ) ;
Group3Spin - > checkBox - > show ( ) ;
Group4Spin - > checkBox - > show ( ) ;
2009-02-13 17:16:39 +05:00
PointClicked ( 1 ) ; // XY
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 0 ) {
// Direction
GroupD1 - > RB_Dir11 - > setChecked ( true ) ;
2004-06-16 21:24:55 +06:00
GroupD1 - > show ( ) ;
GroupD2 - > show ( ) ;
2012-08-09 13:58:02 +06:00
Group3Spin - > checkBox - > hide ( ) ;
Group4Spin - > checkBox - > hide ( ) ;
2012-10-08 17:16:36 +06:00
if ( myConstructorId = = 1 ) {
myRadius = 100.0 ;
myLength = 30.0 ;
myAngle = 0.0 ;
myDX = 0.0 ;
myDY = 0.0 ;
}
2009-02-13 17:16:39 +05:00
Dir1Clicked ( 2 ) ; // Angle
2004-06-16 21:24:55 +06:00
}
2012-08-09 13:58:02 +06:00
resize ( minimumSizeHint ( ) ) ;
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : PointClicked()
// purpose : Radio button management
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : PointClicked ( int constructorId )
2004-06-16 21:24:55 +06:00
{
2012-08-09 13:58:02 +06:00
MESSAGE ( " PointClicked " )
myConstructorPntId = constructorId ;
GroupPt - > RB_Point3 - > setEnabled ( true ) ;
int buttonId = GroupPt2 - > ButtonGroup - > checkedId ( ) ;
if ( buttonId > = 0 ) { // = If a button is checked
Point2Clicked ( buttonId ) ;
}
else {
GroupPt2 - > RB_Point1 - > setChecked ( true ) ;
Point2Clicked ( 1 ) ;
}
}
//=================================================================================
// function : Point2Clicked()
// purpose : Radio button management
//=================================================================================
void EntityGUI_SketcherDlg : : Point2Clicked ( int constructorId )
{
MESSAGE ( " Point2Clicked " )
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
2009-02-13 17:16:39 +05:00
double step = SUIT_Session : : session ( ) - > resourceMgr ( ) - > doubleValue ( " Geometry " , " SettingsGeomStep " , 100.0 ) ;
2008-03-07 12:45:34 +05:00
2012-08-09 13:58:02 +06:00
if ( myConstructorPntId = = 1 ) { // XY
if ( constructorId = = 1 ) { // No additional parameter
2004-06-16 21:24:55 +06:00
mySketchType = PT_ABS ;
2012-08-09 13:58:02 +06:00
initSpinBox ( Group2Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
2009-02-13 17:16:39 +05:00
Group2Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_X2 " ) ) ;
Group2Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_Y2 " ) ) ;
2004-06-16 21:24:55 +06:00
myX = 0.0 ;
2009-02-13 17:16:39 +05:00
Group2Spin - > SpinBox_DX - > setValue ( myX ) ;
2004-06-16 21:24:55 +06:00
myY = 0.0 ;
2009-02-13 17:16:39 +05:00
Group2Spin - > SpinBox_DY - > setValue ( myY ) ;
2004-06-16 21:24:55 +06:00
Group2Spin - > show ( ) ;
Group2Spin - > buttonApply - > setFocus ( ) ;
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
2004-06-16 21:24:55 +06:00
}
2012-08-09 13:58:02 +06:00
else if ( constructorId = = 0 ) { // Point + radius
mySketchType = PT_ABS_RADIUS ;
initSpinBox ( Group3Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , step / 10.0 , " length_precision " ) ;
Group3Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_X2 " ) ) ;
Group3Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_Y2 " ) ) ;
Group3Spin - > TextLabel3 - > setText ( tr ( " GEOM_SKETCHER_RADIUS2 " ) ) ;
myX = 0.0 ;
Group3Spin - > SpinBox_DX - > setValue ( myX ) ;
myY = 0.0 ;
Group3Spin - > SpinBox_DY - > setValue ( myY ) ;
myRadius = 0.0 ;
Group3Spin - > SpinBox_DZ - > setValue ( myRadius ) ;
Group3Spin - > show ( ) ;
Group3Spin - > buttonApply - > setFocus ( ) ;
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
}
else if ( constructorId = = 2 ) { // Point + center
mySketchType = PT_ABS_CENTER ;
initSpinBox ( Group4Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DS , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
Group4Spin - > TextLabel3 - > setText ( tr ( " GEOM_SKETCHER_X2 " ) ) ;
Group4Spin - > TextLabel4 - > setText ( tr ( " GEOM_SKETCHER_Y2 " ) ) ;
Group4Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_CENTER_X " ) ) ;
Group4Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_CENTER_Y " ) ) ;
myXc = 0.0 ;
Group4Spin - > SpinBox_DX - > setValue ( myXc ) ;
myYc = 0.0 ;
Group4Spin - > SpinBox_DY - > setValue ( myYc ) ;
myX = 0.0 ;
Group4Spin - > SpinBox_DZ - > setValue ( myX ) ;
myY = 0.0 ;
Group4Spin - > SpinBox_DS - > setValue ( myY ) ;
Group4Spin - > show ( ) ;
Group4Spin - > buttonApply - > setFocus ( ) ;
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
}
}
else if ( myConstructorPntId = = 0 ) { // DXDY
if ( constructorId = = 1 ) { // No additional parameter
2004-06-16 21:24:55 +06:00
mySketchType = PT_RELATIVE ;
2012-08-09 13:58:02 +06:00
initSpinBox ( Group2Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
2009-02-13 17:16:39 +05:00
Group2Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_DX2 " ) ) ;
Group2Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_DY2 " ) ) ;
2004-06-16 21:24:55 +06:00
myDX = 0.0 ;
2009-02-13 17:16:39 +05:00
Group2Spin - > SpinBox_DX - > setValue ( myDX ) ;
2004-06-16 21:24:55 +06:00
myDY = 0.0 ;
2009-02-13 17:16:39 +05:00
Group2Spin - > SpinBox_DY - > setValue ( myDY ) ;
2004-06-16 21:24:55 +06:00
Group2Spin - > show ( ) ;
Group2Spin - > buttonApply - > setFocus ( ) ;
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
}
else if ( constructorId = = 0 ) { // Point + radius
mySketchType = PT_REL_RADIUS ;
initSpinBox ( Group3Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , step / 10.0 , " length_precision " ) ;
Group3Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_DX2 " ) ) ;
Group3Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_DY2 " ) ) ;
Group3Spin - > TextLabel3 - > setText ( tr ( " GEOM_SKETCHER_RADIUS2 " ) ) ;
myDX = 10.0 ;
Group3Spin - > SpinBox_DX - > setValue ( myDX ) ;
myDY = 0.0 ;
Group3Spin - > SpinBox_DY - > setValue ( myDY ) ;
myRadius = 5.0 ;
Group3Spin - > SpinBox_DZ - > setValue ( myRadius ) ;
Group3Spin - > show ( ) ;
Group3Spin - > buttonApply - > setFocus ( ) ;
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
}
else if ( constructorId = = 2 ) { // Point + center
mySketchType = PT_REL_CENTER ;
initSpinBox ( Group4Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DS , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
Group4Spin - > TextLabel3 - > setText ( tr ( " GEOM_SKETCHER_DX2 " ) ) ;
Group4Spin - > TextLabel4 - > setText ( tr ( " GEOM_SKETCHER_DY2 " ) ) ;
Group4Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_CENTER_DX " ) ) ;
Group4Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_CENTER_DY " ) ) ;
myDXc = 0.0 ;
Group4Spin - > SpinBox_DX - > setValue ( myDXc ) ;
myDYc = 0.0 ;
Group4Spin - > SpinBox_DY - > setValue ( myDYc ) ;
myDX = 0.0 ;
Group4Spin - > SpinBox_DZ - > setValue ( myDX ) ;
myDY = 0.0 ;
Group4Spin - > SpinBox_DS - > setValue ( myDY ) ;
Group4Spin - > show ( ) ;
Group4Spin - > buttonApply - > setFocus ( ) ;
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
2004-06-16 21:24:55 +06:00
}
2012-08-09 13:58:02 +06:00
}
else if ( myConstructorPntId = = 2 ) { // Selection
if ( constructorId = = 1 ) { // No additional parameter
2004-06-16 21:24:55 +06:00
mySketchType = PT_SEL ;
myEditCurrentArgument = Group1Sel - > LineEdit1 ;
2012-08-09 13:58:02 +06:00
Group1Sel - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_END_POINT2 " ) ) ;
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
}
2012-08-09 13:58:02 +06:00
else if ( constructorId = = 0 ) { // Point + radius
mySketchType = PT_SEL_RADIUS ;
myEditCurrentArgument = Group1Sel1Spin - > LineEdit1 ;
initSpinBox ( Group1Sel1Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , step / 10.0 , " length_precision " ) ;
Group1Sel1Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_END_POINT2 " ) ) ;
Group1Sel1Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_RADIUS2 " ) ) ;
myRadius = 0.0 ;
Group1Sel1Spin - > SpinBox_DX - > setValue ( myRadius ) ;
Group1Sel1Spin - > show ( ) ;
Group1Sel1Spin - > buttonApply - > setFocus ( ) ;
SelectionIntoArgument ( ) ;
}
else if ( constructorId = = 2 ) { // Point + center
mySketchType = PT_SEL_CENTER ;
myEditCurrentArgument = Group2Sel - > LineEdit1 ;
Group2Sel - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_END_POINT2 " ) ) ;
Group2Sel - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_CENTER2 " ) ) ;
Group2Sel - > LineEdit1 - > setEnabled ( true ) ;
Group2Sel - > PushButton1 - > setDown ( true ) ;
Group2Sel - > LineEdit2 - > setEnabled ( false ) ;
Group2Sel - > PushButton2 - > setDown ( false ) ;
Group2Sel - > show ( ) ;
Group2Sel - > buttonApply - > setFocus ( ) ;
SelectionIntoArgument ( ) ;
}
2004-06-16 21:24:55 +06:00
}
2012-08-09 13:58:02 +06:00
resize ( minimumSizeHint ( ) ) ;
connect ( myGeometryGUI - > getApp ( ) - > selectionMgr ( ) ,
SIGNAL ( currentSelectionChanged ( ) ) , this , SLOT ( SelectionIntoArgument ( ) ) ) ;
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : Dir1Clicked()
// purpose : Radio button management
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : Dir1Clicked ( int constructorId )
2004-06-16 21:24:55 +06:00
{
myConstructorDirId = constructorId ;
2012-08-09 13:58:02 +06:00
int dirButtonId = GroupD2 - > ButtonGroup - > checkedId ( ) ;
if ( dirButtonId > = 0 ) { // = If a button is checked
Dir2Clicked ( dirButtonId ) ;
}
else {
GroupD2 - > RB_Dir21 - > setChecked ( true ) ;
Dir2Clicked ( 2 ) ;
}
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : Dir2Clicked()
// purpose : Radio button management
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : Dir2Clicked ( int constructorId )
2004-06-16 21:24:55 +06:00
{
2004-12-01 15:39:14 +05:00
InitClick ( ) ;
2012-10-08 17:16:36 +06:00
Group3Spin - > SpinBox_DX - > blockSignals ( true ) ; // Block signals in order not to modify
Group3Spin - > SpinBox_DY - > blockSignals ( true ) ; // defaut values
Group3Spin - > SpinBox_DZ - > blockSignals ( true ) ;
Group2Spin - > SpinBox_DX - > blockSignals ( true ) ;
Group2Spin - > SpinBox_DY - > blockSignals ( true ) ;
Group4Spin - > SpinBox_DX - > blockSignals ( true ) ;
Group4Spin - > SpinBox_DY - > blockSignals ( true ) ;
Group4Spin - > SpinBox_DZ - > blockSignals ( true ) ;
Group4Spin - > SpinBox_DS - > blockSignals ( true ) ;
2008-03-07 12:45:34 +05:00
// Get setting of step value from file configuration
2009-02-13 17:16:39 +05:00
double step = SUIT_Session : : session ( ) - > resourceMgr ( ) - > doubleValue ( " Geometry " , " SettingsGeomStep " , 100.0 ) ;
2008-03-07 12:45:34 +05:00
2009-02-13 17:16:39 +05:00
if ( myConstructorId = = 0 ) { // SEGMENT
2004-06-16 21:24:55 +06:00
myX = 0.0 ;
myY = 0.0 ;
myLength = 100.0 ;
2009-02-13 17:16:39 +05:00
if ( myConstructorDirId = = 2 ) { // Angle
2012-08-09 13:58:02 +06:00
initSpinBox ( Group2Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , 5. , " length_precision " ) ;
2009-02-13 17:16:39 +05:00
Group2Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_ANGLE2 " ) ) ;
Group2Spin - > SpinBox_DX - > setValue ( myAngle ) ;
2004-06-16 21:24:55 +06:00
Group2Spin - > buttonApply - > setFocus ( ) ;
Group2Spin - > show ( ) ;
2009-02-13 17:16:39 +05:00
if ( constructorId = = 2 ) { // Length
2012-08-09 13:58:02 +06:00
mySketchType = DIR_ANGLE_LENGTH ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
Group2Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_LENGTH2 " ) ) ;
Group2Spin - > SpinBox_DY - > setValue ( myLength ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 0 ) { // X
2012-08-09 13:58:02 +06:00
mySketchType = DIR_ANGLE_X ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " angle_precision " ) ;
2014-02-21 18:56:30 +06:00
Group2Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_X2 " ) ) ;
2012-08-09 13:58:02 +06:00
Group2Spin - > SpinBox_DY - > setValue ( myX ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 1 ) { // Y
2012-08-09 13:58:02 +06:00
mySketchType = DIR_ANGLE_Y ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " angle_precision " ) ;
2014-02-21 18:56:30 +06:00
Group2Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_Y2 " ) ) ;
2012-08-09 13:58:02 +06:00
Group2Spin - > SpinBox_DY - > setValue ( myY ) ;
2004-06-16 21:24:55 +06:00
}
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorDirId = = 0 ) { // Perpendicular
2004-06-16 21:24:55 +06:00
Group1Spin - > show ( ) ;
Group1Spin - > buttonApply - > setFocus ( ) ;
2009-02-13 17:16:39 +05:00
if ( constructorId = = 2 ) { // Length
2012-08-09 13:58:02 +06:00
mySketchType = DIR_PER_LENGTH ;
Group1Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_LENGTH2 " ) ) ;
Group1Spin - > SpinBox_DX - > setValue ( myLength ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 0 ) { // X
2012-08-09 13:58:02 +06:00
mySketchType = DIR_PER_X ;
2014-02-21 18:56:30 +06:00
Group1Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_X2 " ) ) ;
2012-08-09 13:58:02 +06:00
Group1Spin - > SpinBox_DX - > setValue ( myX ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 1 ) { // Y
2012-08-09 13:58:02 +06:00
mySketchType = DIR_PER_Y ;
2014-02-21 18:56:30 +06:00
Group1Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_Y2 " ) ) ;
2012-08-09 13:58:02 +06:00
Group1Spin - > SpinBox_DX - > setValue ( myY ) ;
2004-06-16 21:24:55 +06:00
}
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorDirId = = 1 ) { // Tangent
2004-06-16 21:24:55 +06:00
Group1Spin - > show ( ) ;
Group1Spin - > buttonApply - > setFocus ( ) ;
2009-02-13 17:16:39 +05:00
if ( constructorId = = 2 ) { // Length
2012-08-09 13:58:02 +06:00
mySketchType = DIR_TAN_LENGTH ;
Group1Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_LENGTH2 " ) ) ;
Group1Spin - > SpinBox_DX - > setValue ( myLength ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 0 ) { // X
2012-08-09 13:58:02 +06:00
mySketchType = DIR_TAN_X ;
2014-02-21 18:56:30 +06:00
Group1Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_X2 " ) ) ;
2012-08-09 13:58:02 +06:00
Group1Spin - > SpinBox_DX - > setValue ( myX ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 1 ) { // Y
2012-08-09 13:58:02 +06:00
mySketchType = DIR_TAN_Y ;
2014-02-21 18:56:30 +06:00
Group1Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_Y2 " ) ) ;
2012-08-09 13:58:02 +06:00
Group1Spin - > SpinBox_DX - > setValue ( myY ) ;
2004-06-16 21:24:55 +06:00
}
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorDirId = = 3 ) { // DXDY
2012-08-09 13:58:02 +06:00
initSpinBox ( Group3Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , 0.1 , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , 0.1 , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
2009-02-13 17:16:39 +05:00
Group3Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_VX2 " ) ) ;
Group3Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_VY2 " ) ) ;
Group3Spin - > SpinBox_DX - > setValue ( myDX ) ;
Group3Spin - > SpinBox_DY - > setValue ( myDY ) ;
2004-06-16 21:24:55 +06:00
Group3Spin - > show ( ) ;
Group3Spin - > buttonApply - > setFocus ( ) ;
2009-02-13 17:16:39 +05:00
if ( constructorId = = 2 ) { // Length
2012-08-09 13:58:02 +06:00
mySketchType = DIR_DXDY_LENGTH ;
Group3Spin - > TextLabel3 - > setText ( tr ( " GEOM_SKETCHER_LENGTH2 " ) ) ;
Group3Spin - > SpinBox_DZ - > setValue ( myLength ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 0 ) { // X
2012-08-09 13:58:02 +06:00
mySketchType = DIR_DXDY_X ;
2014-02-21 18:56:30 +06:00
Group3Spin - > TextLabel3 - > setText ( tr ( " GEOM_SKETCHER_X2 " ) ) ;
2012-08-09 13:58:02 +06:00
Group3Spin - > SpinBox_DZ - > setValue ( myX ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( constructorId = = 1 ) { // Y
2012-08-09 13:58:02 +06:00
mySketchType = DIR_DXDY_Y ;
2014-02-21 18:56:30 +06:00
Group3Spin - > TextLabel3 - > setText ( tr ( " GEOM_SKETCHER_Y2 " ) ) ;
2012-08-09 13:58:02 +06:00
Group3Spin - > SpinBox_DZ - > setValue ( myY ) ;
2004-06-16 21:24:55 +06:00
}
}
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorId = = 1 ) { // ARC
if ( myConstructorDirId = = 2 ) { // Angle
if ( constructorId = = 2 ) { // Length
2012-08-09 13:58:02 +06:00
mySketchType = DIR_ANGLE_LENGTH ;
initSpinBox ( Group3Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , 5. , " angle_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group3Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , 5. , " angle_precision " ) ;
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 ) ;
Group3Spin - > SpinBox_DY - > setValue ( myRadius ) ;
Group3Spin - > SpinBox_DZ - > setValue ( myLength ) ;
Group3Spin - > show ( ) ;
Group3Spin - > buttonApply - > setFocus ( ) ;
2004-06-16 21:24:55 +06:00
}
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorDirId = = 0 ) { // Perpendicular
if ( constructorId = = 2 ) { // Length
2012-08-09 13:58:02 +06:00
mySketchType = DIR_PER_LENGTH ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , 5. , " angle_precision " ) ;
Group2Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_RADIUS2 " ) ) ;
Group2Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_ANGLE2 " ) ) ;
2012-10-08 17:16:36 +06:00
// myRadius = 100.0;
2012-08-09 13:58:02 +06:00
Group2Spin - > SpinBox_DX - > setValue ( myRadius ) ;
2012-10-08 17:16:36 +06:00
// myLength = 30.0;
2012-08-09 13:58:02 +06:00
Group2Spin - > SpinBox_DY - > setValue ( myLength ) ;
Group2Spin - > show ( ) ;
Group2Spin - > buttonApply - > setFocus ( ) ;
2004-06-16 21:24:55 +06:00
}
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorDirId = = 1 ) { // Tangent
if ( constructorId = = 2 ) { // Length
2012-08-09 13:58:02 +06:00
mySketchType = DIR_TAN_LENGTH ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group2Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , 5. , " angle_precision " ) ;
Group2Spin - > TextLabel1 - > setText ( tr ( " GEOM_SKETCHER_RADIUS2 " ) ) ;
Group2Spin - > TextLabel2 - > setText ( tr ( " GEOM_SKETCHER_ANGLE2 " ) ) ;
2012-10-08 17:16:36 +06:00
// myRadius = 100.0;
2012-08-09 13:58:02 +06:00
Group2Spin - > SpinBox_DX - > setValue ( myRadius ) ;
2012-10-08 17:16:36 +06:00
// myLength = 30.0;
2012-08-09 13:58:02 +06:00
Group2Spin - > SpinBox_DY - > setValue ( myLength ) ;
Group2Spin - > show ( ) ;
Group2Spin - > buttonApply - > setFocus ( ) ;
2004-06-16 21:24:55 +06:00
}
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorDirId = = 3 ) { // DXDY
if ( constructorId = = 2 ) { // Length
2012-08-09 13:58:02 +06:00
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 " ) ) ;
2013-06-17 18:15:50 +06:00
initSpinBox ( Group4Spin - > SpinBox_DZ , COORD_MIN , COORD_MAX , step , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DX , COORD_MIN , COORD_MAX , 0.1 , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DY , COORD_MIN , COORD_MAX , 0.1 , " length_precision " ) ;
initSpinBox ( Group4Spin - > SpinBox_DS , COORD_MIN , COORD_MAX , 5. , " length_precision " ) ;
2012-08-09 13:58:02 +06:00
Group4Spin - > SpinBox_DX - > setValue ( myDX ) ;
Group4Spin - > SpinBox_DY - > setValue ( myDY ) ;
2012-10-08 17:16:36 +06:00
// myRadius = 100.0;
2012-08-09 13:58:02 +06:00
Group4Spin - > SpinBox_DZ - > setValue ( myRadius ) ;
2012-10-08 17:16:36 +06:00
// myLength = 30.0;
2012-08-09 13:58:02 +06:00
Group4Spin - > SpinBox_DS - > setValue ( myLength ) ;
Group4Spin - > show ( ) ;
Group4Spin - > buttonApply - > setFocus ( ) ;
2004-06-16 21:24:55 +06:00
}
}
}
2012-10-08 17:16:36 +06:00
Group3Spin - > SpinBox_DX - > blockSignals ( false ) ; // Restore signals
Group3Spin - > SpinBox_DY - > blockSignals ( false ) ;
Group3Spin - > SpinBox_DZ - > blockSignals ( false ) ;
Group2Spin - > SpinBox_DX - > blockSignals ( false ) ;
Group2Spin - > SpinBox_DY - > blockSignals ( false ) ;
Group4Spin - > SpinBox_DX - > blockSignals ( false ) ;
Group4Spin - > SpinBox_DY - > blockSignals ( false ) ;
Group4Spin - > SpinBox_DZ - > blockSignals ( false ) ;
Group4Spin - > SpinBox_DS - > blockSignals ( false ) ;
2012-08-09 13:58:02 +06:00
resize ( minimumSizeHint ( ) ) ;
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
}
//=================================================================================
// function : CheckBoxClicked()
// purpose : CheckBox management
//=================================================================================
void EntityGUI_SketcherDlg : : CheckBoxClicked ( int State )
{
myCheckFlag = State ;
2004-06-16 21:24:55 +06:00
2012-08-09 13:58:02 +06:00
GEOMBase_Helper : : displayPreview ( true , 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 ( )
{
2012-08-09 13:58:02 +06:00
MESSAGE ( " EntityGUI_SketcherDlg::ClickOnEnd() " )
2009-02-13 17:16:39 +05:00
if ( sender ( ) = = MainWidget - > buttonClose ) {
2004-12-01 15:39:14 +05:00
// Verify validity of commands
2009-02-13 17:16:39 +05:00
if ( myCommand . count ( ) < = 2 ) {
SUIT_MessageBox : : critical ( SUIT_Session : : session ( ) - > activeApplication ( ) - > desktop ( ) ,
2012-08-09 13:58:02 +06:00
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
2013-05-29 22:27:24 +06:00
QString Command = myCommand . join ( " " ) ;
2016-02-11 20:26:21 +05:00
Sketcher_Profile aProfile = Sketcher_Profile ( Command . toLatin1 ( ) ) ;
2013-05-29 22:27:24 +06:00
bool isDone = false ;
TopoDS_Shape myShape = aProfile . GetShape ( & isDone ) ;
if ( isDone ) {
if ( myShape . ShapeType ( ) ! = TopAbs_VERTEX )
2013-06-17 18:15:50 +06:00
myCommand . append ( " :WW " ) ;
2013-05-29 22:27:24 +06:00
}
2004-12-01 15:39:14 +05:00
}
2009-02-13 17:16:39 +05:00
else {
2012-08-09 13:58:02 +06:00
/*// 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 ( ) ) | |
( Group2Sel - > buttonApply - > isEnabled ( ) & & Group2Sel - > isVisible ( ) ) | |
( Group1Sel1Spin - > buttonApply - > isEnabled ( ) & & Group1Sel1Spin - > isVisible ( ) ) ) {
2008-03-07 12:45:34 +05:00
ClickOnApply ( ) ;
2012-08-09 13:58:02 +06:00
} */
// ClickOnApply(); // TEST remove then
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
2012-08-09 13:58:02 +06:00
if ( myConstructorId = = 2 )
{
QString aParameters ;
myCommand . append ( GetNewCommand ( aParameters ) ) ;
mySketchState = NEXT_POINT ;
if ( onAccept ( ) )
ClickOnCancel ( ) ;
}
2009-02-13 17:16:39 +05:00
if ( myCommand . size ( ) > 2 )
2012-08-09 13:58:02 +06:00
{
2009-02-13 17:16:39 +05:00
if ( ! onAccept ( ) )
2004-12-01 15:39:14 +05:00
return ;
2012-08-09 13:58:02 +06:00
}
2004-12-01 15:39:14 +05:00
close ( ) ;
2004-06-16 21:24:55 +06:00
}
2004-12-01 15:39:14 +05:00
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool EntityGUI_SketcherDlg : : ClickOnApply ( )
{
2012-08-09 13:58:02 +06:00
MESSAGE ( " EntityGUI_SketcherDlg::ClickOnApply() " )
2009-02-13 17:16:39 +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
2012-08-09 13:58:02 +06:00
// addSubshapesToStudy();
2009-02-13 17:16:39 +05:00
QString aParameters ;
myCommand . append ( GetNewCommand ( aParameters ) ) ;
2012-08-09 13:58:02 +06:00
if ( mySketchState = = FIRST_POINT )
{
mySketchState = NEXT_POINT ;
OnNextPoint ( ) ;
}
2004-12-01 15:39:14 +05:00
myUndoCommand . clear ( ) ;
myUndoCommand . append ( " Sketcher " ) ;
2009-02-13 17:16:39 +05:00
myParameters . append ( aParameters ) ;
myUndoParameters . clear ( ) ;
setEnabledUndo ( true ) ;
setEnabledRedo ( false ) ;
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
myIsApply = true ;
2012-08-09 13:58:02 +06:00
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
2009-02-13 17:16:39 +05:00
myIsApply = false ;
2008-03-07 12:45:34 +05:00
// Set focus to SpinBox_DX
2009-02-13 17:16:39 +05:00
if ( sender ( ) = = Group1Spin - > buttonApply ) {
2008-03-07 12:45:34 +05:00
( Group1Spin - > SpinBox_DX ) - > setFocus ( ) ;
( Group1Spin - > SpinBox_DX ) - > selectAll ( ) ;
}
2012-08-09 13:58:02 +06:00
else if ( sender ( ) = = Group1Sel1Spin - > buttonApply ) {
( Group1Sel1Spin - > SpinBox_DX ) - > setFocus ( ) ;
( Group1Sel1Spin - > SpinBox_DX ) - > selectAll ( ) ;
}
2009-02-13 17:16:39 +05:00
else if ( sender ( ) = = Group2Spin - > buttonApply ) {
2008-03-07 12:45:34 +05:00
( Group2Spin - > SpinBox_DX ) - > setFocus ( ) ;
( Group2Spin - > SpinBox_DX ) - > selectAll ( ) ;
}
2009-02-13 17:16:39 +05:00
else if ( sender ( ) = = Group3Spin - > buttonApply ) {
2008-03-07 12:45:34 +05:00
( Group3Spin - > SpinBox_DX ) - > setFocus ( ) ;
( Group3Spin - > SpinBox_DX ) - > selectAll ( ) ;
}
2009-02-13 17:16:39 +05:00
else if ( sender ( ) = = Group4Spin - > buttonApply ) {
2008-03-07 12:45:34 +05:00
( Group4Spin - > SpinBox_DX ) - > setFocus ( ) ;
( Group4Spin - > SpinBox_DX ) - > selectAll ( ) ;
}
2012-08-09 13:58:02 +06:00
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 ( )
{
2009-02-13 17:16:39 +05:00
LightApp_Application * app = ( LightApp_Application * ) ( SUIT_Session : : session ( ) - > activeApplication ( ) ) ;
if ( app )
app - > onHelpContextModule ( myGeometryGUI ? app - > moduleName ( myGeometryGUI - > moduleName ( ) ) : QString ( " " ) , myHelpFileName ) ;
2006-05-06 14:44:32 +06:00
else {
2009-02-13 17:16:39 +05:00
QString platform ;
2008-03-07 12:45:34 +05:00
# ifdef WIN32
2009-02-13 17:16:39 +05:00
platform = " winapplication " ;
2008-03-07 12:45:34 +05:00
# else
2009-02-13 17:16:39 +05:00
platform = " application " ;
2008-03-07 12:45:34 +05:00
# endif
2009-02-13 17:16:39 +05:00
SUIT_MessageBox : : warning ( 0 , QObject : : tr ( " WRN_WARNING " ) ,
2012-08-09 13:58:02 +06:00
QObject : : tr ( " EXTERNAL_BROWSER_CANNOT_SHOW_PAGE " ) .
arg ( app - > resourceMgr ( ) - > stringValue ( " ExternalBrowser " , platform ) ) . arg ( myHelpFileName ) ,
QObject : : tr ( " BUT_OK " ) ) ;
2006-05-06 14:44:32 +06:00
}
}
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 ( ) ;
2009-02-13 17:16:39 +05:00
myUndoParameters . append ( myParameters . last ( ) ) ;
myParameters . pop_back ( ) ;
if ( myCommand . count ( ) = = 1 ) {
2004-12-01 15:39:14 +05:00
mySketchState = FIRST_POINT ;
2008-03-07 12:45:34 +05:00
2009-02-13 17:16:39 +05:00
MainWidget - > RadioButton1 - > setChecked ( true ) ;
TypeClicked ( 0 ) ;
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
connect ( myGeometryGUI - > getApp ( ) - > selectionMgr ( ) ,
SIGNAL ( currentSelectionChanged ( ) ) , this , SLOT ( SelectionIntoArgument ( ) ) ) ;
OnFirstPoint ( ) ;
2009-02-13 17:16:39 +05:00
setEnabledUndo ( false ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
setEnabledRedo ( true ) ;
2004-06-16 21:24:55 +06:00
2012-08-09 13:58:02 +06:00
GEOMBase_Helper : : displayPreview ( true , 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
2009-02-13 17:16:39 +05:00
myParameters . append ( myUndoParameters . last ( ) ) ;
myUndoParameters . pop_back ( ) ;
2004-12-01 15:39:14 +05:00
mySketchState = NEXT_POINT ;
2012-08-09 13:58:02 +06:00
OnNextPoint ( ) ;
2009-02-13 17:16:39 +05:00
setEnabledUndo ( true ) ;
2004-06-16 21:24:55 +06:00
2009-02-13 17:16:39 +05:00
if ( myUndoCommand . count ( ) = = 1 )
setEnabledRedo ( false ) ;
2004-06-16 21:24:55 +06:00
2012-08-09 13:58:02 +06:00
GEOMBase_Helper : : displayPreview ( true , 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 :
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : setEnabledUndo ( bool value )
2004-06-16 21:24:55 +06:00
{
2009-02-13 17:16:39 +05:00
Group1Sel - > buttonUndo - > setEnabled ( value ) ;
2012-08-09 13:58:02 +06:00
Group2Sel - > buttonUndo - > setEnabled ( value ) ;
Group1Sel1Spin - > buttonUndo - > setEnabled ( value ) ;
2009-02-13 17:16:39 +05:00
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 :
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : setEnabledRedo ( bool value )
2004-12-01 15:39:14 +05:00
{
2009-02-13 17:16:39 +05:00
Group1Sel - > buttonRedo - > setEnabled ( value ) ;
2012-08-09 13:58:02 +06:00
Group2Sel - > buttonRedo - > setEnabled ( value ) ;
Group1Sel1Spin - > buttonRedo - > setEnabled ( value ) ;
2009-02-13 17:16:39 +05:00
Group1Spin - > buttonRedo - > setEnabled ( value ) ;
Group2Spin - > buttonRedo - > setEnabled ( value ) ;
Group3Spin - > buttonRedo - > setEnabled ( value ) ;
Group4Spin - > buttonRedo - > setEnabled ( value ) ;
2004-12-01 15:39:14 +05:00
}
2004-06-16 21:24:55 +06:00
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed
//=================================================================================
void EntityGUI_SketcherDlg : : SelectionIntoArgument ( )
{
2012-08-09 13:58:02 +06:00
MESSAGE ( " EntityGUI_SketcherDlg::SelectionIntoArgument " )
2009-02-13 17:16:39 +05:00
myEditCurrentArgument - > setText ( " " ) ;
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
LightApp_SelectionMgr * aSelMgr = myGeometryGUI - > getApp ( ) - > selectionMgr ( ) ;
SALOME_ListIO aSelList ;
aSelMgr - > selectedObjects ( aSelList ) ;
2012-08-09 13:58:02 +06:00
this - > activateWindow ( ) ;
if ( aSelList . Extent ( ) = = 0 )
{
selButton - > setDown ( false ) ;
WPlaneLineEdit - > setEnabled ( false ) ;
WPlaneLineEdit - > setText ( tr ( " GEOM_SKETCHER_WPLANE " ) ) ;
return ;
}
else if ( aSelList . Extent ( ) ! = 1 )
return ;
double tmpX = myX ;
double tmpY = myY ;
myX = myLastX1 ;
myY = myLastY1 ;
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX ;
if ( myEditCurrentArgument = = WPlaneLineEdit )
aNeedType = TopAbs_FACE ;
GEOM : : GeomObjPtr aSelectedObject = getSelected ( aNeedType ) ;
TopoDS_Shape aShape ;
if ( aSelectedObject & & GEOMBase : : GetShape ( aSelectedObject . get ( ) , aShape )
& & ! aShape . IsNull ( ) )
{
QString aName = GEOMBase : : GetName ( aSelectedObject . get ( ) ) ;
if ( myEditCurrentArgument = = WPlaneLineEdit )
{
// Check if the face is planar
Handle ( Geom_Surface ) aSurf = BRep_Tool : : Surface ( TopoDS : : Face ( aShape ) ) ;
GeomLib_IsPlanarSurface aPlanarCheck ( aSurf , Precision : : Confusion ( ) ) ;
if ( aPlanarCheck . IsPlanar ( ) )
{
myEditCurrentArgument - > setText ( aName ) ;
AddLocalCS ( aSelectedObject . get ( ) ) ;
selButton - > setDown ( false ) ;
WPlaneLineEdit - > setEnabled ( false ) ;
TypeClicked ( myConstructorId ) ;
}
else
{
myEditCurrentArgument - > setText ( tr ( " GEOM_SKETCHER_WPLANE " ) ) ;
// The following leads to crash TODO : find a way to return a warning
// Standard_Failure::Raise(tr("GEOM_SKETCHER_NOT_PLANAR").toStdString().c_str());
}
}
else
{
gp_Trsf aTrans ;
gp_Ax3 aWPlane = GetActiveLocalCS ( ) ;
aTrans . SetTransformation ( aWPlane ) ;
BRepBuilderAPI_Transform aTransformation ( aShape , aTrans , Standard_False ) ;
aShape = aTransformation . Shape ( ) ;
gp_Pnt aPnt ;
if ( GEOMBase : : VertexToPoint ( aShape , aPnt ) )
{
myEditCurrentArgument - > setText ( aName ) ;
myX = aPnt . X ( ) ;
myY = aPnt . Y ( ) ;
double Xcoord = myX ;
double Ycoord = myY ;
switch ( mySketchType )
{
case PT_ABS :
disconnect ( Group2Spin - > SpinBox_DX , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
disconnect ( Group2Spin - > SpinBox_DY , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
Group2Spin - > SpinBox_DX - > setValue ( Xcoord ) ;
Group2Spin - > SpinBox_DY - > setValue ( Ycoord ) ;
connect ( Group2Spin - > SpinBox_DX , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
connect ( Group2Spin - > SpinBox_DY , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
break ;
case PT_RELATIVE :
if ( myLastX1 & & myLastY1 )
{
Xcoord = myX - myLastX1 ;
Ycoord = myY - myLastY1 ;
}
else if ( mySketchState ! = FIRST_POINT )
{
Xcoord = myX - tmpX ;
Ycoord = myY - tmpY ;
}
Group2Spin - > SpinBox_DX - > setValue ( Xcoord ) ;
Group2Spin - > SpinBox_DY - > setValue ( Ycoord ) ;
break ;
case PT_ABS_RADIUS :
disconnect ( Group3Spin - > SpinBox_DX , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
disconnect ( Group3Spin - > SpinBox_DY , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
Group3Spin - > SpinBox_DX - > setValue ( Xcoord ) ;
Group3Spin - > SpinBox_DY - > setValue ( Ycoord ) ;
connect ( Group3Spin - > SpinBox_DX , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
connect ( Group3Spin - > SpinBox_DY , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
break ;
case PT_REL_RADIUS :
if ( myLastX1 & & myLastY1 )
{
Xcoord = myX - myLastX1 ;
Ycoord = myY - myLastY1 ;
}
else if ( mySketchState ! = FIRST_POINT )
{
Xcoord = myX - tmpX ;
Ycoord = myY - tmpY ;
}
Group3Spin - > SpinBox_DX - > setValue ( Xcoord ) ;
Group3Spin - > SpinBox_DY - > setValue ( Ycoord ) ;
break ;
case PT_ABS_CENTER :
disconnect ( Group4Spin - > SpinBox_DX , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
disconnect ( Group4Spin - > SpinBox_DY , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
Group4Spin - > SpinBox_DX - > setValue ( Xcoord ) ;
Group4Spin - > SpinBox_DY - > setValue ( Ycoord ) ;
connect ( Group4Spin - > SpinBox_DX , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
connect ( Group4Spin - > SpinBox_DY , SIGNAL ( valueChanged ( double ) ) , this , SLOT ( ValueChangedInSpinBox ( double ) ) ) ;
break ;
case PT_REL_CENTER :
if ( myLastX1 & & myLastY1 )
{
Xcoord = myXc - myLastX1 ;
Ycoord = myYc - myLastY1 ;
}
else if ( mySketchState ! = FIRST_POINT )
{
Xcoord = myXc - tmpX ;
Ycoord = myYc - tmpY ;
}
else
{
Xcoord = myXc ;
Ycoord = myYc ;
}
Group4Spin - > SpinBox_DX - > setValue ( Xcoord ) ;
Group4Spin - > SpinBox_DY - > setValue ( Ycoord ) ;
break ;
}
2004-12-01 15:39:14 +05:00
}
}
2004-06-16 21:24:55 +06:00
}
2012-08-09 13:58:02 +06:00
if ( ! autoApply ) {
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
}
else {
ClickOnApply ( ) ;
autoApply = false ;
}
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void EntityGUI_SketcherDlg : : SetEditCurrentArgument ( )
{
2012-08-09 13:58:02 +06:00
TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX ;
2009-02-13 17:16:39 +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
}
2012-08-09 13:58:02 +06:00
else if ( sender ( ) = = Group1Sel1Spin - > PushButton1 ) {
myEditCurrentArgument = Group1Sel1Spin - > LineEdit1 ;
myEditCurrentArgument - > setFocus ( ) ;
}
else if ( sender ( ) = = Group2Sel - > PushButton1 ) {
myEditCurrentArgument = Group2Sel - > LineEdit1 ;
Group2Sel - > PushButton2 - > setDown ( false ) ;
Group2Sel - > PushButton1 - > setDown ( true ) ;
Group2Sel - > LineEdit2 - > setEnabled ( false ) ;
Group2Sel - > LineEdit1 - > setEnabled ( true ) ;
// myEditCurrentArgument->setFocus();
}
else if ( sender ( ) = = Group2Sel - > PushButton2 ) {
myEditCurrentArgument = Group2Sel - > LineEdit2 ;
Group2Sel - > PushButton1 - > setDown ( false ) ;
Group2Sel - > PushButton2 - > setDown ( true ) ;
Group2Sel - > LineEdit1 - > setEnabled ( false ) ;
Group2Sel - > LineEdit2 - > setEnabled ( true ) ;
// myEditCurrentArgument->setFocus();
}
else if ( sender ( ) = = selButton ) {
myNeedType = TopAbs_FACE ;
myEditCurrentArgument = WPlaneLineEdit ;
WPlaneLineEdit - > setEnabled ( true ) ;
selButton - > setDown ( true ) ;
}
globalSelection ( ) ; // close local selection to clear it
2015-09-24 17:01:40 +05:00
localSelection ( myNeedType ) ;
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void EntityGUI_SketcherDlg : : LineEditReturnPressed ( )
{
2012-08-09 13:58:02 +06:00
if ( sender ( ) = = Group1Sel - > LineEdit1 )
2004-12-01 15:39:14 +05:00
myEditCurrentArgument = Group1Sel - > LineEdit1 ;
2012-08-09 13:58:02 +06:00
else if ( sender ( ) = = Group1Sel1Spin - > LineEdit1 )
myEditCurrentArgument = Group1Sel1Spin - > LineEdit1 ;
else if ( sender ( ) = = Group2Sel - > LineEdit1 )
myEditCurrentArgument = Group2Sel - > LineEdit1 ;
else if ( sender ( ) = = Group2Sel - > LineEdit2 )
myEditCurrentArgument = Group2Sel - > LineEdit2 ;
/* 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 ;
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
LightApp_SelectionMgr * aSelMgr = myGeometryGUI - > getApp ( ) - > selectionMgr ( ) ;
SALOME_ListIO aSelList ;
aSelMgr - > selectedObjects ( aSelList ) ;
2009-02-13 17:16:39 +05:00
2012-08-09 13:58:02 +06:00
if ( GEOMBase : : SelectionByNameInDialogs ( thisWidget , objectUserName , aSelList ) )
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 ( ) ;
2009-02-13 17:16:39 +05:00
disconnect ( myGeometryGUI - > getApp ( ) - > selectionMgr ( ) , 0 , this , 0 ) ;
myGeometryGUI - > SetActiveDialogBox ( 0 ) ;
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void EntityGUI_SketcherDlg : : ActivateThisDialog ( )
{
2012-08-09 13:58:02 +06:00
MESSAGE ( " EntityGUI_SketcherDlg::ActivateThisDialog() " )
2005-06-02 13:17:09 +06:00
myGeometryGUI - > EmitSignalDeactivateDialog ( ) ;
2009-02-13 17:16:39 +05:00
setEnabled ( true ) ;
myGeometryGUI - > SetActiveDialogBox ( this ) ;
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
connect ( myGeometryGUI - > getApp ( ) - > selectionMgr ( ) ,
2012-08-09 13:58:02 +06:00
SIGNAL ( currentSelectionChanged ( ) ) , this , SLOT ( SelectionIntoArgument ( ) ) ) ;
2004-06-16 21:24:55 +06:00
2005-06-02 13:17:09 +06:00
//myGeometryGUI->SetState( 0 );
2012-08-09 13:58:02 +06:00
// globalSelection( GEOM_POINT );
myEditCurrentArgument = WPlaneLineEdit ;
2004-12-01 15:39:14 +05:00
myEditCurrentArgument - > setFocus ( ) ;
2012-08-09 13:58:02 +06:00
if ( sender ( ) = = Group1Sel - > LineEdit1 ) {
myEditCurrentArgument = Group1Sel - > LineEdit1 ;
myEditCurrentArgument - > setFocus ( ) ;
}
else if ( sender ( ) = = Group1Sel1Spin - > LineEdit1 ) {
myEditCurrentArgument = Group1Sel1Spin - > LineEdit1 ;
myEditCurrentArgument - > setFocus ( ) ;
}
else if ( sender ( ) = = Group2Sel - > LineEdit1 ) {
myEditCurrentArgument = Group2Sel - > LineEdit1 ;
myEditCurrentArgument - > setFocus ( ) ;
}
else if ( sender ( ) = = Group2Sel - > LineEdit2 ) {
myEditCurrentArgument = Group2Sel - > LineEdit2 ;
myEditCurrentArgument - > setFocus ( ) ;
}
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : enterEvent [REDEFINED]
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : enterEvent ( QEvent * )
2004-06-16 21:24:55 +06:00
{
2012-08-09 13:58:02 +06:00
if ( ! isEnabled ( ) )
2004-12-01 15:39:14 +05:00
ActivateThisDialog ( ) ;
2004-06-16 21:24:55 +06:00
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : closeEvent ( QCloseEvent * e )
2004-06-16 21:24:55 +06:00
{
2012-08-09 13:58:02 +06:00
MESSAGE ( " EntityGUI_SketcherDlg::closeEvent " )
2005-06-02 13:17:09 +06:00
//myGeometryGUI->SetState( -1 );
2009-02-13 17:16:39 +05:00
disconnect ( myGeometryGUI - > getApp ( ) - > selectionMgr ( ) , 0 , this , 0 ) ;
myGeometryGUI - > getApp ( ) - > updateActions ( ) ;
2004-12-01 15:39:14 +05:00
QDialog : : closeEvent ( e ) ;
2004-06-16 21:24:55 +06:00
}
2012-08-09 13:58:02 +06:00
//=================================================================================
// function : OnPointSelected
// purpose :
//=================================================================================
void EntityGUI_SketcherDlg : : OnPointSelected ( Qt : : KeyboardModifiers modifiers , const gp_Pnt & thePnt ,
bool isStart )
{
// NOTE Basing the autoapply functionnality on the background picture has no sense anymore
// The import picture functionnality is now used for drawing on top of a picture
// SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
// OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
//
// QString theImgFileName;
// vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
double x , y ;
x = y = 0 ;
BRepBuilderAPI_MakeVertex mkVertex ( thePnt ) ;
TopoDS_Shape aShape = mkVertex . Shape ( ) ;
// Taking into account LocalCS
gp_Ax3 aWPlane = GetActiveLocalCS ( ) ;
gp_Trsf aTrans ;
aTrans . SetTransformation ( aWPlane ) ;
BRepBuilderAPI_Transform aTransformation ( aShape , aTrans , Standard_False ) ;
aShape = aTransformation . Shape ( ) ;
gp_Pnt aTrsfPnt ;
GEOMBase : : VertexToPoint ( aShape , aTrsfPnt ) ;
// NOTE autoapply disabled : doesn't seem useful anymore
// autoApply = ( (getPnt2ConstructorId() == 1) && (!theImgFileName.isEmpty()) ); // If no additional argument needed after selection and there is a backgroundimage
// -> apply automatically
if ( getPnt1ConstructorId ( ) = = 0 ) { // Relative selection mode
x = aTrsfPnt . X ( ) - myLastX1 ;
y = aTrsfPnt . Y ( ) - myLastY1 ;
}
else {
x = aTrsfPnt . X ( ) ;
y = aTrsfPnt . Y ( ) ;
}
switch ( getPnt2ConstructorId ( ) ) {
case 1 :
Group2Spin - > SpinBox_DX - > setValue ( x ) ;
Group2Spin - > SpinBox_DY - > setValue ( y ) ;
Group2Spin - > buttonApply - > setFocus ( ) ; // Previous setFocus (during preview) may have been inoperative if it was disabled
break ;
case 0 :
Group3Spin - > SpinBox_DX - > setValue ( x ) ;
Group3Spin - > SpinBox_DY - > setValue ( y ) ;
Group3Spin - > buttonApply - > setFocus ( ) ;
break ;
case 2 :
if ( modifiers = = Qt : : MetaModifier ) { // Select center with Meta key
Group4Spin - > SpinBox_DX - > setValue ( x ) ;
Group4Spin - > SpinBox_DY - > setValue ( y ) ;
}
else { // Select end point
Group4Spin - > SpinBox_DZ - > setValue ( x ) ;
Group4Spin - > SpinBox_DS - > setValue ( y ) ;
}
Group4Spin - > buttonApply - > setFocus ( ) ;
break ;
}
if ( myConstructorId = = 2 ) //RECTANGLE
{
if ( isStart )
{
GroupRect - > SpinBox_DX1 - > setValue ( aTrsfPnt . X ( ) ) ;
GroupRect - > SpinBox_DY1 - > setValue ( aTrsfPnt . Y ( ) ) ;
GroupRect - > SpinBox_DX2 - > setValue ( aTrsfPnt . X ( ) ) ;
GroupRect - > SpinBox_DY2 - > setValue ( aTrsfPnt . Y ( ) ) ;
}
else
{
GroupRect - > SpinBox_DX2 - > setValue ( aTrsfPnt . X ( ) ) ;
GroupRect - > SpinBox_DY2 - > setValue ( aTrsfPnt . Y ( ) ) ;
}
}
}
//=================================================================================
// function : OnFirstPoint
// purpose :
//=================================================================================
void EntityGUI_SketcherDlg : : OnFirstPoint ( )
{
MainWidget - > RadioButton3 - > setEnabled ( true ) ;
MainWidget - > GroupDest1 - > setEnabled ( false ) ;
GroupPt2 - > setEnabled ( false ) ;
}
//=================================================================================
// function : OnNextPoint
// purpose :
//=================================================================================
void EntityGUI_SketcherDlg : : OnNextPoint ( )
{
MainWidget - > RadioButton3 - > setEnabled ( false ) ;
MainWidget - > GroupDest1 - > setEnabled ( true ) ;
TypeClicked ( myConstructorId ) ;
}
2004-06-16 21:24:55 +06:00
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : ValueChangedInSpinBox ( double newValue )
2004-06-16 21:24:55 +06:00
{
QObject * send = ( QObject * ) sender ( ) ;
2012-08-09 13:58:02 +06:00
Standard_Real vx , vy , vz , vs , minRad , dx , dy ;
vx = vy = vz = vs = minRad = dx = dy = 0.0 ;
SUIT_ResourceMgr * resMgr = SUIT_Session : : session ( ) - > resourceMgr ( ) ;
int aPrecision = resMgr - > integerValue ( " Geometry " , " length_precision " , 6 ) ;
double LastDecimal = 0.0 ;
2004-06-16 21:24:55 +06:00
2009-02-13 17:16:39 +05:00
QString vxStr , vyStr , vzStr , vsStr ;
QString newValueStr ;
if ( SalomeApp_DoubleSpinBox * aDoubleSpinBox = ( SalomeApp_DoubleSpinBox * ) send )
newValueStr = aDoubleSpinBox - > text ( ) ;
if ( send = = Group1Spin - > SpinBox_DX ) {
vx = newValue ; vxStr = newValueStr ;
2004-06-16 21:24:55 +06:00
}
2012-08-09 13:58:02 +06:00
else if ( send = = Group1Sel1Spin - > SpinBox_DX ) {
vx = newValue ; vxStr = newValueStr ;
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group2Spin - > SpinBox_DX ) {
vx = newValue ; vxStr = newValueStr ;
vy = Group2Spin - > SpinBox_DY - > value ( ) ; vyStr = Group2Spin - > SpinBox_DY - > text ( ) ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group2Spin - > SpinBox_DY ) {
vx = Group2Spin - > SpinBox_DX - > value ( ) ; vxStr = Group2Spin - > SpinBox_DX - > text ( ) ;
vy = newValue ; vyStr = newValueStr ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group3Spin - > SpinBox_DX ) {
vx = newValue ; vxStr = newValueStr ;
vy = Group3Spin - > SpinBox_DY - > value ( ) ; vyStr = Group3Spin - > SpinBox_DY - > text ( ) ;
2012-08-09 13:58:02 +06:00
vz = Group3Spin - > SpinBox_DZ - > value ( ) ;
if ( ( mySketchType = = PT_REL_RADIUS | | mySketchType = = PT_ABS_RADIUS ) & & ( vx ! = 0 | | vy ! = 0 ) ) {
if ( mySketchType = = PT_ABS_RADIUS ) {
dx = vx - myLastX1 ;
dy = vy - myLastY1 ;
}
else {
dx = vx ;
dy = vy ;
}
minRad = 0.5 * Sqrt ( dx * dx + dy * dy ) ; //Computation of the minimum acceptable radius for the arc calculation
if ( aPrecision > = 0 ) // 'f' format in the QString
LastDecimal = aPrecision ;
else // 'g' format in the Qstring
LastDecimal = qAbs ( aPrecision ) - ceil ( log10 ( minRad ) ) ;
minRad = ceil ( pow ( 10 , LastDecimal ) * minRad ) / pow ( 10 , LastDecimal ) ; // Rounded up at the last allowed decimal place
if ( Abs ( vz ) < minRad ) {
if ( vz < 0.0 )
Group3Spin - > SpinBox_DZ - > setValue ( - minRad ) ;
else
Group3Spin - > SpinBox_DZ - > setValue ( minRad ) ;
}
}
2009-02-13 17:16:39 +05:00
vz = Group3Spin - > SpinBox_DZ - > value ( ) ; vzStr = Group3Spin - > SpinBox_DZ - > text ( ) ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group3Spin - > SpinBox_DY ) {
vx = Group3Spin - > SpinBox_DX - > value ( ) ; vxStr = Group3Spin - > SpinBox_DX - > text ( ) ;
vy = newValue ; vyStr = newValueStr ;
vz = Group3Spin - > SpinBox_DZ - > value ( ) ; vzStr = Group3Spin - > SpinBox_DZ - > text ( ) ;
2012-08-09 13:58:02 +06:00
if ( ( mySketchType = = PT_REL_RADIUS | | mySketchType = = PT_ABS_RADIUS ) & & ( vx ! = 0 | | vy ! = 0 ) ) {
if ( mySketchType = = PT_ABS_RADIUS ) {
dx = vx - myLastX1 ;
dy = vy - myLastY1 ;
}
else {
dx = vx ;
dy = vy ;
}
minRad = 0.5 * Sqrt ( dx * dx + dy * dy ) ; //Computation of the minimum acceptable radius for the arc calculation
if ( aPrecision > = 0 ) // 'f' format in the QString
LastDecimal = aPrecision ;
else // 'g' format in the QString
LastDecimal = qAbs ( aPrecision ) - ceil ( log10 ( minRad ) ) ;
minRad = ceil ( pow ( 10 , LastDecimal ) * minRad ) / pow ( 10 , LastDecimal ) ; // Rounded up at the last allowed decimal place
if ( Abs ( vz ) < minRad ) {
if ( vz < 0.0 )
Group3Spin - > SpinBox_DZ - > setValue ( - minRad ) ;
else
Group3Spin - > SpinBox_DZ - > setValue ( minRad ) ;
}
}
vz = Group3Spin - > SpinBox_DZ - > value ( ) ; vzStr = Group3Spin - > SpinBox_DZ - > text ( ) ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group3Spin - > SpinBox_DZ ) {
vx = Group3Spin - > SpinBox_DX - > value ( ) ; vxStr = Group3Spin - > SpinBox_DX - > text ( ) ;
vy = Group3Spin - > SpinBox_DY - > value ( ) ; vyStr = Group3Spin - > SpinBox_DY - > text ( ) ;
vz = newValue ; vzStr = newValueStr ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group4Spin - > SpinBox_DX ) {
vx = newValue ; vxStr = newValueStr ;
vy = Group4Spin - > SpinBox_DY - > value ( ) ; vyStr = Group4Spin - > SpinBox_DY - > text ( ) ;
vz = Group4Spin - > SpinBox_DZ - > value ( ) ; vzStr = Group4Spin - > SpinBox_DZ - > text ( ) ;
vs = Group4Spin - > SpinBox_DS - > value ( ) ; vsStr = Group4Spin - > SpinBox_DS - > text ( ) ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group4Spin - > SpinBox_DY ) {
vx = Group4Spin - > SpinBox_DX - > value ( ) ; vxStr = Group4Spin - > SpinBox_DX - > text ( ) ;
vy = newValue ; vyStr = newValueStr ;
vz = Group4Spin - > SpinBox_DZ - > value ( ) ; vzStr = Group4Spin - > SpinBox_DZ - > text ( ) ;
vs = Group4Spin - > SpinBox_DS - > value ( ) ; vsStr = Group4Spin - > SpinBox_DS - > text ( ) ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group4Spin - > SpinBox_DZ ) {
vx = Group4Spin - > SpinBox_DX - > value ( ) ; vxStr = Group4Spin - > SpinBox_DX - > text ( ) ;
vy = Group4Spin - > SpinBox_DY - > value ( ) ; vyStr = Group4Spin - > SpinBox_DY - > text ( ) ;
vz = newValue ; vzStr = newValueStr ;
vs = Group4Spin - > SpinBox_DS - > value ( ) ; vsStr = Group4Spin - > SpinBox_DS - > text ( ) ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
else if ( send = = Group4Spin - > SpinBox_DS ) {
vx = Group4Spin - > SpinBox_DX - > value ( ) ; vxStr = Group4Spin - > SpinBox_DX - > text ( ) ;
vy = Group4Spin - > SpinBox_DY - > value ( ) ; vyStr = Group4Spin - > SpinBox_DY - > text ( ) ;
vz = Group4Spin - > SpinBox_DZ - > value ( ) ; vzStr = Group4Spin - > SpinBox_DZ - > text ( ) ;
vs = newValue ; vsStr = newValueStr ;
2008-03-07 12:45:34 +05:00
}
2009-02-13 17:16:39 +05:00
// Fix of the NPAL16010 bug is removed, because it's not actual with the Qt-4.x
2004-06-16 21:24:55 +06:00
2009-02-13 17:16:39 +05:00
if ( myConstructorId = = 0 ) { // SEGMENT
if ( mySketchType = = PT_ABS ) {
2004-06-16 21:24:55 +06:00
myX = vx ;
myY = vy ;
2009-02-13 17:16:39 +05:00
myXStr = vxStr ;
myYStr = vyStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = PT_RELATIVE ) {
2004-06-16 21:24:55 +06:00
myDX = vx ;
myDY = vy ;
2009-02-13 17:16:39 +05:00
myDXStr = vxStr ;
myDYStr = vyStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_ANGLE_LENGTH ) {
2004-06-16 21:24:55 +06:00
myAngle = vx ;
myLength = vy ;
2009-02-13 17:16:39 +05:00
myAngleStr = vxStr ;
myLengthStr = vyStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_ANGLE_X ) {
2004-06-16 21:24:55 +06:00
myAngle = vx ;
myX = vy ;
2009-02-13 17:16:39 +05:00
myAngleStr = vxStr ;
myXStr = vyStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_ANGLE_Y ) {
2004-06-16 21:24:55 +06:00
myAngle = vx ;
myY = vy ;
2009-02-13 17:16:39 +05:00
myAngleStr = vxStr ;
myYStr = vyStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_PER_LENGTH ) {
2004-06-16 21:24:55 +06:00
myLength = vx ;
2009-02-13 17:16:39 +05:00
myLengthStr = vxStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_PER_X ) {
2004-06-16 21:24:55 +06:00
myX = vx ;
2009-02-13 17:16:39 +05:00
myXStr = vxStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_PER_Y ) {
2004-06-16 21:24:55 +06:00
myY = vx ;
2009-02-13 17:16:39 +05:00
myYStr = vxStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_TAN_LENGTH ) {
2004-06-16 21:24:55 +06:00
myLength = vx ;
2009-02-13 17:16:39 +05:00
myLengthStr = vxStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_TAN_X ) {
2004-06-16 21:24:55 +06:00
myX = vx ;
2009-02-13 17:16:39 +05:00
myXStr = vxStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_TAN_Y ) {
2004-06-16 21:24:55 +06:00
myY = vx ;
2009-02-13 17:16:39 +05:00
myYStr = vxStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_DXDY_LENGTH ) {
2004-06-16 21:24:55 +06:00
myDX = vx ;
myDY = vy ;
myLength = vz ;
2009-02-13 17:16:39 +05:00
myDXStr = vxStr ;
myDYStr = vyStr ;
myLengthStr = vzStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_DXDY_X ) {
2004-06-16 21:24:55 +06:00
myDX = vx ;
myDY = vy ;
myX = vz ;
2009-02-13 17:16:39 +05:00
myDXStr = vxStr ;
myDYStr = vyStr ;
myXStr = vzStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_DXDY_Y ) {
2004-06-16 21:24:55 +06:00
myDX = vx ;
myDY = vy ;
myY = vz ;
2009-02-13 17:16:39 +05:00
myDXStr = vxStr ;
myDYStr = vyStr ;
myYStr = vzStr ;
2004-06-16 21:24:55 +06:00
}
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorId = = 1 ) { // ARC
2012-08-09 13:58:02 +06:00
if ( mySketchType = = PT_ABS ) {
myX = vx ;
myY = vy ;
myXStr = vxStr ;
myYStr = vyStr ;
}
else if ( mySketchType = = PT_RELATIVE ) {
myDX = vx ;
myDY = vy ;
myDXStr = vxStr ;
myDYStr = vyStr ;
}
if ( mySketchType = = PT_ABS_RADIUS ) {
myX = vx ;
myY = vy ;
myRadius = vz ;
myXStr = vxStr ;
myYStr = vyStr ;
myRadiusStr = vzStr ;
}
else if ( mySketchType = = PT_REL_RADIUS ) {
myDX = vx ;
myDY = vy ;
myRadius = vz ;
myDXStr = vxStr ;
myDYStr = vyStr ;
myRadiusStr = vzStr ;
}
else if ( mySketchType = = PT_SEL_RADIUS ) {
myRadius = vx ;
myRadiusStr = vxStr ;
}
if ( mySketchType = = PT_ABS_CENTER ) {
myXc = vx ;
myYc = vy ;
myX = vz ;
myY = vs ;
myXcStr = vxStr ;
myYcStr = vyStr ;
myXStr = vzStr ;
myYStr = vsStr ;
}
else if ( mySketchType = = PT_REL_CENTER ) {
myDXc = vx ;
myDYc = vy ;
myDX = vz ;
myDY = vs ;
myDXcStr = vxStr ;
myDYcStr = vyStr ;
myDXStr = vzStr ;
myDYStr = vsStr ;
}
2009-02-13 17:16:39 +05:00
if ( mySketchType = = DIR_ANGLE_LENGTH ) {
2004-06-16 21:24:55 +06:00
myAngle = vx ;
myRadius = vy ;
myLength = vz ;
2009-02-13 17:16:39 +05:00
myAngleStr = vxStr ;
myRadiusStr = vyStr ;
myLengthStr = vzStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_PER_LENGTH ) {
2004-06-16 21:24:55 +06:00
myRadius = vx ;
myLength = vy ;
2009-02-13 17:16:39 +05:00
myRadiusStr = vxStr ;
myLengthStr = vyStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_TAN_LENGTH ) {
2004-06-16 21:24:55 +06:00
myRadius = vx ;
myLength = vy ;
2009-02-13 17:16:39 +05:00
myRadiusStr = vxStr ;
myLengthStr = vyStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
else if ( mySketchType = = DIR_DXDY_LENGTH ) {
2004-06-16 21:24:55 +06:00
myDX = vx ;
myDY = vy ;
myRadius = vz ;
myLength = vs ;
2009-02-13 17:16:39 +05:00
myDXStr = vxStr ;
myDYStr = vyStr ;
myRadiusStr = vzStr ;
myLengthStr = vsStr ;
2004-06-16 21:24:55 +06:00
}
}
2012-08-09 13:58:02 +06:00
else if ( myConstructorId = = 2 ) { // RECTANGLE
myX1 = GroupRect - > SpinBox_DX1 - > value ( ) ; myX1Str = GroupRect - > SpinBox_DX1 - > text ( ) ;
myX2 = GroupRect - > SpinBox_DX2 - > value ( ) ; myX2Str = GroupRect - > SpinBox_DX2 - > text ( ) ;
myY1 = GroupRect - > SpinBox_DY1 - > value ( ) ; myY1Str = GroupRect - > SpinBox_DY1 - > text ( ) ;
myY2 = GroupRect - > SpinBox_DY2 - > value ( ) ; myY2Str = GroupRect - > SpinBox_DY2 - > text ( ) ;
}
2004-06-16 21:24:55 +06:00
2012-08-09 13:58:02 +06:00
if ( ! autoApply )
GEOMBase_Helper : : displayPreview ( true , false , true , true , myLineWidth ) ;
double x , y , xc , yc ;
x = y = xc = yc = 0.0 ;
if ( mySketchType = = PT_ABS_CENTER | | mySketchType = = PT_REL_CENTER )
{
if ( mySketchType = = PT_REL_CENTER ) {
x = myDX + myLastX1 ;
y = myDY + myLastY1 ;
xc = myDXc + myLastX1 ;
yc = myDYc + myLastY1 ;
}
else {
x = myX ;
y = myY ;
xc = myXc ;
yc = myYc ;
}
displayPntPreview ( xc , yc ) ;
displayPntPreview ( x , y ) ;
}
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
//=================================================================================
2009-02-13 17:16:39 +05:00
QString EntityGUI_SketcherDlg : : GetNewCommand ( QString & theParameters )
2004-06-16 21:24:55 +06:00
{
2009-02-13 17:16:39 +05:00
theParameters . clear ( ) ;
2004-12-01 15:39:14 +05:00
QString myNewCommand = " : " ;
2012-08-09 13:58:02 +06:00
SUIT_ResourceMgr * resMgr = SUIT_Session : : session ( ) - > resourceMgr ( ) ;
int aPrecision = resMgr - > integerValue ( " Geometry " , " length_precision " , 6 ) ;
int DigNum = qAbs ( aPrecision ) ; // options for the format of numbers in myNewCommand
char Format = ' f ' ;
if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
Format = ' g ' ; // g --> DigNum is the maximum number of significant digits
2004-12-01 15:39:14 +05:00
if ( mySketchState = = FIRST_POINT ) {
2009-02-13 17:16:39 +05:00
if ( mySketchType = = PT_ABS | | mySketchType = = PT_SEL ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " F " + QString : : number ( myX , Format , DigNum ) + " " + QString : : number ( myY , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myXStr + " : " + myYStr ;
}
if ( mySketchType = = PT_RELATIVE ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " F " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myDXStr + " : " + myDYStr ;
}
2012-08-09 13:58:02 +06:00
if ( myConstructorId = = 2 )
myNewCommand = " : " ;
else
return myNewCommand ;
2004-12-01 15:39:14 +05:00
}
2004-06-16 21:24:55 +06:00
2009-02-13 17:16:39 +05:00
if ( myConstructorId = = 0 ) { // SEGMENT
if ( mySketchType = = PT_ABS | | mySketchType = = PT_SEL ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " TT " + QString : : number ( myX , Format , DigNum ) + " " + QString : : number ( myY , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myXStr + " : " + myYStr ;
}
if ( mySketchType = = PT_RELATIVE ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " T " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myDXStr + " : " + myDYStr ;
}
if ( mySketchType = = DIR_ANGLE_LENGTH ) {
myNewCommand = myNewCommand + " R " + QString : : number ( myAngle ) ;
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " : " + " L " + QString : : number ( myLength , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myAngleStr + " : " + myLengthStr ;
}
if ( mySketchType = = DIR_ANGLE_X ) {
myNewCommand = myNewCommand + " R " + QString : : number ( myAngle ) ;
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " : " + " IX " + QString : : number ( myX , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myAngleStr + " : " + myXStr ;
}
if ( mySketchType = = DIR_ANGLE_Y ) {
myNewCommand = myNewCommand + " R " + QString : : number ( myAngle ) ;
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " : " + " IY " + QString : : number ( myY , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myAngleStr + " : " + myYStr ;
}
if ( mySketchType = = DIR_PER_LENGTH ) {
myNewCommand = myNewCommand + " R " + QString : : number ( 90.0 ) ;
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " : " + " L " + QString : : number ( myLength , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = QString : : number ( 90.0 ) + " : " + myLengthStr ;
}
if ( mySketchType = = DIR_PER_X ) {
myNewCommand = myNewCommand + " R " + QString : : number ( 90.0 ) ;
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " : " + " IX " + QString : : number ( myX , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = QString : : number ( 90.0 ) + " : " + myXStr ;
}
if ( mySketchType = = DIR_PER_Y ) {
myNewCommand = myNewCommand + " R " + QString : : number ( 90.0 ) ;
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " : " + " IY " + QString : : number ( myY , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = QString : : number ( 90.0 ) + " : " + myYStr ;
}
if ( mySketchType = = DIR_TAN_LENGTH ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " L " + QString : : number ( myLength , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myLengthStr ;
}
if ( mySketchType = = DIR_TAN_X ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " IX " + QString : : number ( myX , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myXStr ;
}
if ( mySketchType = = DIR_TAN_Y ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " IY " + QString : : number ( myY , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myYStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
if ( mySketchType = = DIR_DXDY_LENGTH ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " D " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) ;
myNewCommand = myNewCommand + " : " + " L " + QString : : number ( myLength , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myDXStr + " : " + myDYStr + " : " + myLengthStr ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
if ( mySketchType = = DIR_DXDY_X ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " D " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) ;
myNewCommand = myNewCommand + " : " + " IX " + QString : : number ( myX , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myDXStr + " : " + myDYStr + " : " + myXStr ;
}
if ( mySketchType = = DIR_DXDY_Y ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " D " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) ;
myNewCommand = myNewCommand + " : " + " IY " + QString : : number ( myY , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myDXStr + " : " + myDYStr + " : " + myYStr ;
2004-06-16 21:24:55 +06:00
}
}
2009-02-13 17:16:39 +05:00
else if ( myConstructorId = = 1 ) { // ARC
2012-08-09 13:58:02 +06:00
if ( mySketchType = = PT_ABS | | mySketchType = = PT_SEL ) {
myNewCommand = myNewCommand + " AA " + QString : : number ( myX , Format , DigNum ) + " " + QString : : number ( myY , Format , DigNum ) ;
theParameters = myXStr + " : " + myYStr ;
}
if ( mySketchType = = PT_RELATIVE ) {
myNewCommand = myNewCommand + " A " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) ;
theParameters = myDXStr + " : " + myDYStr ;
}
if ( mySketchType = = PT_ABS_RADIUS | | mySketchType = = PT_SEL_RADIUS ) {
myNewCommand = myNewCommand + " UU " + QString : : number ( myX , Format , DigNum ) + " " + QString : : number ( myY , Format , DigNum ) + " " + QString : : number ( myRadius , Format , DigNum ) + " " + QString : : number ( myCheckFlag ) ;
theParameters = myXStr + " : " + myYStr + " : " + myRadiusStr ;
}
if ( mySketchType = = PT_REL_RADIUS ) {
myNewCommand = myNewCommand + " U " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) + " " + QString : : number ( myRadius , Format , DigNum ) + " " + QString : : number ( myCheckFlag ) ;
theParameters = myDXStr + " : " + myDYStr + " : " + myRadiusStr ;
}
if ( mySketchType = = PT_ABS_CENTER | | mySketchType = = PT_SEL_CENTER ) {
myNewCommand = myNewCommand + " EE " + QString : : number ( myX , Format , DigNum ) + " " + QString : : number ( myY , Format , DigNum ) + " " + QString : : number ( myXc , Format , DigNum ) + " " + QString : : number ( myYc , Format , DigNum ) + " " + QString : : number ( myCheckFlag ) + " " + QString : : number ( 0 ) ;
theParameters = myXStr + " : " + myYStr + " : " + myXcStr + " : " + myYcStr ;
}
if ( mySketchType = = PT_REL_CENTER ) {
myNewCommand = myNewCommand + " E " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) + " " + QString : : number ( myDXc , Format , DigNum ) + " " + QString : : number ( myDYc , Format , DigNum ) + " " + QString : : number ( myCheckFlag ) + " " + QString : : number ( 0 ) ;
theParameters = myDXStr + " : " + myDYStr + " : " + myDXcStr + " : " + myDYcStr ;
}
2009-02-13 17:16:39 +05:00
if ( mySketchType = = DIR_ANGLE_LENGTH ) {
myNewCommand = myNewCommand + " R " + QString : : number ( myAngle ) ;
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " : " + " C " + QString : : number ( myRadius , Format , DigNum ) + " " + QString : : number ( myLength , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myAngleStr + " : " + myRadiusStr + " : " + myLengthStr ;
}
if ( mySketchType = = DIR_PER_LENGTH ) {
myNewCommand = myNewCommand + " R " + QString : : number ( 90.0 ) ;
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " : " + " C " + QString : : number ( myRadius , Format , DigNum ) + " " + QString : : number ( myLength , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = QString : : number ( 90.0 ) + " : " + myRadiusStr + " : " + myLengthStr ;
}
if ( mySketchType = = DIR_TAN_LENGTH ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " C " + QString : : number ( myRadius , Format , DigNum ) + " " + QString : : number ( myLength , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myRadiusStr + " : " + myLengthStr ;
}
if ( mySketchType = = DIR_DXDY_LENGTH ) {
2012-08-09 13:58:02 +06:00
myNewCommand = myNewCommand + " D " + QString : : number ( myDX , Format , DigNum ) + " " + QString : : number ( myDY , Format , DigNum ) ;
myNewCommand = myNewCommand + " : " + " C " + QString : : number ( myRadius , Format , DigNum ) + " " + QString : : number ( myLength , Format , DigNum ) ;
2009-02-13 17:16:39 +05:00
theParameters = myDXStr + " : " + myDYStr + " : " + myRadiusStr + " : " + myLengthStr ;
2004-06-16 21:24:55 +06:00
}
}
2012-08-09 13:58:02 +06:00
else if ( myConstructorId = = 2 ) { // RECTANGLE
myNewCommand = myNewCommand + " F " + QString : : number ( myX1 , Format , DigNum ) + " " + QString : : number ( myY1 , Format , DigNum )
+ " :TT " + QString : : number ( myX1 , Format , DigNum ) + " " + QString : : number ( myY2 , Format , DigNum )
+ " :TT " + QString : : number ( myX2 , Format , DigNum ) + " " + QString : : number ( myY2 , Format , DigNum )
+ " :TT " + QString : : number ( myX2 , Format , DigNum ) + " " + QString : : number ( myY1 , Format , DigNum )
+ " :WW " ;
2014-12-27 13:24:34 +05:00
theParameters = myX1Str + " : " + myY1Str + " : " + myX1Str + " : " + myY2Str + " : " + myX2Str + " : " + myY2Str + " : " + myX2Str + " : " + myY1Str ;
2012-08-09 13:58:02 +06:00
}
2004-06-16 21:24:55 +06:00
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 )
{
2009-02-13 17:16:39 +05:00
bool ok = true ;
bool toCorrect = ! IsPreview ( ) | | myIsApply ;
if ( Group1Spin - > isVisible ( ) ) {
ok = Group1Spin - > SpinBox_DX - > isValid ( msg , toCorrect ) & & ok ;
}
2012-08-09 13:58:02 +06:00
else if ( Group1Sel1Spin - > isVisible ( ) ) {
ok = Group1Sel1Spin - > SpinBox_DX - > isValid ( msg , toCorrect ) & & ok ;
}
2009-02-13 17:16:39 +05:00
else if ( Group2Spin - > isVisible ( ) ) {
ok = Group2Spin - > SpinBox_DX - > isValid ( msg , toCorrect ) & & ok ;
ok = Group2Spin - > SpinBox_DY - > isValid ( msg , toCorrect ) & & ok ;
}
else if ( Group3Spin - > isVisible ( ) ) {
ok = Group3Spin - > SpinBox_DX - > isValid ( msg , toCorrect ) & & ok ;
ok = Group3Spin - > SpinBox_DY - > isValid ( msg , toCorrect ) & & ok ;
ok = Group3Spin - > SpinBox_DZ - > isValid ( msg , toCorrect ) & & ok ;
}
else if ( Group4Spin - > isVisible ( ) ) {
ok = Group4Spin - > SpinBox_DX - > isValid ( msg , toCorrect ) & & ok ;
ok = Group4Spin - > SpinBox_DY - > isValid ( msg , toCorrect ) & & ok ;
ok = Group4Spin - > SpinBox_DZ - > isValid ( msg , toCorrect ) & & ok ;
ok = Group4Spin - > SpinBox_DS - > isValid ( msg , toCorrect ) & & ok ;
}
if ( myIsApply & & ! ok )
showError ( msg ) ;
return ok ;
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 : execute
// purpose :
//=================================================================================
bool EntityGUI_SketcherDlg : : execute ( ObjectList & objects )
{
2012-08-09 13:58:02 +06:00
MESSAGE ( " EntityGUI_SketcherDlg::execute " )
SUIT_ResourceMgr * resMgr = SUIT_Session : : session ( ) - > resourceMgr ( ) ;
int aPrecision = resMgr - > integerValue ( " Geometry " , " length_precision " , 6 ) ;
int DigNum = qAbs ( aPrecision ) ; // options for the format of numbers in myNewCommand
char Format = ' f ' ;
if ( aPrecision < 0 ) // f --> DigNum is the number of digits after the decimal point
Format = ' g ' ; // g --> DigNum is the maximum number of significant digits
2009-02-13 17:16:39 +05:00
QString aParameters ;
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
if ( mySketchState = = FIRST_POINT ) {
2004-12-01 15:39:14 +05:00
myLastX2 = myX ;
myLastY2 = myY ;
}
else {
//Test if the current point is the same as the last one
TopoDS_Shape myShape1 , myShape2 ;
2013-05-29 22:27:24 +06:00
bool isDone = false ;
double error = 0. ;
2004-12-01 15:39:14 +05:00
2012-08-09 13:58:02 +06:00
// Set "C" numeric locale
Kernel_Utils : : Localizer loc ;
2004-12-01 15:39:14 +05:00
//Last Shape
QString Command1 = myCommand . join ( " " ) ;
2016-02-11 20:26:21 +05:00
Sketcher_Profile aProfile1 ( Command1 . toLatin1 ( ) ) ;
2013-05-29 22:27:24 +06:00
myShape1 = aProfile1 . GetShape ( ) ;
2004-12-01 15:39:14 +05:00
//Current Shape
2009-02-13 17:16:39 +05:00
QString Command2 = Command1 + GetNewCommand ( aParameters ) ;
2016-02-11 20:26:21 +05:00
Sketcher_Profile aProfile2 ( Command2 . toLatin1 ( ) ) ;
2013-05-29 22:27:24 +06:00
myShape2 = aProfile2 . GetShape ( & isDone , & error ) ;
2012-08-09 13:58:02 +06:00
//Error Message
if ( mySketchType = = PT_ABS_CENTER | | mySketchType = = PT_REL_CENTER ) {
2013-05-29 22:27:24 +06:00
if ( error > Precision : : Confusion ( ) ) {
2012-08-09 13:58:02 +06:00
Group4Spin - > label - > show ( ) ;
2013-05-29 22:27:24 +06:00
Group4Spin - > label - > setText ( tr ( " GEOM_SKETCHER_WARNING " ) + QString : : number ( error , Format , DigNum ) ) ;
2012-08-09 13:58:02 +06:00
}
else {
Group4Spin - > label - > hide ( ) ;
}
}
else
Group4Spin - > label - > hide ( ) ;
if ( mySketchType = = PT_SEL_CENTER ) {
2013-05-29 22:27:24 +06:00
if ( error > Precision : : Confusion ( ) ) {
2012-08-09 13:58:02 +06:00
Group2Sel - > label - > show ( ) ;
2013-05-29 22:27:24 +06:00
Group2Sel - > label - > setText ( tr ( " GEOM_SKETCHER_WARNING " ) + QString : : number ( error , Format , DigNum ) ) ;
2012-08-09 13:58:02 +06:00
}
else {
Group2Sel - > label - > hide ( ) ;
}
}
else
Group2Sel - > label - > hide ( ) ;
2009-02-13 17:16:39 +05:00
if ( myShape2 . IsNull ( ) ) {
2004-12-01 15:39:14 +05:00
//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 ;
2009-02-13 17:16:39 +05:00
if ( myShape1 . ShapeType ( ) = = TopAbs_VERTEX ) {
2012-08-09 13:58:02 +06:00
//the last shape is the first point
pt = BRep_Tool : : Pnt ( TopoDS : : Vertex ( myShape1 ) ) ;
myLastX1 = pt . X ( ) ;
myLastY1 = pt . Y ( ) ;
2004-06-16 21:24:55 +06:00
}
else {
2012-08-09 13:58:02 +06:00
TopExp : : Vertices ( TopoDS : : Wire ( myShape1 ) , V1 , V2 ) ;
pt = BRep_Tool : : Pnt ( V2 ) ;
myLastX1 = pt . X ( ) ;
myLastY1 = pt . Y ( ) ;
2004-06-16 21:24:55 +06:00
}
2009-02-13 17:16:39 +05:00
TopExp : : Vertices ( TopoDS : : Wire ( myShape2 ) , V1 , V2 ) ;
pt = BRep_Tool : : Pnt ( V2 ) ;
2004-12-01 15:39:14 +05:00
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 ;
2009-02-13 17:16:39 +05:00
if ( ( mySketchState ! = FIRST_POINT & &
2012-08-09 13:58:02 +06:00
myLastX1 = = myLastX2 & & myLastY1 = = myLastY2 ) | | myIsAllAdded ) {
2004-12-01 15:39:14 +05:00
cmd = myCommand . join ( " " ) ;
if ( Group1Sel - > isVisible ( ) ) {
2009-02-13 17:16:39 +05:00
Group1Sel - > buttonApply - > setEnabled ( false ) ;
2008-03-07 12:45:34 +05:00
//Group1Sel->buttonApply->setFocus();
2004-12-01 15:39:14 +05:00
}
2012-08-09 13:58:02 +06:00
if ( Group2Sel - > isVisible ( ) ) {
Group2Sel - > buttonApply - > setEnabled ( false ) ;
//Group2Sel->buttonApply->setFocus();
}
if ( Group1Sel1Spin - > isVisible ( ) ) {
Group1Sel1Spin - > buttonApply - > setEnabled ( false ) ;
//Group1Sel1Spin->buttonApply->setFocus();
}
2004-12-01 15:39:14 +05:00
if ( Group1Spin - > isVisible ( ) ) {
2009-02-13 17:16:39 +05:00
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 ( ) ) {
2009-02-13 17:16:39 +05:00
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 ( ) ) {
2009-02-13 17:16:39 +05:00
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 ( ) ) {
2009-02-13 17:16:39 +05:00
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 {
2009-02-13 17:16:39 +05:00
cmd = myCommand . join ( " " ) + GetNewCommand ( aParameters ) ;
2004-12-01 15:39:14 +05:00
if ( Group1Sel - > isVisible ( ) ) {
2009-02-13 17:16:39 +05:00
Group1Sel - > buttonApply - > setEnabled ( true ) ;
2012-08-09 13:58:02 +06:00
}
if ( Group2Sel - > isVisible ( ) ) {
Group2Sel - > buttonApply - > setEnabled ( true ) ;
}
if ( Group1Sel1Spin - > isVisible ( ) ) {
Group1Sel1Spin - > buttonApply - > setEnabled ( true ) ; ;
2004-12-01 15:39:14 +05:00
}
if ( Group1Spin - > isVisible ( ) ) {
2009-02-13 17:16:39 +05:00
Group1Spin - > buttonApply - > setEnabled ( true ) ;
2004-12-01 15:39:14 +05:00
}
if ( Group2Spin - > isVisible ( ) ) {
2009-02-13 17:16:39 +05:00
Group2Spin - > buttonApply - > setEnabled ( true ) ;
2004-12-01 15:39:14 +05:00
}
if ( Group3Spin - > isVisible ( ) ) {
2009-02-13 17:16:39 +05:00
Group3Spin - > buttonApply - > setEnabled ( true ) ;
2004-12-01 15:39:14 +05:00
}
if ( Group4Spin - > isVisible ( ) ) {
2009-02-13 17:16:39 +05:00
Group4Spin - > buttonApply - > setEnabled ( true ) ;
2004-12-01 15:39:14 +05:00
}
}
2008-03-07 12:45:34 +05:00
2012-08-09 13:58:02 +06:00
GEOM : : GEOM_ICurvesOperations_var anOper = GEOM : : GEOM_ICurvesOperations : : _narrow ( getOperation ( ) ) ;
GEOM : : GEOM_Object_var anObj = NULL ;
int index = ComboBox1 - > currentIndex ( ) ;
if ( index ! = - 1 & & ! myWPlane - > _is_nil ( ) ) // The combobox is not empty
{
anObj = anOper - > MakeSketcherOnPlane ( cmd . toLatin1 ( ) . constData ( ) , myWPlane ) ;
}
2004-12-01 15:39:14 +05:00
if ( ! anObj - > _is_nil ( ) )
2009-02-13 17:16:39 +05:00
{
if ( ! IsPreview ( ) ) {
QStringList aCurrentParameters = myParameters ;
aCurrentParameters < < aParameters ;
2012-08-09 13:58:02 +06:00
anObj - > SetParameters ( aCurrentParameters . join ( " : " ) . toLatin1 ( ) . constData ( ) ) ;
2009-02-13 17:16:39 +05:00
}
2004-12-01 15:39:14 +05:00
objects . push_back ( anObj . _retn ( ) ) ;
2009-02-13 17:16:39 +05:00
}
2004-12-01 15:39:14 +05:00
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 ,
2009-02-13 17:16:39 +05:00
const double lineWidth ,
const int displayMode ,
const int color )
2012-08-09 13:58:02 +06:00
{
SUIT_ResourceMgr * resMgr = SUIT_Session : : session ( ) - > resourceMgr ( ) ;
QColor aColor = resMgr - > colorValue ( " Geometry " , " line_color " , QColor ( 255 , 0 , 0 ) ) ;
Quantity_NameOfColor line_color = SalomeApp_Tools : : color ( aColor ) . Name ( ) ;
2004-12-01 15:39:14 +05:00
// set width of displayed shape
2012-08-09 13:58:02 +06:00
int lw = lineWidth ;
if ( lw = = - 1 ) {
lw = resMgr - > integerValue ( " Geometry " , " preview_edge_width " , - 1 ) ;
}
getDisplayer ( ) - > SetWidth ( lw ) ;
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
2012-08-09 13:58:02 +06:00
// Create wire from applied object
2004-12-01 15:39:14 +05:00
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
2012-08-09 13:58:02 +06:00
if ( myConstructorId ! = 2 )
getDisplayer ( ) - > SetColor ( line_color ) ;
else
getDisplayer ( ) - > SetColor ( Quantity_NOC_VIOLET ) ;
2004-12-01 15:39:14 +05:00
SALOME_Prs * aPrs = getDisplayer ( ) - > BuildPrs ( anApplyedWire ) ;
if ( aPrs ! = 0 & & ! aPrs - > IsNull ( ) )
GEOMBase_Helper : : displayPreview ( aPrs , append , update ) ;
2012-08-09 13:58:02 +06:00
getDisplayer ( ) - > SetColor ( Quantity_NOC_VIOLET ) ;
2004-12-01 15:39:14 +05:00
aPrs = getDisplayer ( ) - > BuildPrs ( aLastSegment ) ;
2012-08-09 13:58:02 +06:00
2004-12-01 15:39:14 +05:00
if ( aPrs ! = 0 & & ! aPrs - > IsNull ( ) )
GEOMBase_Helper : : displayPreview ( aPrs , append , update ) ;
2012-08-09 13:58:02 +06:00
getDisplayer ( ) - > SetColor ( line_color ) ;
2004-12-01 15:39:14 +05:00
getDisplayer ( ) - > UnsetName ( ) ;
// Enable activation of displayed objects
getDisplayer ( ) - > SetToActivate ( true ) ;
}
2012-08-09 13:58:02 +06:00
//================================================================
// Function : displayPntPreview
// Purpose : creates a TopoDS_VERTEX and display a preview of it
//================================================================
void EntityGUI_SketcherDlg : : displayPntPreview ( const double x ,
const double y ,
bool append ,
bool update
)
{
// Get globalCS and working plane
gp_Ax3 globalCS = WPlaneToLCS ( myGlobalCS ) ;
gp_Ax3 aWPlane = GetActiveLocalCS ( ) ;
// Build point in localCS
gp_Pnt aPnt = gp_Pnt ( x , y , 0.0 ) ;
// Get transfomation from local to global CS
gp_Trsf aTrans ;
aTrans . SetTransformation ( aWPlane , globalCS ) ;
BRepBuilderAPI_MakeVertex mkVertex ( aPnt ) ;
TopoDS_Shape aLocalVertex = mkVertex . Shape ( ) ;
// Perform transformation
BRepBuilderAPI_Transform aTransformation ( aLocalVertex , aTrans , Standard_False ) ;
TopoDS_Shape aGlobalVertex = aTransformation . Shape ( ) ;
// Build prs with vertex in globalCS
SALOME_Prs * aPrs = getDisplayer ( ) - > BuildPrs ( aGlobalVertex ) ;
if ( aPrs ! = 0 & & ! aPrs - > IsNull ( ) )
GEOMBase_Helper : : displayPreview ( aPrs , append , update ) ;
}
2004-12-01 15:39:14 +05:00
//================================================================
// 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 ;
2012-08-09 13:58:02 +06:00
if ( ! GEOMBase : : GetShape ( theObject , aShape ) | |
( aShape . ShapeType ( ) ! = TopAbs_WIRE & & aShape . ShapeType ( ) ! = TopAbs_VERTEX ) )
2004-12-01 15:39:14 +05:00
return false ;
2012-08-09 13:58:02 +06:00
if ( ( Group1Sel - > isVisible ( ) & & ! Group1Sel - > buttonApply - > isEnabled ( ) ) | |
( Group2Sel - > isVisible ( ) & & ! Group2Sel - > buttonApply - > isEnabled ( ) ) | |
( Group1Sel1Spin - > isVisible ( ) & & ! Group1Sel1Spin - > buttonApply - > isEnabled ( ) ) | |
( Group1Spin - > isVisible ( ) & & ! Group1Spin - > buttonApply - > isEnabled ( ) ) | |
( Group2Spin - > isVisible ( ) & & ! Group2Spin - > buttonApply - > isEnabled ( ) ) | |
( Group3Spin - > isVisible ( ) & & ! Group3Spin - > buttonApply - > isEnabled ( ) ) | |
( Group4Spin - > isVisible ( ) & & ! Group4Spin - > buttonApply - > isEnabled ( ) ) ) {
2004-12-01 15:39:14 +05:00
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 ) ;
2009-02-13 17:16:39 +05:00
while ( 1 ) {
2004-12-01 15:39:14 +05:00
TopoDS_Shape anEdge = anExp . Current ( ) ;
anExp . Next ( ) ;
if ( anExp . More ( ) ) // i.e. non-last edge
aBuilder . Add ( TopoDS : : Edge ( anEdge ) ) ;
2009-02-13 17:16:39 +05:00
else {
2004-12-01 15:39:14 +05:00
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
2012-08-09 13:58:02 +06:00
//=================================================================================
// function : acceptMouseEvent()
// purpose :
//=================================================================================
bool EntityGUI_SketcherDlg : : acceptMouseEvent ( ) const
{
return ( ( getPnt1ConstructorId ( ) = = 1
| | getPnt1ConstructorId ( ) = = 0
| | myConstructorId = = 2 ) //accept mouse event only on absolute and relative selection mode
& & ! WPlaneLineEdit - > isEnabled ( ) ) ; //or when the constructor is rectangle
//called by EntityGUI::OnMousePress()
}
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
2009-02-13 17:16:39 +05:00
if ( e - > key ( ) = = Qt : : Key_F1 ) {
e - > accept ( ) ;
ClickOnHelp ( ) ;
}
}
2012-08-09 13:58:02 +06:00
//=================================================================================
// function : initSpinBox()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void EntityGUI_SketcherDlg : : initSpinBox ( SalomeApp_DoubleSpinBox * spinBox ,
2012-08-09 13:58:02 +06:00
double min , double max ,
double step , const char * quantity )
2009-02-13 17:16:39 +05:00
{
2012-08-09 13:58:02 +06:00
// The same stuff as in GEOMBase_Skeleton::initSpinBox()!
// TODO: Think how to keep the single piece of code...
// Obtain precision from preferences
SUIT_ResourceMgr * resMgr = SUIT_Session : : session ( ) - > resourceMgr ( ) ;
int aPrecision = resMgr - > integerValue ( " Geometry " , quantity , 6 ) ;
spinBox - > setPrecision ( aPrecision ) ;
spinBox - > setDecimals ( qAbs ( aPrecision ) ) ; // it's necessary to set decimals before the range setting,
// by default Qt rounds boundaries to 2 decimals at setRange
2009-02-13 17:16:39 +05:00
spinBox - > setRange ( min , max ) ;
spinBox - > setSingleStep ( step ) ;
2012-08-09 13:58:02 +06:00
// Add a hint for the user saying how to tune precision
QString userPropName = QObject : : tr ( QString ( " GEOM_PREF_%1 " ) . arg ( quantity ) . toLatin1 ( ) . constData ( ) ) ;
spinBox - > setProperty ( " validity_tune_hint " ,
QVariant ( QObject : : tr ( " GEOM_PRECISION_HINT " ) . arg ( userPropName ) ) ) ;
2009-02-13 17:16:39 +05:00
}
//=================================================================================
// function : SetDoubleSpinBoxStep()
// purpose : Double spin box management
//=================================================================================
void EntityGUI_SketcherDlg : : SetDoubleSpinBoxStep ( double step )
{
Group1Spin - > SpinBox_DX - > setSingleStep ( step ) ;
2012-08-09 13:58:02 +06:00
Group1Sel1Spin - > SpinBox_DX - > setSingleStep ( step ) ;
2009-02-13 17:16:39 +05:00
Group2Spin - > SpinBox_DX - > setSingleStep ( step ) ;
Group2Spin - > SpinBox_DY - > setSingleStep ( step ) ;
Group3Spin - > SpinBox_DX - > setSingleStep ( step ) ;
Group3Spin - > SpinBox_DY - > setSingleStep ( step ) ;
Group3Spin - > SpinBox_DZ - > setSingleStep ( step ) ;
Group4Spin - > SpinBox_DZ - > setSingleStep ( step ) ;
2012-08-09 13:58:02 +06:00
// san: Do NOT override the step when a speicifc step value is used
// in some input fields!
//Group4Spin->SpinBox_DX->setSingleStep(step);
//Group4Spin->SpinBox_DY->setSingleStep(step);
//Group4Spin->SpinBox_DS->setSingleStep(step);
}
//=================================================================================
// function : AddLocalCS()
// purpose : Add All Coordinates systems in study
//=================================================================================
void EntityGUI_SketcherDlg : : AddLocalCS ( GEOM : : GEOM_Object_var aSelectedObject )
{
QString aName = GEOMBase : : GetName ( aSelectedObject ) ;
int index = ComboBox1 - > findText ( aName , Qt : : MatchExactly ) ;
if ( index = = - 1 ) // If the working plane hasn't been added yet
{
myWPlaneList . push_back ( aSelectedObject ) ;
myWPlane = aSelectedObject ;
addSubshapesToStudy ( ) ;
myLCSList . push_back ( WPlaneToLCS ( aSelectedObject ) ) ;
ComboBox1 - > addItem ( aName ) ;
index = ComboBox1 - > count ( ) ;
ComboBox1 - > setCurrentIndex ( index - 1 ) ;
}
else
{
ComboBox1 - > setCurrentIndex ( index ) ;
}
ActivateLocalCS ( ) ;
}
//=================================================================================
// function : FindLocalCS()
// purpose : Find All Coordinates systems in study
//=================================================================================
void EntityGUI_SketcherDlg : : FindLocalCS ( )
{
ComboBox1 - > clear ( ) ;
myWPlaneList . clear ( ) ;
SalomeApp_Application * app =
dynamic_cast < SalomeApp_Application * > ( SUIT_Session : : session ( ) - > activeApplication ( ) ) ;
if ( ! app )
return ;
SalomeApp_Study * appStudy = dynamic_cast < SalomeApp_Study * > ( app - > activeStudy ( ) ) ;
if ( ! appStudy )
return ;
_PTR ( Study ) aStudy = appStudy - > studyDS ( ) ;
//add Global CS
ComboBox1 - > addItem ( tr ( " GEOM_GCS " ) ) ;
myWPlaneList . push_back ( myGlobalCS ) ;
// get GEOM component
CORBA : : String_var geomIOR = app - > orb ( ) - > object_to_string ( GeometryGUI : : GetGeomGen ( ) ) ;
_PTR ( SObject ) obj = aStudy - > FindObjectIOR ( geomIOR . in ( ) ) ;
if ( ! obj )
return ;
_PTR ( SComponent ) fc = obj - > GetFatherComponent ( ) ;
QString geomComp = fc - > GetID ( ) . c_str ( ) ;
_PTR ( SObject ) comp = aStudy - > FindObjectID ( geomComp . toLatin1 ( ) . data ( ) ) ;
if ( ! comp )
return ;
// browse through all GEOM data tree
_PTR ( ChildIterator ) it ( aStudy - > NewChildIterator ( comp ) ) ;
for ( it - > InitEx ( true ) ; it - > More ( ) ; it - > Next ( ) )
{
_PTR ( SObject ) child ( it - > Value ( ) ) ;
CORBA : : Object_var corbaObj = GeometryGUI : : ClientSObjectToObject ( child ) ;
GEOM : : GEOM_Object_var geomObj = GEOM : : GEOM_Object : : _narrow ( corbaObj ) ;
if ( CORBA : : is_nil ( geomObj ) )
continue ;
if ( geomObj - > GetType ( ) = = GEOM_MARKER )
{
myWPlaneList . push_back ( geomObj ) ;
myLCSList . push_back ( WPlaneToLCS ( geomObj ) ) ;
ComboBox1 - > addItem ( geomObj - > GetName ( ) ) ;
}
}
}
//=================================================================================
// function : WPlaneToLCS ( aWPlane )
// purpose :
//=================================================================================
gp_Ax3 EntityGUI_SketcherDlg : : WPlaneToLCS ( GEOM : : GEOM_Object_var geomObj )
{
TopoDS_Shape aShape = GEOM_Client : : get_client ( ) . GetShape ( GeometryGUI : : GetGeomGen ( ) , geomObj ) ;
gp_Ax3 aLCS ;
if ( CORBA : : is_nil ( geomObj ) | | aShape . IsNull ( ) )
{
MESSAGE ( " CORBA::is_nil( geomObj ) || aShape.IsNull() " )
}
aLCS . Transform ( aShape . Location ( ) . Transformation ( ) ) ;
if ( aShape . ShapeType ( ) = = TopAbs_FACE )
{
GEOM : : GEOM_IMeasureOperations_ptr aMeasureOp =
myGeometryGUI - > GetGeomGen ( ) - > GetIMeasureOperations ( getStudyId ( ) ) ;
double Ox , Oy , Oz , Zx , Zy , Zz , Xx , Xy , Xz ;
aMeasureOp - > GetPosition ( geomObj , Ox , Oy , Oz , Zx , Zy , Zz , Xx , Xy , Xz ) ;
if ( aMeasureOp - > IsDone ( ) )
{
gp_Pnt aPnt ( Ox , Oy , Oz ) ;
gp_Dir aDirN ( Zx , Zy , Zz ) ;
gp_Dir aDirX ( Xx , Xy , Xz ) ;
aLCS = gp_Ax3 ( aPnt , aDirN , aDirX ) ;
}
}
return aLCS ;
}
//=================================================================================
// function : getPnt1ConstructorId()
// purpose :
//=================================================================================
int EntityGUI_SketcherDlg : : getPnt1ConstructorId ( ) const
{
int buttonId = GroupPt - > ButtonGroup - > checkedId ( ) ;
// MESSAGE("buttonId = "<<buttonId)
return buttonId ;
}
//=================================================================================
// function : getPnt2ConstructorId()
// purpose :
//=================================================================================
int EntityGUI_SketcherDlg : : getPnt2ConstructorId ( ) const
{
int buttonId = GroupPt2 - > ButtonGroup - > checkedId ( ) ;
// MESSAGE("buttonId = "<<buttonId)
return buttonId ;
}
//=================================================================================
// function : GetActiveLocalCS()
// purpose : Get Working plane
//=================================================================================
gp_Ax3 EntityGUI_SketcherDlg : : GetActiveLocalCS ( )
{
int ind = ComboBox1 - > currentIndex ( ) ;
if ( ind = = - 1 )
return myGeometryGUI - > GetWorkingPlane ( ) ;
gp_Ax3 aLCS = myLCSList . at ( ind ) ;
myWPlane = myWPlaneList . at ( ind ) ;
return aLCS ;
}
//=================================================================================
// function : ActivateLocalCS()
// purpose : Activate & Fit Working plane
//=================================================================================
void EntityGUI_SketcherDlg : : ActivateLocalCS ( )
{
myGeometryGUI - > SetWorkingPlane ( GetActiveLocalCS ( ) ) ;
myGeometryGUI - > ActiveWorkingPlane ( ) ;
}
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void EntityGUI_SketcherDlg : : addSubshapesToStudy ( )
{
GEOMBase : : PublishSubObject ( myWPlane ) ;
2008-03-07 12:45:34 +05:00
}