Implementation of "Blocks/Propagate" GUI
This commit is contained in:
vkn 2005-01-13 08:30:56 +00:00
parent 3e0be37784
commit ff51610c15
2 changed files with 75 additions and 50 deletions

View File

@ -30,16 +30,9 @@ using namespace std;
#include "BlocksGUI_PropagateDlg.h" #include "BlocksGUI_PropagateDlg.h"
#include "QAD_Desktop.h" #include "QAD_Desktop.h"
#include "QAD_SpinBoxDbl.h"
#include "OCCViewer_Viewer3d.h"
#include "DlgRef_1Sel_Ext.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
//================================================================================= //=================================================================================
// class : BlocksGUI_PropagateDlg() // class : BlocksGUI_PropagateDlg()
// purpose : Constructs a BlocksGUI_PropagateDlg which is a child of 'parent', with the // purpose : Constructs a BlocksGUI_PropagateDlg which is a child of 'parent', with the
@ -61,13 +54,18 @@ BlocksGUI_PropagateDlg::BlocksGUI_PropagateDlg(QWidget* parent, const char* name
RadioButton2->close(TRUE); RadioButton2->close(TRUE);
RadioButton3->close(TRUE); RadioButton3->close(TRUE);
GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_SELECTED_SHAPE" ), this );
GroupPoints->GroupBox1->setTitle(tr("GEOM_PROPAGATE")); QGroupBox* aSelGrp = new QGroupBox(3, Qt::Horizontal, aMainGrp);
GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); aSelGrp->setFrameStyle(QFrame::NoFrame);
GroupPoints->PushButton1->setPixmap(image1); aSelGrp->setInsideMargin(0);
GroupPoints->LineEdit1->setReadOnly( true );
Layout1->removeChild( GroupBoxName ); new QLabel(tr("GEOM_OBJECT"), aSelGrp);
Layout1->addWidget(GroupPoints, 1, 0); mySelBtn = new QPushButton(aSelGrp);
mySelBtn->setPixmap(image1);
mySelName = new QLineEdit(aSelGrp);
mySelName->setReadOnly(true);
Layout1->addWidget(aMainGrp, 1, 0);
/***************************************************************/ /***************************************************************/
@ -91,12 +89,10 @@ BlocksGUI_PropagateDlg::~BlocksGUI_PropagateDlg()
void BlocksGUI_PropagateDlg::Init() void BlocksGUI_PropagateDlg::Init()
{ {
/* init variables */ /* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
myGeomGUI->SetState( 0 ); myGeomGUI->SetState( 0 );
globalSelection( GEOM_COMPOUND );
/* signals and slots connections */ /* signals and slots connections */
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
@ -106,11 +102,10 @@ void BlocksGUI_PropagateDlg::Init()
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(mySelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(mySelName, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
activateSelection();
} }
@ -137,10 +132,10 @@ bool BlocksGUI_PropagateDlg::ClickOnApply()
initName(); initName();
GroupPoints->LineEdit1->setText(""); mySelName->setText("");
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
globalSelection( GEOM_COMPOUND ); activateSelection();
return true; return true;
} }
@ -162,8 +157,7 @@ void BlocksGUI_PropagateDlg::ClickOnCancel()
//================================================================================= //=================================================================================
void BlocksGUI_PropagateDlg::SelectionIntoArgument() void BlocksGUI_PropagateDlg::SelectionIntoArgument()
{ {
erasePreview(); mySelName->setText("");
myEditCurrentArgument->setText("");
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
if ( mySelection->IObjectCount() == 1 ) { if ( mySelection->IObjectCount() == 1 ) {
@ -171,7 +165,7 @@ void BlocksGUI_PropagateDlg::SelectionIntoArgument()
Standard_Boolean aRes; Standard_Boolean aRes;
myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
if ( aRes ) if ( aRes )
myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); mySelName->setText( GEOMBase::GetName( myObject ) );
} }
} }
@ -182,10 +176,10 @@ void BlocksGUI_PropagateDlg::SelectionIntoArgument()
void BlocksGUI_PropagateDlg::SetEditCurrentArgument() void BlocksGUI_PropagateDlg::SetEditCurrentArgument()
{ {
const QObject* send = sender(); const QObject* send = sender();
if ( send == GroupPoints->PushButton1 ) { if ( send == mySelBtn ) {
myEditCurrentArgument->setFocus(); mySelName->setFocus();
SelectionIntoArgument();
} }
activateSelection();
} }
@ -196,8 +190,7 @@ void BlocksGUI_PropagateDlg::SetEditCurrentArgument()
void BlocksGUI_PropagateDlg::LineEditReturnPressed() void BlocksGUI_PropagateDlg::LineEditReturnPressed()
{ {
const QObject* send = sender(); const QObject* send = sender();
if( send == GroupPoints->LineEdit1 ) { if( send == mySelName ) {
myEditCurrentArgument = GroupPoints->LineEdit1;
GEOMBase_Skeleton::LineEditReturnPressed(); GEOMBase_Skeleton::LineEditReturnPressed();
} }
} }
@ -221,13 +214,12 @@ void BlocksGUI_PropagateDlg::DeactivateActiveDialog()
void BlocksGUI_PropagateDlg::ActivateThisDialog() void BlocksGUI_PropagateDlg::ActivateThisDialog()
{ {
GEOMBase_Skeleton::ActivateThisDialog(); GEOMBase_Skeleton::ActivateThisDialog();
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
GroupPoints->LineEdit1->setText(""); mySelName->setText("");
myObject = GEOM::GEOM_Object::_nil(); myObject = GEOM::GEOM_Object::_nil();
myGeomGUI->SetState( 0 ); myGeomGUI->SetState( 0 );
globalSelection( GEOM_COMPOUND ); activateSelection();
} }
@ -276,12 +268,43 @@ bool BlocksGUI_PropagateDlg::isValid( QString& msg )
//================================================================================= //=================================================================================
bool BlocksGUI_PropagateDlg::execute( ObjectList& objects ) bool BlocksGUI_PropagateDlg::execute( ObjectList& objects )
{ {
bool aResult = false;
GEOM::ListOfGO_var aCurrList = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->Propagate( myObject ); GEOM::ListOfGO_var aList = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->Propagate( myObject );
for ( int i = 0, n = aCurrList->length(); i < n; i++ )
if ( !aList->length() )
return false;
for ( int i = 0, n = aList->length(); i < n; i++ )
{ {
//NOT yet implemented objects.push_back(aList[i]._retn());
} }
return aResult; return objects.size() ? true : false;
} }
//=================================================================================
// function : activateSelection
// purpose : Activate selection
//=================================================================================
void BlocksGUI_PropagateDlg::activateSelection()
{
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_SOLID );
aMap.Add( GEOM_COMPOUND );
globalSelection( aMap );
if (myObject->_is_nil()) {
SelectionIntoArgument();
}
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
}
//================================================================
// Function : getFather
// Purpose : Get father object for object to be added in study
// ( called with addInStudy method )
//================================================================
GEOM::GEOM_Object_ptr BlocksGUI_PropagateDlg::getFather (GEOM::GEOM_Object_ptr)
{
return myObject;
}

View File

@ -31,8 +31,6 @@
#include "GEOMBase_Skeleton.h" #include "GEOMBase_Skeleton.h"
class QAD_SpinBoxDbl;
class DlgRef_1Sel_Ext;
//================================================================================= //=================================================================================
// class : BlocksGUI_PropagateDlg // class : BlocksGUI_PropagateDlg
@ -51,16 +49,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& ); virtual bool isValid( QString& );
virtual bool execute( ObjectList& objects ); virtual bool execute( ObjectList& objects );
virtual GEOM::GEOM_Object_ptr getFather(GEOM::GEOM_Object_ptr theObj);
private :
void Init();
void enterEvent(QEvent* e);
void closeEvent(QCloseEvent* e);
void initSelection();
GEOM::GEOM_Object_var myObject;
DlgRef_1Sel_Ext* GroupPoints;
private slots: private slots:
void ClickOnOk(); void ClickOnOk();
@ -73,6 +62,19 @@ private slots:
void LineEditReturnPressed(); void LineEditReturnPressed();
void SelectionIntoArgument(); void SelectionIntoArgument();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
private :
void Init();
void enterEvent(QEvent* e);
void closeEvent(QCloseEvent* e);
void activateSelection();
private :
GEOM::GEOM_Object_var myObject;
QPushButton* mySelBtn;
QLineEdit* mySelName;
}; };
#endif // DIALOGBOX_BlocksGUI_PropagateDlg_H #endif // DIALOGBOX_BlocksGUI_PropagateDlg_H