2009-02-13 17:16:39 +05:00
|
|
|
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2009-02-13 17:16:39 +05:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2004-12-01 15:39:14 +05: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.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2009-02-13 17:16:39 +05:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
// File : BlocksGUI_TrsfDlg.cxx
|
|
|
|
// Author : Julia DOROVSKIKH, Open CASCADE S.A.S. (julia.dorovskikh@opencascade.com)
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
|
|
|
#include "BlocksGUI_TrsfDlg.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_Desktop.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>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// OCCT Includes
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : BlocksGUI_TrsfDlg()
|
|
|
|
// purpose : Constructs a BlocksGUI_TrsfDlg which is a child of 'parent'.
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
BlocksGUI_TrsfDlg::BlocksGUI_TrsfDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
|
|
|
|
: GEOMBase_Skeleton(theGeometryGUI, parent),
|
|
|
|
myInitial(true)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2006-05-06 14:44:32 +06:00
|
|
|
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
|
|
|
|
QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BLOCK_MULTITRSF_SIMPLE")));
|
|
|
|
QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_BLOCK_MULTITRSF_DOUBLE")));
|
|
|
|
QPixmap imageS (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
setWindowTitle(tr("GEOM_BLOCK_MULTITRSF_TITLE"));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
/***************************************************************/
|
2009-02-13 17:16:39 +05:00
|
|
|
mainFrame()->GroupConstructors->setTitle(tr("GEOM_BLOCK_MULTITRSF"));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
mainFrame()->RadioButton1->setIcon(image1);
|
|
|
|
mainFrame()->RadioButton2->setIcon(image2);
|
|
|
|
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
mainFrame()->RadioButton3->close();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Create first group
|
2009-02-13 17:16:39 +05:00
|
|
|
myGrp1 = new QGroupBox(tr("GEOM_BLOCK_MULTITRSF_SIMPLE"), centralWidget());
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, myGrp1, MainObj1);
|
|
|
|
createSelWg(tr("FACE_1"), imageS, myGrp1, Face1);
|
|
|
|
createSelWg(tr("FACE_2"), imageS, myGrp1, Face2);
|
|
|
|
createSpinWg(tr("GEOM_NB_TIMES"), myGrp1, SpinBox1);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Create second group
|
2009-02-13 17:16:39 +05:00
|
|
|
myGrp2 = new QGroupBox(tr("GEOM_BLOCK_MULTITRSF_DOUBLE"), centralWidget());
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, myGrp2, MainObj2);
|
|
|
|
createSelWg(tr("FACE_1U"), imageS, myGrp2, Face1U);
|
|
|
|
createSelWg(tr("FACE_2U"), imageS, myGrp2, Face2U);
|
|
|
|
createSpinWg(tr("GEOM_NB_TIMES_U"), myGrp2, SpinBox2U);
|
|
|
|
createSelWg(tr("FACE_1V"), imageS, myGrp2, Face1V);
|
|
|
|
createSelWg(tr("FACE_2V"), imageS, myGrp2, Face2V);
|
|
|
|
createSpinWg(tr("GEOM_NB_TIMES_V"), myGrp2, SpinBox2V);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// Add groups to layout
|
2009-02-13 17:16:39 +05:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
|
|
|
|
layout->setMargin(0); layout->setSpacing(6);
|
|
|
|
layout->addWidget(myGrp1);
|
|
|
|
layout->addWidget(myGrp2);
|
2004-12-01 15:39:14 +05:00
|
|
|
/***************************************************************/
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
setHelpFileName("multi_transformation_operation_page.html");
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~BlocksGUI_TrsfDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
BlocksGUI_TrsfDlg::~BlocksGUI_TrsfDlg()
|
|
|
|
{
|
|
|
|
// no need to delete child widgets, Qt does it all for us
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::Init()
|
|
|
|
{
|
|
|
|
// Set range of spinboxes
|
2009-02-25 13:54:44 +05:00
|
|
|
int SpecificStep = 1;
|
|
|
|
QMap<int, SalomeApp_IntSpinBox*>::iterator anIter;
|
2004-12-01 15:39:14 +05:00
|
|
|
for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter) {
|
2009-02-25 13:54:44 +05:00
|
|
|
//anIter.data()->RangeStepAndValidator(1, 999, SpecificStep);
|
|
|
|
initSpinBox(anIter.value(), 1, 999, SpecificStep);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// signals and slots connections
|
2009-02-13 17:16:39 +05:00
|
|
|
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
|
|
|
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
|
|
|
|
|
|
|
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
QMap<int, QPushButton*>::iterator anIterBtn;
|
|
|
|
for (anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn)
|
2009-02-13 17:16:39 +05:00
|
|
|
connect(anIterBtn.value(), SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-25 13:54:44 +05:00
|
|
|
QMap<int, SalomeApp_IntSpinBox*>::iterator anIterSpin;
|
2004-12-01 15:39:14 +05:00
|
|
|
for (anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin)
|
2009-02-13 17:16:39 +05:00
|
|
|
connect(anIterSpin.value(), SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int)));
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
// init controls and fields
|
|
|
|
initName(tr("GEOM_BLOCK_MULTITRSF"));
|
|
|
|
|
|
|
|
myConstructorId = -1;
|
|
|
|
ConstructorsClicked(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ConstructorsClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::ConstructorsClicked (int constructorId)
|
|
|
|
{
|
|
|
|
if (myConstructorId == constructorId)
|
|
|
|
return;
|
|
|
|
|
|
|
|
myConstructorId = constructorId;
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// init fields
|
|
|
|
myShape = GEOM::GEOM_Object::_nil();
|
|
|
|
myFaces[Face1] = myFaces[Face2] = -1;
|
|
|
|
myFaces[Face1U] = myFaces[Face2U] = -1;
|
|
|
|
myFaces[Face1V] = myFaces[Face2V] = -1;
|
|
|
|
|
|
|
|
// clear line edits
|
|
|
|
QMap<int, QLineEdit*>::iterator anIterLE;
|
|
|
|
for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE)
|
|
|
|
anIterLE.value()->setText("");
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
switch (constructorId) {
|
|
|
|
case 0:
|
|
|
|
myGrp2->hide();
|
|
|
|
myGrp1->show();
|
2009-02-13 17:16:39 +05:00
|
|
|
mySpinBox[SpinBox1]->setValue(2);
|
|
|
|
mySelBtn[MainObj1]->click();
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
myGrp1->hide();
|
|
|
|
myGrp2->show();
|
2009-02-13 17:16:39 +05:00
|
|
|
mySpinBox[SpinBox2U]->setValue(2);
|
|
|
|
mySpinBox[SpinBox2V]->setValue(2);
|
|
|
|
mySelBtn[MainObj2]->click();
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
qApp->processEvents();
|
|
|
|
updateGeometry();
|
|
|
|
resize(minimumSizeHint());
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// on dialog initialization we init the first field with a selected object (if any)
|
|
|
|
SelectionIntoArgument();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::ClickOnOk()
|
|
|
|
{
|
|
|
|
if (ClickOnApply())
|
|
|
|
ClickOnCancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ClickOnApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool BlocksGUI_TrsfDlg::ClickOnApply()
|
|
|
|
{
|
|
|
|
if (!onAccept())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
initName();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument()
|
2009-02-13 17:16:39 +05:00
|
|
|
// purpose : Called when selection is changed or on dialog initialization or activation
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::SelectionIntoArgument()
|
|
|
|
{
|
|
|
|
erasePreview();
|
|
|
|
myEditCurrentArgument->setText("");
|
|
|
|
|
|
|
|
// Get index of current selection focus
|
|
|
|
int aCurrFocus = -1;
|
|
|
|
QMap<int, QLineEdit*>::iterator anIter;
|
|
|
|
for (anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter) {
|
2009-02-13 17:16:39 +05:00
|
|
|
if (myEditCurrentArgument == anIter.value()) {
|
2004-12-01 15:39:14 +05:00
|
|
|
aCurrFocus = anIter.key();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
|
|
|
|
|
|
|
QString aName;
|
|
|
|
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil();
|
|
|
|
|
|
|
|
if (aCurrFocus == MainObj1 || aCurrFocus == MainObj2)
|
|
|
|
{
|
|
|
|
// If selection of main object is activated
|
|
|
|
if (aSelList.Extent() == 1) {
|
2004-12-01 15:39:14 +05:00
|
|
|
Standard_Boolean aResult = Standard_False;
|
2009-02-13 17:16:39 +05:00
|
|
|
anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
|
|
|
|
|
|
|
|
if (aResult && !anObj->_is_nil() && GEOMBase::IsShape(anObj)) {
|
|
|
|
aName = GEOMBase::GetName(anObj);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
myEditCurrentArgument->setText(aName);
|
|
|
|
myShape = anObj;
|
2004-12-01 15:39:14 +05:00
|
|
|
enableWidgets();
|
|
|
|
}
|
|
|
|
else if (aCurrFocus == Face1 || aCurrFocus == Face2 ||
|
|
|
|
aCurrFocus == Face1U || aCurrFocus == Face2U ||
|
|
|
|
aCurrFocus == Face1V || aCurrFocus == Face2V) {
|
2009-02-13 17:16:39 +05:00
|
|
|
// If face selection is activated
|
|
|
|
int anIndex = -1;
|
|
|
|
if (aSelList.Extent() == 1) {
|
2004-12-01 15:39:14 +05:00
|
|
|
Standard_Boolean aResult = Standard_False;
|
2009-02-13 17:16:39 +05:00
|
|
|
anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult);
|
|
|
|
if (aResult && !anObj->_is_nil() && GEOMBase::IsShape(anObj)) {
|
|
|
|
aName = GEOMBase::GetName(anObj);
|
2004-12-01 15:39:14 +05:00
|
|
|
TColStd_IndexedMapOfInteger anIndexes;
|
2009-02-13 17:16:39 +05:00
|
|
|
aSelMgr->GetIndexes(aSelList.First(), anIndexes);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
if (anIndexes.Extent() == 1) {
|
2009-02-13 17:16:39 +05:00
|
|
|
anIndex = anIndexes(1);
|
|
|
|
aName += QString(":face_%1").arg(anIndex);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
myEditCurrentArgument->setText(aName);
|
|
|
|
myFaces[aCurrFocus] = anIndex;
|
|
|
|
displayPreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aCurrFocus) {
|
|
|
|
// 1D
|
|
|
|
case MainObj1:
|
|
|
|
if (!myShape->_is_nil() && myFaces[Face1] == -1)
|
|
|
|
mySelBtn[Face1]->click();
|
|
|
|
break;
|
|
|
|
case Face1:
|
|
|
|
if (myFaces[Face1] != -1 && myFaces[Face2] == -1)
|
|
|
|
mySelBtn[Face2]->click();
|
|
|
|
break;
|
|
|
|
case Face2:
|
|
|
|
if (myFaces[Face2] != -1 && myShape->_is_nil())
|
|
|
|
mySelBtn[MainObj1]->click();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// 2D
|
|
|
|
case MainObj2:
|
|
|
|
if (!myShape->_is_nil() && myFaces[Face1U] == -1)
|
|
|
|
mySelBtn[Face1U]->click();
|
|
|
|
break;
|
|
|
|
case Face1U:
|
|
|
|
if (myFaces[Face1U] != -1 && myFaces[Face2U] == -1)
|
|
|
|
mySelBtn[Face2U]->click();
|
|
|
|
break;
|
|
|
|
case Face2U:
|
|
|
|
if (myFaces[Face2U] != -1 && myFaces[Face1V] == -1)
|
|
|
|
mySelBtn[Face1V]->click();
|
|
|
|
break;
|
|
|
|
case Face1V:
|
|
|
|
if (myFaces[Face1V] != -1 && myFaces[Face2V] == -1)
|
|
|
|
mySelBtn[Face2V]->click();
|
|
|
|
break;
|
|
|
|
case Face2V:
|
|
|
|
if (myFaces[Face2V] != -1 && myShape->_is_nil())
|
|
|
|
mySelBtn[MainObj1]->click();
|
|
|
|
break;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
default:
|
|
|
|
break;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::SetEditCurrentArgument()
|
|
|
|
{
|
|
|
|
QPushButton* aSender = (QPushButton*)sender();
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// clear selection
|
|
|
|
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
|
|
|
|
if (myInitial)
|
|
|
|
myInitial = false;
|
|
|
|
else
|
|
|
|
myGeomGUI->getApp()->selectionMgr()->clearSelected();
|
|
|
|
|
|
|
|
// disable all
|
|
|
|
switch (myConstructorId) {
|
|
|
|
case 0:
|
|
|
|
mySelBtn[MainObj1]->setDown(false);
|
|
|
|
mySelBtn[Face1]->setDown(false);
|
|
|
|
mySelBtn[Face2]->setDown(false);
|
|
|
|
|
|
|
|
mySelName[MainObj1]->setEnabled(false);
|
|
|
|
mySelName[Face1]->setEnabled(false);
|
|
|
|
mySelName[Face2]->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
mySelBtn[MainObj2]->setDown(false);
|
|
|
|
mySelBtn[Face1U]->setDown(false);
|
|
|
|
mySelBtn[Face2U]->setDown(false);
|
|
|
|
mySelBtn[Face1V]->setDown(false);
|
|
|
|
mySelBtn[Face2V]->setDown(false);
|
|
|
|
|
|
|
|
mySelName[MainObj2]->setEnabled(false);
|
|
|
|
mySelName[Face1U]->setEnabled(false);
|
|
|
|
mySelName[Face2U]->setEnabled(false);
|
|
|
|
mySelName[Face1V]->setEnabled(false);
|
|
|
|
mySelName[Face2V]->setEnabled(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set line edit as current argument
|
2004-12-01 15:39:14 +05:00
|
|
|
QMap<int, QPushButton*>::iterator anIter;
|
|
|
|
for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) {
|
2009-02-13 17:16:39 +05:00
|
|
|
if (anIter.value() == aSender) {
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument = mySelName[anIter.key()];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// enable line edit
|
|
|
|
myEditCurrentArgument->setEnabled(true);
|
|
|
|
myEditCurrentArgument->setFocus();
|
|
|
|
|
|
|
|
// enable push button
|
|
|
|
// after setFocus(), because it will be setDown(false) when loses focus
|
|
|
|
aSender->setDown(true);
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
activateSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ActivateThisDialog()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::ActivateThisDialog()
|
|
|
|
{
|
|
|
|
GEOMBase_Skeleton::ActivateThisDialog();
|
|
|
|
activateSelection();
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
// ??
|
2004-12-01 15:39:14 +05:00
|
|
|
displayPreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
void BlocksGUI_TrsfDlg::enterEvent (QEvent*)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!mainFrame()->GroupConstructors->isEnabled())
|
|
|
|
ActivateThisDialog();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ValueChangedInSpinBox()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
void BlocksGUI_TrsfDlg::ValueChangedInSpinBox(int)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
displayPreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : createSelWg()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::createSelWg (const QString& theLbl,
|
|
|
|
QPixmap& thePix,
|
|
|
|
QWidget* theParent,
|
|
|
|
const int theId)
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
QLabel* lab = new QLabel(theLbl, theParent);
|
2004-12-01 15:39:14 +05:00
|
|
|
mySelBtn[theId] = new QPushButton(theParent);
|
2009-02-13 17:16:39 +05:00
|
|
|
mySelBtn[theId]->setIcon(thePix);
|
|
|
|
mySelBtn[theId]->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
|
2004-12-01 15:39:14 +05:00
|
|
|
mySelName[theId] = new QLineEdit(theParent);
|
|
|
|
mySelName[theId]->setReadOnly(true);
|
2009-02-13 17:16:39 +05:00
|
|
|
QGridLayout* l = 0;
|
|
|
|
if (!theParent->layout()) {
|
|
|
|
l = new QGridLayout(theParent);
|
|
|
|
l->setMargin(9); l->setSpacing(6);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
l = qobject_cast<QGridLayout*>(theParent->layout());
|
|
|
|
}
|
|
|
|
int row = l->rowCount();
|
|
|
|
l->addWidget(lab, row, 0);
|
|
|
|
l->addWidget(mySelBtn[theId], row, 1);
|
|
|
|
l->addWidget(mySelName[theId], row, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : createSpinWg()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::createSpinWg (const QString& theLbl,
|
|
|
|
QWidget* theParent,
|
|
|
|
const int theId)
|
|
|
|
{
|
|
|
|
QLabel* lab = new QLabel(theLbl, theParent);
|
2009-02-25 13:54:44 +05:00
|
|
|
mySpinBox[theId] = new SalomeApp_IntSpinBox(theParent);
|
2009-02-13 17:16:39 +05:00
|
|
|
QGridLayout* l = 0;
|
|
|
|
if (!theParent->layout()) {
|
|
|
|
l = new QGridLayout(theParent);
|
|
|
|
l->setMargin(9); l->setSpacing(6);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
l = qobject_cast<QGridLayout*>(theParent->layout());
|
|
|
|
}
|
|
|
|
int row = l->rowCount();
|
|
|
|
l->addWidget(lab, row, 0);
|
|
|
|
l->addWidget(mySpinBox[theId], row, 2);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : activateSelection
|
|
|
|
// purpose : Activate selection in accordance with myEditCurrentArgument
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::activateSelection()
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
globalSelection(GEOM_ALLSHAPES);
|
2004-12-01 15:39:14 +05:00
|
|
|
if (!myShape->_is_nil() &&
|
2009-02-13 17:16:39 +05:00
|
|
|
(myEditCurrentArgument == mySelName[Face1 ] ||
|
|
|
|
myEditCurrentArgument == mySelName[Face2 ] ||
|
|
|
|
myEditCurrentArgument == mySelName[Face1U] ||
|
|
|
|
myEditCurrentArgument == mySelName[Face2U] ||
|
|
|
|
myEditCurrentArgument == mySelName[Face1V] ||
|
|
|
|
myEditCurrentArgument == mySelName[Face2V]))
|
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
// Local selection is available only in the OCC Viewer
|
2009-02-13 17:16:39 +05:00
|
|
|
if (getDesktop()->activeWindow()->getViewManager()->getType() == OCCViewer_Viewer::Type()) {
|
2004-12-01 15:39:14 +05:00
|
|
|
localSelection(myShape, TopAbs_FACE);
|
|
|
|
}
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
|
|
|
|
this, SLOT(SelectionIntoArgument()));
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enableWidgets
|
|
|
|
// purpose : Enable widgets of faces in accordance with value of main object
|
|
|
|
//=================================================================================
|
|
|
|
void BlocksGUI_TrsfDlg::enableWidgets()
|
|
|
|
{
|
|
|
|
int anId = getConstructorId();
|
|
|
|
|
|
|
|
bool toEnable = !myShape->_is_nil();
|
|
|
|
|
|
|
|
if (anId == 0) {
|
2009-02-13 17:16:39 +05:00
|
|
|
//mySelName[Face1]->setEnabled(toEnable);
|
|
|
|
//mySelName[Face2]->setEnabled(toEnable);
|
|
|
|
//mySelBtn[Face1]->setEnabled(toEnable);
|
|
|
|
//mySelBtn[Face2]->setEnabled(toEnable);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!toEnable) {
|
2004-12-01 15:39:14 +05:00
|
|
|
mySelName[Face1]->setText("");
|
|
|
|
mySelName[Face2]->setText("");
|
|
|
|
myFaces[Face1] = -1;
|
|
|
|
myFaces[Face2] = -1;
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
else if (anId == 1) {
|
|
|
|
//mySelName[Face1U]->setEnabled(toEnable);
|
|
|
|
//mySelName[Face2U]->setEnabled(toEnable);
|
|
|
|
//mySelName[Face1V]->setEnabled(toEnable);
|
|
|
|
//mySelName[Face2V]->setEnabled(toEnable);
|
|
|
|
//mySelBtn[Face1U]->setEnabled(toEnable);
|
|
|
|
//mySelBtn[Face2U]->setEnabled(toEnable);
|
|
|
|
//mySelBtn[Face1V]->setEnabled(toEnable);
|
|
|
|
//mySelBtn[Face2V]->setEnabled(toEnable);
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
if (!toEnable) {
|
|
|
|
mySelName[Face1U]->setText("");
|
|
|
|
mySelName[Face2U]->setText("");
|
|
|
|
mySelName[Face1V]->setText("");
|
|
|
|
mySelName[Face2V]->setText("");
|
|
|
|
myFaces[Face1U] = -1;
|
|
|
|
myFaces[Face2U] = -1;
|
|
|
|
myFaces[Face1V] = -1;
|
|
|
|
myFaces[Face2V] = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : createOperation
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
GEOM::GEOM_IOperations_ptr BlocksGUI_TrsfDlg::createOperation()
|
|
|
|
{
|
|
|
|
return getGeomEngine()->GetIBlocksOperations(getStudyId());
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
// function : isValid
|
2004-12-01 15:39:14 +05:00
|
|
|
// purpose : Verify validity of input data
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
bool BlocksGUI_TrsfDlg::isValid (QString& msg)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
bool ok = false, okSP = true;
|
2004-12-01 15:39:14 +05:00
|
|
|
switch (getConstructorId()) {
|
2009-02-13 17:16:39 +05:00
|
|
|
case 0:
|
|
|
|
ok = !myShape->_is_nil() && myFaces[Face1] > 0;
|
|
|
|
okSP = mySpinBox[SpinBox1]->isValid( msg, !IsPreview() );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ok = !myShape->_is_nil() && myFaces[Face1U] > 0 && myFaces[Face1V] > 0;
|
|
|
|
okSP = mySpinBox[SpinBox2U]->isValid( msg, !IsPreview() ) && okSP;
|
|
|
|
okSP = mySpinBox[SpinBox2V]->isValid( msg, !IsPreview() ) && okSP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
return ok && okSP;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : execute
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool BlocksGUI_TrsfDlg::execute (ObjectList& objects)
|
|
|
|
{
|
|
|
|
bool res = false;
|
|
|
|
|
|
|
|
GEOM::GEOM_Object_var anObj;
|
|
|
|
|
2009-09-21 18:21:38 +06:00
|
|
|
GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation());
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
switch (getConstructorId()) {
|
2009-02-13 17:16:39 +05:00
|
|
|
case 0:
|
2009-09-21 18:21:38 +06:00
|
|
|
anObj = anOper->MakeMultiTransformation1D(myShape,
|
2009-12-25 16:28:58 +05:00
|
|
|
myFaces[Face1], myFaces[Face2],
|
|
|
|
mySpinBox[SpinBox1]->value());
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!anObj->_is_nil() && !IsPreview())
|
|
|
|
{
|
|
|
|
QStringList aParameters;
|
|
|
|
aParameters << "" << "";
|
|
|
|
aParameters << mySpinBox[SpinBox1]->text();
|
2009-09-21 18:21:38 +06:00
|
|
|
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
res = true;
|
|
|
|
break;
|
|
|
|
case 1:
|
2009-09-21 18:21:38 +06:00
|
|
|
anObj = anOper->MakeMultiTransformation2D (myShape,
|
2009-12-25 16:28:58 +05:00
|
|
|
myFaces[Face1U], myFaces[Face2U],
|
|
|
|
mySpinBox[SpinBox2U]->value(),
|
|
|
|
myFaces[Face1V], myFaces[Face2V],
|
|
|
|
mySpinBox[SpinBox2V]->value());
|
2009-02-13 17:16:39 +05:00
|
|
|
if (!anObj->_is_nil() && !IsPreview())
|
|
|
|
{
|
|
|
|
QStringList aParameters;
|
|
|
|
aParameters << "" << "";
|
|
|
|
aParameters << mySpinBox[SpinBox2U]->text();
|
|
|
|
aParameters << "" << "";
|
|
|
|
aParameters << mySpinBox[SpinBox2V]->text();
|
2009-09-21 18:21:38 +06:00
|
|
|
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
res = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!anObj->_is_nil())
|
|
|
|
objects.push_back(anObj._retn());
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|