Bugs 16640, 19050: Improve selection mechanism in GEOM dialog boxes.

This commit is contained in:
jfa 2008-09-26 06:25:05 +00:00
parent 8cee57a187
commit f82c26c9c5
16 changed files with 1309 additions and 1157 deletions

View File

@ -402,7 +402,7 @@ void BlocksGUI_BlockDlg::SetEditCurrentArgument()
// enable push button and line edit // enable push button and line edit
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus // after setFocus(), because it will be setDown(false) when loses focus
aSender->setDown(true); aSender->setDown(true);
globalSelection(); // close local contexts, if any globalSelection(); // close local contexts, if any

View File

@ -407,7 +407,7 @@ void BlocksGUI_QuadFaceDlg::SetEditCurrentArgument()
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// enable push button // enable push button
// after setFocus(), because it will be setDown(false) then loses focus // after setFocus(), because it will be setDown(false) when loses focus
aSender->setDown(true); aSender->setDown(true);
activateSelection(); activateSelection();

View File

@ -373,7 +373,7 @@ void BlocksGUI_TrsfDlg::SetEditCurrentArgument()
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// enable push button // enable push button
// after setFocus(), because it will be setDown(false) then loses focus // after setFocus(), because it will be setDown(false) when loses focus
aSender->setDown(true); aSender->setDown(true);
activateSelection(); activateSelection();

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : BooleanGUI_Dialog.cxx // File : BooleanGUI_Dialog.cxx
@ -30,8 +30,8 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
@ -42,78 +42,77 @@
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
BooleanGUI_Dialog::BooleanGUI_Dialog( const int theOperation, GeometryGUI* theGeometryGUI, BooleanGUI_Dialog::BooleanGUI_Dialog (const int theOperation, GeometryGUI* theGeometryGUI,
QWidget* parent, bool modal, Qt::WindowFlags fl ) QWidget* parent, bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ), : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myOperation( theOperation ) myOperation(theOperation)
{ {
QPixmap image0; QPixmap image0;
QString aTitle, aCaption; QString aTitle, aCaption;
switch ( myOperation ) { switch (myOperation) {
case BooleanGUI::COMMON: case BooleanGUI::COMMON:
image0 = QPixmap( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_COMMON" ) ) ); image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_COMMON")));
aTitle = tr( "GEOM_COMMON" ); aTitle = tr("GEOM_COMMON");
aCaption = tr( "GEOM_COMMON_TITLE" ); aCaption = tr("GEOM_COMMON_TITLE");
setHelpFileName( "common_operation_page.html" ); setHelpFileName("common_operation_page.html");
break; break;
case BooleanGUI::CUT: case BooleanGUI::CUT:
image0 = QPixmap( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CUT" ) ) ); image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CUT")));
aTitle = tr( "GEOM_CUT" ); aTitle = tr("GEOM_CUT");
aCaption = tr( "GEOM_CUT_TITLE" ); aCaption = tr("GEOM_CUT_TITLE");
setHelpFileName( "cut_operation_page.html" ); setHelpFileName("cut_operation_page.html");
break; break;
case BooleanGUI::FUSE: case BooleanGUI::FUSE:
image0 = QPixmap( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FUSE" ) ) ); image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FUSE")));
aTitle = tr( "GEOM_FUSE" ); aTitle = tr("GEOM_FUSE");
aCaption = tr( "GEOM_FUSE_TITLE" ); aCaption = tr("GEOM_FUSE_TITLE");
setHelpFileName( "fuse_operation_page.html" ); setHelpFileName("fuse_operation_page.html");
break; break;
case BooleanGUI::SECTION: case BooleanGUI::SECTION:
image0 = QPixmap( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SECTION" ) ) ); image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SECTION")));
aTitle = tr( "GEOM_SECTION" ); aTitle = tr("GEOM_SECTION");
aCaption = tr( "GEOM_SECTION_TITLE" ); aCaption = tr("GEOM_SECTION_TITLE");
setHelpFileName( "section_opeartion_page.html" ); setHelpFileName("section_opeartion_page.html");
break; break;
} }
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( aCaption ); setWindowTitle(aCaption);
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( aTitle ); mainFrame()->GroupConstructors->setTitle(aTitle);
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
myGroup = new DlgRef_2Sel( centralWidget() ); myGroup = new DlgRef_2Sel(centralWidget());
myGroup->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
if ( myOperation != BooleanGUI::CUT ) { if (myOperation != BooleanGUI::CUT) {
myGroup->TextLabel1->setText( tr( "GEOM_OBJECT_I" ).arg( 1 ) ); myGroup->TextLabel1->setText(tr("GEOM_OBJECT_I").arg(1));
myGroup->TextLabel2->setText( tr( "GEOM_OBJECT_I" ).arg( 2 ) ); myGroup->TextLabel2->setText(tr("GEOM_OBJECT_I").arg(2));
} }
else { else {
myGroup->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); myGroup->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
myGroup->TextLabel2->setText( tr( "GEOM_TOOL_OBJECT" ) ); myGroup->TextLabel2->setText(tr("GEOM_TOOL_OBJECT"));
} }
myGroup->PushButton1->setIcon( image1 );
myGroup->PushButton2->setIcon( image1 );
myGroup->LineEdit1->setReadOnly( true );
myGroup->LineEdit2->setReadOnly( true );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); myGroup->PushButton1->setIcon(image1);
layout->setMargin( 0 ); layout->setSpacing( 6 ); myGroup->PushButton2->setIcon(image1);
layout->addWidget( myGroup ); myGroup->LineEdit1->setReadOnly(true);
myGroup->LineEdit2->setReadOnly(true);
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(myGroup);
/***************************************************************/ /***************************************************************/
/* Initialisation */ // Initialisation
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~BooleanGUI_Dialog() // function : ~BooleanGUI_Dialog()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -122,7 +121,6 @@ BooleanGUI_Dialog::~BooleanGUI_Dialog()
{ {
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
@ -131,33 +129,39 @@ void BooleanGUI_Dialog::Init()
{ {
mainFrame()->GroupBoxPublish->show(); mainFrame()->GroupBoxPublish->show();
/* init variables */ // init variables
myEditCurrentArgument = myGroup->LineEdit1; myEditCurrentArgument = myGroup->LineEdit1;
/* signals and slots connections */ myGroup->LineEdit1->setText("");
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); myGroup->LineEdit2->setText("");
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); myObject1 = myObject2 = GEOM::GEOM_Object::_nil();
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( myGroup->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(myGroup->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( myGroup->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(myGroup->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( myGroup->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( myGroup->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
initName( mainFrame()->GroupConstructors->title() ); initName(mainFrame()->GroupConstructors->title());
setTabOrder( mainFrame()->GroupConstructors, mainFrame()->GroupBoxName ); setTabOrder(mainFrame()->GroupConstructors, mainFrame()->GroupBoxName);
setTabOrder( mainFrame()->GroupBoxName, mainFrame()->GroupMedium ); setTabOrder(mainFrame()->GroupBoxName, mainFrame()->GroupMedium);
setTabOrder( mainFrame()->GroupMedium, mainFrame()->GroupButtons ); setTabOrder(mainFrame()->GroupMedium, mainFrame()->GroupButtons);
mainFrame()->RadioButton1->setFocus(); mainFrame()->RadioButton1->setFocus();
globalSelection( GEOM_ALLSHAPES ); globalSelection(GEOM_ALLSHAPES);
}
myGroup->PushButton1->click();
SelectionIntoArgument();
}
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
@ -165,31 +169,32 @@ void BooleanGUI_Dialog::Init()
//================================================================================= //=================================================================================
void BooleanGUI_Dialog::ClickOnOk() void BooleanGUI_Dialog::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BooleanGUI_Dialog::ClickOnApply() bool BooleanGUI_Dialog::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate selection and connect selection manager
myGroup->PushButton1->click();
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void BooleanGUI_Dialog::SelectionIntoArgument() void BooleanGUI_Dialog::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
@ -204,10 +209,26 @@ void BooleanGUI_Dialog::SelectionIntoArgument()
// nbSel == 1 // nbSel == 1
Standard_Boolean aRes = Standard_False; Standard_Boolean aRes = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
if (!CORBA::is_nil(aSelectedObject) && aRes && GEOMBase::IsShape(aSelectedObject)) { if (!CORBA::is_nil(aSelectedObject) && aRes && GEOMBase::IsShape(aSelectedObject))
{
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
if (myEditCurrentArgument == myGroup->LineEdit1) myObject1 = aSelectedObject;
else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2 = aSelectedObject; // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == myGroup->LineEdit1) {
myObject1 = aSelectedObject;
if (myObject2->_is_nil())
myGroup->PushButton2->click();
}
else if (myEditCurrentArgument == myGroup->LineEdit2) {
myObject2 = aSelectedObject;
if (myObject1->_is_nil())
myGroup->PushButton1->click();
}
} }
} }
@ -219,14 +240,26 @@ void BooleanGUI_Dialog::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
if ( send == myGroup->PushButton1 ) myEditCurrentArgument = myGroup->LineEdit1; if (send == myGroup->PushButton1) {
else if ( send == myGroup->PushButton2 ) myEditCurrentArgument = myGroup->LineEdit2; myEditCurrentArgument = myGroup->LineEdit1;
myGroup->PushButton2->setDown(false);
myGroup->LineEdit2->setEnabled(false);
}
else if (send == myGroup->PushButton2) {
myEditCurrentArgument = myGroup->LineEdit2;
myGroup->PushButton1->setDown(false);
myGroup->LineEdit1->setEnabled(false);
}
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
} }
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
// purpose : // purpose :
@ -234,13 +267,12 @@ void BooleanGUI_Dialog::SetEditCurrentArgument()
void BooleanGUI_Dialog::LineEditReturnPressed() void BooleanGUI_Dialog::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == myGroup->LineEdit1 || send == myGroup->LineEdit2 ) { if (send == myGroup->LineEdit1 || send == myGroup->LineEdit2) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -248,19 +280,18 @@ void BooleanGUI_Dialog::LineEditReturnPressed()
void BooleanGUI_Dialog::ActivateThisDialog() void BooleanGUI_Dialog::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
globalSelection( GEOM_ALLSHAPES );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
}
// reinit, because some selected objects could be removed
Init();
}
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : when mouse enter onto the QWidget // purpose : when mouse enter onto the QWidget
//================================================================================= //=================================================================================
void BooleanGUI_Dialog::enterEvent( QEvent* ) void BooleanGUI_Dialog::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
@ -277,7 +308,7 @@ GEOM::GEOM_IOperations_ptr BooleanGUI_Dialog::createOperation()
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BooleanGUI_Dialog::isValid (QString& msg) bool BooleanGUI_Dialog::isValid (QString&)
{ {
//Handle(SALOME_InteractiveObject) IO = firstIObject(); //Handle(SALOME_InteractiveObject) IO = firstIObject();
//Standard_Boolean testResult; //Standard_Boolean testResult;
@ -292,14 +323,14 @@ bool BooleanGUI_Dialog::isValid (QString& msg)
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BooleanGUI_Dialog::execute( ObjectList& objects ) bool BooleanGUI_Dialog::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
anObj = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_IBooleanOperations::_narrow(getOperation())->
MakeBoolean( myObject1, myObject2, myOperation ); MakeBoolean(myObject1, myObject2, myOperation);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return true; return true;
} }
@ -308,13 +339,13 @@ bool BooleanGUI_Dialog::execute( ObjectList& objects )
// function : restoreSubShapes // function : restoreSubShapes
// purpose : // purpose :
//================================================================================= //=================================================================================
void BooleanGUI_Dialog::restoreSubShapes( SALOMEDS::Study_ptr theStudy, void BooleanGUI_Dialog::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject ) SALOMEDS::SObject_ptr theSObject)
{ {
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) { if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored // empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(), getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
/*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GEOM::FSM_GetSame /*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GEOM::FSM_GetSame
/*theInheritFirstArg=*/myOperation == BooleanGUI::CUT ); // ? false /*theInheritFirstArg=*/myOperation == BooleanGUI::CUT); // ? false
} }
} }

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : BuildGUI_EdgeDlg.cxx // File : BuildGUI_EdgeDlg.cxx
@ -29,59 +29,58 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <GEOMImpl_Types.hxx>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <GEOMImpl_Types.hxx>
//================================================================================= //=================================================================================
// class : BuildGUI_EdgeDlg() // class : BuildGUI_EdgeDlg()
// purpose : Constructs a BuildGUI_EdgeDlg which is a child of 'parent', with the // purpose : Constructs a BuildGUI_EdgeDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
BuildGUI_EdgeDlg::BuildGUI_EdgeDlg( GeometryGUI* theGeometryGUI, QWidget* parent ) BuildGUI_EdgeDlg::BuildGUI_EdgeDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
: GEOMBase_Skeleton( theGeometryGUI, parent ) : GEOMBase_Skeleton(theGeometryGUI, parent)
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BUILD_EDGE" ) ) ); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BUILD_EDGE")));
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_EDGE_TITLE" ) ); setWindowTitle(tr("GEOM_EDGE_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_EDGE" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_EDGE"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_2Sel( centralWidget() ); GroupPoints = new DlgRef_2Sel(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_POINTS" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_POINTS"));
GroupPoints->TextLabel1->setText( tr( "GEOM_POINT_I" ).arg( 1 ) ); GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg(1));
GroupPoints->TextLabel2->setText( tr( "GEOM_POINT_I" ).arg( 2 ) ); GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg(2));
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon(image1);
GroupPoints->PushButton2->setIcon( image1 ); GroupPoints->PushButton2->setIcon(image1);
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); GroupPoints->LineEdit1->setReadOnly(true);
layout->setMargin( 0 ); layout->setSpacing( 6 ); GroupPoints->LineEdit2->setReadOnly(true);
layout->addWidget( GroupPoints );
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
setHelpFileName("create_edge_page.html"); setHelpFileName("create_edge_page.html");
/* Initialisations */ // Initialisation
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~BuildGUI_EdgeDlg() // function : ~BuildGUI_EdgeDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -91,66 +90,65 @@ BuildGUI_EdgeDlg::~BuildGUI_EdgeDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BuildGUI_EdgeDlg::Init() void BuildGUI_EdgeDlg::Init()
{ {
/* init variables */ // init variables
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true );
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
myOkPoint1 = myOkPoint2 = false; myOkPoint1 = myOkPoint2 = false;
globalSelection( GEOM_POINT ); // signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
/* signals and slots connections */ connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); initName(tr("GEOM_EDGE"));
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_EDGE" ) ); GroupPoints->PushButton1->click();
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BuildGUI_EdgeDlg::ClickOnOk() void BuildGUI_EdgeDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BuildGUI_EdgeDlg::ClickOnApply() bool BuildGUI_EdgeDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate selection and connect selection manager
GroupPoints->PushButton1->click();
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void BuildGUI_EdgeDlg::SelectionIntoArgument() void BuildGUI_EdgeDlg::SelectionIntoArgument()
{ {
@ -172,20 +170,65 @@ void BuildGUI_EdgeDlg::SelectionIntoArgument()
// nbSel == 1 // nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult) if (!testResult || aSelectedObject->_is_nil())
return; return;
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
myOkPoint1 = true; myOkPoint1 = true;
if (!myOkPoint2)
GroupPoints->PushButton2->click();
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
myOkPoint2 = true; myOkPoint2 = true;
if (!myOkPoint1)
GroupPoints->PushButton1->click();
} }
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void BuildGUI_EdgeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
//globalSelection();//??
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
}
else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
}
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(GEOM_POINT);
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview(); displayPreview();
} }
@ -196,37 +239,12 @@ void BuildGUI_EdgeDlg::SelectionIntoArgument()
void BuildGUI_EdgeDlg::LineEditReturnPressed() void BuildGUI_EdgeDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2 ) { if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void BuildGUI_EdgeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
globalSelection();
if ( send == GroupPoints->PushButton1 ) {
myEditCurrentArgument = GroupPoints->LineEdit1;
globalSelection( GEOM_POINT );
}
else if ( send == GroupPoints->PushButton2 ) {
myEditCurrentArgument = GroupPoints->LineEdit2;
globalSelection( GEOM_POINT );
}
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -234,20 +252,18 @@ void BuildGUI_EdgeDlg::SetEditCurrentArgument()
void BuildGUI_EdgeDlg::ActivateThisDialog() void BuildGUI_EdgeDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
globalSelection( GEOM_POINT );
displayPreview();
}
// reinit, because some selected objects could be removed
Init();
}
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void BuildGUI_EdgeDlg::enterEvent( QEvent* ) void BuildGUI_EdgeDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
@ -257,14 +273,14 @@ void BuildGUI_EdgeDlg::enterEvent( QEvent* )
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr BuildGUI_EdgeDlg::createOperation() GEOM::GEOM_IOperations_ptr BuildGUI_EdgeDlg::createOperation()
{ {
return getGeomEngine()->GetIShapesOperations( getStudyId() ); return getGeomEngine()->GetIShapesOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BuildGUI_EdgeDlg::isValid( QString& ) bool BuildGUI_EdgeDlg::isValid (QString&)
{ {
return myOkPoint1 && myOkPoint2; return myOkPoint1 && myOkPoint2;
} }
@ -273,14 +289,14 @@ bool BuildGUI_EdgeDlg::isValid( QString& )
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool BuildGUI_EdgeDlg::execute( ObjectList& objects ) bool BuildGUI_EdgeDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeEdge( myPoint1, myPoint2 ); anObj = GEOM::GEOM_IShapesOperations::_narrow(getOperation())->MakeEdge(myPoint1, myPoint2);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return true; return true;
} }

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : GenerationGUI_PipeDlg.cxx // File : GenerationGUI_PipeDlg.cxx
@ -29,8 +29,8 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
@ -44,150 +44,145 @@
//================================================================================= //=================================================================================
// class : GenerationGUI_PipeDlg() // class : GenerationGUI_PipeDlg()
// purpose : Constructs a GenerationGUI_PipeDlg which is a child of 'parent', with the // purpose : Constructs a GenerationGUI_PipeDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
GenerationGUI_PipeDlg::GenerationGUI_PipeDlg( GeometryGUI* theGeometryGUI, QWidget* parent, GenerationGUI_PipeDlg::GenerationGUI_PipeDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl ) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_PIPE" ) ) ); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_PIPE")));
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_PIPE_TITLE" ) ); setWindowTitle(tr("GEOM_PIPE_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PIPE" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_PIPE"));
mainFrame()->RadioButton1->setIcon(image0); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_2Sel( centralWidget() ); GroupPoints = new DlgRef_2Sel(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
GroupPoints->TextLabel1->setText( tr( "GEOM_BASE_OBJECT" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_BASE_OBJECT"));
GroupPoints->TextLabel2->setText( tr( "GEOM_PATH_OBJECT" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_PATH_OBJECT"));
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon(image1);
GroupPoints->PushButton2->setIcon( image1 ); GroupPoints->PushButton2->setIcon(image1);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupPoints ); layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
setHelpFileName( "create_extrusion_alongpath_page.html" ); setHelpFileName("create_extrusion_alongpath_page.html");
/* Initialisations */ // Initialisation
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~GenerationGUI_PipeDlg() // function : ~GenerationGUI_PipeDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
//================================================================================= //=================================================================================
GenerationGUI_PipeDlg::~GenerationGUI_PipeDlg() GenerationGUI_PipeDlg::~GenerationGUI_PipeDlg()
{ {
/* no need to delete child widgets, Qt does it all for us */ // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_PipeDlg::Init() void GenerationGUI_PipeDlg::Init()
{ {
/* init variables */ // init variables
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true );
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myBase = myPath = GEOM::GEOM_Object::_nil();
myOkBase = myOkPath = false; myOkBase = myOkPath = false;
/* signals and slots connections */ // signals and slots connections
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_PIPE" ) ); initName(tr("GEOM_PIPE"));
//globalSelection( GEOM_ALLSHAPES ); GroupPoints->PushButton1->click();
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_PipeDlg::ClickOnOk() void GenerationGUI_PipeDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnAply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_PipeDlg::ClickOnApply() bool GenerationGUI_PipeDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate selection and connect selection manager
GroupPoints->PushButton1->click();
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void GenerationGUI_PipeDlg::SelectionIntoArgument() void GenerationGUI_PipeDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1) myOkBase = false;
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myOkPath = false;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1)
if (myEditCurrentArgument == GroupPoints->LineEdit1) myOkBase = false;
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myOkPath = false;
return; return;
}
// nbSel == 1 // nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult) if (!testResult || aSelectedObject->_is_nil())
return; return;
TopoDS_Shape S; TopoDS_Shape S;
if (!GEOMBase::GetShape(aSelectedObject, S))
return;
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myOkBase = false; if (S.ShapeType() == TopAbs_COMPSOLID ||
if (!GEOMBase::GetShape(aSelectedObject, S) ||
S.ShapeType() == TopAbs_COMPSOLID ||
S.ShapeType() == TopAbs_COMPOUND || S.ShapeType() == TopAbs_COMPOUND ||
S.ShapeType() == TopAbs_SOLID || S.ShapeType() == TopAbs_SOLID ||
S.ShapeType() == TopAbs_SHAPE) S.ShapeType() == TopAbs_SHAPE)
@ -196,49 +191,54 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument()
myBase = aSelectedObject; myBase = aSelectedObject;
myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject)); myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
myOkBase = true; myOkBase = true;
if (!myOkPath)
GroupPoints->PushButton2->click();
} }
else if (myEditCurrentArgument == GroupPoints->LineEdit2) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
myOkPath = false;
if (!GEOMBase::GetShape(aSelectedObject, S))
return;
QString aName = GEOMBase::GetName(aSelectedObject); QString aName = GEOMBase::GetName(aSelectedObject);
if (testResult && !aSelectedObject->_is_nil() && aSelectedObject != myBase) { if (aSelectedObject != myBase) {
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) { if (aMap.Extent() == 1) {
int anIndex = aMap(1); int anIndex = aMap(1);
aName.append(":edge_" + QString::number(anIndex)); aName.append(":edge_" + QString::number(anIndex));
//Find SubShape Object in Father //Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations(getStudyId()); getGeomEngine()->GetIShapesOperations(getStudyId());
myPath = aShapesOp->GetSubShape(aSelectedObject, anIndex); myPath = aShapesOp->GetSubShape(aSelectedObject, anIndex);
myOkPath = true; myOkPath = true;
} }
else { // get Object from study else { // get Object from study
myPath = aFindedObject; myPath = aFindedObject;
myOkPath = true; myOkPath = true;
} }
} }
else { else {
myOkPath = true; myOkPath = true;
if (S.ShapeType() != TopAbs_EDGE) { if (S.ShapeType() != TopAbs_EDGE) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
myOkPath = false; myOkPath = false;
} }
myPath = aSelectedObject; myPath = aSelectedObject;
} }
} }
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if (myOkPath && !myOkBase)
GroupPoints->PushButton1->click();
} }
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview(); displayPreview();
} }
@ -249,22 +249,33 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument()
void GenerationGUI_PipeDlg::SetEditCurrentArgument() void GenerationGUI_PipeDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
globalSelection();
if ( send == GroupPoints->PushButton1 ) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
GroupPoints->LineEdit1->setFocus(); globalSelection(GEOM_ALLSHAPES);
globalSelection( GEOM_ALLSHAPES ); if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
} }
else if ( send == GroupPoints->PushButton2 ) { else if (send == GroupPoints->PushButton2) {
GroupPoints->LineEdit2->setFocus();
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
globalSelection(); GroupPoints->PushButton1->setDown(false);
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); GroupPoints->LineEdit1->setEnabled(false);
}
SelectionIntoArgument();
}
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
@ -273,25 +284,13 @@ void GenerationGUI_PipeDlg::SetEditCurrentArgument()
void GenerationGUI_PipeDlg::LineEditReturnPressed() void GenerationGUI_PipeDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 || if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ) { send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void GenerationGUI_PipeDlg::enterEvent( QEvent* )
{
if ( !mainFrame()->GroupConstructors->isEnabled() )
ActivateThisDialog();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -299,12 +298,20 @@ void GenerationGUI_PipeDlg::enterEvent( QEvent* )
void GenerationGUI_PipeDlg::ActivateThisDialog() void GenerationGUI_PipeDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
globalSelection( GEOM_ALLSHAPES );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), // reinit, because some selected objects could be removed
SIGNAL( currentSelectionChanged() ), this, SLOT(SelectionIntoArgument() ) ); Init();
displayPreview();
} }
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void GenerationGUI_PipeDlg::enterEvent (QEvent*)
{
if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
@ -312,14 +319,14 @@ void GenerationGUI_PipeDlg::ActivateThisDialog()
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr GenerationGUI_PipeDlg::createOperation() GEOM::GEOM_IOperations_ptr GenerationGUI_PipeDlg::createOperation()
{ {
return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); return getGeomEngine()->GetI3DPrimOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_PipeDlg::isValid( QString& ) bool GenerationGUI_PipeDlg::isValid (QString&)
{ {
return myOkBase && myOkPath; return myOkBase && myOkPath;
} }
@ -328,20 +335,18 @@ bool GenerationGUI_PipeDlg::isValid( QString& )
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_PipeDlg::execute( ObjectList& objects ) bool GenerationGUI_PipeDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->MakePipe(myBase, myPath);
getOperation() )->MakePipe( myBase, myPath );
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : addSubshapeToStudy // function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection // purpose : virtual method to add new SubObjects if local selection
@ -352,6 +357,5 @@ void GenerationGUI_PipeDlg::addSubshapesToStudy()
objMap[GroupPoints->LineEdit2->text()] = myPath; objMap[GroupPoints->LineEdit2->text()] = myPath;
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : GenerationGUI_PrismDlg.cxx // File : GenerationGUI_PrismDlg.cxx
@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -45,171 +46,176 @@
//================================================================================= //=================================================================================
// class : GenerationGUI_PrismDlg() // class : GenerationGUI_PrismDlg()
// purpose : Constructs a GenerationGUI_PrismDlg which is a child of 'parent', with the // purpose : Constructs a GenerationGUI_PrismDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
GenerationGUI_PrismDlg::GenerationGUI_PrismDlg( GeometryGUI* theGeometryGUI, QWidget* parent, GenerationGUI_PrismDlg::GenerationGUI_PrismDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl ) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM")));
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM_2P" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM_2P")));
QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PRISM_DXDYDZ" ) ) ); QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_PRISM_DXDYDZ")));
setWindowTitle( tr( "GEOM_EXTRUSION_TITLE" ) ); setWindowTitle(tr("GEOM_EXTRUSION_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_EXTRUSION" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_EXTRUSION"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon( image2 ); mainFrame()->RadioButton2->setIcon(image2);
mainFrame()->RadioButton3->setIcon( image3 ); mainFrame()->RadioButton3->setIcon(image3);
mainFrame()->RadioButton1->setChecked( true ); mainFrame()->RadioButton1->setChecked(true);
myBothway = myBothway2 = myBothway3 = false; myBothway = myBothway2 = myBothway3 = false;
GroupPoints = new DlgRef_2Sel1Spin2Check( centralWidget() ); GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_EXTRUSION_BSV" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV"));
GroupPoints->TextLabel1->setText( tr( "GEOM_BASE" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_BASE"));
GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
GroupPoints->TextLabel3->setText( tr( "GEOM_HEIGHT" ) ); GroupPoints->TextLabel3->setText(tr("GEOM_HEIGHT"));
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon(image1);
GroupPoints->PushButton2->setIcon( image1 ); GroupPoints->PushButton2->setIcon(image1);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) ); GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY"));
GroupPoints->CheckButton1->setChecked( myBothway ); GroupPoints->CheckButton1->setChecked(myBothway);
GroupPoints->CheckButton2->setText( tr( "GEOM_REVERSE" ) ); GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
GroupPoints2 = new DlgRef_3Sel1Check( centralWidget() ); GroupPoints2 = new DlgRef_3Sel1Check(centralWidget());
GroupPoints2->GroupBox1->setTitle( tr( "GEOM_EXTRUSION_BSV_2P" ) ); GroupPoints2->GroupBox1->setTitle(tr("GEOM_EXTRUSION_BSV_2P"));
GroupPoints2->TextLabel1->setText( tr( "GEOM_BASE" ) ); GroupPoints2->TextLabel1->setText(tr("GEOM_BASE"));
GroupPoints2->TextLabel2->setText( tr( "GEOM_POINT_I" ).arg( 1 ) ); GroupPoints2->TextLabel2->setText(tr("GEOM_POINT_I").arg(1));
GroupPoints2->TextLabel3->setText( tr( "GEOM_POINT_I" ).arg( 2 ) ); GroupPoints2->TextLabel3->setText(tr("GEOM_POINT_I").arg(2));
GroupPoints2->PushButton1->setIcon( image1 ); GroupPoints2->PushButton1->setIcon(image1);
GroupPoints2->PushButton2->setIcon( image1 ); GroupPoints2->PushButton2->setIcon(image1);
GroupPoints2->PushButton3->setIcon( image1 ); GroupPoints2->PushButton3->setIcon(image1);
GroupPoints2->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) ); GroupPoints2->CheckButton1->setText(tr("GEOM_BOTHWAY"));
GroupPoints2->CheckButton1->setChecked( myBothway2 ); GroupPoints2->CheckButton1->setChecked(myBothway2);
GroupPoints3 = new DlgRef_1Sel3Spin1Check( centralWidget() ); GroupPoints3 = new DlgRef_1Sel3Spin1Check(centralWidget());
GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ")); GroupPoints3->GroupBox1->setTitle(tr("GEOM_EXTRUSION_DXDYDZ"));
GroupPoints3->TextLabel1->setText(tr("GEOM_BASE")); GroupPoints3->TextLabel1->setText(tr("GEOM_BASE"));
GroupPoints3->PushButton1->setIcon(image1); GroupPoints3->PushButton1->setIcon(image1);
GroupPoints3->TextLabel2->setText(tr("GEOM_DX")); GroupPoints3->TextLabel2->setText(tr("GEOM_DX"));
GroupPoints3->TextLabel3->setText(tr("GEOM_DY")); GroupPoints3->TextLabel3->setText(tr("GEOM_DY"));
GroupPoints3->TextLabel4->setText(tr("GEOM_DZ")); GroupPoints3->TextLabel4->setText(tr("GEOM_DZ"));
GroupPoints3->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) ); GroupPoints3->CheckButton1->setText(tr("GEOM_BOTHWAY"));
GroupPoints3->CheckButton1->setChecked( myBothway3 ); GroupPoints3->CheckButton1->setChecked(myBothway3);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupPoints ); layout->addWidget(GroupPoints);
layout->addWidget( GroupPoints2 ); layout->addWidget(GroupPoints2);
layout->addWidget( GroupPoints3); layout->addWidget(GroupPoints3);
/***************************************************************/ /***************************************************************/
setHelpFileName( "create_extrusion_page.html" ); setHelpFileName("create_extrusion_page.html");
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~GenerationGUI_PrismDlg() // function : ~GenerationGUI_PrismDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
//================================================================================= //=================================================================================
GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg() GenerationGUI_PrismDlg::~GenerationGUI_PrismDlg()
{ {
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::Init() void GenerationGUI_PrismDlg::Init()
{ {
/* init variables */ // Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
// min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPoints3->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3); // VSR:TODO : DBL_DIGITS_DISPLAY
initSpinBox(GroupPoints3->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3); // VSR:TODO : DBL_DIGITS_DISPLAY
initSpinBox(GroupPoints3->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3); // VSR:TODO : DBL_DIGITS_DISPLAY
GroupPoints3->SpinBox_DX->setValue(0.0);
GroupPoints3->SpinBox_DY->setValue(0.0);
GroupPoints3->SpinBox_DZ->setValue(0.0);
initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox_DX->setValue(100.0);
// init variables
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints2->LineEdit1->setReadOnly( true ); GroupPoints2->LineEdit1->setReadOnly(true);
GroupPoints2->LineEdit2->setReadOnly( true ); GroupPoints2->LineEdit2->setReadOnly(true);
GroupPoints2->LineEdit3->setReadOnly( true ); GroupPoints2->LineEdit3->setReadOnly(true);
GroupPoints3->LineEdit1->setReadOnly( true ); GroupPoints3->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
GroupPoints2->LineEdit1->setText("");
GroupPoints2->LineEdit2->setText("");
GroupPoints2->LineEdit3->setText("");
GroupPoints3->LineEdit1->setText("");
myPoint1 = myPoint2 = myBase = myVec = GEOM::GEOM_Object::_nil(); myPoint1 = myPoint2 = myBase = myVec = GEOM::GEOM_Object::_nil();
myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false; myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false;
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
/* min, max, step and decimals for spin boxes & initial values */ // signals and slots connections
initSpinBox( GroupPoints3->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
initSpinBox( GroupPoints3->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
initSpinBox( GroupPoints3->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
GroupPoints3->SpinBox_DX->setValue( 0.0 );
GroupPoints3->SpinBox_DY->setValue( 0.0 );
GroupPoints3->SpinBox_DZ->setValue( 0.0 );
initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
GroupPoints->SpinBox_DX->setValue( 100.0 );
/* signals and slots connections */ connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect(GroupPoints2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect(GroupPoints2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints2->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) ); connect(GroupPoints2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->CheckButton2, SIGNAL( toggled( bool ) ), this, SLOT( onReverse() ) ); connect(GroupPoints2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(GroupPoints2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect( GroupPoints2->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) ); connect(GroupPoints3->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints3->SpinBox_DZ, SIGNAL(valueChanged (double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints3->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect( GroupPoints2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); initName(tr("GEOM_EXTRUSION"));
connect( GroupPoints2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints3->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); ConstructorsClicked(0);
connect( GroupPoints3->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPoints3->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
connect( GroupPoints3->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
connect( GroupPoints3->SpinBox_DZ, SIGNAL( valueChanged ( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
connect( GroupPoints3->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) );
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_EXTRUSION" ) );
ConstructorsClicked( 0 );
} }
//================================================================================= //=================================================================================
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep( double step ) void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep (double step)
{ {
GroupPoints->SpinBox_DX->setSingleStep(step); GroupPoints->SpinBox_DX->setSingleStep(step);
GroupPoints3->SpinBox_DX->setSingleStep(step); GroupPoints3->SpinBox_DX->setSingleStep(step);
@ -217,109 +223,103 @@ void GenerationGUI_PrismDlg::SetDoubleSpinBoxStep( double step )
GroupPoints3->SpinBox_DZ->setSingleStep(step); GroupPoints3->SpinBox_DZ->setSingleStep(step);
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::ConstructorsClicked( int constructorId ) void GenerationGUI_PrismDlg::ConstructorsClicked (int constructorId)
{ {
erasePreview(); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
switch ( constructorId ) { switch (constructorId) {
case 0: case 0:
{ {
globalSelection( GEOM_ALLSHAPES );
GroupPoints2->hide(); GroupPoints2->hide();
GroupPoints3->hide(); GroupPoints3->hide();
GroupPoints->show(); GroupPoints->show();
myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(GroupPoints2->LineEdit1->text()); // keep base
GroupPoints->LineEdit1->setText( GroupPoints2->LineEdit1->text() ); // keep base GroupPoints->LineEdit2->setText("");
GroupPoints->LineEdit2->setText( "" );
myVec = GEOM::GEOM_Object::_nil(); myVec = GEOM::GEOM_Object::_nil();
myOkVec = false; myOkVec = false;
GroupPoints->PushButton1->click();
break; break;
} }
case 1: case 1:
{ {
globalSelection( GEOM_ALLSHAPES );
GroupPoints->hide(); GroupPoints->hide();
GroupPoints2->show(); GroupPoints2->show();
GroupPoints3->hide(); GroupPoints3->hide();
myEditCurrentArgument = GroupPoints2->LineEdit1; GroupPoints2->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
GroupPoints2->LineEdit1->setText( GroupPoints->LineEdit1->text() ); // keep base GroupPoints2->LineEdit2->setText("");
GroupPoints2->LineEdit2->setText( "" ); GroupPoints2->LineEdit3->setText("");
GroupPoints2->LineEdit3->setText( "" );
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
myOkPnt1 = myOkPnt2 = false; myOkPnt1 = myOkPnt2 = false;
GroupPoints2->PushButton1->click();
break; break;
} }
case 2: case 2:
{ {
globalSelection( GEOM_ALLSHAPES );
GroupPoints->hide(); GroupPoints->hide();
GroupPoints2->hide(); GroupPoints2->hide();
GroupPoints3->show(); GroupPoints3->show();
myEditCurrentArgument = GroupPoints3->LineEdit1; GroupPoints3->LineEdit1->setText(GroupPoints->LineEdit1->text()); // keep base
GroupPoints3->LineEdit1->setText( GroupPoints->LineEdit1->text() ); // keep base
GroupPoints3->PushButton1->click();
break;
} }
} }
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
myEditCurrentArgument->setFocus(); if (myInitial) {
connect( myGeomGUI->getApp()->selectionMgr(), myInitial = false;
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if ( !myOkBase )
SelectionIntoArgument(); SelectionIntoArgument();
}
else {
displayPreview();
}
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::ClickOnOk() void GenerationGUI_PrismDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_PrismDlg::ClickOnApply() bool GenerationGUI_PrismDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection has changed // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::SelectionIntoArgument() void GenerationGUI_PrismDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
@ -339,60 +339,68 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument()
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object_var aSelectedObject =
GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult) if (!testResult || CORBA::is_nil(aSelectedObject))
return; return;
QString aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
bool myOk = true; bool myOk = true;
TopoDS_Shape aShape; TopoDS_Shape aShape;
QString aName = GEOMBase::GetName( aSelectedObject ); if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { {
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) { if (aMap.Extent() == 1) {
int anIndex = aMap(1); int anIndex = aMap(1);
aName.append( ":edge_" + QString::number( anIndex ) ); aName.append(":edge_" + QString::number(anIndex));
//Find SubShape Object in Father //Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations( getStudyId() ); getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
} }
else { else {
aSelectedObject = aFindedObject; // get Object from study aSelectedObject = aFindedObject; // get Object from study
} }
} }
else { else { // Global Selection
if ( aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2 ) { if (aShape.ShapeType() != TopAbs_EDGE && myEditCurrentArgument == GroupPoints->LineEdit2) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
myOk = false; myOk = false;
} }
} }
} }
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { myEditCurrentArgument->setText(aName);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
myBase = aSelectedObject; myBase = aSelectedObject;
myOkBase = true; myOkBase = true;
if (!myOkVec)
GroupPoints->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && myOk ) { else if (myEditCurrentArgument == GroupPoints->LineEdit2 && myOk) {
myOkVec = true; myOkVec = true;
myVec = aSelectedObject; myVec = aSelectedObject;
if (!myOkBase)
GroupPoints->PushButton1->click();
} }
myEditCurrentArgument->setText( aName );
} }
else if (getConstructorId() == 1) { // getConstructorId()==1 - extrusion using 2 points else if (getConstructorId() == 1) { // getConstructorId()==1 - extrusion using 2 points
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1) {
if (myEditCurrentArgument == GroupPoints2->LineEdit1) if (myEditCurrentArgument == GroupPoints2->LineEdit1)
myOkBase = false; myOkBase = false;
else if (myEditCurrentArgument == GroupPoints2->LineEdit2) { else if (myEditCurrentArgument == GroupPoints2->LineEdit2) {
myPoint1 = GEOM::GEOM_Object::_nil(); myPoint1 = GEOM::GEOM_Object::_nil();
myOkPnt1 = false; myOkPnt1 = false;
} }
else if (myEditCurrentArgument == GroupPoints2->LineEdit3) { else if (myEditCurrentArgument == GroupPoints2->LineEdit3) {
myPoint2 = GEOM::GEOM_Object::_nil(); myPoint2 = GEOM::GEOM_Object::_nil();
myOkPnt2 = false; myOkPnt2 = false;
} }
return; return;
@ -411,45 +419,51 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument()
bool myOk = true; bool myOk = true;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) { if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) {
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap ); aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) { if (aMap.Extent() == 1) {
int anIndex = aMap(1); int anIndex = aMap(1);
aName.append( ":vertex_" + QString::number( anIndex ) ); aName.append(":vertex_" + QString::number(anIndex));
//Find SubShape Object in Father //Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName ); GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
} }
else { else {
aSelectedObject = aFindedObject; aSelectedObject = aFindedObject;
} }
} }
else { else {
if ( ( aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit2 ) || if ((aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit2) ||
( aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit3 ) ) { (aShape.ShapeType() != TopAbs_VERTEX && myEditCurrentArgument == GroupPoints2->LineEdit3)) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
myOk = false; myOk = false;
} }
} }
} }
myEditCurrentArgument->setText( aName ); myEditCurrentArgument->setText(aName);
if ( myEditCurrentArgument == GroupPoints2->LineEdit1 ) { if (myEditCurrentArgument == GroupPoints2->LineEdit1) {
myOkBase = true; myOkBase = true;
myBase = aSelectedObject; myBase = aSelectedObject;
if (!myOkPnt1)
GroupPoints2->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk ) { else if (myEditCurrentArgument == GroupPoints2->LineEdit2 && myOk) {
myOkPnt1 = true; myOkPnt1 = true;
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
if (!myOkPnt2)
GroupPoints2->PushButton3->click();
} }
else if ( myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk ) { else if (myEditCurrentArgument == GroupPoints2->LineEdit3 && myOk) {
myOkPnt2 = true; myOkPnt2 = true;
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if (!myOkBase)
GroupPoints2->PushButton1->click();
} }
} }
else if (getConstructorId() == 2) { // extrusion using dx dy dz else if (getConstructorId() == 2) { // extrusion using dx dy dz
@ -465,6 +479,12 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument()
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
} }
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview(); displayPreview();
} }
@ -475,40 +495,58 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument()
void GenerationGUI_PrismDlg::SetEditCurrentArgument() void GenerationGUI_PrismDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
globalSelection( GEOM_ALLSHAPES );
if ( send == GroupPoints->PushButton1 ) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
GroupPoints->LineEdit1->setFocus(); globalSelection(GEOM_ALLSHAPES);
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
} }
else if ( send == GroupPoints->PushButton2 ) { else if (send == GroupPoints->PushButton2) {
GroupPoints->LineEdit2->setFocus();
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
} }
else if ( send == GroupPoints2->PushButton1 ) { else if (send == GroupPoints2->PushButton1) {
GroupPoints2->LineEdit1->setFocus();
myEditCurrentArgument = GroupPoints2->LineEdit1; myEditCurrentArgument = GroupPoints2->LineEdit1;
GroupPoints2->PushButton2->setDown(false);
GroupPoints2->PushButton3->setDown(false);
GroupPoints2->LineEdit2->setEnabled(false);
GroupPoints2->LineEdit3->setEnabled(false);
} }
else if ( send == GroupPoints2->PushButton2 ) { else if (send == GroupPoints2->PushButton2) {
GroupPoints2->LineEdit2->setFocus();
myEditCurrentArgument = GroupPoints2->LineEdit2; myEditCurrentArgument = GroupPoints2->LineEdit2;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupPoints2->PushButton1->setDown(false);
GroupPoints2->PushButton3->setDown(false);
GroupPoints2->LineEdit1->setEnabled(false);
GroupPoints2->LineEdit3->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
else if ( send == GroupPoints2->PushButton3 ) { else if (send == GroupPoints2->PushButton3) {
GroupPoints2->LineEdit3->setFocus();
myEditCurrentArgument = GroupPoints2->LineEdit3; myEditCurrentArgument = GroupPoints2->LineEdit3;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); GroupPoints2->PushButton1->setDown(false);
GroupPoints2->PushButton2->setDown(false);
GroupPoints2->LineEdit1->setEnabled(false);
GroupPoints2->LineEdit2->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
} }
else if ( send == GroupPoints3->PushButton1 ) { else if (send == GroupPoints3->PushButton1) {
GroupPoints3->LineEdit1->setFocus();
myEditCurrentArgument = GroupPoints3->LineEdit1; myEditCurrentArgument = GroupPoints3->LineEdit1;
} }
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
SelectionIntoArgument(); // after setFocus(), because it will be setDown(false) when loses focus
} send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
@ -517,28 +555,17 @@ void GenerationGUI_PrismDlg::SetEditCurrentArgument()
void GenerationGUI_PrismDlg::LineEditReturnPressed() void GenerationGUI_PrismDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 || if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 || send == GroupPoints->LineEdit2 ||
send == GroupPoints2->LineEdit1 || send == GroupPoints2->LineEdit1 ||
send == GroupPoints2->LineEdit2 || send == GroupPoints2->LineEdit2 ||
send == GroupPoints2->LineEdit3 || send == GroupPoints2->LineEdit3 ||
send == GroupPoints3->LineEdit1) { send == GroupPoints3->LineEdit1) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void GenerationGUI_PrismDlg::enterEvent( QEvent* )
{
if ( !mainFrame()->GroupConstructors->isEnabled() )
ActivateThisDialog();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -547,12 +574,19 @@ void GenerationGUI_PrismDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), // reinit, because some selected objects could be removed
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); Init();
ConstructorsClicked( getConstructorId() );
} }
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void GenerationGUI_PrismDlg::enterEvent (QEvent*)
{
if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
@ -563,7 +597,6 @@ void GenerationGUI_PrismDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : getHeight() // function : getHeight()
// purpose : // purpose :
@ -579,96 +612,98 @@ double GenerationGUI_PrismDlg::getHeight() const
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation() GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation()
{ {
return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); return getGeomEngine()->GetI3DPrimOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_PrismDlg::isValid( QString& ) bool GenerationGUI_PrismDlg::isValid (QString&)
{ {
if ( getConstructorId() == 0 ) if (getConstructorId() == 0)
return ( myOkBase && myOkVec ); // by vector and height return (myOkBase && myOkVec); // by vector and height
else if ( getConstructorId() == 1 ) else if (getConstructorId() == 1)
return ( myOkBase && myOkPnt1 && myOkPnt2 ); // by two points return (myOkBase && myOkPnt1 && myOkPnt2); // by two points
else if ( getConstructorId() == 2 ) else if (getConstructorId() == 2)
return true; return true;
return false;
} }
//================================================================================= //=================================================================================
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_PrismDlg::execute( ObjectList& objects ) bool GenerationGUI_PrismDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0 : case 0:
if ( !myBothway ) { if (!myBothway) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakePrismVecH( myBase, myVec, getHeight() ); MakePrismVecH(myBase, myVec, getHeight());
} }
else { else {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakePrismVecH2Ways( myBase, myVec, getHeight() ); MakePrismVecH2Ways(myBase, myVec, getHeight());
} }
break; break;
case 1 : case 1:
if ( !myBothway2 ) { if (!myBothway2) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakePrismTwoPnt( myBase, myPoint1, myPoint2 ); MakePrismTwoPnt(myBase, myPoint1, myPoint2);
} }
else { else {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakePrismTwoPnt2Ways( myBase, myPoint1, myPoint2 ); MakePrismTwoPnt2Ways(myBase, myPoint1, myPoint2);
} }
break; break;
case 2 : case 2:
double dx = GroupPoints3->SpinBox_DX->value(); double dx = GroupPoints3->SpinBox_DX->value();
double dy = GroupPoints3->SpinBox_DY->value(); double dy = GroupPoints3->SpinBox_DY->value();
double dz = GroupPoints3->SpinBox_DZ->value(); double dz = GroupPoints3->SpinBox_DZ->value();
if ( !myBothway3 ) { if (!myBothway3) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakePrismDXDYDZ( myBase, dx, dy, dz ); MakePrismDXDYDZ(myBase, dx, dy, dz);
} }
else { else {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakePrismDXDYDZ2Ways( myBase, dx, dy, dz ); MakePrismDXDYDZ2Ways(myBase, dx, dy, dz);
} }
break; break;
} }
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() ); if (!anObj->_is_nil())
objects.push_back(anObj._retn());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : onReverse() // function : onReverse()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::onReverse() void GenerationGUI_PrismDlg::onReverse()
{ {
double anOldValue = GroupPoints->SpinBox_DX->value(); double anOldValue = GroupPoints->SpinBox_DX->value();
GroupPoints->SpinBox_DX->setValue( -anOldValue ); GroupPoints->SpinBox_DX->setValue(-anOldValue);
} }
//================================================================================= //=================================================================================
// function : onBothway() // function : onBothway()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_PrismDlg::onBothway() void GenerationGUI_PrismDlg::onBothway()
{ {
bool anOldValue; bool anOldValue;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
anOldValue = myBothway; anOldValue = myBothway;
myBothway = !anOldValue; myBothway = !anOldValue;
GroupPoints->CheckButton2->setEnabled( !myBothway ); GroupPoints->CheckButton2->setEnabled(!myBothway);
displayPreview(); displayPreview();
break; break;
case 1: case 1:
@ -692,7 +727,7 @@ void GenerationGUI_PrismDlg::addSubshapesToStudy()
{ {
QMap<QString, GEOM::GEOM_Object_var> objMap; QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
objMap[GroupPoints->LineEdit2->text()] = myVec; objMap[GroupPoints->LineEdit2->text()] = myVec;
break; break;
@ -701,5 +736,5 @@ void GenerationGUI_PrismDlg::addSubshapesToStudy()
objMap[GroupPoints2->LineEdit3->text()] = myPoint2; objMap[GroupPoints2->LineEdit3->text()] = myPoint2;
break; break;
} }
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }

View File

@ -69,6 +69,9 @@ private:
bool myBothway2; bool myBothway2;
bool myBothway3; bool myBothway3;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_2Sel1Spin2Check* GroupPoints; DlgRef_2Sel1Spin2Check* GroupPoints;
DlgRef_3Sel1Check* GroupPoints2; // for second layout for extrusion using 2 points DlgRef_3Sel1Check* GroupPoints2; // for second layout for extrusion using 2 points
DlgRef_1Sel3Spin1Check* GroupPoints3; DlgRef_1Sel3Spin1Check* GroupPoints3;

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : GenerationGUI_RevolDlg.cxx // File : GenerationGUI_RevolDlg.cxx
@ -29,8 +29,8 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
@ -46,53 +46,52 @@
//================================================================================= //=================================================================================
// class : GenerationGUI_RevolDlg() // class : GenerationGUI_RevolDlg()
// purpose : Constructs a GenerationGUI_RevolDlg which is a child of 'parent', with the // purpose : Constructs a GenerationGUI_RevolDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
GenerationGUI_RevolDlg::GenerationGUI_RevolDlg( GeometryGUI* theGeometryGUI, QWidget* parent, GenerationGUI_RevolDlg::GenerationGUI_RevolDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl ) bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REVOL" ) ) ); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_REVOL")));
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_REVOLUTION_TITLE" ) ); setWindowTitle(tr("GEOM_REVOLUTION_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_REVOLUTION" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_REVOLUTION"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close(); mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
myBothway = false; myBothway = false;
GroupPoints = new DlgRef_2Sel1Spin2Check( centralWidget() ); GroupPoints = new DlgRef_2Sel1Spin2Check(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT"));
GroupPoints->TextLabel2->setText( tr( "GEOM_AXIS" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_AXIS"));
GroupPoints->TextLabel3->setText( tr( "GEOM_ANGLE" ) ); GroupPoints->TextLabel3->setText(tr("GEOM_ANGLE"));
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon(image1);
GroupPoints->PushButton2->setIcon( image1 ); GroupPoints->PushButton2->setIcon(image1);
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->CheckButton1->setText( tr( "GEOM_BOTHWAY" ) ); GroupPoints->CheckButton1->setText(tr("GEOM_BOTHWAY"));
GroupPoints->CheckButton2->setText( tr( "GEOM_REVERSE" ) ); GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupPoints ); layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
setHelpFileName( "create_revolution_page.html" ); setHelpFileName("create_revolution_page.html");
/* Initialisations */ // Initialisation
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~GenerationGUI_RevolDlg() // function : ~GenerationGUI_RevolDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -102,83 +101,79 @@ GenerationGUI_RevolDlg::~GenerationGUI_RevolDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_RevolDlg::Init() void GenerationGUI_RevolDlg::Init()
{ {
/* init variables */ // min, max, step and decimals for spin boxes & initial values
myEditCurrentArgument = GroupPoints->LineEdit1; double SpecificStep = 5;
GroupPoints->LineEdit1->setReadOnly( true ); initSpinBox(GroupPoints->SpinBox_DX, 0.0, 360.0, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->SpinBox_DX->setValue(45.0);
// init variables
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
myBase = myAxis = GEOM::GEOM_Object::_nil();
myOkBase = myOkAxis = false; myOkBase = myOkAxis = false;
double SpecificStep = 5; // signals and slots connections
/* min, max, step and decimals for spin boxes & initial values */ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
//initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
// 05.06.2008 skl for IPAL12958
initSpinBox( GroupPoints->SpinBox_DX, 0.0, 360.0, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox_DX->setValue( 45.0 );
/* signals and slots connections */ connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse()));
connect( GroupPoints->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect( GroupPoints->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( onBothway() ) );
connect( GroupPoints->CheckButton2, SIGNAL( toggled( bool ) ), this, SLOT( onReverse() ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); initName(tr("GEOM_REVOLUTION"));
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), GroupPoints->PushButton1->click();
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); SelectionIntoArgument();
initName( tr( "GEOM_REVOLUTION" ) );
globalSelection( GEOM_ALLSHAPES );
} }
//================================================================================= //=================================================================================
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
//================================================================================= //=================================================================================
void GenerationGUI_RevolDlg::SetDoubleSpinBoxStep( double step ) void GenerationGUI_RevolDlg::SetDoubleSpinBoxStep (double step)
{ {
GroupPoints->SpinBox_DX->setSingleStep(step); GroupPoints->SpinBox_DX->setSingleStep(step);
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_RevolDlg::ClickOnOk() void GenerationGUI_RevolDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_RevolDlg::ClickOnApply() bool GenerationGUI_RevolDlg::ClickOnApply()
{ {
if ( !onAccept() ) if (!onAccept())
return false; return false;
initName(); initName();
// activate selection and connect selection manager
GroupPoints->PushButton1->click();
return true; return true;
} }
@ -186,10 +181,9 @@ bool GenerationGUI_RevolDlg::ClickOnApply()
//function : isAcceptableBase //function : isAcceptableBase
//purpose : return true if theBase can be used as algo argument //purpose : return true if theBase can be used as algo argument
//======================================================================= //=======================================================================
static bool isAcceptableBase (const TopoDS_Shape& theBase)
static bool isAcceptableBase( const TopoDS_Shape& theBase )
{ {
switch ( theBase.ShapeType() ) { switch (theBase.ShapeType()) {
case TopAbs_VERTEX: case TopAbs_VERTEX:
case TopAbs_EDGE: case TopAbs_EDGE:
case TopAbs_WIRE: case TopAbs_WIRE:
@ -200,7 +194,7 @@ static bool isAcceptableBase( const TopoDS_Shape& theBase )
case TopAbs_COMPSOLID: case TopAbs_COMPSOLID:
return false; return false;
case TopAbs_COMPOUND: { case TopAbs_COMPOUND: {
TopExp_Explorer exp( theBase, TopAbs_SOLID ); TopExp_Explorer exp(theBase, TopAbs_SOLID);
return !exp.More(); return !exp.More();
} }
default: default:
@ -211,83 +205,85 @@ static bool isAcceptableBase( const TopoDS_Shape& theBase )
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void GenerationGUI_RevolDlg::SelectionIntoArgument() void GenerationGUI_RevolDlg::SelectionIntoArgument()
{ {
erasePreview(); erasePreview();
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1) myOkBase = false;
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myOkAxis = false;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1)
if ( myEditCurrentArgument == GroupPoints->LineEdit1 )
myOkBase = false;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 )
myOkAxis = false;
return; return;
}
// nbSel == 1 // nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
QString aName = GEOMBase::GetName( aSelectedObject );
if (!testResult || aSelectedObject->_is_nil())
if ( !testResult )
return; return;
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { TopoDS_Shape S;
TopoDS_Shape S; if (!GEOMBase::GetShape(aSelectedObject, S) || S.IsNull())
myOkBase = false; return;
if ( !GEOMBase::GetShape(aSelectedObject, S) || !isAcceptableBase( S ) ) QString aName = GEOMBase::GetName(aSelectedObject);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
if (!isAcceptableBase(S))
return; return;
myBase = aSelectedObject; myBase = aSelectedObject;
myOkBase = true; myOkBase = true;
myEditCurrentArgument->setText(aName);
if (!myOkAxis)
GroupPoints->PushButton2->click();
} }
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
if ( testResult && !aSelectedObject->_is_nil() ) { TColStd_IndexedMapOfInteger aMap;
TopoDS_Shape aShape; aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) {
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { int anIndex = aMap(1);
TColStd_IndexedMapOfInteger aMap; aName.append(":edge_" + QString::number(anIndex));
aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) { //Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
int anIndex = aMap( 1 );
aName.append( ":edge_" + QString::number( anIndex ) ); if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp =
//Find SubShape Object in Father getGeomEngine()->GetIShapesOperations(getStudyId());
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName ); myAxis = aShapesOp->GetSubShape(aSelectedObject, anIndex);
myOkAxis = true;
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study }
GEOM::GEOM_IShapesOperations_var aShapesOp = else {
getGeomEngine()->GetIShapesOperations( getStudyId() ); myAxis = aFindedObject;
myAxis = aShapesOp->GetSubShape( aSelectedObject, anIndex ); myOkAxis = true;
myOkAxis = true;
}
else {
myAxis = aFindedObject;
myOkAxis = true;
}
}
else {
myOkAxis = true;
if ( aShape.ShapeType() != TopAbs_EDGE ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
myOkAxis = false;
}
myAxis = aSelectedObject;
}
} }
} }
else {
myOkAxis = true;
if (S.ShapeType() != TopAbs_EDGE) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
myOkAxis = false;
}
myAxis = aSelectedObject;
}
myEditCurrentArgument->setText(aName);
if (myOkAxis && !myOkBase)
GroupPoints->PushButton1->click();
} }
myEditCurrentArgument->setText( aName ); // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview(); displayPreview();
} }
@ -299,36 +295,47 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument()
void GenerationGUI_RevolDlg::SetEditCurrentArgument() void GenerationGUI_RevolDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
globalSelection( GEOM_ALLSHAPES );
if ( send == GroupPoints->PushButton1 ) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
GroupPoints->LineEdit1->setFocus(); globalSelection(GEOM_ALLSHAPES);
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1; myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
} }
else if ( send == GroupPoints->PushButton2 ) { else if (send == GroupPoints->PushButton2) {
GroupPoints->LineEdit2->setFocus();
myEditCurrentArgument = GroupPoints->LineEdit2; myEditCurrentArgument = GroupPoints->LineEdit2;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE ); GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
} }
SelectionIntoArgument(); connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
} this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_RevolDlg::LineEditReturnPressed() void GenerationGUI_RevolDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 || if (send == GroupPoints->LineEdit1 ||
send == GroupPoints->LineEdit2 ) { send == GroupPoints->LineEdit2) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -336,25 +343,21 @@ void GenerationGUI_RevolDlg::LineEditReturnPressed()
void GenerationGUI_RevolDlg::ActivateThisDialog() void GenerationGUI_RevolDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
globalSelection( GEOM_ALLSHAPES );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT( SelectionIntoArgument() ) );
GroupPoints->LineEdit1->setFocus();
myEditCurrentArgument = GroupPoints->LineEdit1;
displayPreview();
}
// reinit, because some selected objects could be removed
Init();
}
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void GenerationGUI_RevolDlg::enterEvent( QEvent* ) void GenerationGUI_RevolDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -364,7 +367,6 @@ void GenerationGUI_RevolDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : getAngle() // function : getAngle()
// purpose : // purpose :
@ -380,14 +382,14 @@ double GenerationGUI_RevolDlg::getAngle() const
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr GenerationGUI_RevolDlg::createOperation() GEOM::GEOM_IOperations_ptr GenerationGUI_RevolDlg::createOperation()
{ {
return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); return getGeomEngine()->GetI3DPrimOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_RevolDlg::isValid( QString& ) bool GenerationGUI_RevolDlg::isValid (QString&)
{ {
return myOkBase && myOkAxis; return myOkBase && myOkAxis;
} }
@ -396,26 +398,25 @@ bool GenerationGUI_RevolDlg::isValid( QString& )
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_RevolDlg::execute( ObjectList& objects ) bool GenerationGUI_RevolDlg::execute (ObjectList& objects)
{ {
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
if ( !myBothway ) { if (!myBothway) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
getOperation() )->MakeRevolutionAxisAngle( myBase, myAxis, getAngle() * PI180 ); MakeRevolutionAxisAngle(myBase, myAxis, getAngle() * PI180);
} }
else { else {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
getOperation() )->MakeRevolutionAxisAngle2Ways( myBase, myAxis, getAngle() * PI180 ); MakeRevolutionAxisAngle2Ways(myBase, myAxis, getAngle() * PI180);
} }
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : onReverse() // function : onReverse()
// purpose : // purpose :
@ -423,10 +424,9 @@ bool GenerationGUI_RevolDlg::execute( ObjectList& objects )
void GenerationGUI_RevolDlg::onReverse() void GenerationGUI_RevolDlg::onReverse()
{ {
double anOldValue = GroupPoints->SpinBox_DX->value(); double anOldValue = GroupPoints->SpinBox_DX->value();
GroupPoints->SpinBox_DX->setValue( -anOldValue ); GroupPoints->SpinBox_DX->setValue(-anOldValue);
} }
//================================================================================= //=================================================================================
// function : onBothway() // function : onBothway()
// purpose : // purpose :
@ -435,7 +435,7 @@ void GenerationGUI_RevolDlg::onBothway()
{ {
bool anOldValue = myBothway; bool anOldValue = myBothway;
myBothway = !anOldValue; myBothway = !anOldValue;
GroupPoints->CheckButton2->setEnabled( !myBothway ); GroupPoints->CheckButton2->setEnabled(!myBothway);
displayPreview(); displayPreview();
} }
@ -449,5 +449,5 @@ void GenerationGUI_RevolDlg::addSubshapesToStudy()
objMap[GroupPoints->LineEdit2->text()] = myAxis; objMap[GroupPoints->LineEdit2->text()] = myAxis;
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }

View File

@ -349,7 +349,7 @@ void PrimitiveGUI_BoxDlg::SetEditCurrentArgument()
// enable line edit // enable line edit
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true); send->setDown(true);
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
@ -357,6 +357,9 @@ void PrimitiveGUI_BoxDlg::SetEditCurrentArgument()
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument())); this, SLOT(SelectionIntoArgument()));
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
} }
//================================================================================= //=================================================================================

View File

@ -371,8 +371,11 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument()
// enable line edit // enable line edit
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true); send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
} }
//================================================================================= //=================================================================================

View File

@ -367,8 +367,11 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument()
// enable line edit // enable line edit
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true); send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview();
} }
//================================================================================= //=================================================================================

View File

@ -464,7 +464,7 @@ void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
// enable line edit // enable line edit
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true); send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change // seems we need it only to avoid preview disappearing, caused by selection mode change

View File

@ -121,7 +121,6 @@ void PrimitiveGUI_TorusDlg::Init()
initSpinBox(GroupDimensions->SpinBox_DY, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupDimensions->SpinBox_DY, 0.001, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
// init variables // init variables
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly(true); GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true); GroupPoints->LineEdit2->setReadOnly(true);
@ -138,7 +137,7 @@ void PrimitiveGUI_TorusDlg::Init()
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
@ -254,17 +253,15 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument()
erasePreview(); erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() != 1) { if (aSelList.Extent() != 1)
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myPoint = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2)
myDir = GEOM::GEOM_Object::_nil();
return; return;
}
// nbSel == 1 // nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
@ -367,7 +364,7 @@ void PrimitiveGUI_TorusDlg::SetEditCurrentArgument()
// enable line edit // enable line edit
myEditCurrentArgument->setEnabled(true); myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) then loses focus // after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true); send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change // seems we need it only to avoid preview disappearing, caused by selection mode change

View File

@ -1,22 +1,22 @@
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : TransformationGUI_TranslationDlg.cxx // File : TransformationGUI_TranslationDlg.cxx
@ -29,11 +29,12 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GEOMBase.h> #include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// OCCT Includes
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -45,54 +46,58 @@
//================================================================================= //=================================================================================
// class : TransformationGUI_TranslationDlg() // class : TransformationGUI_TranslationDlg()
// purpose : Constructs a TransformationGUI_TranslationDlg which is a child of 'parent', with the // purpose : Constructs a TransformationGUI_TranslationDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg
( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl ) (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myInitial(true)
{ {
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_TRANSLATION_DXYZ" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_DXYZ")));
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_TRANSLATION_POINTS" ) ) ); QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_POINTS")));
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_TRANSLATION_VECTOR" ) ) ); QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TRANSLATION_VECTOR")));
QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image3 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_TRANSLATION_TITLE" ) ); setWindowTitle(tr("GEOM_TRANSLATION_TITLE"));
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_TRANSLATION" ) ); mainFrame()->GroupConstructors->setTitle(tr("GEOM_TRANSLATION"));
mainFrame()->RadioButton1->setIcon( image0 ); mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setIcon( image1 ); mainFrame()->RadioButton2->setIcon(image1);
mainFrame()->RadioButton3->setIcon( image2 ); mainFrame()->RadioButton3->setIcon(image2);
mainFrame()->RadioButton1->setChecked( true ); mainFrame()->RadioButton1->setChecked(true);
GroupPoints = new DlgRef_3Sel3Spin2Check( centralWidget() ); GroupPoints = new DlgRef_3Sel3Spin2Check(centralWidget());
GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) ); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) ); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
GroupPoints->TextLabel3->setText( tr( "GEOM_POINT_I" ).arg( 2 ) ); GroupPoints->TextLabel3->setText(tr("GEOM_POINT_I").arg(2));
GroupPoints->TextLabel4->setText( tr( "GEOM_DX" ) ); GroupPoints->TextLabel4->setText(tr("GEOM_DX"));
GroupPoints->TextLabel5->setText( tr( "GEOM_DY" ) ); GroupPoints->TextLabel5->setText(tr("GEOM_DY"));
GroupPoints->TextLabel6->setText( tr( "GEOM_DZ" ) ); GroupPoints->TextLabel6->setText(tr("GEOM_DZ"));
GroupPoints->PushButton1->setIcon( image3 ); GroupPoints->PushButton1->setIcon(image3);
GroupPoints->PushButton2->setIcon( image3 ); GroupPoints->PushButton2->setIcon(image3);
GroupPoints->PushButton3->setIcon( image3 ); GroupPoints->PushButton3->setIcon(image3);
GroupPoints->CheckBox1->setText( tr( "Activate Distance" ) ); GroupPoints->CheckBox1->setText(tr("Activate Distance"));
GroupPoints->CheckBox2->setText( tr( "GEOM_CREATE_COPY" ) ); GroupPoints->CheckBox2->setText(tr("GEOM_CREATE_COPY"));
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin(0); layout->setSpacing(6);
layout->addWidget( GroupPoints ); layout->addWidget(GroupPoints);
/***************************************************************/ /***************************************************************/
setHelpFileName( "translation_operation_page.html" ); setHelpFileName("translation_operation_page.html");
// Activate Create a Copy mode
GroupPoints->CheckBox2->setChecked(true);
CreateCopyModeChanged(true);
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~TransformationGUI_TranslationDlg() // function : ~TransformationGUI_TranslationDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -102,75 +107,69 @@ TransformationGUI_TranslationDlg::~TransformationGUI_TranslationDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::Init() void TransformationGUI_TranslationDlg::Init()
{ {
/* init variables */ // Get setting of step value from file configuration
myEditCurrentArgument = GroupPoints->LineEdit1; SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
GroupPoints->LineEdit1->setReadOnly( true ); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
GroupPoints->LineEdit2->setReadOnly( true );
GroupPoints->LineEdit3->setReadOnly( true ); // min, max, step and decimals for spin boxes & initial values
initSpinBox(GroupPoints->SpinBox1, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupPoints->SpinBox2, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox(GroupPoints->SpinBox3, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox1->setValue(0.0);
GroupPoints->SpinBox2->setValue(0.0);
GroupPoints->SpinBox3->setValue(0.0);
// init variables
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints->LineEdit3->setReadOnly(true);
GroupPoints->LineEdit1->setText("");
GroupPoints->LineEdit2->setText("");
GroupPoints->LineEdit3->setText("");
myVector = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); myVector = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
// Activate Create a Copy mode
GroupPoints->CheckBox2->setChecked( true );
CreateCopyModeChanged( true );
mainFrame()->GroupBoxPublish->show(); mainFrame()->GroupBoxPublish->show();
/* Get setting of step value from file configuration */ // signals and slots connections
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
/* min, max, step and decimals for spin boxes & initial values */
initSpinBox( GroupPoints->SpinBox1, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( GroupPoints->SpinBox2, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
initSpinBox( GroupPoints->SpinBox3, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox1->setValue( 0.0 );
GroupPoints->SpinBox2->setValue( 0.0 );
GroupPoints->SpinBox3->setValue( 0.0 );
/* 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(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); //@ Delete ? connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); //@ Delete ?
connect( GroupPoints->SpinBox1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect(GroupPoints->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect( GroupPoints->SpinBox2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect(GroupPoints->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect( GroupPoints->SpinBox3, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) ); connect(GroupPoints->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
connect( GroupPoints->CheckBox1, SIGNAL( toggled( bool ) ), this, SLOT( ActivateDistanceChanged( bool ) ) );
connect( GroupPoints->CheckBox2, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_TRANSLATION" ) ); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
ConstructorsClicked( 0 ); connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(ActivateDistanceChanged(bool)));
connect(GroupPoints->CheckBox2, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
initName(tr("GEOM_TRANSLATION"));
ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::SetDoubleSpinBoxStep( double step ) void TransformationGUI_TranslationDlg::SetDoubleSpinBoxStep (double step)
{ {
GroupPoints->SpinBox1->setSingleStep(step); GroupPoints->SpinBox1->setSingleStep(step);
GroupPoints->SpinBox2->setSingleStep(step); GroupPoints->SpinBox2->setSingleStep(step);
@ -181,179 +180,282 @@ void TransformationGUI_TranslationDlg::SetDoubleSpinBoxStep( double step )
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::ConstructorsClicked( int constructorId ) void TransformationGUI_TranslationDlg::ConstructorsClicked (int constructorId)
{ {
erasePreview(); disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
switch (constructorId) {
myEditCurrentArgument = GroupPoints->LineEdit1; case 0: // translation an object by dx, dy, dz
globalSelection(); {
GroupPoints->ShowRows(1, 2, false);
GroupPoints->ShowRows(3, 5, true);
GroupPoints->TextLabel6->setText(tr("GEOM_DZ"));
GroupPoints->SpinBox3->setEnabled(true);
switch ( constructorId ) {
case 0: /* translation an object by dx, dy, dz */
{
GroupPoints->ShowRows( 1, 2, false );
GroupPoints->ShowRows( 3, 5, true );
GroupPoints->TextLabel6->setText( tr( "GEOM_DZ" ) );
GroupPoints->CheckBox1->hide(); GroupPoints->CheckBox1->hide();
GroupPoints->SpinBox3->setEnabled( true );
GroupPoints->PushButton1->click();
break; break;
} }
case 1: /* translation an object by 2 points */ case 1: // translation an object by 2 points
{ {
GroupPoints->ShowRows( 3, 5, false ); GroupPoints->ShowRows(3, 5, false);
GroupPoints->ShowRows( 0, 2, true ); GroupPoints->ShowRows(0, 2, true);
GroupPoints->CheckBox1->hide();
GroupPoints->TextLabel6->setText( tr( "GEOM_DZ" ) ); GroupPoints->TextLabel6->setText(tr("GEOM_DZ"));
GroupPoints->TextLabel2->setText( tr( "GEOM_POINT_I" ).arg( 1 ) ); GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg(1));
GroupPoints->LineEdit2->clear(); GroupPoints->LineEdit2->clear();
GroupPoints->LineEdit3->clear(); GroupPoints->LineEdit3->clear();
GroupPoints->SpinBox3->setEnabled( true ); GroupPoints->SpinBox3->setEnabled(true);
GroupPoints->CheckBox1->hide();
myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
GroupPoints->PushButton1->click();
break; break;
} }
case 2: /* translation an object by vector */ case 2: // translation an object by vector
{ {
GroupPoints->ShowRows( 0, 1, true ); GroupPoints->ShowRows(0, 1, true);
GroupPoints->ShowRows( 2, 4, false ); GroupPoints->ShowRows(2, 4, false);
GroupPoints->ShowRows( 5, 5, true ); GroupPoints->ShowRows(5, 5, true);
GroupPoints->CheckBox1->show();
GroupPoints->TextLabel6->setText( tr( "GEOM_DISTANCE" ) ); GroupPoints->TextLabel6->setText(tr("GEOM_DISTANCE"));
GroupPoints->SpinBox3->setValue( 0.0 ); GroupPoints->SpinBox3->setValue(0.0);
GroupPoints->SpinBox3->setEnabled( false ); GroupPoints->SpinBox3->setEnabled(false);
GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR" ) ); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
GroupPoints->LineEdit2->clear(); GroupPoints->LineEdit2->clear();
GroupPoints->CheckBox1->show();
myVector = GEOM::GEOM_Object::_nil(); myVector = GEOM::GEOM_Object::_nil();
ActivateDistanceChanged( GroupPoints->CheckBox1->isChecked() ); ActivateDistanceChanged(GroupPoints->CheckBox1->isChecked());
GroupPoints->PushButton1->click();
break; break;
} }
} }
qApp->processEvents(); qApp->processEvents();
updateGeometry(); updateGeometry();
resize( minimumSize() ); resize(minimumSize());
myEditCurrentArgument->setFocus(); if (myInitial) {
connect( myGeomGUI->getApp()->selectionMgr(), myInitial = false;
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); SelectionIntoArgument();
}
else {
displayPreview();
}
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::ClickOnOk() void TransformationGUI_TranslationDlg::ClickOnOk()
{ {
if ( ClickOnApply() ) if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_TranslationDlg::ClickOnApply() bool TransformationGUI_TranslationDlg::ClickOnApply()
{ {
if ( !onAccept(GroupPoints->CheckBox2->isChecked()) ) if (!onAccept(GroupPoints->CheckBox2->isChecked()))
return false; return false;
initName();
initName();
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
return true; return true;
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection is changed or on dialog initialization or activation
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::SelectionIntoArgument() void TransformationGUI_TranslationDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText( "" ); erasePreview();
QString aName; myEditCurrentArgument->setText("");
if (myEditCurrentArgument == GroupPoints->LineEdit1)
myObjects.length(0);
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
myPoint1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2)
myVector = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit3)
myPoint2 = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
QString aName;
if (myEditCurrentArgument == GroupPoints->LineEdit1) { if (myEditCurrentArgument == GroupPoints->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName); int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if (aNbSel < 1)
if (aNbSel < 1) { return;
myObjects.length(0);
return;
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects); GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length()) if (!myObjects.length())
return; return;
else {
myEditCurrentArgument->setText(aName);
// here we do not switch to the next field, because multiple objects can be selected
/*
if (getConstructorId() == 1) {
if (myPoint1->_is_nil())
GroupPoints->PushButton2->click();
}
else if (getConstructorId() == 2) {
if (myVector->_is_nil())
GroupPoints->PushButton2->click();
}
*/
}
} }
else { else {
if (aSelList.Extent() != 1 ) { if (aSelList.Extent() != 1)
if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
myPoint1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2)
myVector = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit3)
myPoint2 = GEOM::GEOM_Object::_nil();
return; return;
}
// nbSel == 1
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
if (!testResult || CORBA::is_nil(aSelectedObject)) if (!testResult || CORBA::is_nil(aSelectedObject))
return; return;
aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape; TopoDS_Shape aShape;
aName = GEOMBase::GetName( aSelectedObject ); if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
{ {
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX; TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 ) if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2)
aNeedType = TopAbs_EDGE; aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if ( aMap.Extent() == 1 ) if (aMap.Extent() == 1)
{ {
int anIndex = aMap( 1 ); int anIndex = aMap(1);
if ( aNeedType == TopAbs_EDGE ) if (aNeedType == TopAbs_EDGE)
aName += QString( ":edge_%1" ).arg( anIndex ); aName += QString(":edge_%1").arg(anIndex);
else else
aName += QString( ":vertex_%1" ).arg( anIndex ); aName += QString(":vertex_%1").arg(anIndex);
//Find SubShape Object in Father //Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName ); GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = GEOM::GEOM_IShapesOperations_var aShapesOp =
getGeomEngine()->GetIShapesOperations( getStudyId() ); getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex ); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
} }
else else {
aSelectedObject = aFindedObject; aSelectedObject = aFindedObject;
}
} }
else // Global Selection else // Global Selection
{ {
if ( aShape.ShapeType() != aNeedType ) { if (aShape.ShapeType() != aNeedType) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
} }
} }
} }
if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1 ) myEditCurrentArgument->setText(aName);
if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) {
myPoint1 = aSelectedObject; myPoint1 = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 ) if (!myPoint1->_is_nil() && myPoint2->_is_nil())
GroupPoints->PushButton3->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) {
myVector = aSelectedObject; myVector = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) if (!myVector->_is_nil() && !myObjects.length())
GroupPoints->PushButton1->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit3) {
myPoint2 = aSelectedObject; myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && !myObjects.length())
GroupPoints->PushButton1->click();
}
} }
myEditCurrentArgument->setText( aName ); // clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_TranslationDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection();
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->PushButton2->setDown(false);
GroupPoints->PushButton3->setDown(false);
GroupPoints->LineEdit2->setEnabled(false);
GroupPoints->LineEdit3->setEnabled(false);
}
else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->PushButton1->setDown(false);
GroupPoints->PushButton3->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
GroupPoints->LineEdit3->setEnabled(false);
if (getConstructorId() == 1)
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
else
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
}
else if (send == GroupPoints->PushButton3) {
myEditCurrentArgument = GroupPoints->LineEdit3;
GroupPoints->PushButton1->setDown(false);
GroupPoints->PushButton2->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
GroupPoints->LineEdit2->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
displayPreview(); displayPreview();
} }
@ -364,42 +466,12 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument()
void TransformationGUI_TranslationDlg::LineEditReturnPressed() void TransformationGUI_TranslationDlg::LineEditReturnPressed()
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPoints->LineEdit1 ) { if (send == GroupPoints->LineEdit1) {
myEditCurrentArgument = send; myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_TranslationDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
globalSelection();
if ( send == GroupPoints->PushButton1 ) {
myEditCurrentArgument = GroupPoints->LineEdit1;
}
else if ( send == GroupPoints->PushButton2 ) {
myEditCurrentArgument = GroupPoints->LineEdit2;
if ( getConstructorId() == 1 )
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
else
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
else if ( send == GroupPoints->PushButton3 ) {
myEditCurrentArgument = GroupPoints->LineEdit3;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
}
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -407,25 +479,21 @@ void TransformationGUI_TranslationDlg::SetEditCurrentArgument()
void TransformationGUI_TranslationDlg::ActivateThisDialog() void TransformationGUI_TranslationDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() ); // reinit, because some selected objects could be removed
Init();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::enterEvent( QEvent* ) void TransformationGUI_TranslationDlg::enterEvent (QEvent*)
{ {
if ( !mainFrame()->GroupConstructors->isEnabled() ) if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -435,45 +503,33 @@ void TransformationGUI_TranslationDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation() GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation()
{ {
return getGeomEngine()->GetITransformOperations( getStudyId() ); return getGeomEngine()->GetITransformOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_TranslationDlg::isValid( QString& /*msg*/ ) bool TransformationGUI_TranslationDlg::isValid (QString& /*msg*/)
{ {
int aConstructorId = getConstructorId(); int aConstructorId = getConstructorId();
switch (aConstructorId) { if (myObjects.length() < 1) return false;
case 0:
{
//LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
//SALOME_ListIO aSelList;
//aSelMgr->selectedObjects(aSelList);
//
//Handle(SALOME_InteractiveObject) IO = aSelList.First();
//Standard_Boolean testResult;
//GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject(IO, testResult);
//if (!testResult || anObject->_is_nil())
// return false;
return !(myObjects.length() == 0); switch (aConstructorId) {
} case 0:
case 1: return true;
return !(myObjects.length() == 0 || myPoint1->_is_nil() || myPoint2->_is_nil()); case 1:
case 2: return !(myPoint1->_is_nil() || myPoint2->_is_nil());
return !( myObjects.length() == 0 || myVector->_is_nil()); case 2:
default: return !(myVector->_is_nil());
default:
break; break;
} }
return false; return false;
@ -483,60 +539,60 @@ bool TransformationGUI_TranslationDlg::isValid( QString& /*msg*/ )
// function : execute // function : execute
// purpose : // purpose :
//================================================================================= //=================================================================================
bool TransformationGUI_TranslationDlg::execute( ObjectList& objects ) bool TransformationGUI_TranslationDlg::execute (ObjectList& objects)
{ {
bool res = false; bool res = false;
bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked(); bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked();
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
{ {
double dx = GroupPoints->SpinBox1->value(); double dx = GroupPoints->SpinBox1->value();
double dy = GroupPoints->SpinBox2->value(); double dy = GroupPoints->SpinBox2->value();
double dz = GroupPoints->SpinBox3->value(); double dz = GroupPoints->SpinBox3->value();
if ( toCreateCopy ) { if (toCreateCopy) {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
TranslateDXDYDZCopy( myObjects[i], dx, dy, dz ); TranslateDXDYDZCopy(myObjects[i], dx, dy, dz);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
else { else {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
TranslateDXDYDZ( myObjects[i], dx, dy, dz ); TranslateDXDYDZ(myObjects[i], dx, dy, dz);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
res = true; res = true;
break; break;
} }
case 1: case 1:
{ {
if ( toCreateCopy ) { if (toCreateCopy) {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
TranslateTwoPointsCopy( myObjects[i], myPoint1, myPoint2 ); TranslateTwoPointsCopy(myObjects[i], myPoint1, myPoint2);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
else { else {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
TranslateTwoPoints( myObjects[i], myPoint1, myPoint2 ); TranslateTwoPoints(myObjects[i], myPoint1, myPoint2);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
res = true; res = true;
break; break;
@ -544,36 +600,35 @@ bool TransformationGUI_TranslationDlg::execute( ObjectList& objects )
case 2: case 2:
{ {
bool byDistance = GroupPoints->CheckBox1->isChecked(); bool byDistance = GroupPoints->CheckBox1->isChecked();
if ( byDistance ) { if (byDistance) {
double aDistance = GroupPoints->SpinBox3->value(); double aDistance = GroupPoints->SpinBox3->value();
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
TranslateVectorDistance( myObjects[i], myVector, aDistance, toCreateCopy ); TranslateVectorDistance(myObjects[i], myVector, aDistance, toCreateCopy);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
} }
} }
else { else {
if ( toCreateCopy ) { if (toCreateCopy) {
for ( int i = 0; i < myObjects.length(); i++ ) { for (int i = 0; i < myObjects.length(); i++) {
myCurrObject = myObjects[i]; myCurrObject = myObjects[i];
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
TranslateVectorCopy( myObjects[i], myVector ); TranslateVectorCopy(myObjects[i], myVector);
if ( !anObj->_is_nil() ) if (!anObj->_is_nil())
objects.push_back( anObj._retn() ); objects.push_back(anObj._retn());
}
} }
} else {
else { for (int i = 0; i < myObjects.length(); i++) {
for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i];
myCurrObject = myObjects[i]; anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )-> TranslateVector(myObjects[i], myVector);
TranslateVector( myObjects[i], myVector ); if (!anObj->_is_nil())
if ( !anObj->_is_nil() ) objects.push_back(anObj._retn());
objects.push_back( anObj._retn() ); }
} }
}
} }
res = true; res = true;
break; break;
@ -586,19 +641,19 @@ bool TransformationGUI_TranslationDlg::execute( ObjectList& objects )
// function : restoreSubShapes // function : restoreSubShapes
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy, void TransformationGUI_TranslationDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject ) SALOMEDS::SObject_ptr theSObject)
{ {
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) { if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// we pass here the first operation argument (object) through the list of arguments // 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, // because the rotation operation place its arguments in the data structure in another order,
// and we need to point the first argument directly // and we need to point the first argument directly
GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO; GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
anArgs->length( 1); anArgs->length(1);
anArgs[0] = myCurrObject; anArgs[0] = myCurrObject;
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, anArgs, getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
/*theFindMethod=*/GEOM::FSM_Transformed, /*theFindMethod=*/GEOM::FSM_Transformed,
/*theInheritFirstArg=*/true ); /*theInheritFirstArg=*/true);
} }
} }
@ -606,18 +661,18 @@ void TransformationGUI_TranslationDlg::restoreSubShapes( SALOMEDS::Study_ptr t
// function : CreateCopyModeChanged() // function : CreateCopyModeChanged()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::CreateCopyModeChanged( bool isCreateCopy ) void TransformationGUI_TranslationDlg::CreateCopyModeChanged (bool isCreateCopy)
{ {
mainFrame()->GroupBoxName->setEnabled( isCreateCopy ); mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
} }
//================================================================================= //=================================================================================
// function : ActivateDistanceChanged() // function : ActivateDistanceChanged()
// purpose : // purpose :
//================================================================================= //=================================================================================
void TransformationGUI_TranslationDlg::ActivateDistanceChanged( bool theEnable ) void TransformationGUI_TranslationDlg::ActivateDistanceChanged (bool theEnable)
{ {
GroupPoints->SpinBox3->setEnabled( theEnable ); GroupPoints->SpinBox3->setEnabled(theEnable);
displayPreview(); displayPreview();
} }
@ -628,10 +683,10 @@ void TransformationGUI_TranslationDlg::ActivateDistanceChanged( bool theEnable )
void TransformationGUI_TranslationDlg::addSubshapesToStudy() void TransformationGUI_TranslationDlg::addSubshapesToStudy()
{ {
bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked(); bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked();
if ( toCreateCopy ) { if (toCreateCopy) {
QMap<QString, GEOM::GEOM_Object_var> objMap; QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) { switch (getConstructorId()) {
case 0: case 0:
return; return;
case 1: case 1:
@ -642,6 +697,6 @@ void TransformationGUI_TranslationDlg::addSubshapesToStudy()
objMap[GroupPoints->LineEdit2->text()] = myVector; objMap[GroupPoints->LineEdit2->text()] = myVector;
break; break;
} }
addSubshapesToFather( objMap ); addSubshapesToFather(objMap);
} }
} }

View File

@ -59,7 +59,9 @@ private:
GEOM::ListOfGO myObjects; GEOM::ListOfGO myObjects;
GEOM::GEOM_Object_var myCurrObject; GEOM::GEOM_Object_var myCurrObject;
GEOM::GEOM_Object_var myVector, myPoint1, myPoint2; GEOM::GEOM_Object_var myVector, myPoint1, myPoint2;
double myTranslateDistance;
// to initialize the first selection field with a selected object on the dialog creation
bool myInitial;
DlgRef_3Sel3Spin2Check* GroupPoints; DlgRef_3Sel3Spin2Check* GroupPoints;