2007-10-17 12:24:45 +00:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
2004-01-07 15:46:21 +00:00
|
|
|
//
|
2007-10-17 12:24:45 +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-17 12:24:45 +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-17 12:24:45 +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-17 12:24:45 +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-17 12:24:45 +00:00
|
|
|
// File : TransformationGUI_ScaleDlg.cxx
|
|
|
|
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
|
2004-01-07 15:46:21 +00:00
|
|
|
|
|
|
|
#include "TransformationGUI_ScaleDlg.h"
|
|
|
|
|
2007-10-24 08:17:54 +00:00
|
|
|
#include <DlgRef.h>
|
2007-10-17 12:24:45 +00:00
|
|
|
#include <GeometryGUI.h>
|
|
|
|
#include <GEOMBase.h>
|
2007-07-11 06:23:48 +00:00
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
#include <QtxDoubleSpinBox.h>
|
2007-10-17 12:24:45 +00:00
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SalomeApp_Application.h>
|
|
|
|
#include <LightApp_SelectionMgr.h>
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2008-02-06 15:43:50 +00:00
|
|
|
#include <TopoDS_Shape.hxx>
|
|
|
|
#include <TopoDS.hxx>
|
|
|
|
#include <TopExp.hxx>
|
|
|
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
|
|
|
#include <TopTools_IndexedMapOfShape.hxx>
|
|
|
|
|
2007-10-17 12:24:45 +00:00
|
|
|
#include <GEOMImpl_Types.hxx>
|
2004-06-16 15:24:55 +00:00
|
|
|
|
2004-01-07 15:46:21 +00:00
|
|
|
//=================================================================================
|
|
|
|
// class : TransformationGUI_ScaleDlg()
|
|
|
|
// purpose : Constructs a TransformationGUI_ScaleDlg 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-17 12:24:45 +00:00
|
|
|
TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
|
|
|
|
bool modal, Qt::WindowFlags fl )
|
|
|
|
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
|
|
|
|
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_SCALE" ) ) );
|
|
|
|
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_SCALE_ALONG_AXES" ) ) );
|
|
|
|
QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2007-10-17 12:24:45 +00:00
|
|
|
setWindowTitle( tr( "GEOM_SCALE_TITLE" ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
// Constructors
|
2007-10-17 12:24:45 +00:00
|
|
|
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_SCALE" ) );
|
2008-07-21 13:51:52 +00:00
|
|
|
mainFrame()->RadioButton1->setIcon( image1 );
|
|
|
|
mainFrame()->RadioButton2->setIcon( image2 );
|
2007-10-17 12:24:45 +00:00
|
|
|
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
|
|
|
|
mainFrame()->RadioButton3->close();
|
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
// Own widgets
|
|
|
|
GroupBox1 = new QGroupBox( tr( "GEOM_ARGUMENTS" ), this );
|
|
|
|
QGridLayout* OwnLayout = new QGridLayout( GroupBox1 );
|
|
|
|
OwnLayout->setSpacing( 6 );
|
|
|
|
OwnLayout->setMargin( 11 );
|
|
|
|
|
|
|
|
TextLabel1 = new QLabel( tr( "GEOM_OBJECTS" ), GroupBox1 );
|
|
|
|
PushButton1 = new QPushButton( GroupBox1 );
|
|
|
|
PushButton1->setIcon( image3 );
|
|
|
|
PushButton1->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
|
|
|
LineEdit1 = new QLineEdit( GroupBox1 );
|
|
|
|
LineEdit1->setReadOnly( true );
|
|
|
|
LineEdit1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
|
|
|
|
|
|
|
|
TextLabel2 = new QLabel( tr( "GEOM_CENTRAL_POINT" ), GroupBox1 );
|
|
|
|
PushButton2 = new QPushButton( GroupBox1 );
|
|
|
|
PushButton2->setIcon( image3 );
|
|
|
|
PushButton2->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
|
|
|
LineEdit2 = new QLineEdit( GroupBox1 );
|
|
|
|
LineEdit2->setReadOnly( true );
|
|
|
|
LineEdit2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
|
|
|
|
|
|
|
|
TextLabel3 = new QLabel( tr( "GEOM_SCALE_FACTOR" ), GroupBox1 );
|
|
|
|
SpinBox_FX = new QtxDoubleSpinBox( GroupBox1 );
|
|
|
|
|
|
|
|
TextLabel4 = new QLabel( tr( "GEOM_SCALE_FACTOR_Y" ), GroupBox1 );
|
|
|
|
SpinBox_FY = new QtxDoubleSpinBox( GroupBox1 );
|
|
|
|
|
|
|
|
TextLabel5 = new QLabel( tr( "GEOM_SCALE_FACTOR_Z" ), GroupBox1 );
|
|
|
|
SpinBox_FZ = new QtxDoubleSpinBox( GroupBox1 );
|
|
|
|
|
|
|
|
CheckBoxCopy = new QCheckBox( tr( "GEOM_CREATE_COPY" ), GroupBox1 );
|
|
|
|
CheckBoxCopy->setChecked( true );
|
|
|
|
|
|
|
|
// Layouting
|
|
|
|
OwnLayout->addWidget( TextLabel1, 0, 0 );
|
|
|
|
OwnLayout->addWidget( PushButton1, 0, 1 );
|
|
|
|
OwnLayout->addWidget( LineEdit1, 0, 2, 1, 2 );
|
|
|
|
OwnLayout->addWidget( TextLabel2, 1, 0 );
|
|
|
|
OwnLayout->addWidget( PushButton2, 1, 1 );
|
|
|
|
OwnLayout->addWidget( LineEdit2, 1, 2, 1, 2 );
|
|
|
|
OwnLayout->addWidget( TextLabel3, 2, 0 );
|
|
|
|
OwnLayout->addWidget( SpinBox_FX, 2, 2 );
|
|
|
|
OwnLayout->addWidget( TextLabel4, 3, 0 );
|
|
|
|
OwnLayout->addWidget( SpinBox_FY, 3, 2 );
|
|
|
|
OwnLayout->addWidget( TextLabel5, 4, 0 );
|
|
|
|
OwnLayout->addWidget( SpinBox_FZ, 4, 2 );
|
|
|
|
OwnLayout->addWidget( CheckBoxCopy, 5, 0, 1, 4 );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-17 12:24:45 +00:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
|
|
|
layout->setMargin( 0 ); layout->setSpacing( 6 );
|
2008-07-21 13:51:52 +00:00
|
|
|
layout->addWidget( GroupBox1 );
|
2007-10-17 12:24:45 +00:00
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
// Min, max, step and decimals for spin boxes & initial values
|
2004-12-01 10:39:14 +00:00
|
|
|
double aFactor = 2.0;
|
|
|
|
double SpecificStep = 0.5;
|
2008-07-21 13:51:52 +00:00
|
|
|
initSpinBox( SpinBox_FX, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY );
|
|
|
|
initSpinBox( SpinBox_FY, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY );
|
|
|
|
initSpinBox( SpinBox_FZ, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY );
|
|
|
|
SpinBox_FX->setValue( aFactor );
|
|
|
|
SpinBox_FY->setValue( aFactor );
|
|
|
|
SpinBox_FZ->setValue( aFactor );
|
|
|
|
|
|
|
|
// Modification of an existing object by offset is not allowed
|
|
|
|
CheckBoxCopy->hide();
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
// Activate Create a Copy mode
|
2007-10-17 12:24:45 +00:00
|
|
|
CreateCopyModeChanged( true );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
// Allowed inheritance of children and visual properties by the scaling result
|
|
|
|
mainFrame()->GroupBoxPublish->show();
|
|
|
|
|
|
|
|
// Signals and slots connections
|
|
|
|
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
|
|
|
|
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
|
|
|
|
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
|
|
|
|
|
|
|
|
connect( PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
|
|
|
connect( PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
|
|
|
|
|
|
|
connect( LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
|
|
|
connect( LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
connect( SpinBox_FX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
|
|
|
|
connect( SpinBox_FY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
|
|
|
|
connect( SpinBox_FZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2008-03-07 07:08:10 +00:00
|
|
|
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
|
2008-07-21 13:51:52 +00:00
|
|
|
|
|
|
|
connect( CheckBoxCopy, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2007-10-17 12:24:45 +00:00
|
|
|
connect( myGeomGUI->getApp()->selectionMgr(),
|
|
|
|
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2008-02-06 15:43:50 +00:00
|
|
|
setHelpFileName( "scale_operation_page.html" );
|
2006-05-06 08:44:32 +00:00
|
|
|
|
2004-01-07 15:46:21 +00:00
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~TransformationGUI_ScaleDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::Init()
|
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
myEditCurrentArgument = LineEdit1;
|
|
|
|
LineEdit2->clear();
|
2004-01-07 15:46:21 +00:00
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
myPoint = GEOM::GEOM_Object::_nil();
|
|
|
|
|
2007-10-17 12:24:45 +00:00
|
|
|
initName( tr( "GEOM_SCALE" ) );
|
2008-07-21 13:51:52 +00:00
|
|
|
|
|
|
|
ConstructorsClicked( 0 );
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : ConstructorsClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::ConstructorsClicked( int constructorId )
|
|
|
|
{
|
|
|
|
erasePreview();
|
|
|
|
|
|
|
|
switch( constructorId )
|
|
|
|
{
|
|
|
|
case 0: /* translation an object by dx, dy, dz */
|
|
|
|
TextLabel3->setText( tr( "GEOM_SCALE_FACTOR" ) );
|
|
|
|
TextLabel4->hide();
|
|
|
|
TextLabel5->hide();
|
|
|
|
SpinBox_FY->hide();
|
|
|
|
SpinBox_FZ->hide();
|
|
|
|
break;
|
|
|
|
case 1: /* translation an object by 2 points */
|
|
|
|
TextLabel3->setText( tr( "GEOM_SCALE_FACTOR_X" ) );
|
|
|
|
TextLabel4->show();
|
|
|
|
TextLabel5->show();
|
|
|
|
SpinBox_FY->show();
|
|
|
|
SpinBox_FZ->show();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
qApp->processEvents();
|
|
|
|
updateGeometry();
|
|
|
|
resize( minimumSize() );
|
|
|
|
|
|
|
|
displayPreview();
|
|
|
|
}
|
2004-01-07 15:46:21 +00:00
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::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 TransformationGUI_ScaleDlg::ClickOnApply()
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
if ( !onAccept( CheckBoxCopy->isChecked() ) )
|
2004-12-01 10:39:14 +00:00
|
|
|
return false;
|
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
initName( tr( "GEOM_SCALE" ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-01-07 15:46:21 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
|
|
|
// purpose : Called when selection as changed or other case
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::SelectionIntoArgument()
|
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
erasePreview();
|
2007-10-17 12:24:45 +00:00
|
|
|
myEditCurrentArgument->setText( "" );
|
2004-12-01 10:39:14 +00:00
|
|
|
QString aName;
|
|
|
|
|
2008-09-15 08:14:51 +00:00
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
|
|
|
|
|
|
|
if (myEditCurrentArgument == LineEdit1)
|
2008-07-21 13:51:52 +00:00
|
|
|
{
|
2008-09-15 08:14:51 +00:00
|
|
|
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
|
|
|
|
if (aNbSel < 1)
|
2008-07-21 13:51:52 +00:00
|
|
|
{
|
2008-09-15 08:14:51 +00:00
|
|
|
myObjects.length(0);
|
2007-10-17 12:24:45 +00:00
|
|
|
return;
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
2008-09-15 08:14:51 +00:00
|
|
|
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
|
|
|
|
if (!myObjects.length())
|
2007-10-17 12:24:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-09-15 08:14:51 +00:00
|
|
|
else if (myEditCurrentArgument == LineEdit2)
|
2008-07-21 13:51:52 +00:00
|
|
|
{
|
|
|
|
GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil();
|
2008-09-15 08:14:51 +00:00
|
|
|
if (aSelList.Extent() == 1)
|
2008-07-21 13:51:52 +00:00
|
|
|
{
|
|
|
|
Standard_Boolean testResult = Standard_False;
|
2008-09-15 08:14:51 +00:00
|
|
|
aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
|
|
|
|
if (testResult)
|
2008-07-21 13:51:52 +00:00
|
|
|
{
|
2008-09-15 08:14:51 +00:00
|
|
|
aName = GEOMBase::GetName(aSelectedObject);
|
2008-07-21 13:51:52 +00:00
|
|
|
|
|
|
|
TopoDS_Shape aShape;
|
2008-09-15 08:14:51 +00:00
|
|
|
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
|
2008-07-21 13:51:52 +00:00
|
|
|
{
|
|
|
|
TColStd_IndexedMapOfInteger aMap;
|
2008-09-15 08:14:51 +00:00
|
|
|
aSelMgr->GetIndexes(aSelList.First(), aMap);
|
|
|
|
if (aMap.Extent() == 1)
|
2008-07-21 13:51:52 +00:00
|
|
|
{
|
|
|
|
int anIndex = aMap( 1 );
|
|
|
|
aName += QString( ":vertex_%1" ).arg( anIndex );
|
|
|
|
|
|
|
|
//Find SubShape Object in Father
|
|
|
|
GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName );
|
|
|
|
|
|
|
|
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
|
|
|
|
GEOM::GEOM_IShapesOperations_var aShapesOp =
|
|
|
|
getGeomEngine()->GetIShapesOperations( getStudyId() );
|
|
|
|
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
|
|
|
|
aSelMgr->clearSelected();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aSelectedObject = aFindedObject; // get Object from study
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( aShape.ShapeType() != TopAbs_VERTEX ) {
|
|
|
|
aSelectedObject = GEOM::GEOM_Object::_nil();
|
|
|
|
aName = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-02-06 15:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
myPoint = aSelectedObject;
|
2007-10-17 12:24:45 +00:00
|
|
|
}
|
2008-07-21 13:51:52 +00:00
|
|
|
|
2008-09-15 08:14:51 +00:00
|
|
|
myEditCurrentArgument->setText(aName);
|
2004-12-01 10:39:14 +00:00
|
|
|
displayPreview();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : LineEditReturnPressed()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::LineEditReturnPressed()
|
|
|
|
{
|
|
|
|
QLineEdit* send = (QLineEdit*)sender();
|
2008-07-21 13:51:52 +00:00
|
|
|
if ( send == LineEdit1 || send == LineEdit2 )
|
|
|
|
{
|
2007-10-17 12:24:45 +00:00
|
|
|
myEditCurrentArgument = send;
|
|
|
|
GEOMBase_Skeleton::LineEditReturnPressed();
|
|
|
|
}
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::SetEditCurrentArgument()
|
|
|
|
{
|
|
|
|
QPushButton* send = (QPushButton*)sender();
|
2008-02-06 15:43:50 +00:00
|
|
|
globalSelection();
|
2004-12-01 10:39:14 +00:00
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
if ( send == PushButton1 ) {
|
|
|
|
myEditCurrentArgument = LineEdit1;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2008-07-21 13:51:52 +00:00
|
|
|
else if ( send == PushButton2 ) {
|
|
|
|
myEditCurrentArgument = LineEdit2;
|
|
|
|
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
|
|
|
|
myEditCurrentArgument->setFocus();
|
|
|
|
SelectionIntoArgument();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
GEOMBase_Skeleton::ActivateThisDialog();
|
2008-07-21 13:51:52 +00:00
|
|
|
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
|
|
|
this, SLOT( SelectionIntoArgument() ) );
|
2004-12-01 10:39:14 +00:00
|
|
|
globalSelection();
|
2008-07-21 13:51:52 +00:00
|
|
|
myEditCurrentArgument->setFocus();
|
|
|
|
if ( myEditCurrentArgument == LineEdit2 ) {
|
|
|
|
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
|
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
|
|
|
|
2004-01-07 15:46:21 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2007-10-17 12:24:45 +00:00
|
|
|
void TransformationGUI_ScaleDlg::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
|
|
|
ActivateThisDialog();
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ValueChangedInSpinBox()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
void TransformationGUI_ScaleDlg::ValueChangedInSpinBox()
|
|
|
|
{
|
|
|
|
displayPreview();
|
|
|
|
}
|
|
|
|
|
2008-03-07 07:08:10 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : SetDoubleSpinBoxStep()
|
|
|
|
// purpose : Double spin box management
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::SetDoubleSpinBoxStep( double step )
|
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
SpinBox_FX->setSingleStep( step );
|
|
|
|
SpinBox_FY->setSingleStep( step );
|
|
|
|
SpinBox_FZ->setSingleStep( step );
|
2008-03-07 07:08:10 +00:00
|
|
|
}
|
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
//=================================================================================
|
|
|
|
// function : createOperation
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2007-10-17 12:24:45 +00:00
|
|
|
GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation()
|
2004-12-01 10:39:14 +00:00
|
|
|
{
|
2006-05-06 08:44:32 +00:00
|
|
|
return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() );
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : isValid
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2007-10-17 12:24:45 +00:00
|
|
|
bool TransformationGUI_ScaleDlg::isValid( QString& /*msg*/)
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
if ( myObjects.length() > 0 && fabs( SpinBox_FX->value() ) > 0.00001 )
|
|
|
|
{
|
|
|
|
// && !myPoint->_is_nil()
|
|
|
|
if ( getConstructorId() == 0 )
|
|
|
|
return true;
|
|
|
|
if ( fabs( SpinBox_FY->value() ) > 0.00001 &&
|
|
|
|
fabs( SpinBox_FZ->value() ) > 0.00001 )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
// function : execute
|
2004-01-07 15:46:21 +00:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2004-12-01 10:39:14 +00:00
|
|
|
bool TransformationGUI_ScaleDlg::execute( ObjectList& objects )
|
2004-01-07 15:46:21 +00:00
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
|
|
|
|
|
2004-12-01 10:39:14 +00:00
|
|
|
GEOM::GEOM_Object_var anObj;
|
|
|
|
|
2008-07-21 13:51:52 +00:00
|
|
|
switch ( getConstructorId() )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if ( toCreateCopy )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < myObjects.length(); i++ )
|
|
|
|
{
|
|
|
|
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
|
|
|
|
ScaleShapeCopy( myObjects[i], myPoint, SpinBox_FX->value() );
|
|
|
|
if ( !anObj->_is_nil() )
|
|
|
|
objects.push_back( anObj._retn() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < myObjects.length(); i++ )
|
|
|
|
{
|
|
|
|
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
|
|
|
|
ScaleShape( myObjects[i], myPoint, SpinBox_FX->value() );
|
|
|
|
if ( !anObj->_is_nil() )
|
|
|
|
objects.push_back( anObj._retn() );
|
|
|
|
}
|
|
|
|
}
|
2007-10-17 12:24:45 +00:00
|
|
|
}
|
2008-07-21 13:51:52 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
if ( toCreateCopy )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < myObjects.length(); i++ )
|
|
|
|
{
|
|
|
|
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
|
|
|
|
ScaleShapeAlongAxesCopy( myObjects[i], myPoint, SpinBox_FX->value(),
|
|
|
|
SpinBox_FY->value(), SpinBox_FZ->value() );
|
|
|
|
if ( !anObj->_is_nil() )
|
|
|
|
objects.push_back( anObj._retn() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < myObjects.length(); i++ )
|
|
|
|
{
|
|
|
|
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
|
|
|
|
ScaleShapeAlongAxes( myObjects[i], myPoint, SpinBox_FX->value(),
|
|
|
|
SpinBox_FY->value(), SpinBox_FZ->value() );
|
|
|
|
if ( !anObj->_is_nil() )
|
|
|
|
objects.push_back( anObj._retn() );
|
|
|
|
}
|
|
|
|
}
|
2007-10-17 12:24:45 +00:00
|
|
|
}
|
2008-07-21 13:51:52 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2007-10-17 12:24:45 +00:00
|
|
|
}
|
2008-07-21 13:51:52 +00:00
|
|
|
|
2007-10-17 12:24:45 +00:00
|
|
|
return true;
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2008-07-21 13:51:52 +00:00
|
|
|
// function : restoreSubShapes
|
2004-12-01 10:39:14 +00:00
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2008-07-21 13:51:52 +00:00
|
|
|
void TransformationGUI_ScaleDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
|
|
|
|
SALOMEDS::SObject_ptr theSObject )
|
2004-12-01 10:39:14 +00:00
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
|
|
|
|
// empty list of arguments means that all arguments should be restored
|
|
|
|
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
|
|
|
|
/*theFindMethod=*/GEOM::FSM_Transformed,
|
|
|
|
/*theInheritFirstArg=*/true );
|
|
|
|
}
|
2004-12-01 10:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : CreateCopyModeChanged()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2007-10-17 12:24:45 +00:00
|
|
|
void TransformationGUI_ScaleDlg::CreateCopyModeChanged( bool isCreateCopy )
|
2004-12-01 10:39:14 +00:00
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
mainFrame()->GroupBoxName->setEnabled( isCreateCopy );
|
2004-01-07 15:46:21 +00:00
|
|
|
}
|
2008-02-06 15:43:50 +00:00
|
|
|
|
|
|
|
//=================================================================================
|
2008-07-21 13:51:52 +00:00
|
|
|
// function : addSubshapesToStudy
|
2008-02-06 15:43:50 +00:00
|
|
|
// purpose : virtual method to add new SubObjects if local selection
|
|
|
|
//=================================================================================
|
|
|
|
void TransformationGUI_ScaleDlg::addSubshapesToStudy()
|
|
|
|
{
|
2008-07-21 13:51:52 +00:00
|
|
|
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
|
|
|
|
if ( toCreateCopy )
|
|
|
|
{
|
|
|
|
if ( !myPoint->_is_nil() )
|
|
|
|
{
|
|
|
|
QMap<QString, GEOM::GEOM_Object_var> objMap;
|
|
|
|
objMap[LineEdit2->text()] = myPoint;
|
|
|
|
addSubshapesToFather( objMap );
|
|
|
|
}
|
2008-02-06 15:43:50 +00:00
|
|
|
}
|
|
|
|
}
|