Add possibility to improve compound of blocks from GUI.

This commit is contained in:
jfa 2006-03-31 08:45:35 +00:00
parent 8e7ad1edfd
commit e6be9c5634
3 changed files with 200 additions and 43 deletions

View File

@ -528,7 +528,7 @@ msgstr "Check Shape"
#Check Blocks Compound #Check Blocks Compound
msgid "GEOM_CHECK_BLOCKS_COMPOUND" msgid "GEOM_CHECK_BLOCKS_COMPOUND"
msgstr "Check Blocks Compound" msgstr "Check and Improve Blocks Compound"
#Check Blocks Compound Errors #Check Blocks Compound Errors
msgid "GEOM_CHECK_BLOCKS_COMPOUND_ERRORS" msgid "GEOM_CHECK_BLOCKS_COMPOUND_ERRORS"
@ -604,6 +604,10 @@ msgstr "Minor radius :"
msgid "GEOM_COMPOUND" msgid "GEOM_COMPOUND"
msgstr "Compound" msgstr "Compound"
#Compound of Blocks
msgid "GEOM_BLOCKS_COMPOUND"
msgstr "BlocksCompound"
#CompSolid #CompSolid
msgid "GEOM_COMPOUNDSOLID" msgid "GEOM_COMPOUNDSOLID"
msgstr "CompSolid" msgstr "CompSolid"
@ -838,10 +842,6 @@ msgstr "Cylinder Construction"
msgid "GEOM_CHECK_TITLE" msgid "GEOM_CHECK_TITLE"
msgstr "Check Shape Informations" msgstr "Check Shape Informations"
#: MeasureGUI_CheckCompoundOfBlocks.cxx:61
msgid "GEOM_CHECK_COMPOUND_BLOCKS_TITLE"
msgstr "Check Blocks Compound"
#: GeometryGUI_CheckShape.cxx:83 #: GeometryGUI_CheckShape.cxx:83
msgid "GEOM_CHECK_INFOS" msgid "GEOM_CHECK_INFOS"
msgstr "Object And Its Topological Informations" msgstr "Object And Its Topological Informations"

View File

@ -31,7 +31,9 @@
#include "utilities.h" #include "utilities.h"
#include "SUIT_Session.h" #include "SUIT_Session.h"
#include "LightApp_SelectionMgr.h"
#include "SalomeApp_Tools.h" #include "SalomeApp_Tools.h"
#include "SalomeApp_Application.h"
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
@ -67,32 +69,33 @@
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( GeometryGUI* GUI, QWidget* parent ) MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( GeometryGUI* GUI, QWidget* parent )
: MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_CheckCompoundOfBlocksDlg" ) : GEOMBase_Skeleton(GUI, parent, "MeasureGUI_CheckCompoundOfBlocksDlg", false, WStyle_Customize |
WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose)
{ {
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
"GEOM",tr( "ICON_DLG_CHECK_COMPOUND_OF_BLOCKS" ) ) ); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_CHECK_COMPOUND_OF_BLOCKS")));
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
"GEOM",tr( "ICON_SELECT" ) ) );
setCaption( tr( "GEOM_CHECK_BLOCKS_COMPOUND" ) ); setCaption( tr( "GEOM_CHECK_BLOCKS_COMPOUND" ) );
/***************************************************************/ /***************************************************************/
GroupConstructors->setTitle( tr( "GEOM_CHECK_BLOCKS_COMPOUND" ) ); GroupConstructors->setTitle( tr( "GEOM_CHECK_BLOCKS_COMPOUND" ) );
RadioButton1->setPixmap( image0 ); RadioButton1->setPixmap( image0 );
RadioButton2->close( TRUE );
RadioButton3->close( TRUE );
myGrp = new MeasureGUI_1Sel1TextView_QTD( this, "myGrp" ); myGrp = new MeasureGUI_1Sel1TextView_QTD( this, "myGrp" );
myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) ); myGrp->GroupBox1->setTitle( tr( "GEOM_CHECK_INFOS" ) );
myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
myGrp->TextEdit1->setReadOnly( TRUE ); myGrp->TextEdit1->setReadOnly( TRUE );
QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE ); QFont aFont( TEXTEDIT_FONT_FAMILY, TEXTEDIT_FONT_SIZE );
aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias ); aFont.setStyleHint( QFont::TypeWriter, QFont::PreferAntialias );
myGrp->TextEdit1->setFont( aFont ); myGrp->TextEdit1->setFont( aFont );
myGrp->PushButton1->setPixmap( image1 ); myGrp->PushButton1->setPixmap( image1 );
myGrp->LineEdit1->setReadOnly( true ); myGrp->LineEdit1->setReadOnly( true );
/***************************************************************/ /***************************************************************/
QGridLayout* aGBLayout = new QGridLayout( myGrp->GroupBox1->layout() ); QGridLayout* aGBLayout = new QGridLayout( myGrp->GroupBox1->layout() );
aGBLayout->setAlignment( Qt::AlignTop ); aGBLayout->setAlignment( Qt::AlignTop );
@ -104,8 +107,8 @@ MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( Geomet
myErrorsLBox->setMinimumSize( 100, 100 ); myErrorsLBox->setMinimumSize( 100, 100 );
Layout2->addWidget( myErrorsLBox, 1, 0 ); Layout2->addWidget( myErrorsLBox, 1, 0 );
mySubShapesLbl = new QLabel( tr( "GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES" ),
mySubShapesLbl = new QLabel( tr( "GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES" ), myGrp, "BlockCompoundSubShapes" ); myGrp, "BlockCompoundSubShapes" );
Layout2->addWidget( mySubShapesLbl, 0, 1 ); Layout2->addWidget( mySubShapesLbl, 0, 1 );
mySubShapesLBox = new QListBox( myGrp, "ListSubShapes" ); mySubShapesLBox = new QListBox( myGrp, "ListSubShapes" );
@ -114,9 +117,11 @@ MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( Geomet
Layout2->addWidget( mySubShapesLBox, 1, 1 ); Layout2->addWidget( mySubShapesLBox, 1, 1 );
aGBLayout->addLayout( Layout2, 1, 0 ); aGBLayout->addLayout( Layout2, 1, 0 );
Layout1->addWidget( myGrp, 1, 0 ); Layout1->addWidget( myGrp, 2, 0 );
connect( myErrorsLBox, SIGNAL( selectionChanged() ), SLOT( onErrorsListSelectionChanged() ) ); connect( myErrorsLBox, SIGNAL( selectionChanged() ), SLOT( onErrorsListSelectionChanged() ) );
connect( mySubShapesLBox, SIGNAL( selectionChanged() ), SLOT( onSubShapesListSelectionChanged() ) ); connect( mySubShapesLBox, SIGNAL( selectionChanged() ), SLOT( onSubShapesListSelectionChanged() ) );
/***************************************************************/
myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#Check_comp_blocks"; myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#Check_comp_blocks";
@ -124,7 +129,6 @@ MeasureGUI_CheckCompoundOfBlocksDlg::MeasureGUI_CheckCompoundOfBlocksDlg( Geomet
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~MeasureGUI_CheckCompoundOfBlocksDlg() // function : ~MeasureGUI_CheckCompoundOfBlocksDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -133,17 +137,126 @@ MeasureGUI_CheckCompoundOfBlocksDlg::~MeasureGUI_CheckCompoundOfBlocksDlg()
{ {
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void MeasureGUI_CheckCompoundOfBlocksDlg::Init() void MeasureGUI_CheckCompoundOfBlocksDlg::Init()
{ {
myEditCurrentArgument = myGrp->LineEdit1;
// signals and slots connections
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( myGrp->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( myGrp->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
initName( tr( "GEOM_BLOCKS_COMPOUND") );
buttonOk->setEnabled(false);
buttonApply->setEnabled(false);
activateSelection(); activateSelection();
mySelBtn = myGrp->PushButton1; SelectionIntoArgument();
mySelEdit = myGrp->LineEdit1;
MeasureGUI_Skeleton::Init(); // displays Dialog
this->show();
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void MeasureGUI_CheckCompoundOfBlocksDlg::ClickOnOk()
{
if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool MeasureGUI_CheckCompoundOfBlocksDlg::ClickOnApply()
{
if ( !onAccept() )
return false;
initName();
return true;
}
//=================================================================================
// function : SelectionIntoArgument
// purpose :
//=================================================================================
void MeasureGUI_CheckCompoundOfBlocksDlg::SelectionIntoArgument()
{
erasePreview();
myObj = GEOM::GEOM_Object::_nil();
if (IObjectCount() != 1) {
myGrp->LineEdit1->setText("");
processObject();
return;
}
Standard_Boolean testResult = Standard_False;
GEOM::GEOM_Object_var aSelectedObject =
GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
if (!testResult || aSelectedObject->_is_nil()) {
myGrp->LineEdit1->setText("");
processObject();
return;
}
myObj = aSelectedObject;
myGrp->LineEdit1->setText(GEOMBase::GetName(myObj));
processObject();
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument
// purpose :
//=================================================================================
void MeasureGUI_CheckCompoundOfBlocksDlg::SetEditCurrentArgument()
{
myGrp->LineEdit1->setFocus();
myEditCurrentArgument = myGrp->LineEdit1;
SelectionIntoArgument();
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void MeasureGUI_CheckCompoundOfBlocksDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if (send == myGrp->LineEdit1) {
myEditCurrentArgument = myGrp->LineEdit1;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void MeasureGUI_CheckCompoundOfBlocksDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
LightApp_SelectionMgr* aSel = myGeomGUI->getApp()->selectionMgr();
if (aSel)
connect(aSel, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
activateSelection();
displayPreview();
} }
//================================================================================= //=================================================================================
@ -194,10 +307,15 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
if (isCompoundOfBlocks) { if (isCompoundOfBlocks) {
aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_NO_ERRORS" ); aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_NO_ERRORS" );
buttonOk->setEnabled(false);
buttonApply->setEnabled(false);
} else { } else {
aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_ERRORS" ); aMsg += tr( "GEOM_CHECK_BLOCKS_COMPOUND_HAS_ERRORS" );
buttonOk->setEnabled(true);
buttonApply->setEnabled(true);
} }
myGrp->TextEdit1->setText(aMsg); myGrp->TextEdit1->setText(aMsg);
QStringList aErrList; QStringList aErrList;
QString aErrStr( "" ); QString aErrStr( "" );
QString aConSfx( " # " ); QString aConSfx( " # " );
@ -237,10 +355,10 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::processObject()
if ( !aErrStr.isEmpty() ) if ( !aErrStr.isEmpty() )
aErrList.append(aErrStr); aErrList.append(aErrStr);
} }
myErrorsLBox->clear(); myErrorsLBox->clear();
mySubShapesLBox->clear(); mySubShapesLBox->clear();
myErrorsLBox->insertStringList(aErrList); myErrorsLBox->insertStringList(aErrList);
return;
} }
//================================================================================= //=================================================================================
@ -295,7 +413,6 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged()
} }
mySubShapesLBox->clear(); mySubShapesLBox->clear();
mySubShapesLBox->insertStringList(aSubShapeList); mySubShapesLBox->insertStringList(aSubShapeList);
return;
} }
//================================================================================= //=================================================================================
@ -359,7 +476,6 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onSubShapesListSelectionChanged()
} }
} }
} }
return;
} }
//================================================================================= //=================================================================================
@ -373,3 +489,38 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::activateSelection()
aMap.Add( GEOM_COMPOUND ); aMap.Add( GEOM_COMPOUND );
globalSelection( aMap ); globalSelection( aMap );
} }
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void MeasureGUI_CheckCompoundOfBlocksDlg::enterEvent(QEvent* e)
{
if (!GroupConstructors->isEnabled())
ActivateThisDialog();
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool MeasureGUI_CheckCompoundOfBlocksDlg::isValid( QString& )
{
return !myObj->_is_nil();
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool MeasureGUI_CheckCompoundOfBlocksDlg::execute( ObjectList& objects )
{
GEOM::GEOM_Object_var anObj;
anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->CheckAndImprove(myObj);
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
return true;
}

View File

@ -24,12 +24,11 @@
// File : MeasureGUI_CheckCompoundOfBlocksDlg.h // File : MeasureGUI_CheckCompoundOfBlocksDlg.h
// Author : VKN // Author : VKN
// Module : GEOM // Module : GEOM
// $Header$
#ifndef DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H #ifndef DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H
#define DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H #define DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H
#include "MeasureGUI_Skeleton.h" #include "GEOMBase_Skeleton.h"
class MeasureGUI_1Sel1TextView_QTD; class MeasureGUI_1Sel1TextView_QTD;
class QListBox; class QListBox;
@ -45,40 +44,47 @@ class QLabel;
// class : MeasureGUI_CheckCompoundOfBlocksDlg // class : MeasureGUI_CheckCompoundOfBlocksDlg
// purpose : // purpose :
//================================================================================= //=================================================================================
class MEASUREGUI_EXPORT MeasureGUI_CheckCompoundOfBlocksDlg : public MeasureGUI_Skeleton class MEASUREGUI_EXPORT MeasureGUI_CheckCompoundOfBlocksDlg : public GEOMBase_Skeleton
{ {
Q_OBJECT Q_OBJECT
public: public:
MeasureGUI_CheckCompoundOfBlocksDlg( GeometryGUI* GUI, MeasureGUI_CheckCompoundOfBlocksDlg(GeometryGUI* GUI, QWidget* theParent);
QWidget* theParent ); ~MeasureGUI_CheckCompoundOfBlocksDlg();
~MeasureGUI_CheckCompoundOfBlocksDlg();
protected:
// redefined from GEOMBase_Helper and MeasureGUI_Skeleton protected:
// redefined from GEOMBase_Helper and GEOMBase_Skeleton
virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& msg );
virtual bool execute( ObjectList& objects );
virtual void processObject(); virtual void processObject();
private slots: private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void onErrorsListSelectionChanged(); void onErrorsListSelectionChanged();
void onSubShapesListSelectionChanged(); void onSubShapesListSelectionChanged();
private: private:
void Init();
void Init(); void enterEvent( QEvent* e );
bool getBCErrors( bool& theIsCompoundOfBlocks, bool getBCErrors( bool& theIsCompoundOfBlocks,
GEOM::GEOM_IBlocksOperations::BCErrors& theErrors); GEOM::GEOM_IBlocksOperations::BCErrors& theErrors);
void activateSelection(); void activateSelection();
private: private:
GEOM::GEOM_Object_var myObj;
MeasureGUI_1Sel1TextView_QTD* myGrp;
MeasureGUI_1Sel1TextView_QTD* myGrp; QLabel* myErrorsLbl;
QLabel* myErrorsLbl; QListBox* myErrorsLBox;
QListBox* myErrorsLBox; QLabel* mySubShapesLbl;
QLabel* mySubShapesLbl; QListBox* mySubShapesLBox;
QListBox* mySubShapesLBox;
}; };
#endif // DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H #endif // DIALOGBOX_CHECKCOMPOUNDOFBLOCKSDLG_H