geom/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx

775 lines
29 KiB
C++
Raw Normal View History

2015-02-10 14:25:19 +05:00
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// File : TransformationGUI_MultiTranslationDlg.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
2004-01-07 20:46:21 +05:00
#include "TransformationGUI_MultiTranslationDlg.h"
2009-02-13 17:16:39 +05:00
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
2009-02-13 17:16:39 +05:00
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
2012-08-09 13:58:02 +06:00
#include <SUIT_Desktop.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_ViewManager.h>
2009-02-13 17:16:39 +05:00
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
2012-08-09 13:58:02 +06:00
#include <GEOM_AISVector.hxx>
#include <SOCC_Prs.h>
#include <SOCC_ViewModel.h>
2009-02-13 17:16:39 +05:00
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
2012-08-09 13:58:02 +06:00
#include <ShapeAnalysis_Edge.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRep_Builder.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_MultiTranslationDlg()
// purpose : Constructs a TransformationGUI_MultiTranslationDlg 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_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg
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();
QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_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_MULTITRANSLATION_TITLE"));
2004-01-07 20:46:21 +05:00
/***************************************************************/
2009-02-13 17:16:39 +05:00
mainFrame()->GroupConstructors->setTitle(tr("GEOM_MULTITRANSLATION"));
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
2009-02-13 17:16:39 +05:00
GroupPoints = new DlgRef_2Sel2Spin1Check(centralWidget());
2004-01-07 20:46:21 +05:00
GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE"));
GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
2013-02-12 17:35:16 +06:00
GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
GroupPoints->TextLabel3->setText(tr("GEOM_STEP"));
GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES"));
GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_DIRECTION"));
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton1->setIcon(image2);
GroupPoints->PushButton2->setIcon(image2);
2004-12-01 15:39:14 +05:00
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
GroupDimensions = new DlgRef_3Sel4Spin2Check(centralWidget());
2004-01-07 20:46:21 +05:00
GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE"));
GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR_U"));
GroupDimensions->TextLabel3->setText(tr("GEOM_VECTOR_V"));
GroupDimensions->TextLabel4->setText(tr("GEOM_STEP_U"));
GroupDimensions->TextLabel5->setText(tr("GEOM_NB_TIMES_U"));
GroupDimensions->TextLabel6->setText(tr("GEOM_STEP_V"));
GroupDimensions->TextLabel7->setText(tr("GEOM_NB_TIMES_V"));
GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE_U"));
GroupDimensions->CheckButton2->setText(tr("GEOM_REVERSE_V"));
2009-02-13 17:16:39 +05:00
GroupDimensions->PushButton1->setIcon(image2);
GroupDimensions->PushButton2->setIcon(image2);
GroupDimensions->PushButton3->setIcon(image2);
2004-12-01 15:39:14 +05:00
GroupDimensions->LineEdit1->setReadOnly(true);
GroupDimensions->LineEdit2->setReadOnly(true);
GroupDimensions->LineEdit3->setReadOnly(true);
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
layout->addWidget(GroupDimensions);
2004-01-07 20:46:21 +05:00
/***************************************************************/
setHelpFileName("multi_translation_operation_page.html");
2004-01-07 20:46:21 +05:00
Init();
}
//=================================================================================
// function : ~TransformationGUI_MultiTranslationDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void TransformationGUI_MultiTranslationDlg::Init()
{
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);
2012-08-09 13:58:02 +06:00
int SpecificStep = 1;
// init variables
myStepU = myStepV = 50.0;
2013-02-12 17:35:16 +06:00
myNbTimesU = myNbTimesV = 3;
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// min, max, step and decimals for spin boxes & initial values
2012-08-09 13:58:02 +06:00
initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
initSpinBox(GroupPoints->SpinBox_DY, 1, 999, SpecificStep);
2009-02-13 17:16:39 +05:00
GroupPoints->SpinBox_DX->setValue(myStepU);
GroupPoints->SpinBox_DY->setValue(myNbTimesU);
2012-08-09 13:58:02 +06:00
initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
initSpinBox(GroupDimensions->SpinBox_DY1, 1, 999, SpecificStep);
initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
initSpinBox(GroupDimensions->SpinBox_DY2, 1, 999, SpecificStep);
2009-02-13 17:16:39 +05:00
GroupDimensions->SpinBox_DX1->setValue(myStepU);
GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
GroupDimensions->SpinBox_DX2->setValue(myStepV);
GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
GroupDimensions->LineEdit1->setText("");
GroupDimensions->LineEdit2->setText("");
GroupDimensions->LineEdit3->setText("");
2012-08-09 13:58:02 +06:00
myBase.nullify();
myVectorU.nullify();
myVectorV.nullify();
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()));
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
2004-01-07 20:46:21 +05:00
connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
2009-02-13 17:16:39 +05:00
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
2012-08-09 13:58:02 +06:00
connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
2004-01-07 20:46:21 +05:00
connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
2012-08-09 13:58:02 +06:00
connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
2004-01-07 20:46:21 +05:00
connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
2012-08-09 13:58:02 +06:00
connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
2004-01-07 20:46:21 +05:00
2012-08-09 13:58:02 +06:00
connect(GroupPoints->SpinBox_DX, SIGNAL(textChanged(const QString& )),
2009-02-13 17:16:39 +05:00
this, SLOT(TextValueChangedInSpinBox(const QString& )));
2012-08-09 13:58:02 +06:00
connect(GroupDimensions->SpinBox_DX1, SIGNAL(textChanged(const QString& )),
2009-02-13 17:16:39 +05:00
this, SLOT(TextValueChangedInSpinBox(const QString& )));
2012-08-09 13:58:02 +06:00
connect(GroupDimensions->SpinBox_DX2, SIGNAL(textChanged(const QString& )),
2009-02-13 17:16:39 +05:00
this, SLOT(TextValueChangedInSpinBox(const QString& )));
2012-08-09 13:58:02 +06:00
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
2009-02-13 17:16:39 +05:00
connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
2004-12-01 15:39:14 +05:00
connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
connect(GroupDimensions->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(ReverseStepV()));
2009-02-13 17:16:39 +05:00
initName(tr("GEOM_MULTITRANSLATION"));
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_MultiTranslationDlg::SetDoubleSpinBoxStep (double step)
{
GroupPoints->SpinBox_DX->setSingleStep(step);
GroupDimensions->SpinBox_DX1->setSingleStep(step);
GroupDimensions->SpinBox_DX2->setSingleStep(step);
2012-08-09 13:58:02 +06:00
// san : Commented so as not to override specific step settings
//GroupPoints->SpinBox_DY->setSingleStep((int)step);
//GroupDimensions->SpinBox_DY1->setSingleStep((int)step);
//GroupDimensions->SpinBox_DY2->setSingleStep((int)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_MultiTranslationDlg::ConstructorsClicked (int constructorId)
2004-01-07 20:46:21 +05:00
{
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
2009-02-13 17:16:39 +05:00
switch (constructorId) {
case 0: // Translate simple
{
GroupDimensions->hide();
GroupPoints->show();
2013-12-18 20:23:59 +06:00
//GroupPoints->LineEdit1->setText("");
//GroupPoints->LineEdit2->setText("");
//myBase.nullify();
//myVectorU.nullify();
if ( myBase ) GroupDimensions->LineEdit1->setText( GEOMBase::GetName( myBase.get() ) );
if ( myVectorU ) GroupDimensions->LineEdit2->setText( GEOMBase::GetName( myVectorU.get() ) );
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
GroupPoints->SpinBox_DX->setValue(myStepU);
GroupPoints->SpinBox_DY->setValue(myNbTimesU);
2004-01-07 20:46:21 +05:00
2013-12-18 20:23:59 +06:00
if ( !myBase )
GroupPoints->PushButton1->click();
else if ( !myVectorU )
GroupPoints->PushButton2->click();
2009-02-13 17:16:39 +05:00
break;
}
case 1: // Translate double
2004-01-07 20:46:21 +05:00
{
2009-02-13 17:16:39 +05:00
GroupPoints->hide();
GroupDimensions->show();
2013-12-18 20:23:59 +06:00
//GroupDimensions->LineEdit1->setText("");
//GroupDimensions->LineEdit2->setText("");
//GroupDimensions->LineEdit3->setText("");
//myBase.nullify();
//myVectorU.nullify();
//myVectorV.nullify();
if ( myBase ) GroupDimensions->LineEdit1->setText( GEOMBase::GetName( myBase.get() ) );
if ( myVectorU ) GroupDimensions->LineEdit2->setText( GEOMBase::GetName( myVectorU.get() ) );
if ( myVectorV ) GroupDimensions->LineEdit3->setText( GEOMBase::GetName( myVectorV.get() ) );
2009-02-13 17:16:39 +05:00
GroupDimensions->SpinBox_DX1->setValue(myStepU);
GroupDimensions->SpinBox_DY1->setValue(myNbTimesU);
GroupDimensions->SpinBox_DX2->setValue(myStepV);
GroupDimensions->SpinBox_DY2->setValue(myNbTimesV);
2013-12-18 20:23:59 +06:00
if ( !myBase )
GroupDimensions->PushButton1->click();
else if ( !myVectorU )
GroupDimensions->PushButton2->click();
else if ( !myVectorV )
GroupDimensions->PushButton3->click();
2009-02-13 17:16:39 +05:00
break;
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
}
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_MultiTranslationDlg::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_MultiTranslationDlg::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_MultiTranslationDlg::SelectionIntoArgument()
{
2009-02-13 17:16:39 +05:00
erasePreview();
2012-08-09 13:58:02 +06:00
TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
2013-06-17 18:15:50 +06:00
myEditCurrentArgument == GroupDimensions->LineEdit2 ||
myEditCurrentArgument == GroupDimensions->LineEdit3 ) ?
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
2013-12-18 20:23:59 +06:00
if ( myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1 ) {
2012-08-09 13:58:02 +06:00
myBase = aSelectedObject;
2013-02-12 17:35:16 +06:00
// recompute myStepU (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()) {
myStepU = floor(1.5 * (Xmax - Xmin));
2013-12-18 20:23:59 +06:00
myStepV = floor(1.5 * (Ymax - Ymin));
2013-02-12 17:35:16 +06:00
GroupPoints->SpinBox_DX->setValue(myStepU);
2013-12-18 20:23:59 +06:00
GroupDimensions->SpinBox_DX1->setValue(myStepU);
GroupDimensions->SpinBox_DX2->setValue(myStepV);
2013-02-12 17:35:16 +06:00
}
2013-12-18 20:23:59 +06:00
if ( myEditCurrentArgument == GroupPoints->LineEdit1 && !myVectorU )
2013-06-17 18:15:50 +06:00
GroupPoints->PushButton2->click();
2013-12-18 20:23:59 +06:00
if ( myEditCurrentArgument == GroupDimensions->LineEdit1 ) {
if ( !myVectorU )
GroupDimensions->PushButton2->click();
else if ( !myVectorV )
GroupDimensions->PushButton3->click();
}
2012-08-09 13:58:02 +06:00
}
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
myVectorU = aSelectedObject;
if ( !myBase )
2013-06-17 18:15:50 +06:00
GroupPoints->PushButton1->click();
2012-08-09 13:58:02 +06:00
}
else if ( myEditCurrentArgument == GroupDimensions->LineEdit2 ) {
myVectorU = aSelectedObject;
if ( !myVectorV )
2013-06-17 18:15:50 +06:00
GroupDimensions->PushButton3->click();
2012-08-09 13:58:02 +06:00
else if ( !myBase )
2013-06-17 18:15:50 +06:00
GroupDimensions->PushButton1->click();
2012-08-09 13:58:02 +06:00
}
else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 ) {
myVectorV = aSelectedObject;
if ( !myBase )
2013-06-17 18:15:50 +06:00
GroupDimensions->PushButton1->click();
2012-08-09 13:58:02 +06:00
else if ( !myVectorU )
2013-06-17 18:15:50 +06:00
GroupDimensions->PushButton2->click();
}
2012-08-09 13:58:02 +06:00
// clear selection
2013-12-18 20:23:59 +06:00
// disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
// myGeomGUI->getApp()->selectionMgr()->clearSelected();
// connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
// this, SLOT(SelectionIntoArgument()));
2009-02-13 17:16:39 +05:00
}
2012-08-09 13:58:02 +06:00
else {
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
2013-06-17 18:15:50 +06:00
myEditCurrentArgument == GroupDimensions->LineEdit1 )
2012-08-09 13:58:02 +06:00
myBase.nullify();
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
2013-06-17 18:15:50 +06:00
myEditCurrentArgument == GroupDimensions->LineEdit2 )
2012-08-09 13:58:02 +06:00
myVectorU.nullify();
else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
myVectorV.nullify();
myEditCurrentArgument->setText("");
2009-02-13 17:16:39 +05:00
}
2004-01-07 20:46:21 +05:00
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 : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
2009-02-13 17:16:39 +05:00
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(GEOM_ALLSHAPES);
if (send == GroupPoints->PushButton1) {
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupPoints->LineEdit1;
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
else if (send == GroupPoints->PushButton2) {
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupPoints->LineEdit2;
2009-02-13 17:16:39 +05:00
localSelection(TopAbs_EDGE);
2009-02-13 17:16:39 +05:00
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
else if (send == GroupDimensions->PushButton1) {
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupDimensions->LineEdit1;
2009-02-13 17:16:39 +05:00
GroupDimensions->PushButton2->setDown(false);
GroupDimensions->PushButton3->setDown(false);
GroupDimensions->LineEdit2->setEnabled(false);
GroupDimensions->LineEdit3->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
else if (send == GroupDimensions->PushButton2) {
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupDimensions->LineEdit2;
2009-02-13 17:16:39 +05:00
localSelection(TopAbs_EDGE);
2009-02-13 17:16:39 +05:00
GroupDimensions->PushButton1->setDown(false);
GroupDimensions->PushButton3->setDown(false);
GroupDimensions->LineEdit1->setEnabled(false);
GroupDimensions->LineEdit3->setEnabled(false);
2004-01-07 20:46:21 +05:00
}
2009-02-13 17:16:39 +05:00
else if (send == GroupDimensions->PushButton3) {
2004-01-07 20:46:21 +05:00
myEditCurrentArgument = GroupDimensions->LineEdit3;
2009-02-13 17:16:39 +05:00
localSelection(TopAbs_EDGE);
2009-02-13 17:16:39 +05:00
GroupDimensions->PushButton1->setDown(false);
GroupDimensions->PushButton2->setDown(false);
GroupDimensions->LineEdit1->setEnabled(false);
GroupDimensions->LineEdit2->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()));
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_MultiTranslationDlg::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-01-07 20:46:21 +05:00
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_MultiTranslationDlg::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 :
//=================================================================================
void TransformationGUI_MultiTranslationDlg::TextValueChangedInSpinBox( const QString& s)
{
QObject* send = (QObject*)sender();
bool isDigit = true;
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
switch (getConstructorId()) {
2012-08-09 13:58:02 +06:00
case 0:
2009-02-13 17:16:39 +05:00
GroupPoints->SpinBox_DX->text().toDouble(&isDigit);
if(!isDigit){
GroupPoints->CheckButton1->setChecked(false);
}
GroupPoints->CheckButton1->setEnabled(isDigit);
break;
2012-08-09 13:58:02 +06:00
case 1:
2009-02-13 17:16:39 +05:00
if (send == GroupDimensions->SpinBox_DX1) {
GroupDimensions->SpinBox_DX1->text().toDouble(&isDigit);
2012-08-09 13:58:02 +06:00
if(!isDigit)
2009-02-13 17:16:39 +05:00
GroupDimensions->CheckButton1->setChecked(false);
GroupDimensions->CheckButton1->setEnabled(isDigit);
}
else if(send == GroupDimensions->SpinBox_DX2){
GroupDimensions->SpinBox_DX2->text().toDouble(&isDigit);
2012-08-09 13:58:02 +06:00
if(!isDigit)
2009-02-13 17:16:39 +05:00
GroupDimensions->CheckButton2->setChecked(false);
GroupDimensions->CheckButton2->setEnabled(isDigit);
}
break;
}
}
2004-01-07 20:46:21 +05:00
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (double newValue)
2004-01-07 20:46:21 +05:00
{
QObject* send = (QObject*)sender();
2009-02-13 17:16:39 +05:00
switch (getConstructorId()) {
case 0:
if (send == GroupPoints->SpinBox_DX)
myStepU = newValue;
break;
case 1:
if (send == GroupDimensions->SpinBox_DX1)
myStepU = newValue;
else if (send == GroupDimensions->SpinBox_DX2)
myStepV = newValue;
2012-08-09 13:58:02 +06:00
break;
}
processPreview();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox (int newValue)
{
QObject* send = (QObject*)sender();
switch (getConstructorId()) {
case 0:
if (send == GroupPoints->SpinBox_DY)
myNbTimesU = newValue;
break;
case 1:
if (send == GroupDimensions->SpinBox_DY1)
myNbTimesU = newValue;
2009-02-13 17:16:39 +05:00
else if (send == GroupDimensions->SpinBox_DY2)
2012-08-09 13:58:02 +06:00
myNbTimesV = newValue;
2009-02-13 17:16:39 +05:00
break;
}
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : ReverseStepU()
2004-01-07 20:46:21 +05:00
// purpose : 'state' not used here
//=================================================================================
2004-12-01 15:39:14 +05:00
void TransformationGUI_MultiTranslationDlg::ReverseStepU()
2004-01-07 20:46:21 +05:00
{
2004-12-01 15:39:14 +05:00
myStepU = -myStepU;
2004-12-01 15:39:14 +05:00
int aConstructorId = getConstructorId();
2009-02-13 17:16:39 +05:00
if (aConstructorId == 0)
GroupPoints->SpinBox_DX->setValue(myStepU);
else if (aConstructorId == 1)
GroupDimensions->SpinBox_DX1->setValue(myStepU);
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : ReverseStepV
2004-01-07 20:46:21 +05:00
// purpose : 'state' not used here
//=================================================================================
2004-12-01 15:39:14 +05:00
void TransformationGUI_MultiTranslationDlg::ReverseStepV()
2004-01-07 20:46:21 +05:00
{
2004-12-01 15:39:14 +05:00
myStepV = -myStepV;
2009-02-13 17:16:39 +05:00
GroupDimensions->SpinBox_DX2->setValue(myStepV);
2012-08-09 13:58:02 +06:00
processPreview();
2004-01-07 20:46:21 +05:00
}
//=================================================================================
2004-12-01 15:39:14 +05:00
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation()
{
2009-02-13 17:16:39 +05:00
return getGeomEngine()->GetITransformOperations(getStudyId());
2004-12-01 15:39:14 +05:00
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
bool TransformationGUI_MultiTranslationDlg::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()) {
2012-08-09 13:58:02 +06:00
case 0:
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
2013-02-12 17:35:16 +06:00
myBase;
//myBase && myVectorU; // Mantis issue 0021718
2012-08-09 13:58:02 +06:00
break;
case 1:
ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) &&
GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) &&
GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) &&
GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) &&
2013-02-12 17:35:16 +06:00
myBase;
//myBase && myVectorU && myVectorV; // Mantis issue 0021718
2012-08-09 13:58:02 +06:00
break;
default:
break;
2009-02-13 17:16:39 +05:00
}
2012-08-09 13:58:02 +06:00
return ok;
2004-12-01 15:39:14 +05:00
}
//=================================================================================
// function : execute
2004-01-07 20:46:21 +05:00
// purpose :
//=================================================================================
2009-02-13 17:16:39 +05:00
bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
2004-01-07 20:46:21 +05:00
{
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
createPathPreview(myVectorU.get());
anObj = anOper->MultiTranslate1D(myBase.get(), myVectorU.get(), myStepU, myNbTimesU);
if (!IsPreview()) {
aParameters << GroupPoints->SpinBox_DX->text();
aParameters << GroupPoints->SpinBox_DY->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
createPathPreview(myVectorU.get());
createPathPreview(myVectorV.get());
anObj = anOper->MultiTranslate2D(myBase.get(),
2013-12-18 20:23:59 +06:00
myVectorU.get(), myStepU, myNbTimesU,
myVectorV.get(), myStepV, myNbTimesV);
2013-02-12 17:35:16 +06:00
if (!IsPreview()) {
aParameters << GroupDimensions->SpinBox_DX1->text();
aParameters << GroupDimensions->SpinBox_DY1->text();
aParameters << GroupDimensions->SpinBox_DX2->text();
aParameters << GroupDimensions->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_MultiTranslationDlg::addSubshapesToStudy()
{
2009-02-13 17:16:39 +05:00
switch (getConstructorId()) {
case 0:
2012-08-09 13:58:02 +06:00
GEOMBase::PublishSubObject( myVectorU.get() );
2009-02-13 17:16:39 +05:00
break;
case 1:
2012-08-09 13:58:02 +06:00
GEOMBase::PublishSubObject( myVectorU.get() );
GEOMBase::PublishSubObject( myVectorV.get() );
break;
default:
2009-02-13 17:16:39 +05:00
break;
}
2012-08-09 13:58:02 +06:00
}
//=================================================================================
// function : getSourceObjects
// purpose : virtual method to get source objects
//=================================================================================
QList<GEOM::GeomObjPtr> TransformationGUI_MultiTranslationDlg::getSourceObjects()
{
QList<GEOM::GeomObjPtr> res;
res << myBase << myVectorU << myVectorV;
return res;
}
2012-08-09 13:58:02 +06:00
//=================================================================================
// function : restoreSubShapes
// purpose :
//=================================================================================
void TransformationGUI_MultiTranslationDlg::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());
}
}
//=================================================================================
// function : createPathPreview
// purpose :
//=================================================================================
void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Object_ptr thePath )
{
if ( IsPreview() ) {
2013-02-12 17:35:16 +06:00
if (thePath->_is_nil()) return;
2012-08-09 13:58:02 +06:00
TopoDS_Shape aShape;
GEOMBase::GetShape( thePath, aShape, TopAbs_SHAPE );
TopoDS_Edge anEdge = TopoDS::Edge( aShape );
ShapeAnalysis_Edge aShapeAnal;
TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge );
TopoDS_Vertex aLast = aShapeAnal.LastVertex( anEdge );
2013-12-18 20:23:59 +06:00
if ( BRep_Tool::Pnt(aFirst).IsEqual( BRep_Tool::Pnt(aLast), Precision::Confusion() ) ) return;
2012-08-09 13:58:02 +06:00
TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape();
const char* aName = "tmpVector";
Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName );
2013-12-18 20:23:59 +06:00
2012-08-09 13:58:02 +06:00
// add Prs to preview
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
if (aPrs)
aPrs->AddObject(anIO);
GEOMBase_Helper::displayPreview( aPrs, false, true );
}
}