geom/src/OperationGUI/OperationGUI_FilletDlg.cxx

672 lines
23 KiB
C++
Raw Normal View History

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
//
// 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_FilletDlg.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
2004-01-07 15:46:21 +00:00
//
#include "OperationGUI_FilletDlg.h"
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>
#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>
#include <TColStd_MapOfInteger.hxx>
2004-12-01 10:39:14 +00:00
#include <TColStd_IndexedMapOfInteger.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_FilletDlg()
// purpose : Constructs a OperationGUI_FilletDlg which is a child of 'parent', with the
// 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_FilletDlg::OperationGUI_FilletDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
: GEOMBase_Skeleton( theGeometryGUI, parent, false )
2004-01-07 15:46:21 +00:00
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
2007-10-18 14:47:58 +00:00
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_ALL" ) ) );
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_EDGE" ) ) );
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_FACE" ) ) );
2007-10-18 14:47:58 +00:00
QPixmap iconSelect( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
2007-10-18 14:47:58 +00:00
setWindowTitle( tr( "GEOM_FILLET_TITLE" ) );
2004-01-07 15:46:21 +00:00
/***************************************************************/
2007-10-18 14:47:58 +00:00
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_FILLET" ) );
mainFrame()->RadioButton1->setIcon( image0 );
mainFrame()->RadioButton2->setIcon( image1 );
mainFrame()->RadioButton3->setIcon( image2 );
2004-12-01 10:39:14 +00:00
2007-10-18 14:47:58 +00:00
Group1 = new DlgRef_1Sel1Spin( centralWidget() );
2004-12-01 10:39:14 +00:00
Group1->GroupBox1->setTitle( tr( "GEOM_FILLET_ALL" ) );
Group1->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
Group1->TextLabel2->setText( tr( "GEOM_RADIUS" ) );
2007-10-18 14:47:58 +00:00
Group1->PushButton1->setIcon( iconSelect );
2004-12-01 10:39:14 +00:00
Group1->LineEdit1->setReadOnly( true );
Group2 = new DlgRef_2Sel3Spin2Rb( centralWidget() );
2004-12-01 10:39:14 +00:00
Group2->GroupBox1->setTitle( tr( "GEOM_FILLET_EDGES" ) );
Group2->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
Group2->TextLabel2->setText( tr( "SELECTED_EDGES" ) );
Group2->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
Group2->TextLabel4->setText( tr( "GEOM_R1" ) );
Group2->TextLabel5->setText( tr( "GEOM_R2" ) );
2007-10-18 14:47:58 +00:00
Group2->PushButton1->setIcon( iconSelect );
Group2->PushButton2->setIcon( iconSelect );
2004-12-01 10:39:14 +00:00
Group2->LineEdit1->setReadOnly( true );
Group2->LineEdit2->setReadOnly( true );
Group3 = new DlgRef_2Sel3Spin2Rb( centralWidget() );
2007-10-18 14:47:58 +00:00
Group3->GroupBox1->setTitle( tr( "GEOM_FILLET_FACES" ) );
Group3->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) );
Group3->TextLabel2->setText( tr( "SELECTED_FACES" ) );
Group3->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
Group3->TextLabel4->setText( tr( "GEOM_R1" ) );
Group3->TextLabel5->setText( tr( "GEOM_R2" ) );
2007-10-18 14:47:58 +00:00
Group3->PushButton1->setIcon( iconSelect );
Group3->PushButton2->setIcon( iconSelect );
2004-12-01 10:39:14 +00:00
Group3->LineEdit1->setReadOnly( true );
Group3->LineEdit2->setReadOnly( true );
2007-10-18 14:47:58 +00:00
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( Group1 );
layout->addWidget( Group2 );
layout->addWidget( Group3 );
2004-01-07 15:46:21 +00:00
/***************************************************************/
2004-12-01 10:39:14 +00:00
double SpecificStep = 10.0;
initSpinBox( Group1->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group2->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group2->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group2->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group3->SpinBox_DX, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group3->SpinBox_DY, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( Group3->SpinBox_DZ, 0.001, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
setHelpFileName( "fillet_operation_page.html" );
2004-01-07 15:46:21 +00:00
/* Initialisations */
Init();
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : ~OperationGUI_FilletDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
OperationGUI_FilletDlg::~OperationGUI_FilletDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::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
// 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
2007-10-18 14:47:58 +00:00
connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
2004-12-01 10:39:14 +00:00
// line edits
2007-10-18 14:47:58 +00:00
connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3->LineEdit1, SIGNAL( returnPressed() ), 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
connect( Group1->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group2->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group2->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group2->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
2007-10-18 14:47:58 +00:00
connect( Group3->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group3->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group3->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
// radio buttons
connect( Group2->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) );
connect( Group2->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) );
connect( Group3->RadioButton1, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) );
connect( Group3->RadioButton2, SIGNAL( clicked() ), this, SLOT( RadioButtonClicked() ) );
2004-01-07 15:46:21 +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_FILLET" ) );
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_FilletDlg::ConstructorsClicked( int constructorId )
2004-01-07 15:46:21 +00:00
{
if ( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
2007-10-18 14:47:58 +00:00
!= OCCViewer_Viewer::Type() ) {
mainFrame()->RadioButton1->setChecked( true );
2004-12-01 10:39:14 +00:00
return;
}
if ( myConstructorId == constructorId )
return;
// Get radius from previous widget
double R = 5, R1 = 5, R2 = 5;
if ( myConstructorId == 0 ) {
R = Group1->SpinBox_DX->value();
}
else if ( myConstructorId == 1 ) {
R = Group2->SpinBox_DX->value();
R1 = Group2->SpinBox_DY->value();
R2 = Group2->SpinBox_DZ->value();
}
else {
R = Group3->SpinBox_DX->value();
R1 = Group3->SpinBox_DY->value();
R2 = Group3->SpinBox_DZ->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:
Group2->hide();
Group3->hide();
Group1->show();
Group1->SpinBox_DX->setValue( R );
2004-12-01 10:39:14 +00:00
break;
2007-10-18 14:47:58 +00:00
case 1:
Group1->hide();
Group3->hide();
Group2->show();
Group2->SpinBox_DX->setValue( R );
Group2->SpinBox_DY->setValue( R1 );
Group2->SpinBox_DZ->setValue( R2 );
2004-12-01 10:39:14 +00:00
break;
2007-10-18 14:47:58 +00:00
case 2:
Group1->hide();
Group2->hide();
Group3->show();
Group3->SpinBox_DX->setValue( R );
Group3->SpinBox_DY->setValue( R1 );
Group3->SpinBox_DZ->setValue( R2 );
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
}
2004-12-01 10:39:14 +00:00
if ( constructorId == 0 ) myEditCurrentArgument = Group1->LineEdit1;
else if ( constructorId == 1 ) myEditCurrentArgument = Group2->LineEdit1;
else myEditCurrentArgument = Group3->LineEdit1;
activateSelection();
enableWidgets();
2007-10-18 14:47:58 +00:00
if ( !myShape->_is_nil() ) {
2004-12-01 10:39:14 +00:00
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( "" );
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_FilletDlg::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_FilletDlg::ClickOnApply()
2004-01-07 15:46:21 +00:00
{
2007-10-18 14:47:58 +00:00
if ( !onAccept() )
2004-12-01 10:39:14 +00:00
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_FilletDlg::SelectionIntoArgument()
{
2004-12-01 10:39:14 +00:00
erasePreview();
myEditCurrentArgument->setText( "" );
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
2004-12-01 10:39:14 +00:00
// If selection of main object is activated
if (myEditCurrentArgument == Group1->LineEdit1 ||
myEditCurrentArgument == Group2->LineEdit1 ||
myEditCurrentArgument == Group3->LineEdit1)
{
if (aSelList.Extent() == 1) {
2004-12-01 10:39:14 +00:00
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
if (aResult && !anObj->_is_nil()) {
2004-12-01 10:39:14 +00:00
myShape = anObj;
myEditCurrentArgument->setText(GEOMBase::GetName(anObj));
2004-12-01 10:39:14 +00:00
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 or edge selection is activated
else if (myEditCurrentArgument == Group2->LineEdit2 ||
myEditCurrentArgument == Group3->LineEdit2)
{
if (aSelList.Extent() == 1) {
2004-12-01 10:39:14 +00:00
Standard_Boolean aResult = Standard_False;
GEOM::GEOM_Object_var anObj =
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
2004-12-01 10:39:14 +00:00
if (aResult && !anObj->_is_nil()) {
TColStd_IndexedMapOfInteger anIndexes;
aSelMgr->GetIndexes(aSelList.First(), anIndexes);
if (anIndexes.Extent() > 0) {
QString aName;
if (anIndexes.Extent() == 1) {
int anIndex = anIndexes(1);
aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex );
}
else
aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() );
myEditCurrentArgument->setText( aName );
if ( myConstructorId == 1 )
myEdges = anIndexes;
else
myFaces = anIndexes;
displayPreview();
return;
}
2004-01-07 15:46:21 +00:00
}
}
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_FilletDlg::LineEditReturnPressed()
{
QLineEdit* send = ( QLineEdit* )sender();
2004-01-07 15:46:21 +00:00
2004-12-01 10:39:14 +00:00
if ( send == Group1->LineEdit1 )
myEditCurrentArgument = Group1->LineEdit1;
else if ( send == Group2->LineEdit1 )
myEditCurrentArgument = Group2->LineEdit1;
else if ( send == Group3->LineEdit1 )
myEditCurrentArgument = Group3->LineEdit1;
else
return;
GEOMBase_Skeleton::LineEditReturnPressed();
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::SetEditCurrentArgument()
{
2004-12-01 10:39:14 +00:00
QPushButton* send = (QPushButton*)sender();
2004-01-07 15:46:21 +00:00
2007-10-18 14:47:58 +00:00
if ( send == Group1->PushButton1 ) {
2004-01-07 15:46:21 +00:00
Group1->LineEdit1->setFocus();
2004-12-01 10:39:14 +00:00
myEditCurrentArgument = Group1->LineEdit1;
}
2007-10-18 14:47:58 +00:00
else if ( send == Group2->PushButton1 ) {
2004-12-01 10:39:14 +00:00
Group2->LineEdit1->setFocus();
myEditCurrentArgument = Group2->LineEdit1;
}
2007-10-18 14:47:58 +00:00
else if ( send == Group2->PushButton2 ) {
2004-12-01 10:39:14 +00:00
Group2->LineEdit2->setFocus();
myEditCurrentArgument = Group2->LineEdit2;
}
2007-10-18 14:47:58 +00:00
else if ( send == Group3->PushButton1 ) {
2004-12-01 10:39:14 +00:00
Group3->LineEdit1->setFocus();
myEditCurrentArgument = Group3->LineEdit1;
}
2007-10-18 14:47:58 +00:00
else if ( send == Group3->PushButton2 ) {
2004-12-01 10:39:14 +00:00
Group3->LineEdit1->setFocus();
myEditCurrentArgument = Group3->LineEdit2;
}
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_FilletDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
2004-12-01 10:39:14 +00:00
2007-10-18 14:47:58 +00:00
connect( myGeomGUI->getApp()->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_FilletDlg::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_FilletDlg::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 : reset()
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::reset()
{
// Set Initial values of spinboxes
2007-10-18 14:47:58 +00:00
Group1->SpinBox_DX->setValue( 5 );
Group2->SpinBox_DX->setValue( 5 );
Group2->SpinBox_DY->setValue( 5 );
Group2->SpinBox_DZ->setValue( 5 );
2007-10-18 14:47:58 +00:00
Group3->SpinBox_DX->setValue( 5 );
Group3->SpinBox_DY->setValue( 5 );
Group3->SpinBox_DZ->setValue( 5 );
2004-12-01 10:39:14 +00:00
Group1->LineEdit1->setText( "" );
Group2->LineEdit1->setText( "" );
Group2->LineEdit2->setText( "" );
Group3->LineEdit1->setText( "" );
Group3->LineEdit2->setText( "" );
// constructor id
int aConstructorId = getConstructorId();
if ( aConstructorId == 0 ) myEditCurrentArgument = Group1->LineEdit1;
else if ( aConstructorId == 1 ) myEditCurrentArgument = Group2->LineEdit1;
else myEditCurrentArgument = Group3->LineEdit1;
myShape = GEOM::GEOM_Object::_nil();
myFaces.Clear();
myEdges.Clear();
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_FilletDlg::activateSelection()
{
if ( !myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2 )
localSelection( myShape, TopAbs_EDGE );
else if ( !myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2 )
localSelection( myShape, TopAbs_FACE );
2007-10-18 14:47:58 +00:00
else {
2004-12-01 10:39:14 +00:00
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_SHELL );
aMap.Add( GEOM_SOLID );
aMap.Add( GEOM_COMPOUND );
globalSelection( aMap );
}
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
2004-01-07 15:46:21 +00:00
//=================================================================================
2004-12-01 10:39:14 +00:00
void OperationGUI_FilletDlg::enableWidgets()
2004-01-07 15:46:21 +00:00
{
2004-12-01 10:39:14 +00:00
int anId = getConstructorId();
2004-01-07 15:46:21 +00:00
2004-12-01 10:39:14 +00:00
bool toEnable = !myShape->_is_nil();
2004-01-07 15:46:21 +00:00
2007-10-18 14:47:58 +00:00
if ( anId == 1 ) {
2004-12-01 10:39:14 +00:00
Group2->LineEdit2->setEnabled( toEnable );
Group2->PushButton2->setEnabled( toEnable );
2007-10-18 14:47:58 +00:00
if ( !toEnable ) {
2004-12-01 10:39:14 +00:00
Group2->LineEdit2->setText( "" );
myEdges.Clear();
}
}
2007-10-18 14:47:58 +00:00
else if ( anId == 2 ) {
2004-12-01 10:39:14 +00:00
Group3->LineEdit2->setEnabled( toEnable );
Group3->PushButton2->setEnabled( toEnable );
2007-10-18 14:47:58 +00:00
if ( !toEnable ) {
2004-12-01 10:39:14 +00:00
Group3->LineEdit2->setText( "" );
myFaces.Clear();
}
}
2004-01-07 15:46:21 +00:00
}
2004-12-01 10:39:14 +00:00
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr OperationGUI_FilletDlg::createOperation()
{
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_FilletDlg::isValid( QString& )
{
switch ( getConstructorId() )
{
case 0: return !myShape->_is_nil();
case 1: return !myShape->_is_nil() && myEdges.Extent() > 0;
case 2: return !myShape->_is_nil() && myFaces.Extent() > 0;
default: return false;
}
}
//=================================================================================
// function : execute
2004-01-07 15:46:21 +00:00
// purpose :
//=================================================================================
2004-12-01 10:39:14 +00:00
bool OperationGUI_FilletDlg::execute( ObjectList& objects )
2004-01-07 15:46:21 +00:00
{
2004-12-01 10:39:14 +00:00
GEOM::GEOM_Object_var anObj;
int anId = getConstructorId();
if ( anId == 0 )
anObj = GEOM::GEOM_ILocalOperations::_narrow(
getOperation() )->MakeFilletAll( myShape, getRadius() );
2007-10-18 14:47:58 +00:00
else if ( anId == 1 ) {
2004-12-01 10:39:14 +00:00
GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
aList->length( myEdges.Extent() );
for ( int i = 1, n = myEdges.Extent(); i <= n; i++ )
aList[ i - 1 ] = myEdges( i );
if ( Group2->RadioButton1->isChecked() )
anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
MakeFilletEdges( myShape, getRadius(), aList );
else
anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
MakeFilletEdgesR1R2( myShape,
Group2->SpinBox_DY->value(),
Group2->SpinBox_DZ->value(),
aList );
2004-12-01 10:39:14 +00:00
}
2007-10-18 14:47:58 +00:00
else if ( anId == 2 ) {
2004-12-01 10:39:14 +00:00
GEOM::ListOfLong_var aList = new GEOM::ListOfLong;
aList->length( myFaces.Extent() );
2004-01-07 15:46:21 +00:00
2004-12-01 10:39:14 +00:00
for ( int i = 1, n = myFaces.Extent(); i <= n; i++ )
aList[ i - 1 ] = myFaces( i );
2004-01-07 15:46:21 +00:00
if ( Group3->RadioButton1->isChecked() ) {
anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
MakeFilletFaces( myShape, getRadius(), aList );
}
else {
anObj = GEOM::GEOM_ILocalOperations::_narrow( getOperation() )->
MakeFilletFacesR1R2( myShape,
Group3->SpinBox_DY->value(),
Group3->SpinBox_DZ->value(), aList );
}
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
//=================================================================================
// function : getRadius
// purpose : Get radius
//=================================================================================
double OperationGUI_FilletDlg::getRadius() const
{
int anId = getConstructorId();
2007-10-18 14:47:58 +00:00
if ( anId == 0 ) return Group1->SpinBox_DX->value();
else if ( anId == 1 ) return Group2->SpinBox_DX->value();
else return Group3->SpinBox_DX->value();
2004-12-01 10:39:14 +00:00
}
//=================================================================================
// function : RadiobuttonClicked
// purpose :
//=================================================================================
void OperationGUI_FilletDlg::RadioButtonClicked()
{
const QObject* s = sender();
bool flag = s == Group2->RadioButton1 || s == Group3->RadioButton1;
Group2->RadioButton1->blockSignals( true );
Group2->RadioButton2->blockSignals( true );
Group3->RadioButton1->blockSignals( true );
Group3->RadioButton2->blockSignals( true );
Group2->SpinBox_DX->setEnabled( flag );
Group2->SpinBox_DY->setEnabled( !flag );
Group2->SpinBox_DZ->setEnabled( !flag );
Group2->RadioButton1->setChecked( flag );
Group2->RadioButton2->setChecked( !flag );
Group3->SpinBox_DX->setEnabled( flag );
Group3->SpinBox_DY->setEnabled( !flag );
Group3->SpinBox_DZ->setEnabled( !flag );
Group3->RadioButton1->setChecked( flag );
Group3->RadioButton2->setChecked( !flag );
Group2->RadioButton1->blockSignals( false );
Group2->RadioButton2->blockSignals( false );
Group3->RadioButton1->blockSignals( false );
Group3->RadioButton2->blockSignals( false );
displayPreview();
}