geom/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx

651 lines
24 KiB
C++
Raw Normal View History

2013-04-01 18:25:01 +06:00
// Copyright (C) 2007-2013 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
// version 2.1 of the License.
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
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// File : TransformationGUI_MultiRotationDlg.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
2004-01-07 20:46:21 +05:00
#include "TransformationGUI_MultiRotationDlg.h"
2009-02-13 17:16:39 +05:00
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
2009-02-13 17:16:39 +05:00
#include <GEOMImpl_Types.hxx>
2004-06-16 21:24:55 +06:00
2004-01-07 20:46:21 +05:00
//=================================================================================
// class : TransformationGUI_MultiRotationDlg()
// purpose : Constructs a TransformationGUI_MultiRotationDlg 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.
//=================================================================================
TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg
2009-02-13 17:16:39 +05:00
(GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
2004-01-07 20:46:21 +05:00
{
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
2009-02-13 17:16:39 +05:00
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTIROTATION_SIMPLE")));
QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTIROTATION_DOUBLE")));
QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
setWindowTitle(tr("GEOM_MULTIROTATION_TITLE"));
2004-01-07 20:46:21 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTIROTATION"));
mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon(image1);
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
bool isAngleStep = false;
GroupArgs = new TransformationGUI_2Sel4Spin1Check (centralWidget());
GroupArgs->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_DOUBLE"));
GroupArgs->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
GroupArgs->TextLabel2->setText(tr("GEOM_VECTOR"));
//GroupArgs->TextLabel3->setText(tr("GEOM_ANGLE_STEP"));
GroupArgs->CheckAngleStep->setText(tr("GEOM_ANGLE_STEP"));
GroupArgs->CheckAngleStep->setChecked(isAngleStep);
GroupArgs->TextLabel4->setText(tr("GEOM_NB_TIMES"));
GroupArgs->TextLabel5->setText(tr("GEOM_STEP_R"));
GroupArgs->TextLabel6->setText(tr("GEOM_NB_TIMES"));
GroupArgs->CheckButton1->setText(tr("GEOM_REVERSE"));
GroupArgs->PushButton1->setIcon(image2);
GroupArgs->PushButton2->setIcon(image2);
GroupArgs->LineEdit1->setReadOnly(true);
GroupArgs->LineEdit2->setReadOnly(true);
GroupArgs->SpinBox_DX1->setEnabled(isAngleStep);
GroupArgs->CheckButton1->setEnabled(isAngleStep);
2004-01-07 20:46:21 +05:00
/***************************************************************/
setHelpFileName("multi_rotation_operation_page.html");
2004-01-07 20:46:21 +05:00
Init();
}
//=================================================================================
// function : ~TransformationGUI_MultiRotationDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
TransformationGUI_MultiRotationDlg::~TransformationGUI_MultiRotationDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void TransformationGUI_MultiRotationDlg::Init()
{
2013-02-12 17:35:16 +06:00
// init variables
myAng = 45.0;
myStep = 50.0;
myNbTimes1 = myNbTimes2 = 3;
2009-02-13 17:16:39 +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 step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
2004-01-07 20:46:21 +05:00
2012-08-09 13:58:02 +06:00
int SpecificStep1 = 5;
int SpecificStep2 = 1;
2009-02-13 17:16:39 +05:00
// min, max, step and decimals for spin boxes & initial values
2013-02-12 17:35:16 +06:00
initSpinBox(GroupArgs->SpinBox_DX1, COORD_MIN, COORD_MAX, SpecificStep1, "angle_precision");
initSpinBox(GroupArgs->SpinBox_DY1, 1, 999, SpecificStep2);
initSpinBox(GroupArgs->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision");
initSpinBox(GroupArgs->SpinBox_DY2, 1, 999, SpecificStep2);
2012-08-09 13:58:02 +06:00
mainFrame()->GroupBoxPublish->show();
2009-02-13 17:16:39 +05:00
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
2013-02-12 17:35:16 +06:00
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
2009-02-13 17:16:39 +05:00
2013-02-12 17:35:16 +06:00
connect(GroupArgs->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupArgs->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
connect(GroupArgs->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupArgs->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
connect(GroupArgs->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
connect(GroupArgs->SpinBox_DY2, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
connect(GroupArgs->SpinBox_DX1, SIGNAL(textChanged(const QString&)),
this, SLOT(TextValueChangedInSpinBox(const QString&)));
2009-02-13 17:16:39 +05:00
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
connect(GroupArgs->CheckAngleStep, SIGNAL(toggled(bool)), this, SLOT(CheckAngleStep(bool)));
connect(GroupArgs->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseAngle()));
2009-02-13 17:16:39 +05:00
initName(tr("GEOM_MULTIROTATION"));
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +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 TransformationGUI_MultiRotationDlg::SetDoubleSpinBoxStep (double step)
{
2013-02-12 17:35:16 +06:00
GroupArgs->SpinBox_DX2->setSingleStep(step);
2009-02-13 17:16:39 +05:00
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
2009-02-13 17:16:39 +05:00
void TransformationGUI_MultiRotationDlg::ConstructorsClicked (int constructorId)
2004-01-07 20:46:21 +05:00
{
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
2013-02-12 17:35:16 +06:00
myBase.nullify();
myVector.nullify();
2013-02-12 17:35:16 +06:00
GroupArgs->LineEdit1->setText("");
GroupArgs->LineEdit2->setText("");
2004-01-07 20:46:21 +05:00
2013-02-12 17:35:16 +06:00
GroupArgs->SpinBox_DX1->setValue(myAng);
GroupArgs->SpinBox_DY1->setValue(myNbTimes1);
GroupArgs->SpinBox_DX2->setValue(myStep);
GroupArgs->SpinBox_DY2->setValue(myNbTimes2);
2009-02-13 17:16:39 +05:00
2013-02-12 17:35:16 +06:00
switch (constructorId) {
case 0: // Rotate simple
{
GroupArgs->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_SIMPLE"));
GroupArgs->TextLabel5->hide();
GroupArgs->TextLabel6->hide();
GroupArgs->SpinBox_DX2->hide();
GroupArgs->SpinBox_DY2->hide();
GroupArgs->CheckButton1->hide();
2009-02-13 17:16:39 +05:00
}
break;
case 1: // Rotate double
2004-01-07 20:46:21 +05:00
{
2013-02-12 17:35:16 +06:00
GroupArgs->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_DOUBLE"));
GroupArgs->TextLabel5->show();
GroupArgs->TextLabel6->show();
GroupArgs->SpinBox_DX2->show();
GroupArgs->SpinBox_DY2->show();
GroupArgs->CheckButton1->show();
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
break;
}
2004-12-01 15:39:14 +05:00
2013-02-12 17:35:16 +06:00
GroupArgs->PushButton1->click();
2009-02-13 17:16:39 +05:00
qApp->processEvents();
updateGeometry();
resize(minimumSizeHint());
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
if (myInitial) {
myInitial = false;
SelectionIntoArgument();
}
else {
2012-08-09 13:58:02 +06:00
processPreview();
2009-02-13 17:16:39 +05:00
}
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void TransformationGUI_MultiRotationDlg::ClickOnOk()
{
2012-08-09 13:58:02 +06:00
setIsApplyAndClose( true );
2009-02-13 17:16:39 +05:00
if (ClickOnApply())
2004-12-01 15:39:14 +05:00
ClickOnCancel();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
2004-12-01 15:39:14 +05:00
bool TransformationGUI_MultiRotationDlg::ClickOnApply()
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
if (!onAccept())
2004-12-01 15:39:14 +05:00
return false;
2004-12-01 15:39:14 +05:00
initName();
2009-02-13 17:16:39 +05:00
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
2004-12-01 15:39:14 +05:00
return true;
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : SelectionIntoArgument()
2009-02-13 17:16:39 +05:00
// purpose : Called when selection is changed or on dialog initialization or activation
2004-01-07 20:46:21 +05:00
//=================================================================================
void TransformationGUI_MultiRotationDlg::SelectionIntoArgument()
{
2009-02-13 17:16:39 +05:00
erasePreview();
2013-02-12 17:35:16 +06:00
TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupArgs->LineEdit2 ) ?
2012-08-09 13:58:02 +06:00
TopAbs_EDGE : TopAbs_SHAPE;
GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape;
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName );
2013-02-12 17:35:16 +06:00
if ( myEditCurrentArgument == GroupArgs->LineEdit1 ) {
2012-08-09 13:58:02 +06:00
myBase = aSelectedObject;
2013-02-12 17:35:16 +06:00
// recompute myAng and myStep (Mantis issue 0021718)
GEOM::GEOM_IMeasureOperations_var anOper = getGeomEngine()->GetIMeasureOperations(getStudyId());
double Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
anOper->GetBoundingBox(myBase.get(), true, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax);
2013-02-12 17:35:16 +06:00
if (anOper->IsDone()) {
// angular step
double diag = sqrt((Xmax-Xmin)*(Xmax-Xmin) + (Ymax-Ymin)*(Ymax-Ymin));
double d = sqrt((0.5*(Xmax+Xmin))*(0.5*(Xmax+Xmin)) + (0.5*(Ymax+Ymin))*(0.5*(Ymax+Ymin)));
myAng = floor(2.0 * atan(diag/d) * 180.0 / M_PI);
GroupArgs->SpinBox_DX1->setValue(myAng);
// radial step
myStep = Max(floor(1.5*(Xmax-Xmin)), floor(1.5*(Ymax-Ymin)));
GroupArgs->SpinBox_DX2->setValue(myStep);
}
2012-08-09 13:58:02 +06:00
if ( !myVector )
2013-06-17 18:15:50 +06:00
GroupArgs->PushButton2->click();
2012-08-09 13:58:02 +06:00
}
2013-02-12 17:35:16 +06:00
else if ( myEditCurrentArgument == GroupArgs->LineEdit2 ) {
2012-08-09 13:58:02 +06:00
myVector = aSelectedObject;
if ( !myBase )
2013-06-17 18:15:50 +06:00
GroupArgs->PushButton1->click();
2012-08-09 13:58:02 +06:00
}
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
2013-06-17 18:15:50 +06:00
this, SLOT(SelectionIntoArgument()));
2009-02-13 17:16:39 +05:00
}
2012-08-09 13:58:02 +06:00
else {
2013-02-12 17:35:16 +06:00
if ( myEditCurrentArgument == GroupArgs->LineEdit1 )
2012-08-09 13:58:02 +06:00
myBase.nullify();
2013-02-12 17:35:16 +06:00
else if ( myEditCurrentArgument == GroupArgs->LineEdit2 )
2012-08-09 13:58:02 +06:00
myVector.nullify();
myEditCurrentArgument->setText("");
2009-02-13 17:16:39 +05:00
}
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
2009-02-13 17:16:39 +05:00
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(GEOM_ALLSHAPES);
2013-02-12 17:35:16 +06:00
if (send == GroupArgs->PushButton1) {
myEditCurrentArgument = GroupArgs->LineEdit1;
2009-02-13 17:16:39 +05:00
2013-02-12 17:35:16 +06:00
GroupArgs->PushButton2->setDown(false);
GroupArgs->LineEdit2->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2013-02-12 17:35:16 +06:00
else if (send == GroupArgs->PushButton2) {
myEditCurrentArgument = GroupArgs->LineEdit2;
2009-02-13 17:16:39 +05:00
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
2013-02-12 17:35:16 +06:00
GroupArgs->PushButton1->setDown(false);
GroupArgs->LineEdit1->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
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
2009-02-13 17:16:39 +05:00
// enable line edit
myEditCurrentArgument->setEnabled(true);
2004-12-01 15:39:14 +05:00
myEditCurrentArgument->setFocus();
2009-02-13 17:16:39 +05:00
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
// seems we need it only to avoid preview disappearing, caused by selection mode change
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void TransformationGUI_MultiRotationDlg::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
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void TransformationGUI_MultiRotationDlg::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
}
2009-02-13 17:16:39 +05:00
//=================================================================================
// function : TextValueChangedInSpinBox()
// purpose :
//=================================================================================
2013-02-12 17:35:16 +06:00
void TransformationGUI_MultiRotationDlg::TextValueChangedInSpinBox (const QString& s)
{
2009-02-13 17:16:39 +05:00
bool isDigit;
s.toDouble(&isDigit);
2013-02-12 17:35:16 +06:00
if (!isDigit)
GroupArgs->CheckButton1->setChecked(false);
GroupArgs->CheckButton1->setEnabled(isDigit);
2009-02-13 17:16:39 +05:00
}
2012-08-09 13:58:02 +06:00
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (double newValue)
2004-01-07 20:46:21 +05:00
{
QObject* send = (QObject*)sender();
2013-02-12 17:35:16 +06:00
if (send == GroupArgs->SpinBox_DX1)
2004-01-07 20:46:21 +05:00
myAng = newValue;
2013-02-12 17:35:16 +06:00
else if (send == GroupArgs->SpinBox_DX2)
2004-01-07 20:46:21 +05:00
myStep = newValue;
2012-08-09 13:58:02 +06:00
processPreview();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (int newValue)
{
QObject* send = (QObject*)sender();
2013-02-12 17:35:16 +06:00
if (send == GroupArgs->SpinBox_DY1)
2012-08-09 13:58:02 +06:00
myNbTimes1 = newValue;
2013-02-12 17:35:16 +06:00
else if (send == GroupArgs->SpinBox_DY2)
2012-08-09 13:58:02 +06:00
myNbTimes2 = newValue;
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
// function : ReverseAngle()
2013-02-12 17:35:16 +06:00
// purpose :
2004-01-07 20:46:21 +05:00
//=================================================================================
2004-12-01 15:39:14 +05:00
void TransformationGUI_MultiRotationDlg::ReverseAngle()
2004-01-07 20:46:21 +05:00
{
myAng = -myAng;
2004-12-01 15:39:14 +05:00
int aConstructorId = getConstructorId();
2012-08-09 13:58:02 +06:00
if (aConstructorId == 1)
2013-02-12 17:35:16 +06:00
GroupArgs->SpinBox_DX1->setValue(myAng);
2004-01-07 20:46:21 +05:00
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
2013-02-12 17:35:16 +06:00
//=================================================================================
// function : CheckAngleStep()
// purpose :
//=================================================================================
void TransformationGUI_MultiRotationDlg::CheckAngleStep (bool isOn)
{
GroupArgs->SpinBox_DX1->setEnabled(isOn);
GroupArgs->CheckButton1->setEnabled(isOn);
processPreview();
}
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 TransformationGUI_MultiRotationDlg::createOperation()
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
return getGeomEngine()->GetITransformOperations(getStudyId());
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 : isValid
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
bool TransformationGUI_MultiRotationDlg::isValid (QString& msg)
2004-12-01 15:39:14 +05:00
{
2012-08-09 13:58:02 +06:00
bool ok = false;
2013-02-12 17:35:16 +06:00
switch (getConstructorId()) {
2009-02-13 17:16:39 +05:00
case 0:
2013-02-12 17:35:16 +06:00
ok = (GroupArgs->SpinBox_DX1->isValid( msg, !IsPreview() ) &&
GroupArgs->SpinBox_DY1->isValid( msg, !IsPreview() ) &&
//myBase && myVector); // myVector = DZ by default
myBase);
2012-08-09 13:58:02 +06:00
break;
case 1:
2013-02-12 17:35:16 +06:00
ok = (GroupArgs->SpinBox_DX1->isValid( msg, !IsPreview() ) &&
GroupArgs->SpinBox_DY1->isValid( msg, !IsPreview() ) &&
GroupArgs->SpinBox_DX2->isValid( msg, !IsPreview() ) &&
GroupArgs->SpinBox_DY2->isValid( msg, !IsPreview() ) &&
//myBase && myVector); // myVector = DZ by default
myBase);
2009-02-13 17:16:39 +05:00
break;
2012-08-09 13:58:02 +06:00
default:
2009-02-13 17:16:39 +05:00
break;
}
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 TransformationGUI_MultiRotationDlg::execute (ObjectList& objects)
2004-12-01 15:39:14 +05:00
{
bool res = false;
2004-12-01 15:39:14 +05:00
GEOM::GEOM_Object_var anObj;
2009-02-13 17:16:39 +05:00
QStringList aParameters;
2012-08-09 13:58:02 +06:00
GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
2009-02-13 17:16:39 +05:00
switch (getConstructorId()) {
case 0:
2013-02-12 17:35:16 +06:00
if (GroupArgs->CheckAngleStep->isChecked())
anObj = anOper->MultiRotate1DByStep(myBase.get(), myVector.get(), myAng * M_PI / 180., myNbTimes1);
else
2012-08-09 13:58:02 +06:00
anObj = anOper->MultiRotate1D(myBase.get(), myVector.get(), myNbTimes1);
2013-02-12 17:35:16 +06:00
if (!IsPreview()) {
if (GroupArgs->CheckAngleStep->isChecked())
aParameters << GroupArgs->SpinBox_DX1->text();
aParameters << GroupArgs->SpinBox_DY1->text();
2009-02-13 17:16:39 +05:00
}
2013-02-12 17:35:16 +06:00
res = true;
2009-02-13 17:16:39 +05:00
break;
case 1:
2013-02-12 17:35:16 +06:00
if (GroupArgs->CheckAngleStep->isChecked())
anObj = anOper->MultiRotate2DByStep(myBase.get(), myVector.get(), myAng * M_PI / 180., myNbTimes1,
myStep, myNbTimes2);
else
anObj = anOper->MultiRotate2DNbTimes(myBase.get(), myVector.get(), myNbTimes1, myStep, myNbTimes2);
if (!IsPreview()) {
if (GroupArgs->CheckAngleStep->isChecked())
aParameters << GroupArgs->SpinBox_DX1->text();
aParameters << GroupArgs->SpinBox_DY1->text();
aParameters << GroupArgs->SpinBox_DX2->text();
aParameters << GroupArgs->SpinBox_DY2->text();
2004-12-01 15:39:14 +05:00
}
2013-02-12 17:35:16 +06:00
res = true;
2009-02-13 17:16:39 +05:00
break;
}
2009-02-13 17:16:39 +05:00
if (!anObj->_is_nil()) {
2013-02-12 17:35:16 +06:00
if (!IsPreview())
2012-08-09 13:58:02 +06:00
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
2009-02-13 17:16:39 +05:00
objects.push_back(anObj._retn());
}
2004-12-01 15:39:14 +05:00
return res;
}
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void TransformationGUI_MultiRotationDlg::addSubshapesToStudy()
{
2009-02-13 17:16:39 +05:00
switch (getConstructorId()) {
case 0:
case 1:
2012-08-09 13:58:02 +06:00
GEOMBase::PublishSubObject( myVector.get() );
2009-02-13 17:16:39 +05:00
break;
2012-08-09 13:58:02 +06:00
default:
break;
}
}
//=================================================================================
// function : restoreSubShapes
// purpose :
//=================================================================================
void TransformationGUI_MultiRotationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// we pass here the first operation argument (object) through the list of arguments
// because the rotation operation place its arguments in the data structure in another order,
// and we need to point the first argument directly
GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
anArgs->length(1);
anArgs[0] = myBase.copy();
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
/*theFindMethod=*/GEOM::FSM_MultiTransformed,
/*theInheritFirstArg=*/true,
mainFrame()->CheckBoxAddPrefix->isChecked());
2009-02-13 17:16:39 +05:00
}
}
2013-02-12 17:35:16 +06:00
//=================================================================================
// function : TransformationGUI_2Sel4Spin1Check
// purpose :
//=================================================================================
TransformationGUI_2Sel4Spin1Check::TransformationGUI_2Sel4Spin1Check (QWidget *parent)
{
gridLayout = new QGridLayout (parent);
gridLayout->setSpacing(6);
gridLayout->setContentsMargins(11, 11, 11, 11);
gridLayout->setHorizontalSpacing(0);
gridLayout->setVerticalSpacing(0);
gridLayout->setContentsMargins(0, 0, 0, 0);
GroupBox1 = new QGroupBox (parent);
gridLayout1 = new QGridLayout (GroupBox1);
gridLayout1->setSpacing(6);
gridLayout1->setContentsMargins(11, 11, 11, 11);
gridLayout1->setHorizontalSpacing(6);
gridLayout1->setVerticalSpacing(6);
gridLayout1->setContentsMargins(9, 9, 9, 9);
// 2Sel
TextLabel1 = new QLabel(GroupBox1);
TextLabel2 = new QLabel(GroupBox1);
PushButton1 = new QPushButton (GroupBox1);
PushButton2 = new QPushButton (GroupBox1);
LineEdit2 = new QLineEdit(GroupBox1);
LineEdit1 = new QLineEdit(GroupBox1);
gridLayout1->addWidget(TextLabel1, 0, 0, 1, 1);
gridLayout1->addWidget(TextLabel2, 1, 0, 1, 1);
gridLayout1->addWidget(PushButton1, 0, 1, 1, 1);
gridLayout1->addWidget(PushButton2, 1, 1, 1, 1);
gridLayout1->addWidget(LineEdit1, 0, 2, 1, 1);
gridLayout1->addWidget(LineEdit2, 1, 2, 1, 1);
// 4Spin (double-int-double-int)
//TextLabel3 = new QLabel (GroupBox1);
CheckAngleStep = new QCheckBox (GroupBox1);
TextLabel4 = new QLabel (GroupBox1);
TextLabel5 = new QLabel (GroupBox1);
TextLabel6 = new QLabel (GroupBox1);
SpinBox_DX1 = new SalomeApp_DoubleSpinBox (GroupBox1);
SpinBox_DY1 = new SalomeApp_IntSpinBox (GroupBox1);
SpinBox_DX2 = new SalomeApp_DoubleSpinBox (GroupBox1);
SpinBox_DY2 = new SalomeApp_IntSpinBox (GroupBox1);
//gridLayout1->addWidget(TextLabel3, 2, 0, 1, 1);
gridLayout1->addWidget(CheckAngleStep, 2, 0, 1, 1);
gridLayout1->addWidget(TextLabel4, 3, 0, 1, 1);
gridLayout1->addWidget(TextLabel5, 5, 0, 1, 1);
gridLayout1->addWidget(TextLabel6, 6, 0, 1, 1);
gridLayout1->addWidget(SpinBox_DX1, 2, 1, 1, 2);
gridLayout1->addWidget(SpinBox_DY1, 3, 1, 1, 2);
gridLayout1->addWidget(SpinBox_DX2, 5, 1, 1, 2);
gridLayout1->addWidget(SpinBox_DY2, 6, 1, 1, 2);
// 1Check
CheckButton1 = new QCheckBox (GroupBox1);
gridLayout1->addWidget(CheckButton1, 4, 0, 1, 3);
gridLayout->addWidget(GroupBox1, 0, 0, 1, 1);
}
//=================================================================================
// function : ~TransformationGUI_2Sel4Spin1Check()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
TransformationGUI_2Sel4Spin1Check::~TransformationGUI_2Sel4Spin1Check()
{
// no need to delete child widgets, Qt does it all for us
}