geom/src/BasicGUI/BasicGUI_CircleDlg.cxx

655 lines
24 KiB
C++
Raw Normal View History

2022-05-05 17:01:14 +05:00
// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
2004-01-07 20:46:21 +05: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
2004-01-07 20:46:21 +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.
2004-01-07 20:46:21 +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.
2009-02-13 17:16:39 +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
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : BasicGUI_CircleDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
2004-01-07 20:46:21 +05:00
//
#include "BasicGUI_CircleDlg.h"
2009-02-13 17:16:39 +05:00
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
2014-11-19 20:45:44 +05:00
#include "utilities.h"
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
2004-06-16 21:24:55 +06:00
2004-01-07 20:46:21 +05:00
//=================================================================================
// class : BasicGUI_CircleDlg()
2009-02-13 17:16:39 +05:00
// purpose : Constructs a BasicGUI_CircleDlg which is a child of 'parent', with the
2004-01-07 20:46:21 +05:00
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
2009-02-13 17:16:39 +05:00
BasicGUI_CircleDlg::BasicGUI_CircleDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
2012-08-09 13:58:02 +06:00
bool modal, Qt::WindowFlags fl )
2009-02-13 17:16:39 +05:00
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PV" ) ) );
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PNTS" ) ) );
QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_C2P" ) ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
setWindowTitle( tr( "GEOM_CIRCLE_TITLE" ) );
2004-01-07 20:46:21 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CIRCLE" ) );
mainFrame()->RadioButton1->setIcon( image0 );
mainFrame()->RadioButton2->setIcon( image2 );
mainFrame()->RadioButton3->setIcon( image3 );
GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() );
GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
2012-08-09 13:58:02 +06:00
GroupPntVecR->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) + " " + tr( "GEOM_CENTER_DEFAULT" ) );
GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " " + tr( "GEOM_AXIS_DEFAULT" ) );
2009-02-13 17:16:39 +05:00
GroupPntVecR->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
GroupPntVecR->PushButton1->setIcon( image1 );
GroupPntVecR->PushButton2->setIcon( image1 );
GroupPntVecR->PushButton1->setDown( true );
2004-12-01 15:39:14 +05:00
GroupPntVecR->LineEdit1->setReadOnly( true );
GroupPntVecR->LineEdit2->setReadOnly( true );
2009-02-13 17:16:39 +05:00
GroupPntVecR->LineEdit1->setEnabled( true );
GroupPntVecR->LineEdit2->setEnabled( false );
Group3Pnts = new DlgRef_3Sel( centralWidget() );
Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
Group3Pnts->PushButton1->setIcon( image1 );
Group3Pnts->PushButton2->setIcon( image1 );
Group3Pnts->PushButton3->setIcon( image1 );
Group3Pnts->PushButton1->setDown( true );
2004-12-01 15:39:14 +05:00
Group3Pnts->LineEdit1->setReadOnly( true );
Group3Pnts->LineEdit2->setReadOnly( true );
Group3Pnts->LineEdit3->setReadOnly( true );
2009-02-13 17:16:39 +05:00
Group3Pnts->LineEdit1->setEnabled( true );
Group3Pnts->LineEdit2->setEnabled( false );
Group3Pnts->LineEdit3->setEnabled( false );
GroupCenter2Pnts = new DlgRef_3Sel( centralWidget() );
GroupCenter2Pnts->GroupBox1->setTitle( tr( "GEOM_CENTER_2POINTS" ) );
GroupCenter2Pnts->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) );
GroupCenter2Pnts->TextLabel2->setText( tr( "GEOM_POINT1" ) );
GroupCenter2Pnts->TextLabel3->setText( tr( "GEOM_POINT2" ) );
GroupCenter2Pnts->PushButton1->setIcon( image1 );
GroupCenter2Pnts->PushButton2->setIcon( image1 );
GroupCenter2Pnts->PushButton3->setIcon( image1 );
GroupCenter2Pnts->PushButton1->setDown( true );
GroupCenter2Pnts->LineEdit1->setReadOnly( true );
GroupCenter2Pnts->LineEdit2->setReadOnly( true );
GroupCenter2Pnts->LineEdit3->setReadOnly( true );
2009-02-13 17:16:39 +05:00
GroupCenter2Pnts->LineEdit1->setEnabled( true );
GroupCenter2Pnts->LineEdit2->setEnabled( false );
GroupCenter2Pnts->LineEdit3->setEnabled( false );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPntVecR );
layout->addWidget( Group3Pnts );
layout->addWidget( GroupCenter2Pnts );
2004-01-07 20:46:21 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
setHelpFileName( "create_circle_page.html" );
2004-01-07 20:46:21 +05:00
Init();
}
//=================================================================================
// function : ~BasicGUI_CircleDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
BasicGUI_CircleDlg::~BasicGUI_CircleDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void BasicGUI_CircleDlg::Init()
{
/* init variables */
2004-12-01 15:39:14 +05:00
myEditCurrentArgument = GroupPntVecR->LineEdit1;
2004-01-07 20:46:21 +05:00
2012-08-09 13:58:02 +06:00
myPoint.nullify();
myDir.nullify();
myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
myPoint4.nullify();
myPoint5.nullify();
myPoint6.nullify();
2004-01-07 20:46:21 +05:00
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2009-02-13 17:16:39 +05:00
double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
2004-01-07 20:46:21 +05:00
/* min, max, step and decimals for spin boxes & initial values */
2012-08-09 13:58:02 +06:00
initSpinBox( GroupPntVecR->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
2009-02-13 17:16:39 +05:00
GroupPntVecR->SpinBox_DX->setValue( 100 );
2004-01-07 20:46:21 +05:00
/* signals and slots connections */
2009-02-13 17:16:39 +05:00
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
2009-02-13 17:16:39 +05:00
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
connect( GroupPntVecR->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPntVecR->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
connect( GroupCenter2Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
2009-02-13 17:16:39 +05:00
connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
2009-02-13 17:16:39 +05:00
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
initName( tr( "GEOM_CIRCLE" ) );
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
ConstructorsClicked( 0 );
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
//=================================================================================
// function : SetDoubleSpinBoxStep()
// purpose : Double spin box management
//=================================================================================
void BasicGUI_CircleDlg::SetDoubleSpinBoxStep( double step )
{
GroupPntVecR->SpinBox_DX->setSingleStep(step);
}
2004-12-01 15:39:14 +05:00
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId )
{
2009-02-13 17:16:39 +05:00
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
2012-08-09 13:58:02 +06:00
myPoint.nullify();
myDir.nullify();
myPoint1.nullify();
myPoint2.nullify();
myPoint3.nullify();
myPoint4.nullify();
myPoint5.nullify();
myPoint6.nullify();
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
switch ( constructorId ) {
case 0:
{
Group3Pnts->hide();
GroupCenter2Pnts->hide();
GroupPntVecR->show();
myEditCurrentArgument = GroupPntVecR->LineEdit1;
2009-02-13 17:16:39 +05:00
GroupPntVecR->LineEdit1->setText( "" );
GroupPntVecR->LineEdit2->setText( "" );
GroupPntVecR->PushButton1->setDown( true );
GroupPntVecR->PushButton2->setDown( false );
GroupPntVecR->LineEdit1->setEnabled( true );
GroupPntVecR->LineEdit2->setEnabled( false );
break;
}
case 1:
{
GroupPntVecR->hide();
GroupCenter2Pnts->hide();
Group3Pnts->show();
myEditCurrentArgument = Group3Pnts->LineEdit1;
2009-02-13 17:16:39 +05:00
Group3Pnts->LineEdit1->setText( "" );
Group3Pnts->LineEdit2->setText( "" );
Group3Pnts->LineEdit3->setText( "" );
Group3Pnts->PushButton1->setDown( true );
Group3Pnts->PushButton2->setDown( false );
Group3Pnts->PushButton3->setDown( false );
Group3Pnts->LineEdit1->setEnabled( true );
Group3Pnts->LineEdit2->setEnabled( false );
Group3Pnts->LineEdit3->setEnabled( false );
break;
}
case 2:
{
GroupPntVecR->hide();
2012-08-09 13:58:02 +06:00
Group3Pnts->hide();
GroupCenter2Pnts->show();
myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
2009-02-13 17:16:39 +05:00
GroupCenter2Pnts->LineEdit1->setText( "" );
GroupCenter2Pnts->LineEdit2->setText( "" );
GroupCenter2Pnts->LineEdit3->setText( "" );
GroupCenter2Pnts->PushButton1->setDown( true );
GroupCenter2Pnts->PushButton2->setDown( false );
GroupCenter2Pnts->PushButton3->setDown( false );
GroupCenter2Pnts->LineEdit1->setEnabled( true );
GroupCenter2Pnts->LineEdit2->setEnabled( false );
GroupCenter2Pnts->LineEdit3->setEnabled( false );
break;
}
2004-12-01 15:39:14 +05:00
}
2009-02-13 17:16:39 +05:00
qApp->processEvents();
updateGeometry();
resize( minimumSizeHint() );
2004-12-01 15:39:14 +05:00
myEditCurrentArgument->setFocus();
globalSelection(); // close local contexts, if any
localSelection( TopAbs_VERTEX );
2009-02-13 17:16:39 +05:00
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
2012-08-09 13:58:02 +06:00
this, SLOT( SelectionIntoArgument() ) );
2009-02-13 17:16:39 +05:00
2013-02-12 17:35:16 +06:00
SelectionIntoArgument();
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void BasicGUI_CircleDlg::ClickOnOk()
{
2012-08-09 13:58:02 +06:00
setIsApplyAndClose( true );
2004-12-01 15:39:14 +05:00
if ( ClickOnApply() )
ClickOnCancel();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
bool BasicGUI_CircleDlg::ClickOnApply()
2004-01-07 20:46:21 +05:00
{
2004-12-01 15:39:14 +05:00
if ( !onAccept() )
return false;
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
initName();
2009-02-13 17:16:39 +05:00
ConstructorsClicked( getConstructorId() );
2004-12-01 15:39:14 +05:00
return true;
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void BasicGUI_CircleDlg::SelectionIntoArgument()
{
2009-02-13 17:16:39 +05:00
myEditCurrentArgument->setText( "" );
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aList;
2009-02-13 17:16:39 +05:00
aSelMgr->selectedObjects( aList );
if ( aList.Extent() != 1 ) {
2012-08-09 13:58:02 +06:00
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint.nullify();
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4.nullify();
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5.nullify();
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6.nullify();
2004-01-07 20:46:21 +05:00
return;
}
2012-08-09 13:58:02 +06:00
TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
TopAbs_EDGE : TopAbs_VERTEX;
GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape;
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
QString aName = GEOMBase::GetName( aSelectedObject.get() );
2009-02-13 17:16:39 +05:00
myEditCurrentArgument->setText( aName );
2009-02-13 17:16:39 +05:00
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
myPoint = aSelectedObject;
2012-08-09 13:58:02 +06:00
if ( myPoint && !myDir )
GroupPntVecR->PushButton2->click();
2009-02-13 17:16:39 +05:00
}
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
myDir = aSelectedObject;
2012-08-09 13:58:02 +06:00
if ( myDir && !myPoint )
GroupPntVecR->PushButton1->click();
2009-02-13 17:16:39 +05:00
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
myPoint1 = aSelectedObject;
2012-08-09 13:58:02 +06:00
if ( myPoint1 && !myPoint2 )
Group3Pnts->PushButton2->click();
2009-02-13 17:16:39 +05:00
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
myPoint2 = aSelectedObject;
2012-08-09 13:58:02 +06:00
if ( myPoint2 && !myPoint3 )
Group3Pnts->PushButton3->click();
2009-02-13 17:16:39 +05:00
}
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
myPoint3 = aSelectedObject;
2012-08-09 13:58:02 +06:00
if ( myPoint3 && !myPoint1 )
Group3Pnts->PushButton1->click();
2009-02-13 17:16:39 +05:00
}
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
myPoint4 = aSelectedObject;
2012-08-09 13:58:02 +06:00
if ( myPoint4 && !myPoint5 )
GroupCenter2Pnts->PushButton2->click();
2009-02-13 17:16:39 +05:00
}
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
myPoint5 = aSelectedObject;
2012-08-09 13:58:02 +06:00
if ( myPoint5 && !myPoint6 )
GroupCenter2Pnts->PushButton3->click();
2009-02-13 17:16:39 +05:00
}
else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
myPoint6 = aSelectedObject;
2012-08-09 13:58:02 +06:00
if ( myPoint6 && !myPoint4 )
GroupCenter2Pnts->PushButton1->click();
2009-02-13 17:16:39 +05:00
}
}
2009-02-13 17:16:39 +05:00
2012-08-09 13:58:02 +06:00
displayPreview(true);
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void BasicGUI_CircleDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
2009-02-13 17:16:39 +05:00
if ( send == GroupPntVecR->PushButton1 ) {
myEditCurrentArgument = GroupPntVecR->LineEdit1;
GroupPntVecR->PushButton2->setDown(false);
GroupPntVecR->LineEdit1->setEnabled( true );
GroupPntVecR->LineEdit2->setEnabled( false );
}
else if ( send == GroupPntVecR->PushButton2 ) {
myEditCurrentArgument = GroupPntVecR->LineEdit2;
GroupPntVecR->PushButton1->setDown(false);
GroupPntVecR->LineEdit1->setEnabled( false );
GroupPntVecR->LineEdit2->setEnabled( true );
}
else if ( send == Group3Pnts->PushButton1 ) {
myEditCurrentArgument = Group3Pnts->LineEdit1;
Group3Pnts->PushButton2->setDown( false );
Group3Pnts->PushButton3->setDown( false );
Group3Pnts->LineEdit1->setEnabled( true );
Group3Pnts->LineEdit2->setEnabled( false );
Group3Pnts->LineEdit3->setEnabled( false );
}
else if ( send == Group3Pnts->PushButton2 ) {
myEditCurrentArgument = Group3Pnts->LineEdit2;
Group3Pnts->PushButton1->setDown( false );
Group3Pnts->PushButton3->setDown( false );
Group3Pnts->LineEdit1->setEnabled( false );
Group3Pnts->LineEdit2->setEnabled( true );
Group3Pnts->LineEdit3->setEnabled( false );
}
else if ( send == Group3Pnts->PushButton3 ) {
myEditCurrentArgument = Group3Pnts->LineEdit3;
Group3Pnts->PushButton1->setDown( false );
Group3Pnts->PushButton2->setDown( false );
Group3Pnts->LineEdit1->setEnabled( false );
Group3Pnts->LineEdit2->setEnabled( false );
Group3Pnts->LineEdit3->setEnabled( true );
}
else if ( send == GroupCenter2Pnts->PushButton1 ) {
myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
GroupCenter2Pnts->PushButton2->setDown( false );
GroupCenter2Pnts->PushButton3->setDown( false );
GroupCenter2Pnts->LineEdit1->setEnabled( true );
GroupCenter2Pnts->LineEdit2->setEnabled( false );
GroupCenter2Pnts->LineEdit3->setEnabled( false );
}
else if ( send == GroupCenter2Pnts->PushButton2 ) {
myEditCurrentArgument = GroupCenter2Pnts->LineEdit2;
GroupCenter2Pnts->PushButton1->setDown( false );
GroupCenter2Pnts->PushButton3->setDown( false );
GroupCenter2Pnts->LineEdit1->setEnabled( false );
GroupCenter2Pnts->LineEdit2->setEnabled( true );
GroupCenter2Pnts->LineEdit3->setEnabled( false );
}
else if ( send == GroupCenter2Pnts->PushButton3 ) {
myEditCurrentArgument = GroupCenter2Pnts->LineEdit3;
GroupCenter2Pnts->PushButton1->setDown( false );
GroupCenter2Pnts->PushButton2->setDown( false );
GroupCenter2Pnts->LineEdit1->setEnabled( false );
GroupCenter2Pnts->LineEdit2->setEnabled( false );
GroupCenter2Pnts->LineEdit3->setEnabled( true );
}
2009-02-13 17:16:39 +05:00
2004-12-01 15:39:14 +05:00
myEditCurrentArgument->setFocus();
2012-08-09 13:58:02 +06:00
TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
TopAbs_EDGE : TopAbs_VERTEX;
globalSelection(); // close local contexts, if any
localSelection( aNeedType );
2009-02-13 17:16:39 +05:00
myEditCurrentArgument->setFocus();
// SelectionIntoArgument();
send->setDown(true);
2012-08-09 13:58:02 +06:00
displayPreview(true);
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void BasicGUI_CircleDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
2009-02-13 17:16:39 +05:00
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
2012-08-09 13:58:02 +06:00
this, SLOT( SelectionIntoArgument() ) );
2004-12-01 15:39:14 +05:00
ConstructorsClicked( getConstructorId() );
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void BasicGUI_CircleDlg::enterEvent( QEvent* )
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
if ( !mainFrame()->GroupConstructors->isEnabled() )
2004-12-01 15:39:14 +05:00
ActivateThisDialog();
2004-01-07 20:46:21 +05:00
}
2004-12-01 15:39:14 +05:00
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void BasicGUI_CircleDlg::DeactivateActiveDialog()
{
GEOMBase_Skeleton::DeactivateActiveDialog();
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
void BasicGUI_CircleDlg::ValueChangedInSpinBox()
2004-01-07 20:46:21 +05:00
{
2012-08-09 13:58:02 +06:00
displayPreview(true);
2004-01-07 20:46:21 +05:00
}
2004-12-01 15:39:14 +05:00
//=================================================================================
// function : getRadius()
// purpose :
//=================================================================================
double BasicGUI_CircleDlg::getRadius() const
{
2009-02-13 17:16:39 +05:00
double r = 0.;
switch ( getConstructorId() ) {
case 0:
2009-02-13 17:16:39 +05:00
r = GroupPntVecR->SpinBox_DX->value(); break;
}
2009-02-13 17:16:39 +05:00
return r;
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : createOperation
2004-01-07 20:46:21 +05:00
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation()
2004-01-07 20:46:21 +05:00
{
2017-06-13 14:57:14 +05:00
return myGeomGUI->GetGeomGen()->GetICurvesOperations();
2004-12-01 15:39:14 +05:00
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
bool BasicGUI_CircleDlg::isValid( QString& msg )
2004-12-01 15:39:14 +05:00
{
2012-08-09 13:58:02 +06:00
bool ok = false;
switch( getConstructorId() ) {
case 0:
// nil point means origin of global CS
// nil vector means Z axis
ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview()) && getRadius() > 0;
break;
case 1:
ok = myPoint1 && myPoint2 && myPoint3 && myPoint1 != myPoint2 &&
myPoint1 != myPoint3 && myPoint2 != myPoint3;
break;
case 2:
ok = myPoint4 && myPoint5 && myPoint6 && myPoint4 != myPoint5 &&
myPoint5 != myPoint6 && myPoint4 != myPoint6;
break;
default:
break;
2009-02-13 17:16:39 +05:00
}
2012-08-09 13:58:02 +06:00
return ok;
2004-12-01 15:39:14 +05:00
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
bool BasicGUI_CircleDlg::execute( ObjectList& objects )
2004-12-01 15:39:14 +05:00
{
bool res = false;
2009-02-13 17:16:39 +05:00
2004-12-01 15:39:14 +05:00
GEOM::GEOM_Object_var anObj;
2009-02-13 17:16:39 +05:00
2012-08-09 13:58:02 +06:00
GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
2009-02-13 17:16:39 +05:00
switch ( getConstructorId() ) {
case 0 :
{
QStringList aParameters;
aParameters << GroupPntVecR->SpinBox_DX->text();
2012-08-09 13:58:02 +06:00
anObj = anOper->MakeCirclePntVecR( myPoint.get(), myDir.get(), getRadius() );
2009-02-13 17:16:39 +05:00
if ( !anObj->_is_nil() && !IsPreview() )
anObj->SetParameters(aParameters.join(":").toUtf8().constData());
2009-02-13 17:16:39 +05:00
res = true;
break;
}
case 1 :
2012-08-09 13:58:02 +06:00
anObj = anOper->MakeCircleThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get() );
2004-12-01 15:39:14 +05:00
res = true;
break;
case 2:
2012-08-09 13:58:02 +06:00
anObj = anOper->MakeCircleCenter2Pnt( myPoint4.get(), myPoint5.get(), myPoint6.get() );
2004-12-01 15:39:14 +05:00
res = true;
break;
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
else {
2009-02-13 17:16:39 +05:00
MESSAGE( "Execute Object is NULL!" );
}
2009-02-13 17:16:39 +05:00
2004-12-01 15:39:14 +05:00
return res;
}
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void BasicGUI_CircleDlg::addSubshapesToStudy()
{
2009-02-13 17:16:39 +05:00
switch ( getConstructorId() ) {
case 0:
2012-08-09 13:58:02 +06:00
GEOMBase::PublishSubObject( myPoint.get() );
GEOMBase::PublishSubObject( myDir.get() );
break;
case 1:
2012-08-09 13:58:02 +06:00
GEOMBase::PublishSubObject( myPoint1.get() );
GEOMBase::PublishSubObject( myPoint2.get() );
GEOMBase::PublishSubObject( myPoint3.get() );
break;
case 2:
2012-08-09 13:58:02 +06:00
GEOMBase::PublishSubObject( myPoint4.get() );
GEOMBase::PublishSubObject( myPoint5.get() );
GEOMBase::PublishSubObject( myPoint6.get() );
break;
2012-08-09 13:58:02 +06:00
default:
break;
}
}
//=================================================================================
// function : getSourceObjects
// purpose : virtual method to get source objects
//=================================================================================
QList<GEOM::GeomObjPtr> BasicGUI_CircleDlg::getSourceObjects()
{
QList<GEOM::GeomObjPtr> res;
res << myPoint << myDir << myPoint1 << myPoint2 << myPoint3
<< myPoint4 << myPoint5 << myPoint6;
return res;
}