2007-10-18 14:47:58 +00:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
2004-01-07 15:46:21 +00:00
|
|
|
//
|
2007-10-18 14:47:58 +00:00
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2004-01-07 15:46:21 +00:00
|
|
|
//
|
2007-10-18 14:47:58 +00:00
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License.
|
2004-01-07 15:46:21 +00:00
|
|
|
//
|
2007-10-18 14:47:58 +00: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.
|
2004-01-07 15:46:21 +00:00
|
|
|
//
|
2007-10-18 14:47:58 +00: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
|
2004-01-07 15:46:21 +00:00
|
|
|
//
|
2006-06-01 11:32:40 +00:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2004-01-07 15:46:21 +00:00
|
|
|
//
|
2007-10-18 14:47:58 +00:00
|
|
|
// File : OperationGUI_ChamferDlg.cxx
|
|
|
|
// Author : Damien COQUERET, Open CASCADE S.A.S.
|
2004-01-07 15:46:21 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "OperationGUI_ChamferDlg.h"
|
2005-06-02 07:17:09 +00:00
|
|
|
|
2007-10-24 08:17:54 +00:00
|
|
|
#include <DlgRef.h>
|
2007-10-18 14:47:58 +00:00
|
|
|
#include <GeometryGUI.h>
|
|
|
|
#include <GEOMBase.h>
|
2005-06-02 07:17:09 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
#include <SUIT_Desktop.h>
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
#include <SUIT_ViewWindow.h>
|
|
|
|
#include <SUIT_ViewManager.h>
|
|
|
|
#include <SalomeApp_Application.h>
|
|
|
|
#include <LightApp_SelectionMgr.h>
|
|
|
|
#include <OCCViewer_ViewModel.h>
|
2005-06-02 07:17:09 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
#include <GEOMImpl_Types.hxx>
|
2004-06-16 15:24:55 +00:00
|
|
|
|
2004-01-07 15:46:21 +00:00
|
|
|
//=================================================================================
|
|
|
|
// class : OperationGUI_ChamferDlg()
|
2004-12-01 10:39:14 +00:00
|
|
|
// purpose : Constructs a OperationGUI_ChamferDlg which is a child of 'parent', with the
|
2004-01-07 15:46:21 +00: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.
|
|
|
|
//=================================================================================
|
2007-10-18 14:47:58 +00:00
|
|
|
OperationGUI_ChamferDlg::OperationGUI_ChamferDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
|
|
|
|
: GEOMBase_Skeleton( theGeometryGUI, parent, false )
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2007-10-18 14:47:58 +00:00
|
|
|
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_ALL" ) ) );
|
|
|
|
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_EDGE" ) ) );
|
|
|
|
QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CHAMFER_FACE" ) ) );
|
|
|
|
QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
setWindowTitle( tr( "GEOM_CHAMFER_TITLE" ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
mainFrame()->RadioButton1->setIcon( image1 );
|
|
|
|
mainFrame()->RadioButton2->setIcon( image2 );
|
|
|
|
mainFrame()->RadioButton3->setIcon( image3 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
// Create first group
|
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
myGrp1 = new QGroupBox( tr( "GEOM_CHAMFER_ALL" ), centralWidget() );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
QGridLayout* aLayout = new QGridLayout( myGrp1 );
|
|
|
|
aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp1, aLayout, MainObj1 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
int row = aLayout->rowCount();
|
|
|
|
aLayout->addWidget( new QLabel( tr( "D" ), myGrp1 ), row, 0 );
|
|
|
|
aLayout->addWidget( ( mySpinBox[ SpinBox1 ] = new QDoubleSpinBox( myGrp1 ) ), row++, 2 );
|
|
|
|
aLayout->setRowStretch( row, 10 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
// Create second group
|
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
myGrp2 = new QGroupBox( tr( "GEOM_CHAMFER_EDGES" ), centralWidget() );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
aLayout = new QGridLayout( myGrp2 );
|
|
|
|
aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp2, aLayout, MainObj2 );
|
|
|
|
createSelWg( tr( "FACE_1" ), iconSelect, myGrp2, aLayout, Face1 );
|
|
|
|
createSelWg( tr( "FACE_2" ), iconSelect, myGrp2, aLayout, Face2 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
row = aLayout->rowCount();
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
aLayout->addWidget( new QLabel( tr( "GEOM_D1" ), myGrp2 ), row, 0 );
|
|
|
|
aLayout->addWidget( ( mySpinBox[ SpinBox21 ] = new QDoubleSpinBox( myGrp2 ) ), row++, 2 );
|
|
|
|
aLayout->addWidget( new QLabel( tr( "GEOM_D2" ), myGrp2 ), row, 0 );
|
|
|
|
aLayout->addWidget( ( mySpinBox[ SpinBox22 ] = new QDoubleSpinBox( myGrp2 ) ), row++, 2 );
|
|
|
|
aLayout->setRowStretch( row, 10 );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// Create third group
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
myGrp3 = new QGroupBox( tr( "GEOM_CHAMFER_FACES" ), centralWidget() );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
aLayout = new QGridLayout( myGrp3 );
|
|
|
|
aLayout->setMargin( 9 ); aLayout->setSpacing( 6 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, myGrp3, aLayout, MainObj3 );
|
|
|
|
createSelWg( tr( "SELECTED_FACES" ), iconSelect, myGrp3, aLayout, Faces );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
row = aLayout->rowCount();
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
aLayout->addWidget( new QLabel( tr( "GEOM_D1" ), myGrp3 ), row, 0 );
|
|
|
|
aLayout->addWidget( ( mySpinBox[ SpinBox31 ] = new QDoubleSpinBox( myGrp3 ) ), row++, 2 );
|
|
|
|
aLayout->addWidget( new QLabel( tr( "GEOM_D2" ), myGrp3 ), row, 0 );
|
|
|
|
aLayout->addWidget( ( mySpinBox[ SpinBox32 ] = new QDoubleSpinBox( myGrp3 ) ), row++, 2 );
|
|
|
|
aLayout->setRowStretch( row, 10 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
// Add groups to layout
|
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
|
|
|
layout->setMargin( 0 ); layout->setSpacing( 6 );
|
|
|
|
layout->addWidget( myGrp1 );
|
|
|
|
layout->addWidget( myGrp2 );
|
|
|
|
layout->addWidget( myGrp3 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
// Set range of spinboxes
|
|
|
|
|
|
|
|
double SpecificStep = 10.0;
|
2007-10-18 14:47:58 +00:00
|
|
|
QMap< int, QDoubleSpinBox* >::iterator anIter;
|
2004-12-01 10:39:14 +00:00
|
|
|
for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
|
2007-10-18 14:47:58 +00:00
|
|
|
initSpinBox( anIter.value(), 0.001, COORD_MAX, SpecificStep, 3 );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
setHelpFileName( "chamfer.htm" );
|
2006-05-06 08:44:32 +00:00
|
|
|
|
2004-01-07 15:46:21 +00:00
|
|
|
/* Initialisations */
|
2005-06-02 07:17:09 +00:00
|
|
|
Init();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~OperationGUI_ChamferDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg()
|
2004-12-01 10:39:14 +00:00
|
|
|
{
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-02 07:17:09 +00:00
|
|
|
void OperationGUI_ChamferDlg::Init()
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2004-12-01 10:39:14 +00:00
|
|
|
myConstructorId = -1;
|
|
|
|
reset();
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
/* signals and slots connections */
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// main buttons
|
2007-10-18 14:47:58 +00:00
|
|
|
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
|
|
|
|
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// group box
|
2007-10-18 14:47:58 +00:00
|
|
|
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// push buttons
|
|
|
|
QMap< int, QPushButton* >::iterator anIterBtn;
|
|
|
|
for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn )
|
2007-10-18 14:47:58 +00:00
|
|
|
connect( anIterBtn.value(), SIGNAL( clicked() ),
|
2004-12-01 10:39:14 +00:00
|
|
|
this, SLOT( SetEditCurrentArgument() ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// line edits
|
|
|
|
QMap< int, QLineEdit* >::iterator anIterLE2;
|
|
|
|
for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 )
|
2007-10-18 14:47:58 +00:00
|
|
|
connect( anIterLE2.value(), SIGNAL( returnPressed() ),
|
2004-12-01 10:39:14 +00:00
|
|
|
this, SLOT( LineEditReturnPressed() ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// spin boxes
|
2007-10-18 14:47:58 +00:00
|
|
|
QMap< int, QDoubleSpinBox* >::iterator anIterSpin;
|
2004-12-01 10:39:14 +00:00
|
|
|
for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin )
|
2007-10-18 14:47:58 +00:00
|
|
|
connect( anIterSpin.value(), SIGNAL( valueChanged( double ) ),
|
2004-12-01 10:39:14 +00:00
|
|
|
this, SLOT( ValueChangedInSpinBox( double ) ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// selection
|
2007-10-18 14:47:58 +00:00
|
|
|
connect( myGeomGUI->getApp()->selectionMgr(),
|
|
|
|
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
initName( tr( "GEOM_CHAMFER" ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
ConstructorsClicked( 0 );
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ConstructorsClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId )
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2004-12-01 10:39:14 +00:00
|
|
|
// Activate next widget
|
2007-10-18 14:47:58 +00:00
|
|
|
if ( myGeomGUI->getApp()->desktop()->activeWindow()->getViewManager()->getType()
|
|
|
|
!= OCCViewer_Viewer::Type() ) {
|
|
|
|
mainFrame()->RadioButton1->setChecked( true );
|
2006-05-06 08:44:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
if ( myConstructorId == constructorId )
|
2004-12-01 10:39:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Get values from previous widget
|
|
|
|
double D1 = 5, D2 = 5;
|
|
|
|
if ( myConstructorId == 0 )
|
2007-10-18 14:47:58 +00:00
|
|
|
D1 = D2 = mySpinBox[ SpinBox1 ]->value();
|
|
|
|
else if ( myConstructorId == 1 ) {
|
|
|
|
D1 = mySpinBox[ SpinBox21 ]->value();
|
|
|
|
D2 = mySpinBox[ SpinBox22 ]->value();
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
2007-10-18 14:47:58 +00:00
|
|
|
else if ( myConstructorId == 2 ) {
|
|
|
|
D1 = mySpinBox[ SpinBox31 ]->value();
|
|
|
|
D2 = mySpinBox[ SpinBox32 ]->value();
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
|
|
|
|
2004-01-07 15:46:21 +00:00
|
|
|
myConstructorId = constructorId;
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
switch ( constructorId ) {
|
|
|
|
case 0:
|
|
|
|
myGrp2->hide();
|
|
|
|
myGrp3->hide();
|
|
|
|
myGrp1->show();
|
|
|
|
mySpinBox[ SpinBox1 ]->setValue( D1 );
|
2004-12-01 10:39:14 +00:00
|
|
|
break;
|
2007-10-18 14:47:58 +00:00
|
|
|
case 1:
|
|
|
|
myGrp1->hide();
|
|
|
|
myGrp3->hide();
|
|
|
|
myGrp2->show();
|
|
|
|
mySpinBox[ SpinBox21 ]->setValue( D1 );
|
|
|
|
mySpinBox[ SpinBox22 ]->setValue( D2 );
|
2004-12-01 10:39:14 +00:00
|
|
|
break;
|
2007-10-18 14:47:58 +00:00
|
|
|
case 2:
|
|
|
|
myGrp1->hide();
|
|
|
|
myGrp2->hide();
|
|
|
|
myGrp3->show();
|
|
|
|
mySpinBox[ SpinBox31 ]->setValue( D1 );
|
|
|
|
mySpinBox[ SpinBox32 ]->setValue( D2 );
|
2004-12-01 10:39:14 +00:00
|
|
|
break;
|
2007-10-18 14:47:58 +00:00
|
|
|
default:
|
2004-12-01 10:39:14 +00:00
|
|
|
break;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2007-10-18 14:47:58 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
if ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
|
|
|
|
else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
|
|
|
|
else myEditCurrentArgument = mySelName[ MainObj3 ];
|
|
|
|
|
|
|
|
activateSelection();
|
|
|
|
enableWidgets();
|
|
|
|
|
|
|
|
if ( !myShape->_is_nil() )
|
|
|
|
{
|
|
|
|
myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) );
|
|
|
|
GEOMBase_Skeleton::LineEditReturnPressed();
|
2004-06-16 15:24:55 +00:00
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
else
|
|
|
|
myEditCurrentArgument->setText( "" );
|
2004-06-16 15:24:55 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
qApp->processEvents();
|
|
|
|
updateGeometry();
|
|
|
|
resize( minimumSize() );
|
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
displayPreview();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void OperationGUI_ChamferDlg::ClickOnOk()
|
|
|
|
{
|
2004-12-01 10:39:14 +00:00
|
|
|
if ( ClickOnApply() )
|
|
|
|
ClickOnCancel();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
bool OperationGUI_ChamferDlg::ClickOnApply()
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2004-12-01 10:39:14 +00:00
|
|
|
if ( !onAccept() )
|
|
|
|
return false;
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
initName();
|
|
|
|
return true;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection has changed
|
|
|
|
//=================================================================================
|
|
|
|
void OperationGUI_ChamferDlg::SelectionIntoArgument()
|
|
|
|
{
|
2004-12-01 10:39:14 +00:00
|
|
|
erasePreview();
|
|
|
|
myEditCurrentArgument->setText( "" );
|
|
|
|
|
|
|
|
// Get index of current selection focus
|
|
|
|
int aCurrFocus = -1;
|
|
|
|
QMap< int, QLineEdit* >::iterator anIter;
|
2007-10-18 14:47:58 +00:00
|
|
|
for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) {
|
|
|
|
if ( myEditCurrentArgument == anIter.value() ) {
|
2004-12-01 10:39:14 +00:00
|
|
|
aCurrFocus = anIter.key();
|
|
|
|
break;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2007-10-18 14:47:58 +00:00
|
|
|
}
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// If selection of main object is activated
|
2007-10-18 14:47:58 +00:00
|
|
|
if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 ) {
|
|
|
|
if ( IObjectCount() == 1 ) {
|
2004-12-01 10:39:14 +00:00
|
|
|
Standard_Boolean aResult = Standard_False;
|
|
|
|
GEOM::GEOM_Object_var anObj =
|
2005-06-02 07:17:09 +00:00
|
|
|
GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
if ( aResult && !anObj->_is_nil() ) {
|
2004-12-01 10:39:14 +00:00
|
|
|
myShape = anObj;
|
|
|
|
mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) );
|
|
|
|
displayPreview();
|
|
|
|
enableWidgets();
|
|
|
|
return;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
myShape = GEOM::GEOM_Object::_nil();
|
|
|
|
enableWidgets();
|
|
|
|
}
|
|
|
|
// If face selection of second tab is activated
|
2007-10-18 14:47:58 +00:00
|
|
|
else if ( aCurrFocus == Face1 || aCurrFocus == Face2 ) {
|
|
|
|
if ( IObjectCount() == 1 ) {
|
2004-12-01 10:39:14 +00:00
|
|
|
Standard_Boolean aResult = Standard_False;
|
|
|
|
GEOM::GEOM_Object_var anObj =
|
2005-06-02 07:17:09 +00:00
|
|
|
GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
if ( aResult && !anObj->_is_nil() ) {
|
2004-12-01 10:39:14 +00:00
|
|
|
TColStd_IndexedMapOfInteger anIndexes;
|
2007-10-18 14:47:58 +00:00
|
|
|
( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
if ( anIndexes.Extent() == 1 ) {
|
2004-12-01 10:39:14 +00:00
|
|
|
int anIndex = anIndexes( 1 );
|
|
|
|
QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1";
|
|
|
|
myEditCurrentArgument->setText( aFaceName.arg( anIndex ) );
|
|
|
|
myFace[ aCurrFocus ] = anIndex;
|
|
|
|
displayPreview();
|
|
|
|
return;
|
|
|
|
}
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
myFace[ aCurrFocus ] = -1;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
// If face selection of third tab is activated
|
2007-10-18 14:47:58 +00:00
|
|
|
else if ( aCurrFocus == Faces ) {
|
|
|
|
if ( IObjectCount() == 1 ) {
|
2004-12-01 10:39:14 +00:00
|
|
|
Standard_Boolean aResult = Standard_False;
|
|
|
|
GEOM::GEOM_Object_var anObj =
|
2005-06-02 07:17:09 +00:00
|
|
|
GEOMBase::ConvertIOinGEOMObject( firstIObject(), aResult );
|
2007-10-18 14:47:58 +00:00
|
|
|
|
|
|
|
if ( aResult && !anObj->_is_nil() ) {
|
|
|
|
TColStd_IndexedMapOfInteger anIndexes;
|
|
|
|
( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr()->GetIndexes( firstIObject(), anIndexes );
|
|
|
|
|
|
|
|
if ( anIndexes.Extent() > 0 ) {
|
|
|
|
QString aFaceName;
|
|
|
|
if ( anIndexes.Extent() == 1 ) {
|
|
|
|
int anIndex = anIndexes( 1 );
|
|
|
|
|
|
|
|
aFaceName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aFaceName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
|
|
|
|
}
|
|
|
|
|
|
|
|
myEditCurrentArgument->setText( aFaceName );
|
|
|
|
myFaces = anIndexes;
|
|
|
|
displayPreview();
|
|
|
|
return;
|
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
myFaces.Clear();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : LineEditReturnPressed()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void OperationGUI_ChamferDlg::LineEditReturnPressed()
|
|
|
|
{
|
|
|
|
QLineEdit* aSender = ( QLineEdit* )sender();
|
|
|
|
|
|
|
|
QMap< int, QLineEdit* >::iterator anIterLE;
|
|
|
|
for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
|
2007-10-18 14:47:58 +00:00
|
|
|
if ( anIterLE.value() == aSender )
|
|
|
|
myEditCurrentArgument = anIterLE.value();
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
GEOMBase_Skeleton::LineEditReturnPressed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-07 15:46:21 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void OperationGUI_ChamferDlg::SetEditCurrentArgument()
|
|
|
|
{
|
2004-12-01 10:39:14 +00:00
|
|
|
QPushButton* aSender = ( QPushButton* )sender();
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
QMap< int, QPushButton* >::iterator anIter;
|
2007-10-18 14:47:58 +00:00
|
|
|
for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) {
|
|
|
|
if ( anIter.value() == aSender ) {
|
2004-12-01 10:39:14 +00:00
|
|
|
mySelName[ anIter.key() ]->setFocus();
|
|
|
|
myEditCurrentArgument = mySelName[ anIter.key() ];
|
|
|
|
}
|
2007-10-18 14:47:58 +00:00
|
|
|
}
|
2004-06-16 15:24:55 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
activateSelection();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void OperationGUI_ChamferDlg::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
GEOMBase_Skeleton::ActivateThisDialog();
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-18 14:47:58 +00:00
|
|
|
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
|
|
|
|
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
activateSelection();
|
|
|
|
displayPreview();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2007-10-18 14:47:58 +00:00
|
|
|
void OperationGUI_ChamferDlg::enterEvent( QEvent* )
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2007-10-18 14:47:58 +00:00
|
|
|
if ( !mainFrame()->GroupConstructors->isEnabled() )
|
2004-12-01 10:39:14 +00:00
|
|
|
this->ActivateThisDialog();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
// function : ValueChangedInSpinBox()
|
2004-01-07 15:46:21 +00:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2007-10-18 14:47:58 +00:00
|
|
|
void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double )
|
2004-12-01 10:39:14 +00:00
|
|
|
{
|
|
|
|
displayPreview();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
// function : createSelWg()
|
2004-01-07 15:46:21 +00:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl,
|
|
|
|
QPixmap& thePix,
|
|
|
|
QWidget* theParent,
|
2007-10-18 14:47:58 +00:00
|
|
|
QGridLayout* theLayout,
|
2004-12-01 10:39:14 +00:00
|
|
|
const int theId )
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2007-10-18 14:47:58 +00:00
|
|
|
QLabel* lab = new QLabel( theLbl, theParent );
|
2004-12-01 10:39:14 +00:00
|
|
|
mySelBtn[ theId ] = new QPushButton( theParent );
|
2007-10-18 14:47:58 +00:00
|
|
|
mySelBtn[ theId ]->setIcon( thePix );
|
2004-12-01 10:39:14 +00:00
|
|
|
mySelName[ theId ] = new QLineEdit( theParent );
|
|
|
|
mySelName[ theId ]->setReadOnly( true );
|
2007-10-18 14:47:58 +00:00
|
|
|
int row = theLayout->rowCount();
|
|
|
|
theLayout->addWidget( lab, row, 0 );
|
|
|
|
theLayout->addWidget( mySelBtn[ theId ], row, 1 );
|
|
|
|
theLayout->addWidget( mySelName[ theId ], row, 2 );
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : reset()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void OperationGUI_ChamferDlg::reset()
|
|
|
|
{
|
|
|
|
// Set Initial values of spinboxes
|
2007-10-18 14:47:58 +00:00
|
|
|
QMap< int, QDoubleSpinBox* >::iterator anIter;
|
2004-12-01 10:39:14 +00:00
|
|
|
for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter )
|
2007-10-18 14:47:58 +00:00
|
|
|
anIter.value()->setValue( 5 );
|
2004-06-16 15:24:55 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// clear line edits
|
|
|
|
QMap< int, QLineEdit* >::iterator anIterLE;
|
|
|
|
for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE )
|
2007-10-18 14:47:58 +00:00
|
|
|
anIterLE.value()->setText( "" );
|
2004-06-16 15:24:55 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
// constructor id
|
|
|
|
int aConstructorId = getConstructorId();
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ];
|
|
|
|
else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ];
|
|
|
|
else myEditCurrentArgument = mySelName[ MainObj3 ];
|
|
|
|
|
|
|
|
myShape = GEOM::GEOM_Object::_nil();
|
|
|
|
|
|
|
|
myFaces.Clear();
|
|
|
|
myFace[ Face1 ] = -1;
|
|
|
|
myFace[ Face2 ] = -1;
|
|
|
|
|
|
|
|
erasePreview( true );
|
|
|
|
|
|
|
|
activateSelection();
|
|
|
|
|
|
|
|
enableWidgets();
|
|
|
|
}
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : activateSelection
|
|
|
|
// purpose : Activate selection in accordance with myEditCurrentArgument
|
|
|
|
//=================================================================================
|
|
|
|
void OperationGUI_ChamferDlg::activateSelection()
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2004-12-01 10:39:14 +00:00
|
|
|
if ( !myShape->_is_nil() &&
|
|
|
|
( myEditCurrentArgument == mySelName[ Face1 ] ||
|
|
|
|
myEditCurrentArgument == mySelName[ Face2 ] ||
|
|
|
|
myEditCurrentArgument == mySelName[ Faces ] ) )
|
|
|
|
localSelection( myShape, TopAbs_FACE );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TColStd_MapOfInteger aMap;
|
|
|
|
aMap.Add( GEOM_SHELL );
|
|
|
|
aMap.Add( GEOM_SOLID );
|
|
|
|
aMap.Add( GEOM_COMPOUND );
|
|
|
|
globalSelection( aMap );
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
SelectionIntoArgument();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : enableWidgets
|
|
|
|
// purpose : Enable widgets of faces in accordance with value of main object
|
|
|
|
//=================================================================================
|
|
|
|
void OperationGUI_ChamferDlg::enableWidgets()
|
|
|
|
{
|
|
|
|
int anId = getConstructorId();
|
|
|
|
|
|
|
|
bool toEnable = !myShape->_is_nil();
|
|
|
|
|
|
|
|
if ( anId == 1 )
|
|
|
|
{
|
|
|
|
mySelName[ Face1 ]->setEnabled( toEnable );
|
|
|
|
mySelName[ Face2 ]->setEnabled( toEnable );
|
|
|
|
mySelBtn[ Face1 ]->setEnabled( toEnable );
|
|
|
|
mySelBtn[ Face2 ]->setEnabled( toEnable );
|
|
|
|
|
|
|
|
if ( !toEnable )
|
|
|
|
{
|
|
|
|
mySelName[ Face1 ]->setText( "" );
|
|
|
|
mySelName[ Face2 ]->setText( "" );
|
|
|
|
myFace[ Face1 ] = -1;
|
|
|
|
myFace[ Face2 ] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( anId == 2 )
|
|
|
|
{
|
|
|
|
mySelName[ Faces ]->setEnabled( toEnable );
|
|
|
|
|
|
|
|
if ( !toEnable )
|
|
|
|
myFaces.Clear();
|
|
|
|
}
|
|
|
|
}
|
2004-01-07 15:46:21 +00:00
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
// function : createOperation
|
2004-01-07 15:46:21 +00:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation()
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2004-12-01 10:39:14 +00:00
|
|
|
return getGeomEngine()->GetILocalOperations( getStudyId() );
|
|
|
|
}
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose : Verify validity of input data
|
|
|
|
//=================================================================================
|
|
|
|
bool OperationGUI_ChamferDlg::isValid( QString& )
|
|
|
|
{
|
|
|
|
switch ( getConstructorId() )
|
|
|
|
{
|
|
|
|
case 0: return !myShape->_is_nil();
|
|
|
|
case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0;
|
|
|
|
case 2: return !myShape->_is_nil() && myFaces.Extent() > 0;
|
|
|
|
default: return false;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : execute
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool OperationGUI_ChamferDlg::execute( ObjectList& objects )
|
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var anObj;
|
|
|
|
|
|
|
|
int anId = getConstructorId();
|
|
|
|
if ( anId == 0 )
|
|
|
|
anObj = GEOM::GEOM_ILocalOperations::_narrow(
|
|
|
|
getOperation() )->MakeChamferAll( myShape,
|
2007-10-18 14:47:58 +00:00
|
|
|
mySpinBox[ SpinBox1 ]->value() );
|
2004-12-01 10:39:14 +00:00
|
|
|
else if ( anId == 1 )
|
|
|
|
anObj = GEOM::GEOM_ILocalOperations::_narrow(
|
|
|
|
getOperation() )->MakeChamferEdge( myShape,
|
2007-10-18 14:47:58 +00:00
|
|
|
mySpinBox[ SpinBox21 ]->value(),
|
|
|
|
mySpinBox[ SpinBox22 ]->value(),
|
2004-12-01 10:39:14 +00:00
|
|
|
myFace[ Face1 ],
|
|
|
|
myFace[ Face2 ] );
|
|
|
|
else if ( anId == 2 )
|
|
|
|
{
|
|
|
|
GEOM::ListOfLong_var anArray = new GEOM::ListOfLong;
|
|
|
|
anArray->length( myFaces.Extent() );
|
|
|
|
|
|
|
|
|
|
|
|
for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
|
|
|
|
anArray[ i - 1 ] = myFaces( i );
|
|
|
|
|
|
|
|
anObj = GEOM::GEOM_ILocalOperations::_narrow(
|
|
|
|
getOperation() )->MakeChamferFaces( myShape,
|
2007-10-18 14:47:58 +00:00
|
|
|
mySpinBox[ SpinBox31 ]->value(),
|
|
|
|
mySpinBox[ SpinBox32 ]->value(),
|
2004-12-01 10:39:14 +00:00
|
|
|
anArray );
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2004-06-16 15:24:55 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
if ( !anObj->_is_nil() )
|
|
|
|
objects.push_back( anObj._retn() );
|
|
|
|
|
|
|
|
return true;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|