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

@ -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>
@ -109,11 +109,10 @@ BooleanGUI_Dialog::BooleanGUI_Dialog( const int theOperation, GeometryGUI* theGe
layout->addWidget(myGroup); 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,10 +129,14 @@ 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("");
myGroup->LineEdit2->setText("");
myObject1 = myObject2 = GEOM::GEOM_Object::_nil();
// 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()));
@ -156,8 +158,10 @@ void BooleanGUI_Dialog::Init()
mainFrame()->RadioButton1->setFocus(); mainFrame()->RadioButton1->setFocus();
globalSelection(GEOM_ALLSHAPES); globalSelection(GEOM_ALLSHAPES);
}
myGroup->PushButton1->click();
SelectionIntoArgument();
}
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
@ -169,7 +173,6 @@ void BooleanGUI_Dialog::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -180,12 +183,14 @@ bool BooleanGUI_Dialog::ClickOnApply()
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()
{ {
@ -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,13 +240,25 @@ 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;
myEditCurrentArgument->setFocus(); myGroup->PushButton2->setDown(false);
SelectionIntoArgument(); 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();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
}
//================================================================================= //=================================================================================
// function : LineEditReturnPressed() // function : LineEditReturnPressed()
@ -240,7 +273,6 @@ void BooleanGUI_Dialog::LineEditReturnPressed()
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -248,11 +280,10 @@ 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()
@ -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;

View File

@ -29,13 +29,13 @@
#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
@ -77,11 +77,10 @@ BuildGUI_EdgeDlg::BuildGUI_EdgeDlg( GeometryGUI* theGeometryGUI, QWidget* parent
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,23 +90,22 @@ 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
/* 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()));
@ -117,12 +115,11 @@ void BuildGUI_EdgeDlg::Init()
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_EDGE")); initName(tr("GEOM_EDGE"));
}
GroupPoints->PushButton1->click();
SelectionIntoArgument();
}
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
@ -134,7 +131,6 @@ void BuildGUI_EdgeDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -145,12 +141,14 @@ bool BuildGUI_EdgeDlg::ClickOnApply()
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();
} }
@ -202,31 +245,6 @@ void BuildGUI_EdgeDlg::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,12 +252,10 @@ 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()

View File

@ -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>
@ -83,35 +83,35 @@ GenerationGUI_PipeDlg::GenerationGUI_PipeDlg( GeometryGUI* theGeometryGUI, QWidg
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()));
@ -121,15 +121,12 @@ void GenerationGUI_PipeDlg::Init()
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 :
@ -140,9 +137,8 @@ void GenerationGUI_PipeDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnAply() // function : ClickOnApply()
// purpose : // purpose :
//================================================================================= //=================================================================================
bool GenerationGUI_PipeDlg::ClickOnApply() bool GenerationGUI_PipeDlg::ClickOnApply()
@ -151,43 +147,42 @@ bool GenerationGUI_PipeDlg::ClickOnApply()
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,16 +191,13 @@ 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) {
@ -237,8 +229,16 @@ void GenerationGUI_PipeDlg::SelectionIntoArgument()
} }
} }
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);
GroupPoints->LineEdit1->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); 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()
@ -280,6 +291,17 @@ void GenerationGUI_PipeDlg::LineEditReturnPressed()
} }
} }
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GenerationGUI_PipeDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
// reinit, because some selected objects could be removed
Init();
}
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
@ -291,21 +313,6 @@ void GenerationGUI_PipeDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GenerationGUI_PipeDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
globalSelection( GEOM_ALLSHAPES );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT(SelectionIntoArgument() ) );
displayPreview();
}
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
@ -332,8 +339,7 @@ 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());
@ -341,7 +347,6 @@ bool GenerationGUI_PipeDlg::execute( ObjectList& objects )
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
@ -354,4 +359,3 @@ void GenerationGUI_PipeDlg::addSubshapesToStudy()
addSubshapesToFather(objMap); addSubshapesToFather(objMap);
} }

View File

@ -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>
@ -52,7 +53,8 @@
//================================================================================= //=================================================================================
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")));
@ -117,7 +119,6 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg( GeometryGUI* theGeometryGUI, QWi
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
@ -127,32 +128,17 @@ 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
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
GroupPoints2->LineEdit1->setReadOnly( true );
GroupPoints2->LineEdit2->setReadOnly( true );
GroupPoints2->LineEdit3->setReadOnly( true );
GroupPoints3->LineEdit1->setReadOnly( true );
myPoint1 = myPoint2 = myBase = myVec = GEOM::GEOM_Object::_nil();
myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false;
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
/* min, max, step and decimals for spin boxes & initial values */ // 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_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_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 initSpinBox(GroupPoints3->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3); // VSR:TODO : DBL_DIGITS_DISPLAY
@ -163,7 +149,30 @@ void GenerationGUI_PrismDlg::Init()
initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox_DX->setValue(100.0); GroupPoints->SpinBox_DX->setValue(100.0);
/* signals and slots connections */ // init variables
myEditCurrentArgument = GroupPoints->LineEdit1;
GroupPoints->LineEdit1->setReadOnly(true);
GroupPoints->LineEdit2->setReadOnly(true);
GroupPoints2->LineEdit1->setReadOnly(true);
GroupPoints2->LineEdit2->setReadOnly(true);
GroupPoints2->LineEdit3->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();
myOkBase = myOkVec = myOkPnt1 = myOkPnt2 = false;
// 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()));
@ -197,9 +206,6 @@ void GenerationGUI_PrismDlg::Init()
connect(GroupPoints3->SpinBox_DZ, 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(GroupPoints3->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(onBothway()));
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_EXTRUSION")); initName(tr("GEOM_EXTRUSION"));
ConstructorsClicked(0); ConstructorsClicked(0);
@ -217,60 +223,54 @@ 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;
} }
} }
@ -278,14 +278,14 @@ void GenerationGUI_PrismDlg::ConstructorsClicked( int constructorId )
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()
@ -297,7 +297,6 @@ void GenerationGUI_PrismDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -308,13 +307,14 @@ bool GenerationGUI_PrismDlg::ClickOnApply()
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()
{ {
@ -339,13 +339,16 @@ 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) {
@ -364,7 +367,7 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument()
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 = "";
@ -373,15 +376,20 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument()
} }
} }
myEditCurrentArgument->setText(aName);
if (myEditCurrentArgument == GroupPoints->LineEdit1) { 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) {
@ -442,14 +450,20 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument()
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 );
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(GEOM_ALLSHAPES);
if (send == GroupPoints->PushButton1) { if (send == GroupPoints->PushButton1) {
GroupPoints->LineEdit1->setFocus();
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;
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); 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;
GroupPoints2->PushButton1->setDown(false);
GroupPoints2->PushButton3->setDown(false);
GroupPoints2->LineEdit1->setEnabled(false);
GroupPoints2->LineEdit3->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); 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;
GroupPoints2->PushButton1->setDown(false);
GroupPoints2->PushButton2->setDown(false);
GroupPoints2->LineEdit1->setEnabled(false);
GroupPoints2->LineEdit2->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); 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()
@ -528,6 +566,18 @@ void GenerationGUI_PrismDlg::LineEditReturnPressed()
} }
} }
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GenerationGUI_PrismDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
// 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
@ -538,22 +588,6 @@ void GenerationGUI_PrismDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GenerationGUI_PrismDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() );
}
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -563,7 +597,6 @@ void GenerationGUI_PrismDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : getHeight() // function : getHeight()
// purpose : // purpose :
@ -594,6 +627,8 @@ bool GenerationGUI_PrismDlg::isValid( QString& )
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;
} }
//================================================================================= //=================================================================================
@ -640,13 +675,13 @@ bool GenerationGUI_PrismDlg::execute( ObjectList& objects )
} }
break; break;
} }
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 :

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

@ -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>
@ -88,11 +88,10 @@ GenerationGUI_RevolDlg::GenerationGUI_RevolDlg( GeometryGUI* theGeometryGUI, QWi
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,28 +101,27 @@ 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;
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
myOkBase = myOkAxis = false;
double SpecificStep = 5; double SpecificStep = 5;
/* min, max, step and decimals for spin boxes & initial values */
//initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, SpecificStep, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
// 05.06.2008 skl for IPAL12958
initSpinBox(GroupPoints->SpinBox_DX, 0.0, 360.0, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY initSpinBox(GroupPoints->SpinBox_DX, 0.0, 360.0, SpecificStep, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
GroupPoints->SpinBox_DX->setValue(45.0); GroupPoints->SpinBox_DX->setValue(45.0);
/* signals and slots connections */ // 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;
// 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()));
@ -139,12 +137,10 @@ void GenerationGUI_RevolDlg::Init()
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_REVOLUTION")); initName(tr("GEOM_REVOLUTION"));
globalSelection( GEOM_ALLSHAPES ); GroupPoints->PushButton1->click();
SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
@ -156,8 +152,6 @@ void GenerationGUI_RevolDlg::SetDoubleSpinBoxStep( double step )
GroupPoints->SpinBox_DX->setSingleStep(step); GroupPoints->SpinBox_DX->setSingleStep(step);
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
@ -168,7 +162,6 @@ void GenerationGUI_RevolDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -179,6 +172,8 @@ bool GenerationGUI_RevolDlg::ClickOnApply()
return false; return false;
initName(); initName();
// activate selection and connect selection manager
GroupPoints->PushButton1->click();
return true; return true;
} }
@ -186,7 +181,6 @@ 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()) {
@ -211,52 +205,49 @@ 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 ) if (!testResult || aSelectedObject->_is_nil())
return; return;
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
TopoDS_Shape S; TopoDS_Shape S;
myOkBase = false; if (!GEOMBase::GetShape(aSelectedObject, S) || S.IsNull())
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() ) {
TopoDS_Shape aShape;
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));
@ -276,18 +267,23 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument()
} }
else { else {
myOkAxis = true; myOkAxis = true;
if ( aShape.ShapeType() != TopAbs_EDGE ) { if (S.ShapeType() != TopAbs_EDGE) {
aSelectedObject = GEOM::GEOM_Object::_nil(); aSelectedObject = GEOM::GEOM_Object::_nil();
aName = ""; aName = "";
myOkAxis = false; myOkAxis = false;
} }
myAxis = aSelectedObject; 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,20 +295,32 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument()
void GenerationGUI_RevolDlg::SetEditCurrentArgument() void GenerationGUI_RevolDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
globalSelection( GEOM_ALLSHAPES );
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(GEOM_ALLSHAPES);
if (send == GroupPoints->PushButton1) { if (send == GroupPoints->PushButton1) {
GroupPoints->LineEdit1->setFocus();
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;
GroupPoints->PushButton1->setDown(false);
GroupPoints->LineEdit1->setEnabled(false);
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); 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()
@ -328,7 +336,6 @@ void GenerationGUI_RevolDlg::LineEditReturnPressed()
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -336,13 +343,10 @@ 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()
@ -354,7 +358,6 @@ void GenerationGUI_RevolDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -364,7 +367,6 @@ void GenerationGUI_RevolDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : getAngle() // function : getAngle()
// purpose : // purpose :
@ -401,12 +403,12 @@ 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())
@ -415,7 +417,6 @@ bool GenerationGUI_RevolDlg::execute( ObjectList& objects )
return true; return true;
} }
//================================================================================= //=================================================================================
// function : onReverse() // function : onReverse()
// purpose : // purpose :
@ -426,7 +427,6 @@ void GenerationGUI_RevolDlg::onReverse()
GroupPoints->SpinBox_DX->setValue(-anOldValue); GroupPoints->SpinBox_DX->setValue(-anOldValue);
} }
//================================================================================= //=================================================================================
// function : onBothway() // function : onBothway()
// purpose : // purpose :

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);
@ -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

@ -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>
@ -52,7 +53,8 @@
//================================================================================= //=================================================================================
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")));
@ -89,10 +91,13 @@ TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg
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,32 +107,17 @@ 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;
GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->LineEdit2->setReadOnly( true );
GroupPoints->LineEdit3->setReadOnly( true );
myVector = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
// Activate Create a Copy mode
GroupPoints->CheckBox2->setChecked( true );
CreateCopyModeChanged( true );
mainFrame()->GroupBoxPublish->show();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
/* min, max, step and decimals for spin boxes & initial values */ // 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->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->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 initSpinBox(GroupPoints->SpinBox3, COORD_MIN, COORD_MAX, step, 3); // VSR: TODO: DBL_DIGITS_DISPLAY
@ -136,7 +126,20 @@ void TransformationGUI_TranslationDlg::Init()
GroupPoints->SpinBox2->setValue(0.0); GroupPoints->SpinBox2->setValue(0.0);
GroupPoints->SpinBox3->setValue(0.0); GroupPoints->SpinBox3->setValue(0.0);
/* signals and slots connections */ // 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();
mainFrame()->GroupBoxPublish->show();
// 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()));
@ -157,15 +160,11 @@ void TransformationGUI_TranslationDlg::Init()
connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(ActivateDistanceChanged(bool))); connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(ActivateDistanceChanged(bool)));
connect(GroupPoints->CheckBox2, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); connect(GroupPoints->CheckBox2, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
initName(tr("GEOM_TRANSLATION")); initName(tr("GEOM_TRANSLATION"));
ConstructorsClicked(0); ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : SetDoubleSpinBoxStep() // function : SetDoubleSpinBoxStep()
// purpose : Double spin box management // purpose : Double spin box management
@ -183,48 +182,58 @@ void TransformationGUI_TranslationDlg::SetDoubleSpinBoxStep( double step )
//================================================================================= //=================================================================================
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);
myEditCurrentArgument = GroupPoints->LineEdit1;
globalSelection();
switch (constructorId) { switch (constructorId) {
case 0: /* translation an object by dx, dy, dz */ case 0: // translation an object by dx, dy, dz
{ {
GroupPoints->ShowRows(1, 2, false); GroupPoints->ShowRows(1, 2, false);
GroupPoints->ShowRows(3, 5, true); GroupPoints->ShowRows(3, 5, true);
GroupPoints->TextLabel6->setText(tr("GEOM_DZ")); GroupPoints->TextLabel6->setText(tr("GEOM_DZ"));
GroupPoints->CheckBox1->hide();
GroupPoints->SpinBox3->setEnabled(true); GroupPoints->SpinBox3->setEnabled(true);
GroupPoints->CheckBox1->hide();
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;
} }
} }
@ -233,11 +242,14 @@ void TransformationGUI_TranslationDlg::ConstructorsClicked( int constructorId )
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()
@ -249,7 +261,6 @@ void TransformationGUI_TranslationDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose :
@ -260,54 +271,74 @@ bool TransformationGUI_TranslationDlg::ClickOnApply()
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()
{ {
erasePreview();
myEditCurrentArgument->setText(""); myEditCurrentArgument->setText("");
QString aName;
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); if (myEditCurrentArgument == GroupPoints->LineEdit1)
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if (aNbSel < 1) {
myObjects.length(0); myObjects.length(0);
return; else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
}
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length())
return;
}
else {
if (aSelList.Extent() != 1 ) {
if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
myPoint1 = GEOM::GEOM_Object::_nil(); myPoint1 = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2)
myVector = GEOM::GEOM_Object::_nil(); myVector = GEOM::GEOM_Object::_nil();
else if (myEditCurrentArgument == GroupPoints->LineEdit3) else if (myEditCurrentArgument == GroupPoints->LineEdit3)
myPoint2 = GEOM::GEOM_Object::_nil(); myPoint2 = GEOM::GEOM_Object::_nil();
return;
}
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
QString aName;
if (myEditCurrentArgument == GroupPoints->LineEdit1) {
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
if (aNbSel < 1)
return;
GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
if (!myObjects.length())
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 {
if (aSelList.Extent() != 1)
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;
TopoDS_Shape aShape;
aName = GEOMBase::GetName(aSelectedObject); aName = GEOMBase::GetName(aSelectedObject);
// Get Selected object if selected subshape
TopoDS_Shape aShape;
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;
@ -332,9 +363,10 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument()
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) {
@ -344,16 +376,86 @@ void TransformationGUI_TranslationDlg::SelectionIntoArgument()
} }
} }
if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1 )
myPoint1 = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 )
myVector = aSelectedObject;
else if ( myEditCurrentArgument == GroupPoints->LineEdit3 )
myPoint2 = aSelectedObject;
}
myEditCurrentArgument->setText(aName); myEditCurrentArgument->setText(aName);
if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) {
myPoint1 = aSelectedObject;
if (!myPoint1->_is_nil() && myPoint2->_is_nil())
GroupPoints->PushButton3->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) {
myVector = aSelectedObject;
if (!myVector->_is_nil() && !myObjects.length())
GroupPoints->PushButton1->click();
}
else if (myEditCurrentArgument == GroupPoints->LineEdit3) {
myPoint2 = aSelectedObject;
if (!myPoint2->_is_nil() && !myObjects.length())
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();
}
//=================================================================================
// 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();
} }
@ -370,36 +472,6 @@ void TransformationGUI_TranslationDlg::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 :
@ -408,13 +480,10 @@ void TransformationGUI_TranslationDlg::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() // function : enterEvent()
// purpose : // purpose :
@ -425,7 +494,6 @@ void TransformationGUI_TranslationDlg::enterEvent( QEvent* )
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -435,7 +503,6 @@ void TransformationGUI_TranslationDlg::ValueChangedInSpinBox()
displayPreview(); displayPreview();
} }
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
@ -445,7 +512,6 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation()
return getGeomEngine()->GetITransformOperations(getStudyId()); return getGeomEngine()->GetITransformOperations(getStudyId());
} }
//================================================================================= //=================================================================================
// function : isValid // function : isValid
// purpose : // purpose :
@ -454,25 +520,15 @@ bool TransformationGUI_TranslationDlg::isValid( QString& /*msg*/ )
{ {
int aConstructorId = getConstructorId(); int aConstructorId = getConstructorId();
if (myObjects.length() < 1) return false;
switch (aConstructorId) { switch (aConstructorId) {
case 0: case 0:
{ return true;
//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);
}
case 1: case 1:
return !(myObjects.length() == 0 || myPoint1->_is_nil() || myPoint2->_is_nil()); return !(myPoint1->_is_nil() || myPoint2->_is_nil());
case 2: case 2:
return !( myObjects.length() == 0 || myVector->_is_nil()); return !(myVector->_is_nil());
default: default:
break; break;
} }
@ -562,7 +618,6 @@ bool TransformationGUI_TranslationDlg::execute( ObjectList& objects )
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 {

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;