0022751: [EDF] Publish results of the Check Free Faces operation

This commit is contained in:
skv 2014-10-09 17:30:30 +04:00
parent f4bb8ea64a
commit 797eeddded
3 changed files with 145 additions and 192 deletions

View File

@ -836,6 +836,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_FREE_FACES</source> <source>GEOM_FREE_FACES</source>
<translation>Free faces</translation> <translation>Free faces</translation>
</message> </message>
<message>
<source>GEOM_FREE_FACES_NAME</source>
<translation>Free_face_%1</translation>
</message>
<message> <message>
<source>GEOM_FREE_FACES_TITLE</source> <source>GEOM_FREE_FACES_TITLE</source>
<translation>Free faces</translation> <translation>Free faces</translation>

View File

@ -26,38 +26,35 @@
// //
#include "RepairGUI_FreeFacesDlg.h" #include "RepairGUI_FreeFacesDlg.h"
#include <LightApp_Application.h> #include <GEOMBase.h>
#include <LightApp_SelectionMgr.h> #include <GeometryGUI.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Tools.h>
#include <SalomeApp_Study.h>
#include <SUIT_MessageBox.h>
#include <SUIT_Session.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_ViewManager.h>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_Constants.h> #include <GEOM_Constants.h>
#include <TopTools_IndexedMapOfShape.hxx> #include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <SalomeApp_Tools.h>
#include <SUIT_Desktop.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_ViewManager.h>
#include <SUIT_ViewWindow.h>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMBase.h>
#include <GeometryGUI.h>
#include <GEOM_Displayer.h>
#include <QLineEdit>
#include <QLabel>
#include <QGroupBox> #include <QGroupBox>
#include <QPushButton>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QKeyEvent>
#define SPACING 6 #define SPACING 6
#define MARGIN 9 #define MARGIN 9
@ -71,27 +68,32 @@
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg( GeometryGUI* GUI, QWidget* parent, RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg( GeometryGUI* GUI, QWidget* parent,
bool modal ) bool modal)
: QDialog( parent, 0 ), : GEOMBase_Skeleton(GUI, parent, modal),
GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) ), myDisplayer (0),
myGeomGUI( GUI ), myEdit (0)
myDisplayer( 0 )
{ {
setAttribute( Qt::WA_DeleteOnClose ); QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FREE_FACES")));
setSizeGripEnabled( true );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
setWindowTitle( tr( "GEOM_FREE_FACES_TITLE" ) ); setWindowTitle( tr( "GEOM_FREE_FACES_TITLE" ) );
/***************************************************************/ /***************************************************************/
mainFrame()->GroupConstructors->setTitle(tr("GEOM_FREE_FACES"));
mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
mainFrame()->GroupBoxName->hide();
QGroupBox* aMainGrp = new QGroupBox( tr( "GEOM_SELECTED_SHAPE" ), this ); QGroupBox* aMainGrp = new QGroupBox( tr( "GEOM_SELECTED_SHAPE" ), this );
QLabel* lab = new QLabel( tr( "GEOM_OBJECT" ), aMainGrp ); QLabel* lab = new QLabel( tr( "GEOM_OBJECT" ), aMainGrp );
mySelBtn = new QPushButton( aMainGrp ); QPushButton *aSelBtn = new QPushButton( aMainGrp );
mySelBtn->setIcon( image1 ); aSelBtn->setIcon( image1 );
myEdit = new QLineEdit( aMainGrp ); myEdit = new QLineEdit( aMainGrp );
myEdit->setReadOnly( true ); myEdit->setReadOnly( true );
myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
@ -101,37 +103,19 @@ RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg( GeometryGUI* GUI, QWidget* paren
aMainLay->setSpacing( SPACING ); aMainLay->setSpacing( SPACING );
aMainLay->setMargin( MARGIN ); aMainLay->setMargin( MARGIN );
aMainLay->addWidget( lab ); aMainLay->addWidget( lab );
aMainLay->addWidget( mySelBtn ); aMainLay->addWidget( aSelBtn );
aMainLay->addWidget( myEdit ); aMainLay->addWidget( myEdit );
QFrame* aFrame = new QFrame( this ); QVBoxLayout* aLay = new QVBoxLayout (centralWidget());
aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); aLay->setSpacing(SPACING);
QPushButton* aCloseBtn = new QPushButton( tr( "GEOM_BUT_CLOSE" ), aFrame ); aLay->setMargin(MARGIN);
QPushButton* aHelpBtn = new QPushButton( tr( "GEOM_BUT_HELP" ), aFrame ); aLay->addWidget(aMainGrp);
QHBoxLayout* aBtnLay = new QHBoxLayout( aFrame ); resize(minimumSizeHint());
aBtnLay->setSpacing( SPACING ); /***************************************************************/
aBtnLay->setMargin( MARGIN );
aBtnLay->addWidget( aCloseBtn );
aBtnLay->addSpacing( SPACING );
aBtnLay->addStretch();
aBtnLay->addWidget( aHelpBtn );
QVBoxLayout* aLay = new QVBoxLayout( this );
aLay->setSpacing( SPACING );
aLay->setMargin( MARGIN );
aLay->addWidget( aMainGrp );
aLay->addStretch();
aLay->addWidget( aFrame );
myHelpFileName = "using_measurement_tools_page.html#faces_anchor"; myHelpFileName = "using_measurement_tools_page.html#faces_anchor";
connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) );
connect( aHelpBtn, SIGNAL( clicked() ), SLOT( onHelp() ) );
connect( mySelBtn, SIGNAL( clicked() ),
this, SLOT ( onSetEditCurrentArgument() ) );
/***************************************************************/
Init(); Init();
} }
@ -145,70 +129,6 @@ RepairGUI_FreeFacesDlg::~RepairGUI_FreeFacesDlg()
} }
//=================================================================================
// function : onClose
// purpose : SLOT. Called when "close" button pressed. Close dialog
//=================================================================================
void RepairGUI_FreeFacesDlg::onClose()
{
globalSelection();
disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 );
myGeomGUI->SetActiveDialogBox( 0 );
reject();
erasePreview();
}
//=================================================================================
// function : onHelp()
// purpose :
//=================================================================================
void RepairGUI_FreeFacesDlg::onHelp()
{
LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
if ( app )
app->onHelpContextModule( myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString(""), myHelpFileName );
else {
QString platform;
#ifdef WIN32
platform = "winapplication";
#else
platform = "application";
#endif
SUIT_MessageBox::warning( this,
tr( "WRN_WARNING" ),
tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
arg( app->resourceMgr()->stringValue( "ExternalBrowser",
platform ) ).
arg( myHelpFileName ) );
}
}
//=================================================================================
// function : onDeactivate
// purpose : Deactivate this dialog
//=================================================================================
void RepairGUI_FreeFacesDlg::onDeactivate()
{
setEnabled( false );
globalSelection();
disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 );
myGeomGUI->SetActiveDialogBox( 0 );
}
//=================================================================================
// function : onActivate
// purpose : Activate this dialog
//=================================================================================
void RepairGUI_FreeFacesDlg::onActivate()
{
myGeomGUI->EmitSignalDeactivateDialog();
setEnabled( true );
myGeomGUI->SetActiveDialogBox( this );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
activateSelection();
}
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
@ -216,22 +136,71 @@ void RepairGUI_FreeFacesDlg::onActivate()
void RepairGUI_FreeFacesDlg::Init() void RepairGUI_FreeFacesDlg::Init()
{ {
myObj = GEOM::GEOM_Object::_nil(); myObj = GEOM::GEOM_Object::_nil();
myEditCurrentArgument = myEdit;
/* signals and slots connections */ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT ( onDeactivate() ) ); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
SIGNAL( currentSelectionChanged() ), SLOT ( onSelectionDone() ) ); this, SLOT(SelectionIntoArgument()));
activateSelection(); activateSelection();
onSelectionDone(); SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : onSelectionDone // function : ClickOnOk()
// purpose :
//=================================================================================
void RepairGUI_FreeFacesDlg::ClickOnOk()
{
if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool RepairGUI_FreeFacesDlg::ClickOnApply()
{
if (!onAccept())
return false;
return true;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void RepairGUI_FreeFacesDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
activateSelection();
displayPreview(true);
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void RepairGUI_FreeFacesDlg::enterEvent(QEvent*)
{
if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
//=================================================================================
// function : SelectionIntoArgument
// purpose : SLOT. Called when selection changed. // purpose : SLOT. Called when selection changed.
//================================================================================= //=================================================================================
void RepairGUI_FreeFacesDlg::onSelectionDone() void RepairGUI_FreeFacesDlg::SelectionIntoArgument()
{ {
myEditCurrentArgument->setText("");
myObj = GEOM::GEOM_Object::_nil();
erasePreview(); erasePreview();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -239,7 +208,6 @@ void RepairGUI_FreeFacesDlg::onSelectionDone()
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
if ( aSelList.Extent() != 1 ) { if ( aSelList.Extent() != 1 ) {
myEdit->setText( "" );
return; return;
} }
@ -247,27 +215,17 @@ void RepairGUI_FreeFacesDlg::onSelectionDone()
GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( !GEOMBase::IsShape( anObj ) ) { if ( !GEOMBase::IsShape( anObj ) ) {
myEdit->setText( "" );
return; return;
} } else {
else {
myObj = anObj; myObj = anObj;
myEditCurrentArgument->setText(GEOMBase::GetName(myObj));
displayPreview( true, false, true, true, 3 ); displayPreview( true, false, true, true, 3 );
} }
} }
//=================================================================================
// function : enterEvent()
// purpose : Mouse enter onto the dialog to activate it
//=================================================================================
void RepairGUI_FreeFacesDlg::enterEvent( QEvent* )
{
onActivate();
}
//================================================================================= //=================================================================================
// function : activateSelection // function : activateSelection
// purpose : activate selection of faces, shells, and solids // purpose : activate selection of solids
//================================================================================= //=================================================================================
void RepairGUI_FreeFacesDlg::activateSelection() void RepairGUI_FreeFacesDlg::activateSelection()
{ {
@ -277,15 +235,6 @@ void RepairGUI_FreeFacesDlg::activateSelection()
globalSelection( aMap ); globalSelection( aMap );
} }
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void RepairGUI_FreeFacesDlg::closeEvent( QCloseEvent* )
{
onClose();
}
//================================================================================= //=================================================================================
// function : createOperation // function : createOperation
// purpose : // purpose :
@ -350,7 +299,10 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects )
} }
} }
for ( int i = 0, n = aFaceLst->length(); i < n; i++ ) { int i;
int n = aFaceLst->length();
for (i = 0; i < n; i++ ) {
aFace = anIndices.FindKey( aFaceLst[i] ); aFace = anIndices.FindKey( aFaceLst[i] );
try { try {
getDisplayer()->SetColor( Quantity_NOC_RED ); getDisplayer()->SetColor( Quantity_NOC_RED );
@ -363,8 +315,18 @@ bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects )
catch( const SALOME::SALOME_Exception& e ) catch( const SALOME::SALOME_Exception& e )
{ {
SalomeApp_Tools::QtCatchCorbaException( e ); SalomeApp_Tools::QtCatchCorbaException( e );
return false;
} }
} }
// Create sub-objects
GEOM::ListOfGO_var aList = anOper->MakeSubShapes(myObj, aFaceLst);
for (i = 0, n = aList->length(); i < n; i++) {
objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i]));
}
aResult = true;
} }
return aResult; return aResult;
} }
@ -380,28 +342,23 @@ GEOM_Displayer* RepairGUI_FreeFacesDlg::getDisplayer()
return myDisplayer; return myDisplayer;
} }
//================================================================================= //================================================================
// function : SetEditCurrentArgument // Function : getNewObjectName
// purpose : // Purpose : Redefine this method to return proper name for a new object
//================================================================================= //================================================================
void RepairGUI_FreeFacesDlg::onSetEditCurrentArgument() QString RepairGUI_FreeFacesDlg::getNewObjectName (int currObj) const
{ {
myEdit->setFocus(); QString aName = tr("GEOM_FREE_FACES_NAME").arg(currObj);
onSelectionDone();
return aName;
} }
//================================================================================= //================================================================
// function : keyPressEvent() // Function : getFather
// purpose : // Purpose : Get father object for object to be added in study
//================================================================================= // (called with addInStudy method)
void RepairGUI_FreeFacesDlg::keyPressEvent( QKeyEvent* e ) //================================================================
GEOM::GEOM_Object_ptr RepairGUI_FreeFacesDlg::getFather (GEOM::GEOM_Object_ptr)
{ {
QDialog::keyPressEvent( e ); return myObj;
if ( e->isAccepted() )
return;
if ( e->key() == Qt::Key_F1 ) {
e->accept();
onHelp();
}
} }

View File

@ -27,11 +27,9 @@
#ifndef REPAIRGUI_FREEFACESDLG_H #ifndef REPAIRGUI_FREEFACESDLG_H
#define REPAIRGUI_FREEFACESDLG_H #define REPAIRGUI_FREEFACESDLG_H
#include <QDialog> #include <GEOMBase_Skeleton.h>
#include <GEOMBase_Helper.h>
class GEOM_Displayer; class GEOM_Displayer;
class QPushButton;
class QLineEdit; class QLineEdit;
class GeometryGUI; class GeometryGUI;
@ -39,8 +37,7 @@ class GeometryGUI;
// class : RepairGUI_FreeFacesDlg // class : RepairGUI_FreeFacesDlg
// purpose : // purpose :
//================================================================================= //=================================================================================
class RepairGUI_FreeFacesDlg : public QDialog, class RepairGUI_FreeFacesDlg : public GEOMBase_Skeleton
public GEOMBase_Helper
{ {
Q_OBJECT Q_OBJECT
@ -53,30 +50,25 @@ 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& ); virtual bool execute( ObjectList& );
virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr);
virtual QString getNewObjectName (int CurrObj = -1) const;
private: private:
void Init(); void Init();
void enterEvent( QEvent* ); void enterEvent( QEvent* );
void closeEvent( QCloseEvent* );
void keyPressEvent( QKeyEvent* );
void activateSelection(); void activateSelection();
GEOM_Displayer* getDisplayer(); GEOM_Displayer* getDisplayer();
private slots: private slots:
void onClose(); void ClickOnOk();
void onHelp(); bool ClickOnApply();
void onDeactivate(); void SelectionIntoArgument();
void onActivate(); void ActivateThisDialog();
void onSelectionDone();
void onSetEditCurrentArgument();
private: private:
GEOM_Displayer* myDisplayer; GEOM_Displayer* myDisplayer;
GEOM::GEOM_Object_var myObj; GEOM::GEOM_Object_var myObj;
QPushButton* mySelBtn;
QLineEdit* myEdit; QLineEdit* myEdit;
GeometryGUI* myGeomGUI;
QString myHelpFileName;
}; };
#endif // REPAIRGUI_FREEFACESDLG_H #endif // REPAIRGUI_FREEFACESDLG_H