1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GeometryGUI_SubShapeDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_SubShapeDlg.h"
32 #include "GeometryGUI.h"
33 #include "QAD_Application.h"
34 #include "QAD_Desktop.h"
35 #include "QAD_RightFrame.h"
36 #include "OCCViewer_Viewer3d.h"
37 #include "utilities.h"
39 #include <TopExp_Explorer.hxx>
41 #include <qbuttongroup.h>
42 #include <qcheckbox.h>
43 #include <qcombobox.h>
44 #include <qgroupbox.h>
46 #include <qlineedit.h>
47 #include <qpushbutton.h>
48 #include <qradiobutton.h>
52 #include <qwhatsthis.h>
57 #include <qmessagebox.h>
59 //=================================================================================
60 // class : GeometryGUI_SubShapeDlg()
61 // purpose : Constructs a GeometryGUI_SubShapeDlg which is a child of 'parent', with the
62 // name 'name' and widget flags set to 'f'.
63 // The dialog will by default be modeless, unless you set 'modal' to
64 // TRUE to construct a modal dialog.
65 //=================================================================================
66 GeometryGUI_SubShapeDlg::GeometryGUI_SubShapeDlg( QWidget* parent,
68 SALOME_Selection* Sel,
69 Handle (AIS_InteractiveContext) ic,
73 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
75 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SUBSHAPE")));
76 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT")));
79 setName( "GeometryGUI_SUBSHAPE" );
81 setCaption( tr( "GEOM_SUBSHAPE_TITLE" ) );
82 setSizeGripEnabled( TRUE );
83 GeometryGUI_SubShapeDlgLayout = new QGridLayout( this );
84 GeometryGUI_SubShapeDlgLayout->setSpacing( 6 );
85 GeometryGUI_SubShapeDlgLayout->setMargin( 11 );
87 /***************************************************************/
88 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
89 GroupConstructors->setTitle( tr( "GEOM_SUB_SHAPE" ) );
90 GroupConstructors->setExclusive( TRUE );
91 GroupConstructors->setColumnLayout(0, Qt::Vertical );
92 GroupConstructors->layout()->setSpacing( 0 );
93 GroupConstructors->layout()->setMargin( 0 );
94 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
95 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
96 GroupConstructorsLayout->setSpacing( 6 );
97 GroupConstructorsLayout->setMargin( 11 );
98 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
99 Constructor1->setText( tr( "" ) );
100 Constructor1->setPixmap( image0 );
101 Constructor1->setChecked( TRUE );
102 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
103 Constructor1->setMinimumSize( QSize( 50, 0 ) );
104 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
105 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
106 GroupConstructorsLayout->addItem( spacer, 0, 1 );
107 GeometryGUI_SubShapeDlgLayout->addWidget( GroupConstructors, 0, 0 );
109 /***************************************************************/
110 GroupButtons = new QGroupBox( this, "GroupButtons" );
111 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
112 GroupButtons->setTitle( tr( "" ) );
113 GroupButtons->setColumnLayout(0, Qt::Vertical );
114 GroupButtons->layout()->setSpacing( 0 );
115 GroupButtons->layout()->setMargin( 0 );
116 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
117 GroupButtonsLayout->setAlignment( Qt::AlignTop );
118 GroupButtonsLayout->setSpacing( 6 );
119 GroupButtonsLayout->setMargin( 11 );
120 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
121 buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
122 buttonCancel->setAutoDefault( TRUE );
123 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
124 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
125 buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
126 buttonApply->setAutoDefault( TRUE );
127 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
128 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
129 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
130 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
131 buttonOk->setText( tr( "GEOM_BUT_OK" ) );
132 buttonOk->setAutoDefault( TRUE );
133 buttonOk->setDefault( TRUE );
134 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
135 GeometryGUI_SubShapeDlgLayout->addWidget( GroupButtons, 2, 0 );
137 /***************************************************************/
138 GroupC1 = new QGroupBox( this, "GroupC1" );
139 GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) );
140 GroupC1->setMinimumSize( QSize( 0, 0 ) );
141 GroupC1->setFrameShape( QGroupBox::Box );
142 GroupC1->setFrameShadow( QGroupBox::Sunken );
143 GroupC1->setColumnLayout(0, Qt::Vertical );
144 GroupC1->layout()->setSpacing( 0 );
145 GroupC1->layout()->setMargin( 0 );
146 GroupC1Layout = new QGridLayout( GroupC1->layout() );
147 GroupC1Layout->setAlignment( Qt::AlignTop );
148 GroupC1Layout->setSpacing( 6 );
149 GroupC1Layout->setMargin( 11 );
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 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
156 TextLabelComboBox1 = new QLabel( GroupC1, "TextLabelComboBox1" );
157 TextLabelComboBox1->setText( tr( "GEOM_SUBSHAPE_TYPE" ) );
158 GroupC1Layout->addMultiCellWidget( TextLabelComboBox1, 1, 1, 0, 1 );
159 ComboBox1 = new QComboBox( FALSE, GroupC1, "ComboBox1" );
160 ComboBox1->setMaxCount( 100 );
161 GroupC1Layout->addMultiCellWidget( ComboBox1, 1, 1, 2, 3 );
162 CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" );
163 CheckBox1->setText( tr( "GEOM_SUBSHAPE_SELECT" ) );
164 CheckBox1->setChecked( FALSE );
165 GroupC1Layout->addMultiCellWidget( CheckBox1, 2, 2, 0, 1 );
166 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
167 GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 3 );
168 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
169 SelectButtonC1A1->setText( tr( "" ) );
170 SelectButtonC1A1->setPixmap( image1 );
171 SelectButtonC1A1->setToggleButton( FALSE );
172 SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
173 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
174 GeometryGUI_SubShapeDlgLayout->addWidget( GroupC1, 1, 0 );
175 /***************************************************************/
177 /* Initialisations */
182 //=================================================================================
183 // function : ~GeometryGUI_SubShapeDlg()
184 // purpose : Destroys the object and frees any allocated resources
185 //=================================================================================
186 GeometryGUI_SubShapeDlg::~GeometryGUI_SubShapeDlg()
188 // no need to delete child widgets, Qt does it all for us
192 //=================================================================================
195 //=================================================================================
196 void GeometryGUI_SubShapeDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
200 myConstructorId = 0 ;
201 Constructor1->setChecked( TRUE );
202 myEditCurrentArgument = LineEditC1A1 ;
207 myUseLocalContext = false ;
208 myLocalContextId = -1;
211 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
213 /* type for sub shape selection */
214 ComboBox1->insertItem("Compound");
215 ComboBox1->insertItem("Compsolid");
216 ComboBox1->insertItem("Solid");
217 ComboBox1->insertItem("Shell");
218 ComboBox1->insertItem("Face");
219 ComboBox1->insertItem("Wire");
220 ComboBox1->insertItem("Edge");
221 ComboBox1->insertItem("Vertex");
222 ComboBox1->insertItem("Shape");
225 myShapeType = ComboBox1->currentItem();
227 /* Select sub shapes mode not checked */
228 CheckBox1->setChecked( FALSE );
229 myOkSelectSubMode = CheckBox1->isChecked();
231 // TODO : previous selection into argument ?
233 /* Filter definitions */
234 Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
235 myGeom = GEOM::GEOM_Gen::_narrow(comp);
237 /* signals and slots connections */
238 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
239 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
240 connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
241 connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) );
243 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
244 connect( CheckBox1, SIGNAL (stateChanged(int) ), this, SLOT( AllOrNotAll() ) ) ;
246 connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
248 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
249 connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
250 connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
252 connect( ComboBox1, SIGNAL( activated(int) ), this, SLOT( ComboTextChanged() ) );
254 /* Move widget on the botton right corner of main widget */
256 myGeomGUI->DefineDlgPosition( this, x, y ) ;
258 this->show() ; /* display Dialog */
263 //=================================================================================
264 // function : ConstructorsClicked()
265 // purpose : Radio button management
266 //=================================================================================
267 void GeometryGUI_SubShapeDlg::ConstructorsClicked(int constructorId)
272 //=================================================================================
273 // function : ClickOnOk()
275 //=================================================================================
276 void GeometryGUI_SubShapeDlg::ClickOnOk()
278 this->ClickOnApply() ;
280 /* User has aborted or not operation of explode all with many sub shapes */
281 if( this->myAbort == false )
282 this->ClickOnCancel() ;
284 this->myAbort = false ;
290 //=================================================================================
291 // function : ClickOnApply()
293 //=================================================================================
294 void GeometryGUI_SubShapeDlg::ClickOnApply()
296 myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
297 bool testResult = false ;
299 this->myAbort = false ; /* Not aborted by default */
301 switch(myConstructorId)
305 /* Explode all sub shapes */
306 if( myOkShape && !myOkSelectSubMode ) {
308 /* More than 30 subshapes : ask confirmation */
309 unsigned int nb = NumberOfSubShapes( myShape, myShapeType ) ;
311 const QString caption = tr("GEOM_CONFIRM") ;
312 const QString text = tr("GEOM_CONFIRM_INFO").arg(nb) ;
313 const QString button0 = tr("GEOM_BUT_EXPLODE") ;
314 const QString button1 = tr("GEOM_BUT_CANCEL") ;
316 if( QMessageBox::warning( this, caption, text, button0, button1 ) == 0 )
317 testResult = myGeomGUI->OnSubShapeGetAll( myShape, myShapeIOR, myShapeType ) ;
319 this->myAbort = true ; /* aborted */
322 testResult = myGeomGUI->OnSubShapeGetAll( myShape, myShapeIOR, myShapeType ) ;
325 /* explode only selected sub shapes */
326 else if( myOkShape && myOkSelectSubMode ) {
327 testResult = myGeomGUI->OnSubShapeGetSelected( myShape, myShapeIOR, myShapeType, myLocalContextId, myUseLocalContext ) ;
330 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
331 this->myAbort = true;
334 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
336 /* Reset all arguments and local context to allow user a new selection ...*/
337 this->ResetStateOfDialog() ;
345 //=================================================================================
346 // function : ClickOnCancel()
348 //=================================================================================
349 void GeometryGUI_SubShapeDlg::ClickOnCancel()
351 disconnect( mySelection, 0, this, 0 );
352 myGeomGUI->ResetState() ;
354 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
355 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
356 myIC = v3d->getAISContext();
357 if(myUseLocalContext) {
358 myIC->CloseLocalContext(myLocalContextId) ;
359 myGeomGUI->OnDisplayAll(true) ;
360 this->myUseLocalContext = false ;
368 //=================================================================================
369 // function : SelectionIntoArgument()
370 // purpose : Called when selection as changed or other case
371 // : used only by SelectButtonC1A1 (LineEditC1A1)
372 //=================================================================================
373 void GeometryGUI_SubShapeDlg::SelectionIntoArgument()
376 /* Reset all arguments and local context when selection as changed */
377 this->ResetStateOfDialog() ;
379 QString aString = ""; /* future name of selection */
381 int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
384 LineEditC1A1->setText("") ;
391 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
393 if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
396 if( !IO->hasEntry() ) {
397 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ;
401 if ( !S.IsNull() && S.ShapeType() != TopAbs_VERTEX )
403 if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) )
405 Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
406 myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */
407 LineEditC1A1->setText(aString) ;
413 SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
414 SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
415 SALOMEDS::GenericAttribute_var anAttr;
416 SALOMEDS::AttributeIOR_var anIOR;
417 if ( !obj->_is_nil() )
419 if (obj->FindAttribute(anAttr, "AttributeIOR"))
421 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
422 myShapeIOR = anIOR->Value();
425 LineEditC1A1->setText(aString) ;
430 int SelectedShapeType = ComboBox1->currentItem();
431 int count = ComboBox1->count();
432 if ( myWithShape ) count = count - 1;
435 while ( i <= myShape.ShapeType() ) {
436 ComboBox1->removeItem(0);
440 if (myShape.ShapeType()==TopAbs_COMPOUND)
442 if (myWithShape == false) {
443 ComboBox1->insertItem("Shape");
449 if (myWithShape == true) {
450 ComboBox1->removeItem( ComboBox1->count() -1 );
455 int count1 = ComboBox1->count();
456 if ( myWithShape ) count1 = count1 - 1;
458 if ( SelectedShapeType > myShape.ShapeType() ) {
459 if ( SelectedShapeType == 8 ) {
460 if ( myShape.ShapeType() != TopAbs_COMPOUND ) {
461 ComboBox1->setCurrentItem(0);
462 myShapeType = 8 - count1;
465 ComboBox1->setCurrentItem( count1 - count + SelectedShapeType );
466 myShapeType = 8 - count1 + ComboBox1->currentItem();
469 ComboBox1->setCurrentItem(0);
470 myShapeType = 8 - count1;
476 //=================================================================================
477 // function : SetEditCurrentArgument()
479 //=================================================================================
480 void GeometryGUI_SubShapeDlg::SetEditCurrentArgument()
482 QPushButton* send = (QPushButton*)sender();
483 switch (myConstructorId)
485 case 0: /* default constructor */
487 if(send == SelectButtonC1A1) {
488 LineEditC1A1->setFocus() ;
489 myEditCurrentArgument = LineEditC1A1;
490 SelectionIntoArgument() ;
500 //=================================================================================
501 // function : LineEditReturnPressed()
503 //=================================================================================
504 void GeometryGUI_SubShapeDlg::LineEditReturnPressed()
506 QLineEdit* send = (QLineEdit*)sender();
507 if( send == LineEditC1A1 )
508 myEditCurrentArgument = LineEditC1A1 ;
512 /* User name of object input management */
513 /* If successfull the selection is changed and signal emitted... */
514 /* so SelectionIntoArgument() is automatically called. */
515 const QString objectUserName = myEditCurrentArgument->text() ;
516 QWidget* thisWidget = (QWidget*)this ;
517 if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
518 myEditCurrentArgument->setText( objectUserName ) ;
524 //=================================================================================
525 // function : DeactivateActiveDialog()
527 //=================================================================================
528 void GeometryGUI_SubShapeDlg::DeactivateActiveDialog()
530 /* Check if active */
531 if ( GroupConstructors->isEnabled() ) {
533 this->ResetStateOfDialog() ;
535 disconnect( mySelection, 0, this, 0 );
536 GroupConstructors->setEnabled(false) ;
537 GroupC1->setEnabled(false) ;
538 GroupButtons->setEnabled(false) ;
539 myGeomGUI->ResetState() ;
540 myGeomGUI->SetActiveDialogBox(0) ;
541 myGeomGUI->OnDisplayAll(true) ;
547 //=================================================================================
548 // function : ActivateThisDialog()
550 //=================================================================================
551 void GeometryGUI_SubShapeDlg::ActivateThisDialog()
553 /* Emit a signal to deactivate other active dialog */
554 myGeomGUI->EmitSignalDeactivateDialog() ;
555 GroupConstructors->setEnabled(true) ;
556 GroupC1->setEnabled(true) ;
557 GroupButtons->setEnabled(true) ;
558 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
559 myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
564 //=================================================================================
565 // function : enterEvent()
567 //=================================================================================
568 void GeometryGUI_SubShapeDlg::enterEvent(QEvent* e)
570 if ( GroupConstructors->isEnabled() )
572 ActivateThisDialog() ;
577 //=================================================================================
578 // function : closeEvent()
580 //=================================================================================
581 void GeometryGUI_SubShapeDlg::closeEvent( QCloseEvent* e )
583 /* same than click on cancel button */
584 this->ClickOnCancel() ;
589 //=================================================================================
590 // function : AllOrNotAll()
591 // purpose : Allow user selection of all or only selected sub shapes
592 // : Called when 'CheckBox1' state change
593 //=================================================================================
594 void GeometryGUI_SubShapeDlg::AllOrNotAll()
597 /* No sub shape selection if main shape not selected */
598 if( !this->myOkShape ) {
599 ResetStateOfDialog() ;
600 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")) ;
604 if (myShapeType ==TopAbs_SHAPE && myShape.ShapeType()==TopAbs_COMPOUND)
606 /* Select sub shapes mode not checked */
607 myOkSelectSubMode = false ;
608 CheckBox1->setChecked( FALSE );
609 //no meaning to allow user selection for type = shape
610 //TODO - add another message
611 //myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")) ;
615 myOkSelectSubMode = CheckBox1->isChecked() ;
617 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
618 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
619 myIC = v3d->getAISContext();
620 if( this->myUseLocalContext ) {
621 myIC->CloseLocalContext(myLocalContextId) ;
622 this->myUseLocalContext = false ;
623 myGeomGUI->OnDisplayAll(true) ;
626 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
630 if( myOkShape && myOkSelectSubMode ) {
631 /* local context is defined into the method */
632 myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ;
633 myUseLocalContext = true ;
634 myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FACE")) ;
640 //=================================================================================
641 // function : ResetStateOfDialog()
642 // purpose : Completely reset the state of method including local context
643 //=================================================================================
644 void GeometryGUI_SubShapeDlg::ResetStateOfDialog()
646 /* To leave current selection if explode all as been aborted by user */
647 if( this->myAbort == true ) {
648 this->myOkShape = false ;
649 this->myEditCurrentArgument->setText("") ;
652 ; /* nothing to do : keep selection argument */
655 int SelectedShapeType = ComboBox1->currentItem();
656 int count = ComboBox1->count();
657 if ( myWithShape ) count = count - 1;
658 /* type for sub shape selection */
660 ComboBox1->insertItem("Compound");
661 ComboBox1->insertItem("Compsolid");
662 ComboBox1->insertItem("Solid");
663 ComboBox1->insertItem("Shell");
664 ComboBox1->insertItem("Face");
665 ComboBox1->insertItem("Wire");
666 ComboBox1->insertItem("Edge");
667 ComboBox1->insertItem("Vertex");
668 ComboBox1->insertItem("Shape");
669 this->myWithShape=true;
670 ComboBox1->setCurrentItem( 8 - count + SelectedShapeType );
673 /* unpress buttons : due to abort box*/
674 this->buttonApply->setDown(FALSE) ;
675 this->buttonOk->setDown(FALSE) ;
677 /* Select sub shapes mode not checked */
678 this->myOkSelectSubMode = false ;
679 this->CheckBox1->setChecked( FALSE );
681 /* Close its local contact if opened */
682 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
683 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
684 myIC = v3d->getAISContext();
685 if( this->myUseLocalContext ) {
686 myIC->CloseLocalContext(this->myLocalContextId) ;
687 this->myUseLocalContext = false ;
688 myGeomGUI->OnDisplayAll(true) ;
696 //=================================================================================
697 // function : ComboTextChanged()
699 //=================================================================================
700 void GeometryGUI_SubShapeDlg::ComboTextChanged()
703 this->myShapeType = ComboBox1->currentItem() + myShape.ShapeType() + 1;
705 this->myShapeType = ComboBox1->currentItem();
707 /* Select sub shapes mode not checked */
708 CheckBox1->setChecked( FALSE );
709 myOkSelectSubMode = FALSE ;
711 if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
712 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
713 myIC = v3d->getAISContext();
714 if( this->myUseLocalContext ) {
715 myIC->CloseLocalContext(myLocalContextId) ;
716 this->myUseLocalContext = false ;
717 myGeomGUI->OnDisplayAll(true) ;
724 //=================================================================================
725 // function : NumberOfSubShapes()
727 //=================================================================================
728 unsigned int GeometryGUI_SubShapeDlg::NumberOfSubShapes( const TopoDS_Shape& S, const int shapeType )
733 unsigned int index = 0 ;
734 TopExp_Explorer Exp( S, TopAbs_ShapeEnum(shapeType) );
735 TopTools_MapOfShape M;
736 while ( Exp.More() ) {
737 if ( M.Add(Exp.Current()) )