2 // File : SMESHGUI_EditHypothesesDlg.cxx
3 // Created : Fri Aug 02 09:14:56 2002
4 // Author : Nicolas REJNERI
8 // Copyright : Open CASCADE 2002
11 #include "SMESHGUI_EditHypothesesDlg.h"
13 #include "SALOME_ListIteratorOfListIO.hxx"
15 #include "QAD_Application.h"
16 #include "QAD_Desktop.h"
17 #include "utilities.h"
20 #include <qbuttongroup.h>
21 #include <qgroupbox.h>
23 #include <qlineedit.h>
24 #include <qpushbutton.h>
25 #include <qradiobutton.h>
29 #include <qwhatsthis.h>
33 //VRV: porting on Qt 3.0.5
34 #if QT_VERSION >= 0x030005
37 //VRV: porting on Qt 3.0.5
39 //=================================================================================
40 // class : SMESHGUI_EditHypothesesDlg()
41 // purpose : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the
42 // name 'name' and widget flags set to 'f'.
43 // The dialog will by default be modeless, unless you set 'modal' to
44 // TRUE to construct a modal dialog.
45 //=================================================================================
46 SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
47 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
49 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDIT_MESH")));
50 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
52 setName( "SMESHGUI_EditHypothesesDlg" );
54 setCaption( tr( "SMESH_EDIT_HYPOTHESES" ) );
55 setSizeGripEnabled( TRUE );
56 SMESHGUI_EditHypothesesDlgLayout = new QGridLayout( this );
57 SMESHGUI_EditHypothesesDlgLayout->setSpacing( 6 );
58 SMESHGUI_EditHypothesesDlgLayout->setMargin( 11 );
60 /***************************************************************/
61 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
62 GroupConstructors->setTitle( tr( "SMESH_HYPOTHESES" ) );
63 GroupConstructors->setExclusive( TRUE );
64 GroupConstructors->setColumnLayout(0, Qt::Vertical );
65 GroupConstructors->layout()->setSpacing( 0 );
66 GroupConstructors->layout()->setMargin( 0 );
67 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
68 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
69 GroupConstructorsLayout->setSpacing( 6 );
70 GroupConstructorsLayout->setMargin( 11 );
71 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
72 Constructor1->setText( tr( "" ) );
73 Constructor1->setPixmap( image1 );
74 Constructor1->setChecked( TRUE );
75 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
76 Constructor1->setMinimumSize( QSize( 50, 0 ) );
77 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
78 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
79 GroupConstructorsLayout->addItem( spacer, 0, 1 );
80 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupConstructors, 0, 0 );
82 /***************************************************************/
83 GroupButtons = new QGroupBox( this, "GroupButtons" );
84 GroupButtons->setGeometry( QRect( 10, 10, 281, 96 ) );
85 GroupButtons->setTitle( tr( "" ) );
86 GroupButtons->setColumnLayout(0, Qt::Vertical );
87 GroupButtons->layout()->setSpacing( 0 );
88 GroupButtons->layout()->setMargin( 0 );
89 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
90 GroupButtonsLayout->setAlignment( Qt::AlignTop );
91 GroupButtonsLayout->setSpacing( 6 );
92 GroupButtonsLayout->setMargin( 11 );
93 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
94 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
95 buttonCancel->setAutoDefault( TRUE );
96 buttonCancel->setDefault( TRUE );
97 buttonCancel->setEnabled( TRUE ) ;
99 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
100 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
101 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
102 buttonApply->setAutoDefault( TRUE );
103 buttonApply->setDefault( FALSE );
104 buttonApply->setEnabled( FALSE ) ;
106 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
107 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
108 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
109 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
110 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
112 buttonOk->setAutoDefault( TRUE );
113 buttonOk->setDefault( FALSE );
114 buttonOk->setEnabled( FALSE ) ;
116 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
117 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupButtons, 5, 0 );
119 /***************************************************************/
120 GroupC1 = new QGroupBox( this, "GroupC1" );
121 GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
122 GroupC1->setMinimumSize( QSize( 0, 0 ) );
123 GroupC1->setFrameShape( QGroupBox::Box );
124 GroupC1->setFrameShadow( QGroupBox::Sunken );
125 GroupC1->setColumnLayout(0, Qt::Vertical );
126 GroupC1->layout()->setSpacing( 0 );
127 GroupC1->layout()->setMargin( 0 );
128 GroupC1Layout = new QGridLayout( GroupC1->layout() );
129 GroupC1Layout->setAlignment( Qt::AlignTop );
130 GroupC1Layout->setSpacing( 6 );
131 GroupC1Layout->setMargin( 11 );
133 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
134 TextLabelC1A1->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) );
135 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
136 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
137 TextLabelC1A1->setFrameShadow( QLabel::Plain );
138 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
139 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
140 SelectButtonC1A1->setText( tr( "" ) );
141 SelectButtonC1A1->setPixmap( image0 );
142 SelectButtonC1A1->setToggleButton( FALSE );
143 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
144 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
145 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
147 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
148 TextLabelC1A2->setText( tr( "SMESH_OBJECT_GEOM" ) );
149 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
150 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
151 TextLabelC1A2->setFrameShadow( QLabel::Plain );
152 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
153 SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
154 SelectButtonC1A2->setText( tr( "" ) );
155 SelectButtonC1A2->setPixmap( image0 );
156 SelectButtonC1A2->setToggleButton( FALSE );
157 GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
158 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
159 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
161 GroupHypotheses = new QGroupBox( this, "GroupHypotheses" );
162 GroupHypotheses->setTitle( tr( "SMESH_HYPOTHESES" ) );
163 GroupHypotheses->setColumnLayout(0, Qt::Vertical );
164 GroupHypotheses->layout()->setSpacing( 0 );
165 GroupHypotheses->layout()->setMargin( 0 );
166 grid_3 = new QGridLayout( GroupHypotheses->layout() );
167 grid_3->setGeometry( QRect( 12, 18, 139, 110 ) );
168 grid_3->setAlignment( Qt::AlignTop );
169 grid_3->setSpacing( 6 );
170 grid_3->setMargin( 11 );
172 hbox_2 = new QHBoxLayout;
173 hbox_2->setSpacing( 6 );
174 hbox_2->setMargin( 0 );
176 vbox = new QVBoxLayout;
177 vbox->setSpacing( 6 );
178 vbox->setMargin( 0 );
180 TextHypDefinition = new QLabel( GroupHypotheses, "TextHypDefinition" );
181 TextHypDefinition->setText( tr( "SMESH_AVAILABLE" ) );
182 vbox->addWidget( TextHypDefinition );
184 ListHypDefinition = new QListBox( GroupHypotheses, "ListHypDefinition" );
185 ListHypDefinition->setMinimumSize( 100, 50);
186 // ListHypDefinition->setRowMode(4);
187 // ListHypDefinition->setRowMode( QListBox::FixedNumber );
188 // ListHypDefinition->setLineWidth( 4 );
189 // ListHypDefinition->setColumnMode( QListBox::Variable );
190 // ListHypDefinition->setVariableHeight( FALSE );
191 // ListHypDefinition->insertItem( tr( "New Item" ) );
192 vbox->addWidget( ListHypDefinition );
193 hbox_2->addLayout( vbox );
195 vbox_2 = new QVBoxLayout;
196 vbox_2->setSpacing( 6 );
197 vbox_2->setMargin( 0 );
199 TextHypAssignation = new QLabel( GroupHypotheses, "TextHypAssignation" );
200 TextHypAssignation->setText( tr( "SMESH_EDIT_USED" ) );
201 vbox_2->addWidget( TextHypAssignation );
203 ListHypAssignation = new QListBox( GroupHypotheses, "ListHypAssignation" );
204 ListHypAssignation->setMinimumSize( 100, 50);
205 // ListHypAssignation->setRowMode(4);
206 // ListHypAssignation->setRowMode( QListBox::FixedNumber );
207 // ListHypAssignation->setLineWidth( 4 );
208 // ListHypAssignation->setColumnMode( QListBox::Variable );
209 // ListHypAssignation->setVariableHeight( FALSE );
210 // ListHypAssignation->insertItem( tr( "New Item" ) );
211 vbox_2->addWidget( ListHypAssignation );
212 hbox_2->addLayout( vbox_2 );
214 grid_3->addLayout( hbox_2, 0, 0 );
216 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupHypotheses, 2, 0 );
218 GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" );
219 GroupAlgorithms->setTitle( tr( "SMESH_ADD_ALGORITHM" ) );
220 GroupAlgorithms->setColumnLayout(0, Qt::Vertical );
221 GroupAlgorithms->layout()->setSpacing( 0 );
222 GroupAlgorithms->layout()->setMargin( 0 );
223 grid_4 = new QGridLayout( GroupAlgorithms->layout() );
224 grid_4->setGeometry( QRect( 12, 18, 139, 110 ) );
225 grid_4->setAlignment( Qt::AlignTop );
226 grid_4->setSpacing( 6 );
227 grid_4->setMargin( 11 );
229 hbox_3 = new QHBoxLayout;
230 hbox_3->setSpacing( 6 );
231 hbox_3->setMargin( 0 );
233 vbox_3 = new QVBoxLayout;
234 vbox_3->setSpacing( 6 );
235 vbox_3->setMargin( 0 );
237 TextAlgoDefinition = new QLabel( GroupAlgorithms, "TextAlgoDefinition" );
238 TextAlgoDefinition->setText( tr( "SMESH_AVAILABLE" ) );
239 vbox_3->addWidget( TextAlgoDefinition );
241 ListAlgoDefinition = new QListBox( GroupAlgorithms, "ListAlgoDefinition" );
242 ListAlgoDefinition->setMinimumSize( 100, 50);
243 // ListAlgoDefinition->setRowMode(4);
244 // ListAlgoDefinition->setRowMode( QListBox::FixedNumber );
245 // ListAlgoDefinition->setLineWidth( 4 );
246 // ListAlgoDefinition->setColumnMode( QListBox::Variable );
247 // ListAlgoDefinition->setVariableHeight( FALSE );
248 // ListAlgoDefinition->insertItem( tr( "New Item" ) );
249 vbox_3->addWidget( ListAlgoDefinition );
250 hbox_3->addLayout( vbox_3 );
252 vbox_4 = new QVBoxLayout;
253 vbox_4->setSpacing( 6 );
254 vbox_4->setMargin( 0 );
256 TextAlgoAssignation = new QLabel( GroupAlgorithms, "TextAlgoAssignation" );
257 TextAlgoAssignation->setText( tr( "SMESH_EDIT_USED" ) );
258 vbox_4->addWidget( TextAlgoAssignation );
260 ListAlgoAssignation = new QListBox( GroupAlgorithms, "ListAlgoAssignation" );
261 ListAlgoAssignation ->setMinimumSize( 100, 50);
262 // ListAlgoAssignation->setRowMode(4);
263 // ListAlgoAssignation->setRowMode( QListBox::FixedNumber );
264 // ListAlgoAssignation->setLineWidth( 4 );
265 // ListAlgoAssignation->setColumnMode( QListBox::Variable );
266 // ListAlgoAssignation->setVariableHeight( FALSE );
267 // ListAlgoAssignation->insertItem( tr( "New Item" ) );
268 vbox_4->addWidget( ListAlgoAssignation );
269 hbox_3->addLayout( vbox_4 );
271 grid_4->addLayout( hbox_3, 0, 0 );
272 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupAlgorithms, 3, 0 );
274 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 1, 0 );
275 /***************************************************************/
282 //=================================================================================
283 // function : ~SMESHGUI_EditHypothesesDlg()
284 // purpose : Destroys the object and frees any allocated resources
285 //=================================================================================
286 SMESHGUI_EditHypothesesDlg::~SMESHGUI_EditHypothesesDlg()
288 // no need to delete child widgets, Qt does it all for us
292 //=================================================================================
295 //=================================================================================
296 void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel )
299 myConstructorId = 0 ;
300 Constructor1->setChecked( TRUE );
301 myEditCurrentArgument = LineEditC1A1 ;
303 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
304 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
307 InitAlgoDefinition();
309 InitHypAssignation();
310 InitAlgoAssignation();
312 myGeomFilter = new SALOME_TypeFilter( "GEOM" );
313 myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
315 myGeomShape = GEOM::GEOM_Shape::_nil();
316 myMesh = SMESH::SMESH_Mesh::_nil();
317 mySubMesh = SMESH::SMESH_subMesh::_nil();
319 /* signals and slots connections */
320 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
321 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
323 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
324 connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
326 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
327 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
328 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
330 connect( ListHypAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
331 connect( ListAlgoAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
333 connect( ListHypDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
334 connect( ListAlgoDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
337 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
340 SelectionIntoArgument();
346 //=================================================================================
347 // function : ConstructorsClicked()
348 // purpose : Radio button management
349 //=================================================================================
350 void SMESHGUI_EditHypothesesDlg::ConstructorsClicked(int constructorId)
355 //=================================================================================
356 // function : ClickOnCancel()
358 //=================================================================================
359 void SMESHGUI_EditHypothesesDlg::ClickOnCancel()
361 disconnect( mySelection, 0, this, 0 );
362 mySMESHGUI->ResetState() ;
363 mySelection->ClearFilters() ;
369 //=================================================================================
370 // function : SelectionIntoArgument()
371 // purpose : Called when selection as changed or other case
372 //=================================================================================
373 void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
375 myEditCurrentArgument->setText("") ;
376 QString aString = "";
378 int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
380 switch (myConstructorId)
384 if ( myEditCurrentArgument == LineEditC1A1 ) {
386 myOkHypothesis = false;
387 myOkAlgorithm = false;
388 myMesh = SMESH::SMESH_Mesh::_nil();
389 mySubMesh = SMESH::SMESH_subMesh::_nil();
390 InitHypAssignation();
391 InitAlgoAssignation();
395 Standard_Boolean testResult ;
396 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
397 myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
399 myMesh = SMESH::SMESH_Mesh::_nil();
401 mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IO, testResult) ;
403 mySubMesh = SMESH::SMESH_subMesh::_nil();
404 InitHypAssignation();
405 InitAlgoAssignation();
410 InitHypAssignation();
411 InitAlgoAssignation();
414 } else if ( myEditCurrentArgument == LineEditC1A2 ) {
416 myOkHypothesis = false;
417 myOkAlgorithm = false;
418 myGeomShape = GEOM::GEOM_Shape::_nil();
419 InitHypAssignation();
420 InitAlgoAssignation();
424 Standard_Boolean testResult ;
425 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
426 myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
428 myGeomShape = GEOM::GEOM_Shape::_nil();
429 InitHypAssignation();
430 InitAlgoAssignation();
434 InitHypAssignation();
435 InitAlgoAssignation();
443 myEditCurrentArgument->setText(aString) ;
447 //=================================================================================
448 // function : SetEditCurrentArgument()
450 //=================================================================================
451 void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument()
453 QPushButton* send = (QPushButton*)sender();
454 switch (myConstructorId)
456 case 0: /* default constructor */
458 if(send == SelectButtonC1A1) {
459 LineEditC1A1->setFocus() ;
460 myEditCurrentArgument = LineEditC1A1;
461 mySelection->ClearFilters() ;
462 mySelection->AddFilter(myMeshOrSubMeshFilter) ;
463 } else if (send == SelectButtonC1A2) {
464 LineEditC1A2->setFocus() ;
465 myEditCurrentArgument = LineEditC1A2;
466 mySelection->ClearFilters() ;
467 mySelection->AddFilter(myGeomFilter) ;
469 SelectionIntoArgument() ;
476 //=================================================================================
477 // function : DeactivateActiveDialog()
479 //=================================================================================
480 void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog()
482 if ( GroupConstructors->isEnabled() ) {
483 disconnect( mySelection, 0, this, 0 );
484 GroupConstructors->setEnabled(false) ;
485 GroupC1->setEnabled(false) ;
486 GroupButtons->setEnabled(false) ;
491 //=================================================================================
492 // function : ActivateThisDialog()
494 //=================================================================================
495 void SMESHGUI_EditHypothesesDlg::ActivateThisDialog()
497 mySMESHGUI->EmitSignalDeactivateDialog() ;
498 GroupConstructors->setEnabled(true) ;
499 GroupC1->setEnabled(true) ;
500 GroupButtons->setEnabled(true) ;
501 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
506 //=================================================================================
507 // function : enterEvent()
509 //=================================================================================
510 void SMESHGUI_EditHypothesesDlg::enterEvent(QEvent* e)
512 if ( GroupConstructors->isEnabled() )
514 ActivateThisDialog() ;
519 //=================================================================================
520 // function : closeEvent()
522 //=================================================================================
523 void SMESHGUI_EditHypothesesDlg::closeEvent( QCloseEvent* e )
525 this->ClickOnCancel() ;
529 //=================================================================================
530 // function : TextChangedInLineEdit()
532 //=================================================================================
533 void SMESHGUI_EditHypothesesDlg::TextChangedInLineEdit(const QString& newText)
535 QLineEdit* send = (QLineEdit*)sender();
536 QString newT = strdup(newText) ;
541 void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* i)
545 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
546 int index = ListHypAssignation->index( i );
548 if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) {
549 SMESH::SMESH_Hypothesis_var Hyp =
550 SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR( mapNameIOR[ string(i->text()) ].c_str() ) );
552 if ( !myMesh->_is_nil() ) {
553 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh);
554 mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp);
555 // mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false );
556 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
558 if ( !mySubMesh->_is_nil() ) {
559 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh);
560 mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp);
561 // mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false );
562 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
565 ListHypAssignation->removeItem( index );
569 index = ListAlgoAssignation->index( i );
571 if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) {
572 SMESH::SMESH_Hypothesis_var Hyp =
573 SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) );
575 if ( !myMesh->_is_nil() ) {
576 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh);
577 mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp);
578 // mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false );
579 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
581 if ( !mySubMesh->_is_nil() ) {
582 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh);
583 mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp);
584 // mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false );
585 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
588 ListAlgoAssignation->removeItem( index );
594 //=================================================================================
595 // function : addItem()
597 //=================================================================================
598 void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* i)
602 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
603 if ( ListHypDefinition->findItem( i->text() ) ) {
604 if ( !ListHypAssignation->findItem( i->text() ) ) {
605 ListHypAssignation->insertItem( i->text() );
607 if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) {
608 SMESH::SMESH_Hypothesis_var Hyp =
609 SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) );
611 if ( !myMesh->_is_nil() )
612 mySMESHGUI->AddHypothesisOnMesh(myMesh, Hyp);
613 if ( !mySubMesh->_is_nil() )
614 mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, Hyp);
619 if ( ListAlgoDefinition->findItem( i->text() ) ) {
620 if ( !ListAlgoAssignation->findItem( i->text() ) ) {
621 ListAlgoAssignation->insertItem( i->text() );
623 if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) {
624 SMESH::SMESH_Hypothesis_var Hyp =
625 SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) );
627 if ( !myMesh->_is_nil() )
628 mySMESHGUI->AddAlgorithmOnMesh(myMesh, Hyp);
629 if ( !mySubMesh->_is_nil() )
630 mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, Hyp);
634 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
638 //=================================================================================
639 // function : InitHypDefinition()
641 //=================================================================================
642 void SMESHGUI_EditHypothesesDlg::InitHypDefinition()
644 SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
645 SALOMEDS::SObject_var HypothesisRoot;
646 SALOMEDS::GenericAttribute_var anAttr;
647 SALOMEDS::AttributeName_var aName;
648 SALOMEDS::AttributeIOR_var anIOR;
650 int Tag_HypothesisRoot = 1;
651 if (father->FindSubObject (1, HypothesisRoot)) {
652 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(HypothesisRoot);
653 for (; it->More();it->Next()) {
654 SALOMEDS::SObject_var Obj = it->Value();
655 if (Obj->FindAttribute(anAttr, "AttributeName") ) {
656 aName = SALOMEDS::AttributeName::_narrow(anAttr);
657 ListHypDefinition->insertItem(aName->Value());
659 if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
660 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
661 mapNameIOR[ aName->Value() ] = anIOR->Value();
668 //=================================================================================
669 // function : InitHypAssignation()
671 //=================================================================================
672 void SMESHGUI_EditHypothesesDlg::InitHypAssignation()
674 MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() )
675 MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() )
676 ListHypAssignation->clear();
677 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
678 int Tag_RefOnAppliedHypothesis = 2;
679 SALOMEDS::SObject_var AHR, aRef;
680 SALOMEDS::GenericAttribute_var anAttr;
681 SALOMEDS::AttributeName_var aName;
683 if ( !myMesh->_is_nil() ) {
684 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
685 if ( aMesh->FindSubObject (2, AHR)) {
686 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
687 for (; it->More();it->Next()) {
688 SALOMEDS::SObject_var Obj = it->Value();
689 if ( Obj->ReferencedObject(aRef) ) {
690 if (aRef->FindAttribute(anAttr, "AttributeName") ) {
691 aName = SALOMEDS::AttributeName::_narrow(anAttr);
692 ListHypAssignation->insertItem(aName->Value());
698 if ( !mySubMesh->_is_nil() ) {
699 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
700 if ( aSubMesh->FindSubObject (2, AHR)) {
701 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
702 for (; it->More();it->Next()) {
703 SALOMEDS::SObject_var Obj = it->Value();
704 if ( Obj->ReferencedObject(aRef) ) {
705 if (aRef->FindAttribute(anAttr, "AttributeName") ) {
706 aName = SALOMEDS::AttributeName::_narrow(anAttr);
707 ListHypAssignation->insertItem(aName->Value());
715 //=================================================================================
716 // function : InitAlgoDefinition()
718 //=================================================================================
719 void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition()
721 SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
722 SALOMEDS::SObject_var AlgorithmsRoot;
723 SALOMEDS::GenericAttribute_var anAttr;
724 SALOMEDS::AttributeName_var aName;
725 SALOMEDS::AttributeIOR_var anIOR;
727 int Tag_AlgorithmsRoot = 2;
728 if (father->FindSubObject (2, AlgorithmsRoot)) {
729 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AlgorithmsRoot);
730 for (; it->More();it->Next()) {
731 SALOMEDS::SObject_var Obj = it->Value();
732 if (Obj->FindAttribute(anAttr, "AttributeName") ) {
733 aName = SALOMEDS::AttributeName::_narrow(anAttr);
734 ListAlgoDefinition->insertItem(aName->Value());
736 if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
737 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
738 mapNameIOR[ aName->Value() ] = anIOR->Value();
746 //=================================================================================
747 // function : InitAlgoAssignation()
749 //=================================================================================
750 void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation()
752 MESSAGE ( " InitAlgoAssignation " << myMesh->_is_nil() )
753 MESSAGE ( " InitAlgoAssignation " << mySubMesh->_is_nil() )
754 ListAlgoAssignation->clear();
755 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
756 int Tag_RefOnAppliedAlgorithms = 3;
757 SALOMEDS::SObject_var AHR, aRef;
758 SALOMEDS::GenericAttribute_var anAttr;
759 SALOMEDS::AttributeName_var aName;
761 if ( !myMesh->_is_nil() ) {
762 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
763 if ( aMesh->FindSubObject (3, AHR) ) {
764 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
765 for (; it->More();it->Next()) {
766 SALOMEDS::SObject_var Obj = it->Value();
767 if ( Obj->ReferencedObject(aRef) ) {
768 if (aRef->FindAttribute(anAttr, "AttributeName") ) {
769 aName = SALOMEDS::AttributeName::_narrow(anAttr);
770 ListAlgoAssignation->insertItem(aName->Value());
776 if ( !mySubMesh->_is_nil() ) {
777 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
778 if ( aSubMesh->FindSubObject (3, AHR) ) {
779 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
780 for (; it->More();it->Next()) {
781 SALOMEDS::SObject_var Obj = it->Value();
782 if ( Obj->ReferencedObject(aRef) ) {
783 if (aRef->FindAttribute(anAttr, "AttributeName") ) {
784 aName = SALOMEDS::AttributeName::_narrow(anAttr);
785 ListAlgoAssignation->insertItem(aName->Value());
793 //=================================================================================
794 // function : InitGeom()
796 //=================================================================================
797 void SMESHGUI_EditHypothesesDlg::InitGeom()
799 LineEditC1A2->setText("") ;
800 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
802 if ( !myMesh->_is_nil() ) {
803 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
804 if ( !aMesh->_is_nil() )
805 myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aMesh);
807 if ( !mySubMesh->_is_nil() ) {
808 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
809 if ( !aSubMesh->_is_nil() )
810 myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aSubMesh);
813 SALOMEDS::GenericAttribute_var anAttr;
814 SALOMEDS::AttributeName_var aName;
815 if ( !myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil()) ) {
816 SALOMEDS::SObject_var aSO = mySMESHGUI->GetStudy()->FindObjectIOR( myGeomShape->Name() );
817 if ( !aSO->_is_nil() ) {
818 if (aSO->FindAttribute(anAttr, "AttributeName") ) {
819 aName = SALOMEDS::AttributeName::_narrow(anAttr);
820 LineEditC1A2->setText( QString(aName->Value()) ) ;