From: vkn Date: Thu, 13 Jan 2005 08:28:14 +0000 (+0000) Subject: Fix of Bug PAL7333 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3e0be377845458e3069fa4917ba4b6a858ee2b6d;p=modules%2Fgeom.git Fix of Bug PAL7333 Bug Description: - DEVELOPMENT : Free faces in GEOM module Fix Description: "Repair/Check free faces" function displays (in red) the face which are free. --- diff --git a/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx b/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx index 885495f88..54b50e964 100644 --- a/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx +++ b/src/RepairGUI/RepairGUI_FreeFacesDlg.cxx @@ -30,15 +30,30 @@ using namespace std; #include "RepairGUI_FreeFacesDlg.h" #include "QAD_Desktop.h" -#include "QAD_SpinBoxDbl.h" +#include "QAD_WaitCursor.h" -#include "OCCViewer_Viewer3d.h" -#include "DlgRef_1Sel_Ext.h" #include "SALOME_ListIteratorOfListIO.hxx" #include "GEOMImpl_Types.hxx" +#include +#include +#include "GEOMBase.h" +#include "GeometryGUI.h" +#include "GEOM_Displayer.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SALOME_Selection.h" +#include "SALOME_Prs.h" +#include +#include +#include +#include +#include +#define SPACING 5 +#define MARGIN 10 +#define MIN_WIDTH 200 + //================================================================================= // class : RepairGUI_FreeFacesDlg() @@ -47,31 +62,55 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +RepairGUI_FreeFacesDlg::RepairGUI_FreeFacesDlg(QWidget* parent, const char* name, SALOME_Selection* theSelection, bool modal, WFlags fl) +:QDialog( parent, "RepairGUI_FreeBoundDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_FREE_FACES"))); + myDisplayer = 0; + + setSizeGripEnabled( TRUE ); QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_FREE_FACES_TITLE")); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_FREE_FACES_TITLE")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_FREE_FACES")); - GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); - GroupPoints->PushButton1->setPixmap(image1); - GroupPoints->LineEdit1->setReadOnly( true ); - Layout1->removeChild( GroupBoxName ); - Layout1->addWidget(GroupPoints, 1, 0); + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_SELECTED_SHAPE" ), this ); + + + QGroupBox* aSelGrp = new QGroupBox( 1, Qt::Vertical, aMainGrp ); + + aSelGrp->setInsideMargin( 0 ); + aSelGrp->setFrameStyle( QFrame::NoFrame ); + new QLabel( tr( "GEOM_OBJECT" ), aSelGrp ); + mySelBtn = new QPushButton( aSelGrp ); + mySelBtn->setPixmap( image1 ); + myEdit = new QLineEdit( aSelGrp ); + myEdit->setReadOnly( true ); + myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myEdit->setMinimumWidth( MIN_WIDTH ); + + QFrame* aFrame = new QFrame( this ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + QPushButton* aCloseBtn = new QPushButton( tr( "GEOM_BUT_CLOSE" ), aFrame ); + QHBoxLayout* aBtnLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + aBtnLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aBtnLay->addWidget( aCloseBtn ); + aBtnLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + + QVBoxLayout* aLay = new QVBoxLayout( this ); + aLay->setSpacing( SPACING ); + aLay->setMargin( MARGIN ); + aLay->addWidget( aMainGrp ); + aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aLay->addWidget( aFrame ); + + connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ); + connect( mySelBtn, SIGNAL( clicked() ), + this, SLOT ( onSetEditCurrentArgument() ) ); /***************************************************************/ - Init(); + Init( theSelection ); } @@ -85,171 +124,119 @@ RepairGUI_FreeFacesDlg::~RepairGUI_FreeFacesDlg() //================================================================================= -// function : Init() -// purpose : +// function : onClose +// purpose : SLOT. Called when "close" button pressed. Close dialog //================================================================================= -void RepairGUI_FreeFacesDlg::Init() +void RepairGUI_FreeFacesDlg::onClose() { - /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - - myObject = GEOM::GEOM_Object::_nil(); - - myGeomGUI->SetState( 0 ); - globalSelection( GEOM_COMPOUND ); - - /* signals and slots connections */ - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - + globalSelection(); + disconnect( mySelection, 0, this, 0 ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 ); + reject(); + erasePreview(); } - //================================================================================= -// function : ClickOnOk() -// purpose : Same than click on apply but close this dialog. +// function : onDeactivate +// purpose : Deactivate this dialog //================================================================================= -void RepairGUI_FreeFacesDlg::ClickOnOk() +void RepairGUI_FreeFacesDlg::onDeactivate() { - if ( ClickOnApply() ) - ClickOnCancel(); + setEnabled(false); + globalSelection(); + disconnect( mySelection, 0, this, 0 ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 ); } - - //================================================================================= -// function : ClickOnApply() -// purpose : +// function : onActivate +// purpose : Activate this dialog //================================================================================= -bool RepairGUI_FreeFacesDlg::ClickOnApply() +void RepairGUI_FreeFacesDlg::onActivate() { - if ( !onAccept() ) - return false; - - initName(); - - GroupPoints->LineEdit1->setText(""); - myObject = GEOM::GEOM_Object::_nil(); - - globalSelection( GEOM_COMPOUND ); - - return true; + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + setEnabled( true ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( this ); + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT ( onSelectionDone() ) ); + activateSelection(); } - //================================================================================= -// function : ClickOnCancel() +// function : Init() // purpose : //================================================================================= -void RepairGUI_FreeFacesDlg::ClickOnCancel() +void RepairGUI_FreeFacesDlg::Init(SALOME_Selection* theSel) { - GEOMBase_Skeleton::ClickOnCancel(); -} + myObj = GEOM::GEOM_Object::_nil(); + mySelection = theSel; -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection -//================================================================================= -void RepairGUI_FreeFacesDlg::SelectionIntoArgument() -{ - erasePreview(); - myEditCurrentArgument->setText(""); - myObject = GEOM::GEOM_Object::_nil(); - - if ( mySelection->IObjectCount() == 1 ) { - Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); - Standard_Boolean aRes; - myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); - if ( aRes ) - myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); - } -} + /* signals and slots connections */ + GeometryGUI* aGeomGUI = GeometryGUI::GetGeomGUI(); + connect( aGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT ( onDeactivate() ) ); + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT ( onSelectionDone() ) ); -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void RepairGUI_FreeFacesDlg::SetEditCurrentArgument() -{ - const QObject* send = sender(); - if ( send == GroupPoints->PushButton1 ) { - myEditCurrentArgument->setFocus(); - SelectionIntoArgument(); - } + activateSelection(); + onSelectionDone(); } - //================================================================================= -// function : LineEditReturnPressed() -// purpose : +// function : onSelectionDone +// purpose : SLOT. Called when selection changed. //================================================================================= -void RepairGUI_FreeFacesDlg::LineEditReturnPressed() +void RepairGUI_FreeFacesDlg::onSelectionDone() { - const QObject* send = sender(); - if( send == GroupPoints->LineEdit1 ) { - myEditCurrentArgument = GroupPoints->LineEdit1; - GEOMBase_Skeleton::LineEditReturnPressed(); + erasePreview(); + if( mySelection->IObjectCount() != 1 ) + { + myEdit->setText( "" ); + return; } -} + Standard_Boolean isOk = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), isOk ); -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void RepairGUI_FreeFacesDlg::DeactivateActiveDialog() -{ - myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::DeactivateActiveDialog(); + if ( !isOk || anObj->_is_nil() || !GEOMBase::IsShape( anObj ) ) + { + myEdit->setText( "" ); + return; + } + else + { + myObj = anObj; + displayPreview( false, true, true, 3 ); + } } - //================================================================================= -// function : ActivateThisDialog() -// purpose : +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it //================================================================================= -void RepairGUI_FreeFacesDlg::ActivateThisDialog() +void RepairGUI_FreeFacesDlg::enterEvent(QEvent* e) { - GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - GroupPoints->LineEdit1->setText(""); - myObject = GEOM::GEOM_Object::_nil(); - - myGeomGUI->SetState( 0 ); - globalSelection( GEOM_COMPOUND ); + onActivate(); } - //================================================================================= -// function : enterEvent() -// purpose : Mouse enter onto the dialog to activate it +// function : activateSelection +// purpose : activate selection of faces, shells, and solids //================================================================================= -void RepairGUI_FreeFacesDlg::enterEvent(QEvent* e) +void RepairGUI_FreeFacesDlg::activateSelection() { - if ( !GroupConstructors->isEnabled() ) - ActivateThisDialog(); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SOLID ); + aMap.Add( GEOM_COMPOUND ); + globalSelection( aMap ); } - //================================================================================= // function : closeEvent() // purpose : //================================================================================= void RepairGUI_FreeFacesDlg::closeEvent(QCloseEvent* e) { - myGeomGUI->SetState( -1 ); - GEOMBase_Skeleton::closeEvent( e ); + onClose(); } //================================================================================= @@ -267,7 +254,7 @@ GEOM::GEOM_IOperations_ptr RepairGUI_FreeFacesDlg::createOperation() //================================================================================= bool RepairGUI_FreeFacesDlg::isValid( QString& msg ) { - return !myObject->_is_nil() ; + return !myObj->_is_nil() ; } //================================================================================= @@ -277,11 +264,63 @@ bool RepairGUI_FreeFacesDlg::isValid( QString& msg ) bool RepairGUI_FreeFacesDlg::execute( ObjectList& objects ) { bool aResult = false; - GEOM::ListOfLong_var aCurrList = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->GetFreeFacesIDs( myObject ); - for ( int i = 0, n = aCurrList->length(); i < n; i++ ) + GEOM::ListOfLong_var aFaceLst = + GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->GetFreeFacesIDs( myObj ); + TopoDS_Shape aSelShape; + TopoDS_Shape aFace; + TopTools_IndexedMapOfShape anIndices; + if ( !myObj->_is_nil() && GEOMBase::GetShape( myObj, aSelShape ) ) { - //NOT yet implemented + myEdit->setText( GEOMBase::GetName( myObj ) ); + QString aMess; + if ( !isValid( aMess ) ) + { + erasePreview( true ); + return false; + } + + TopExp::MapShapes( aSelShape, anIndices); + SALOME_Prs* aPrs = 0; + QAD_WaitCursor wc; + + for ( int i = 0, n = aFaceLst->length(); i < n; i++ ) + { + aFace = anIndices.FindKey( aFaceLst[i] ); + try + { + getDisplayer()->SetColor( Quantity_NOC_RED ); + getDisplayer()->SetToActivate( false ); + aPrs = !aFace.IsNull() ? getDisplayer()->BuildPrs( aFace ) : 0; + if ( aPrs ) + displayPreview( aPrs, true ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + } + } } - return aResult; } + +//================================================================ +// Function : getDisplayer +// Purpose : +//================================================================ +GEOM_Displayer* RepairGUI_FreeFacesDlg::getDisplayer() +{ + if ( !myDisplayer ) + myDisplayer = new GEOM_Displayer(); + return myDisplayer; +} + +//================================================================================= +// function : SetEditCurrentArgument +// purpose : +//================================================================================= +void RepairGUI_FreeFacesDlg::onSetEditCurrentArgument() +{ + myEdit->setFocus(); + onSelectionDone(); +} + diff --git a/src/RepairGUI/RepairGUI_FreeFacesDlg.h b/src/RepairGUI/RepairGUI_FreeFacesDlg.h index a153ef69b..a8fd91d2d 100644 --- a/src/RepairGUI/RepairGUI_FreeFacesDlg.h +++ b/src/RepairGUI/RepairGUI_FreeFacesDlg.h @@ -29,16 +29,21 @@ #ifndef DIALOGBOX_FreeFaces_H #define DIALOGBOX_FreeFaces_H -#include "GEOMBase_Skeleton.h" +#include +#include "GEOMBase_Helper.h" -class QAD_SpinBoxDbl; -class DlgRef_1Sel_Ext; +class GEOM_Displayer; +class SALOME_Selection; +class SALOME_Prs; +class QPushButton; +class QLineEdit; //================================================================================= // class : RepairGUI_FreeFacesDlg // purpose : //================================================================================= -class RepairGUI_FreeFacesDlg : public GEOMBase_Skeleton +class RepairGUI_FreeFacesDlg : public QDialog, + public GEOMBase_Helper { Q_OBJECT @@ -53,26 +58,29 @@ protected: virtual bool execute( ObjectList& objects ); private : - void Init(); + + void Init(SALOME_Selection*); void enterEvent(QEvent* e); void closeEvent(QCloseEvent* e); - void initSelection(); + void activateSelection(); + GEOM_Displayer* getDisplayer(); - GEOM::GEOM_Object_var myObject; +private slots: - DlgRef_1Sel_Ext* GroupPoints; + void onClose(); + void onDeactivate(); + void onActivate(); + void onSelectionDone(); + void onSetEditCurrentArgument(); -private slots: - void ClickOnOk(); - bool ClickOnApply(); - void ClickOnCancel(); +private : - void ActivateThisDialog(); - void DeactivateActiveDialog(); + GEOM_Displayer* myDisplayer; + GEOM::GEOM_Object_var myObj; + SALOME_Selection* mySelection; + QPushButton* mySelBtn; + QLineEdit* myEdit; - void LineEditReturnPressed(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); }; #endif // DIALOGBOX_FreeFaces_H