2 // File : GeometryGUI_SuppressHoleDlg.cxx
4 // Author : Lucien PIGNOLONI
6 // Module : GeometryGUI
7 // Copyright : OPEN CASCADE
10 #include "GeometryGUI_SuppressHoleDlg.h"
11 #include "GeometryGUI.h"
13 #include "TopExp_Explorer.hxx"
15 #include "QAD_Application.h"
16 #include "QAD_Desktop.h"
17 #include "QAD_RightFrame.h"
18 #include "OCCViewer_Viewer3d.h"
19 #include "utilities.h"
21 #include <qapplication.h>
22 #include <qbuttongroup.h>
23 #include <qcheckbox.h>
24 #include <qgroupbox.h>
26 #include <qlineedit.h>
27 #include <qpushbutton.h>
28 #include <qradiobutton.h>
32 #include <qwhatsthis.h>
37 //=================================================================================
38 // class : GeometryGUI_SuppressHoleDlg()
39 // purpose : Constructs a GeometryGUI_SuppressHoleDlg which is a child of 'parent', with the
40 // name 'name' and widget flags set to 'f'.
41 // The dialog will by default be modeless, unless you set 'modal' to
42 // TRUE to construct a modal dialog.
43 //=================================================================================
44 GeometryGUI_SuppressHoleDlg::GeometryGUI_SuppressHoleDlg( QWidget* parent,
46 SALOME_Selection* Sel,
47 Handle (AIS_InteractiveContext) ic,
50 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
53 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_SUPRESS_HOLE")));
54 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
55 QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_SUPRESS_HOLE_FACE_SHELL")));
58 setName( "GeometryGUI_SuppressHoleDlg" );
60 setCaption( tr( "GEOM_SUPPRESSHOLE_TITLE" ) );
61 setSizeGripEnabled( TRUE );
62 GeometryGUI_SuppressHoleLayout = new QGridLayout( this );
63 GeometryGUI_SuppressHoleLayout->setSpacing( 6 );
64 GeometryGUI_SuppressHoleLayout->setMargin( 11 );
67 /***************************************************************/
68 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
69 GroupConstructors->setTitle( tr( "" ) );
70 GroupConstructors->setExclusive( TRUE );
71 GroupConstructors->setColumnLayout(0, Qt::Vertical );
72 GroupConstructors->layout()->setSpacing( 0 );
73 GroupConstructors->layout()->setMargin( 0 );
74 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
75 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
76 GroupConstructorsLayout->setSpacing( 6 );
77 GroupConstructorsLayout->setMargin( 11 );
79 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
80 Constructor1->setText( tr( "" ) );
81 Constructor1->setPixmap( image0 );
82 Constructor1->setChecked( TRUE );
83 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
84 Constructor1->setMinimumSize( QSize( 50, 0 ) );
85 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
86 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
87 GroupConstructorsLayout->addItem( spacer, 0, 1 );
89 Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
90 Constructor2->setText( tr( "" ) );
91 Constructor2->setPixmap( image2 );
92 Constructor2->setChecked( TRUE );
93 Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
94 Constructor2->setMinimumSize( QSize( 50, 0 ) );
95 GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
96 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
97 GroupConstructorsLayout->addItem( spacer_4, 0, 3 );
98 GeometryGUI_SuppressHoleLayout->addWidget( GroupConstructors, 0, 0 );
101 /***************************************************************/
102 GroupButtons = new QGroupBox( this, "GroupButtons" );
103 GroupButtons->setTitle( tr( "" ) );
104 GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupButtons->sizePolicy().hasHeightForWidth() ) );
105 GroupButtons->setColumnLayout(0, Qt::Vertical );
106 GroupButtons->layout()->setSpacing( 0 );
107 GroupButtons->layout()->setMargin( 0 );
108 GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );
109 GroupButtonsLayout->setAlignment( Qt::AlignTop );
110 GroupButtonsLayout->setSpacing( 6 );
111 GroupButtonsLayout->setMargin( 11 );
113 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
114 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
115 buttonOk->setAutoDefault( TRUE );
116 buttonOk->setDefault( TRUE );
117 buttonOk->setAccel( 276824143 );
118 GroupButtonsLayout->addWidget( buttonOk );
119 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
120 GroupButtonsLayout->addItem( spacer_2 );
121 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
122 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
123 buttonApply->setAutoDefault( TRUE );
124 buttonApply->setDefault( TRUE );
125 GroupButtonsLayout->addWidget( buttonApply );
126 buttonClose = new QPushButton( GroupButtons, "buttonClose" );
127 buttonClose->setText( tr( "GEOM_BUT_CLOSE" ) );
128 buttonClose->setAutoDefault( TRUE );
129 GroupButtonsLayout->addWidget( buttonClose );
130 GeometryGUI_SuppressHoleLayout->addWidget( GroupButtons, 2, 0 );
132 /* First constructor */
133 GroupC1 = new QGroupBox( this, "GroupC1" );
134 GroupC1->setTitle( tr( "" ) );
135 GroupC1->setMinimumSize( QSize( 0, 0 ) );
136 GroupC1->setFrameShape( QGroupBox::Box );
137 GroupC1->setFrameShadow( QGroupBox::Sunken );
138 GroupC1->setColumnLayout(0, Qt::Vertical );
139 GroupC1->layout()->setSpacing( 0 );
140 GroupC1->layout()->setMargin( 0 );
141 GroupC1Layout = new QGridLayout( GroupC1->layout() );
142 GroupC1Layout->setAlignment( Qt::AlignTop );
143 GroupC1Layout->setSpacing( 6 );
144 GroupC1Layout->setMargin( 11 );
146 Layout2 = new QHBoxLayout;
147 Layout2->setSpacing( 6 );
148 Layout2->setMargin( 0 );
150 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
151 TextLabelC1A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
152 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
153 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
154 TextLabelC1A1->setFrameShadow( QLabel::Plain );
155 Layout2->addWidget( TextLabelC1A1 );
157 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
158 SelectButtonC1A1->setText( tr( "" ) );
159 SelectButtonC1A1->setPixmap( image1 );
160 SelectButtonC1A1->setToggleButton( FALSE );
161 SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
162 Layout2->addWidget( SelectButtonC1A1 );
164 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
165 LineEditC1A1->setAlignment( int( QLineEdit::AlignLeft ) );
166 Layout2->addWidget( LineEditC1A1 );
168 GroupC1Layout->addLayout( Layout2, 0, 0 );
170 CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" );
171 CheckBox1->setText( tr( "GEOM_SUPPRESSHOLE_SELECTFACE" ) );
172 CheckBox1->setChecked( FALSE );
173 GroupC1Layout->addWidget( CheckBox1, 1, 0 );
175 CheckBox2 = new QCheckBox( GroupC1, "CheckBox2" );
176 CheckBox2->setText( tr( "GEOM_SUPPRESSHOLE_SELECTWIRE" ) );
177 CheckBox2->setChecked( FALSE );
178 GroupC1Layout->addWidget( CheckBox2, 2, 0 );
180 CheckBox3 = new QCheckBox( GroupC1, "CheckBox3" );
181 CheckBox3->setText( tr( "GEOM_SUPPRESSHOLE_SELECTFACE_END" ) );
182 CheckBox3->setChecked( FALSE );
183 GroupC1Layout->addWidget( CheckBox3, 3, 0 );
184 GeometryGUI_SuppressHoleLayout->addWidget( GroupC1, 1, 0 );
186 /* Second constructor */
187 GroupC2 = new QGroupBox( this, "GroupC2" );
188 GroupC2->setTitle( tr( "" ) );
189 GroupC2->setMinimumSize( QSize( 0, 0 ) );
190 GroupC2->setFrameShape( QGroupBox::Box );
191 GroupC2->setFrameShadow( QGroupBox::Sunken );
192 GroupC2->setColumnLayout(0, Qt::Vertical );
193 GroupC2->layout()->setSpacing( 0 );
194 GroupC2->layout()->setMargin( 0 );
195 GroupC2Layout = new QGridLayout( GroupC2->layout() );
196 GroupC2Layout->setAlignment( Qt::AlignTop );
197 GroupC2Layout->setSpacing( 6 );
198 GroupC2Layout->setMargin( 11 );
200 Layout3 = new QHBoxLayout;
201 Layout3->setSpacing( 6 );
202 Layout3->setMargin( 0 );
204 TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
205 TextLabelC2A1->setText( tr( "GEOM_SUPPRESSHOLE_FACE_SHELL" ) );
206 TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
207 TextLabelC2A1->setFrameShape( QLabel::NoFrame );
208 TextLabelC2A1->setFrameShadow( QLabel::Plain );
209 Layout3->addWidget( TextLabelC2A1 );
211 SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
212 SelectButtonC2A1->setText( tr( "" ) );
213 SelectButtonC2A1->setPixmap( image1 );
214 SelectButtonC2A1->setToggleButton( FALSE );
215 SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
216 Layout3->addWidget( SelectButtonC2A1 );
218 LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
219 LineEditC2A1->setAlignment( int( QLineEdit::AlignLeft ) );
220 Layout3->addWidget( LineEditC2A1 );
222 GroupC2Layout->addLayout( Layout3, 0, 0 );
223 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
224 GroupC2Layout->addItem( spacer_3, 2, 0 );
226 CheckBoxC2_1 = new QCheckBox( GroupC2, "CheckBoxC2_1" );
227 CheckBoxC2_1->setText( tr( "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE" ) );
228 CheckBoxC2_1->setChecked( FALSE );
230 GroupC2Layout->addWidget( CheckBoxC2_1, 1, 0 );
231 GeometryGUI_SuppressHoleLayout->addWidget( GroupC2, 1, 0 );
234 /* Initialisations */
239 //=================================================================================
240 // function : ~GeometryGUI_SuppressHoleDlg()
241 // purpose : Destroys the object and frees any allocated resources
242 //=================================================================================
243 GeometryGUI_SuppressHoleDlg::~GeometryGUI_SuppressHoleDlg()
245 // no need to delete child widgets, Qt does it all for us
250 //=================================================================================
253 //=================================================================================
254 void GeometryGUI_SuppressHoleDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
259 myConstructorId = 0 ;
260 Constructor1->setChecked( TRUE );
261 myEditCurrentArgument = LineEditC1A1 ;
266 myUseLocalContext = false ;
268 myOkSelectFace = false ;
270 myListOfIdFace = new GEOM::GEOM_Shape::ListOfSubShapeID;
271 myListOfIdWire = new GEOM::GEOM_Shape::ListOfSubShapeID;
272 myListOfIdEndFace = new GEOM::GEOM_Shape::ListOfSubShapeID;
274 myListOfIdFace->length(0) ;
275 myListOfIdWire->length(0) ;
276 myListOfIdEndFace->length(0) ;
278 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
280 /* Select sub modes not checked */
281 CheckBox1->setChecked( FALSE ); /* sub mode GEOM::FACE */
282 CheckBox2->setChecked( FALSE ); /* sub mode GEOM::WIRE */
283 CheckBox3->setChecked( FALSE ); /* sub mode END GEOM::FACE */
285 CheckBoxC2_1->setChecked( FALSE ); /* sub mode GEOM::WIRE(S) */
287 // TODO : previous selection into argument ?
289 /* Filter definitions */
290 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
291 myGeom = GEOM::GEOM_Gen::_narrow(comp);
293 /* signals and slots connections */
294 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
295 connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
296 connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) );
297 connect( GroupConstructors, SIGNAL( clicked(int) ), this, SLOT( ConstructorsClicked(int) ));
299 connect( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ));
300 connect( SelectButtonC2A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ));
302 connect( CheckBox1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserFaceSelection() ));
303 connect( CheckBox2, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserWireSelection() ));
304 connect( CheckBox3, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserEndFaceSelection() ));
306 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
307 connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
309 /* for the second constructor */
310 connect( CheckBoxC2_1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserWiresOnFaceShellSelection() ));
312 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ));
313 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
314 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnClose() ));
316 /* Move widget on the botton right corner of main widget */
318 myGeomGUI->DefineDlgPosition( this, x, y ) ;
320 this->show() ; /* display Dialog */
325 //=================================================================================
326 // function : ConstructorsClicked()
327 // purpose : Radio button management
328 //=================================================================================
329 void GeometryGUI_SuppressHoleDlg::ConstructorsClicked(int constructorId)
331 switch (constructorId)
337 myConstructorId = constructorId ;
338 myEditCurrentArgument = LineEditC1A1 ;
339 LineEditC1A1->setText(tr("")) ;
341 myOkSelectFace = false ;
342 this->ResetPartial() ;
343 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
350 myConstructorId = constructorId ;
351 myEditCurrentArgument = LineEditC2A1 ;
352 LineEditC2A1->setText(tr("")) ;
354 this->ResetPartial() ;
355 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
356 this->ResetPartial() ;
364 //=================================================================================
365 // function : ClickOnOk()
366 // purpose : Same than click on apply but close this dialog.
367 //=================================================================================
368 void GeometryGUI_SuppressHoleDlg::ClickOnOk()
370 this->ClickOnApply() ;
378 //=================================================================================
379 // function : ClickOnApply()
381 //=================================================================================
382 void GeometryGUI_SuppressHoleDlg::ClickOnApply()
384 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
385 bool testResult = false ;
389 switch (myConstructorId)
391 case 0: /* default constructor */
393 if( !myOkSelectFace )
396 if( CheckBox2->isChecked() ) {
398 if( !CheckBox3->isChecked() ) {
400 /* Call method to get sub shape selection of GEOM::WIRE */
401 bool aTest = myGeomGUI->GetIndexSubShapeSelected(myFace, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ;
403 myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
404 if( !aTest || myListOfIdWire->length() != 1 ) {
405 CheckBox2->setChecked(FALSE) ;
406 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
409 myListOfIdEndFace->length(0) ; /* no end face */
410 QApplication::setOverrideCursor( Qt::waitCursor );
411 testResult = myGeomGUI->OnSuppressHole( myShapeIOR, myListOfIdFace, myListOfIdWire, myListOfIdEndFace ) ;
412 QApplication::restoreOverrideCursor();
415 else { /* CheckBox3->isChecked() */
417 /* Call method to get sub shape selection of END GEOM::FACE */
418 bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_FACE), myListOfIdEndFace, myLocalContextId, myUseLocalContext) ;
420 myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
421 if( !aTest || myListOfIdEndFace->length() != 1 ) {
422 CheckBox3->setChecked(FALSE) ;
423 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
426 QApplication::setOverrideCursor( Qt::waitCursor );
427 testResult = myGeomGUI->OnSuppressHole( myShapeIOR, myListOfIdFace, myListOfIdWire, myListOfIdEndFace ) ;
428 QApplication::restoreOverrideCursor();
435 case 1: /* second constructor */
437 if( CheckBoxC2_1->isChecked() ) {
439 /* Call method to get sub shape selection of one or more GEOM::WIRE(s) on a face or a shell */
440 bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ;
442 myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
444 if( !aTest || myListOfIdWire->length() < 1 ) {
445 CheckBoxC2_1->setChecked(FALSE) ;
446 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
449 QApplication::setOverrideCursor( Qt::waitCursor );
450 testResult = myGeomGUI->OnSuppressHolesInFaceOrShell( myShapeIOR, myListOfIdWire ) ;
451 QApplication::restoreOverrideCursor();
460 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
462 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_DONE") ) ;
464 /* Reset arguments to allow a new selection */
465 this->ResetStateOfDialog() ;
471 //=================================================================================
472 // function : ClickOnClose()
474 //=================================================================================
475 void GeometryGUI_SuppressHoleDlg::ClickOnClose()
477 disconnect( mySelection, 0, this, 0 );
478 myGeomGUI->ResetState() ;
480 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
481 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
482 myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
483 if(myUseLocalContext) {
484 myIC->CloseLocalContext(myLocalContextId) ;
485 this->myUseLocalContext = false ;
486 myGeomGUI->OnDisplayAll(true) ;
495 //=================================================================================
496 // function : SelectionIntoArgument()
497 // purpose : Called when selection as changed or other case
498 // : used only by SelectButtonC1A1 and SelectButtonC2A1
499 //=================================================================================
500 void GeometryGUI_SuppressHoleDlg::SelectionIntoArgument()
503 /* Reset argument and local context when selection as changed */
504 this->ResetStateOfDialog() ;
506 QString aString = ""; /* Name of selection */
508 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
514 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
516 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
519 if ( S.IsNull() || S.ShapeType() == TopAbs_VERTEX || S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE ) {
523 /* Test the exact type of topology to suppress faces into. */
524 /* For the second constructor a face or shell selection is needed */
525 if ( myConstructorId == 0 || ( myConstructorId == 1 && ( S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL ) ) ) {
527 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
528 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
530 /* The Geom IOR string of selection */
531 myShapeIOR = GIObject->getIOR();
532 myEditCurrentArgument->setText(aString) ;
538 if ( IO->hasEntry() ) {
539 SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
540 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
541 SALOMEDS::GenericAttribute_var anAttr;
542 SALOMEDS::AttributeIOR_var anIOR;
543 if ( !obj->_is_nil() ) {
544 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
545 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
546 myShapeIOR = anIOR->Value();
549 myEditCurrentArgument->setText(aString) ;
560 //=================================================================================
561 // function : SetEditCurrentArgument()
563 //=================================================================================
564 void GeometryGUI_SuppressHoleDlg::SetEditCurrentArgument()
566 QPushButton* send = (QPushButton*)sender();
567 switch (myConstructorId)
569 case 0: /* default constructor */
571 if(send == SelectButtonC1A1) {
572 LineEditC1A1->setFocus() ;
573 myEditCurrentArgument = LineEditC1A1;
574 SelectionIntoArgument() ;
580 if(send == SelectButtonC2A1) {
581 LineEditC2A1->setFocus() ;
582 myEditCurrentArgument = LineEditC2A1;
583 SelectionIntoArgument() ;
592 //=================================================================================
593 // function : LineEditReturnPressed()
595 //=================================================================================
596 void GeometryGUI_SuppressHoleDlg::LineEditReturnPressed()
598 QLineEdit* send = (QLineEdit*)sender();
599 if( send == LineEditC1A1 )
600 myEditCurrentArgument = LineEditC1A1 ;
601 else if ( send == LineEditC2A1)
602 myEditCurrentArgument = LineEditC2A1;
606 /* User name of object input management */
607 /* If successfull the selection is changed and signal emitted... */
608 /* so SelectionIntoArgument() is automatically called. */
609 const QString objectUserName = myEditCurrentArgument->text() ;
610 QWidget* thisWidget = (QWidget*)this ;
611 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
612 myEditCurrentArgument->setText( objectUserName ) ;
619 //=================================================================================
620 // function : DeactivateActiveDialog()
622 //=================================================================================
623 void GeometryGUI_SuppressHoleDlg::DeactivateActiveDialog()
625 if ( GroupConstructors->isEnabled() ) {
627 this->ResetStateOfDialog() ;
629 disconnect( mySelection, 0, this, 0 );
630 GroupConstructors->setEnabled(false) ;
631 GroupC1->setEnabled(false) ;
632 GroupC2->setEnabled(false) ;
633 GroupButtons->setEnabled(false) ;
635 myGeomGUI->ResetState() ;
636 myGeomGUI->SetActiveDialogBox(0) ;
637 myGeomGUI->OnDisplayAll(true) ;
643 //=================================================================================
644 // function : ActivateThisDialog()
646 //=================================================================================
647 void GeometryGUI_SuppressHoleDlg::ActivateThisDialog()
649 /* Emit a signal to deactivate other active dialog */
650 myGeomGUI->EmitSignalDeactivateDialog() ;
652 GroupConstructors->setEnabled(true) ;
653 GroupC1->setEnabled(true) ;
654 GroupC2->setEnabled(true) ;
655 GroupButtons->setEnabled(true) ;
657 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
658 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
663 //=================================================================================
664 // function : enterEvent()
665 // purpose : Mouse enter onto the dialog to activate it
666 //=================================================================================
667 void GeometryGUI_SuppressHoleDlg::enterEvent(QEvent* e)
669 if ( GroupConstructors->isEnabled() )
671 ActivateThisDialog() ;
676 //=================================================================================
677 // function : closeEvent()
679 //=================================================================================
680 void GeometryGUI_SuppressHoleDlg::closeEvent( QCloseEvent* e )
682 /* same than click on cancel button */
683 this->ClickOnClose() ;
688 //=================================================================================
689 // function : ActivateUserFaceSelection()
690 // purpose : Called when CheckBox1 state has changed. (Face selection is ckecked)
691 // : Be careful user must first select a face then a wire !
692 //=================================================================================
693 void GeometryGUI_SuppressHoleDlg::ActivateUserFaceSelection()
695 if( !this->myOkShape ) {
696 this->ResetStateOfDialog() ;
697 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_MAIN_OBJECT") ) ;
701 /* Test the viewer type VTK */
702 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
703 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
704 this->ResetStateOfDialog() ;
708 if( CheckBox1->isChecked() ) {
710 /* local context is opened into the method : Prepare GEOM::FACE sub selection */
711 myGeomGUI->PrepareSubShapeSelection( int(TopAbs_FACE), this->myLocalContextId ) ;
712 myUseLocalContext = true ;
713 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTFACE") ) ;
716 this->ResetPartial() ;
723 //=================================================================================
724 // function : ActivateUserWireSelection()
725 // purpose : Called when CheckBox2 state has changed. (Wire selection is ckecked)
726 // : Be careful user must first select a face then a wire !
727 //=================================================================================
728 void GeometryGUI_SuppressHoleDlg::ActivateUserWireSelection()
731 if( !this->myOkShape ) {
732 this->ResetStateOfDialog() ;
733 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ;
737 /* Test the type of viewer VTK */
738 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
739 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
740 this->ResetStateOfDialog() ;
744 if( CheckBox1->isChecked() ) {
746 /* Get sub shape selection GEOM::FACE : local context is closed */
747 bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_FACE), myListOfIdFace, myLocalContextId, myUseLocalContext) ;
749 myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
750 if( !aTest || myListOfIdFace->length() != 1 ) {
751 CheckBox1->setChecked(FALSE) ;
752 myOkSelectFace = false ;
753 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
756 myOkSelectFace = true ;
760 this->ResetPartial() ;
765 if( CheckBox2->isChecked() ) {
767 /* Get the face selection */
768 this->myFace = FaceFromList(myShape, myListOfIdFace) ;
769 /* Local context is opened into the method : Prepare GEOM::WIRE sub selection into a face */
770 myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myFace, int(TopAbs_WIRE), this->myLocalContextId ) ;
771 myUseLocalContext = true ;
772 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTWIRE") ) ;
775 this->ResetPartial() ;
783 //=================================================================================
784 // function : ActivateUserlEndFaceSelection()
785 // purpose : Called when CheckBox3 state has changed. ( Optional End Face selection )
786 // : Be careful user must first select a face then a wire then this optional end face !
787 //=================================================================================
788 void GeometryGUI_SuppressHoleDlg::ActivateUserEndFaceSelection()
791 if( !this->myOkShape ) {
792 this->ResetStateOfDialog() ;
793 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ;
797 /* Test the type of viewer VTK */
798 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
799 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
800 this->ResetStateOfDialog() ;
805 if( CheckBox2->isChecked() ) {
806 /* Call method to get sub shape selection for the GEOM::WIRE into myFace : local context is closed */
807 bool aTest = myGeomGUI->GetIndexSubShapeSelected(this->myFace, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ;
809 myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
811 if( !aTest || myListOfIdWire->length() != 1 ) {
812 CheckBox2->setChecked(FALSE) ;
813 CheckBox3->setChecked(FALSE) ;
814 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
819 this->ResetPartial() ;
824 if( CheckBox3->isChecked() ) {
825 /* Local context is opened into the method : prepare GEOM::FACE(end) into myShape sub selection */
826 myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myShape, int(TopAbs_FACE), this->myLocalContextId ) ;
827 myUseLocalContext = true ;
828 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTFACE_END") ) ;
831 this->ResetPartial() ;
839 //=================================================================================
840 // function : ActivateUserWiresOnFaceShellSelection()
841 // purpose : Called when CheckBoxC2_1 state has changed.
842 // : Only for second constructor !
843 // : Prepare selection for wire(s) on main object that is a face or a shell
844 //=================================================================================
845 void GeometryGUI_SuppressHoleDlg::ActivateUserWiresOnFaceShellSelection()
848 if( !this->myOkShape ) {
849 this->ResetStateOfDialog() ;
850 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ;
854 /* Test the type of viewer VTK */
855 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
856 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
857 this->ResetStateOfDialog() ;
861 if( CheckBoxC2_1->isChecked() ) {
862 /* Local context is opened to prepare GEOM::WIRE(S) selection into 'myShape' that is a (main) face */
863 myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myShape, int(TopAbs_WIRE), this->myLocalContextId ) ;
864 myUseLocalContext = true ;
865 myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE") ) ;
868 this->ResetPartial() ;
875 //=================================================================================
876 // function : FaceFromList()
877 // purpose : Return the face (selected by user) that is a sub shape of 'aShape'
878 // : and which unique index is in 'ListOfSub'.
879 // : This allows opening a local context with this face loaded.
880 // : See : myGeomGUI->PrepareSubShapeSelectionArgumentShape(...)
881 //=================================================================================
882 TopoDS_Shape GeometryGUI_SuppressHoleDlg::FaceFromList( const TopoDS_Shape& aShape,
883 const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSub )
887 if( ListOfSub.length() != 1 || aShape.IsNull() )
890 int i = ListOfSub[0] ;
891 TopExp_Explorer exp ;
893 for( exp.Init(aShape, TopAbs_FACE); exp.More(); exp.Next() ) {
895 return exp.Current() ;
904 //=================================================================================
905 // function : ResetStateOfDialog()
906 // purpose : Completely reset the state of method including local context
907 //=================================================================================
908 void GeometryGUI_SuppressHoleDlg::ResetStateOfDialog()
910 this->myOkShape = false ;
911 this->myEditCurrentArgument->setText("") ;
913 /* Partial reset and more ...*/
914 this->ResetPartial() ;
920 //=================================================================================
921 // function : ResetPartial()
922 // purpose : Partially reset to keep only main selection
923 //=================================================================================
924 void GeometryGUI_SuppressHoleDlg::ResetPartial()
926 /* Select sub shape modes not checked */
927 this->myOkSelectFace = false ;
928 this->CheckBox1->setChecked( FALSE );
929 this->CheckBox2->setChecked( FALSE );
930 this->CheckBox3->setChecked( FALSE );
931 this->CheckBoxC2_1->setChecked( FALSE );
933 myListOfIdFace->length(0) ;
934 myListOfIdWire->length(0) ;
935 myListOfIdEndFace->length(0) ;
937 /* Close its local contact if opened */
938 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
939 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
940 myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
941 if( this->myUseLocalContext ) {
942 myIC->CloseLocalContext(this->myLocalContextId) ;
943 this->myUseLocalContext = false ;
944 myGeomGUI->OnDisplayAll(true) ;