1 // SMESH SMESHGUI : GUI for SMESH 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 : SMESHGUI_EditHypothesesDlg.cxx
25 // Author : Nicolas REJNERI
30 #include "SMESHGUI_EditHypothesesDlg.h"
32 #include "SALOME_ListIteratorOfListIO.hxx"
34 #include "QAD_Application.h"
35 #include "QAD_Desktop.h"
36 #include "utilities.h"
39 #include <qbuttongroup.h>
40 #include <qgroupbox.h>
42 #include <qlineedit.h>
43 #include <qpushbutton.h>
44 #include <qradiobutton.h>
48 #include <qwhatsthis.h>
52 //VRV: porting on Qt 3.0.5
53 #if QT_VERSION >= 0x030005
56 //VRV: porting on Qt 3.0.5
58 //=================================================================================
59 // class : SMESHGUI_EditHypothesesDlg()
60 // purpose : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the
61 // name 'name' and widget flags set to 'f'.
62 // The dialog will by default be modeless, unless you set 'modal' to
63 // TRUE to construct a modal dialog.
64 //=================================================================================
65 SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
66 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
68 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDIT_MESH")));
69 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT")));
71 setName( "SMESHGUI_EditHypothesesDlg" );
73 setCaption( tr( "SMESH_EDIT_HYPOTHESES" ) );
74 setSizeGripEnabled( TRUE );
75 SMESHGUI_EditHypothesesDlgLayout = new QGridLayout( this );
76 SMESHGUI_EditHypothesesDlgLayout->setSpacing( 6 );
77 SMESHGUI_EditHypothesesDlgLayout->setMargin( 11 );
79 /***************************************************************/
80 GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
81 GroupConstructors->setTitle( tr( "SMESH_HYPOTHESES" ) );
82 GroupConstructors->setExclusive( TRUE );
83 GroupConstructors->setColumnLayout(0, Qt::Vertical );
84 GroupConstructors->layout()->setSpacing( 0 );
85 GroupConstructors->layout()->setMargin( 0 );
86 GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
87 GroupConstructorsLayout->setAlignment( Qt::AlignTop );
88 GroupConstructorsLayout->setSpacing( 6 );
89 GroupConstructorsLayout->setMargin( 11 );
90 Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
91 Constructor1->setText( tr( "" ) );
92 Constructor1->setPixmap( image1 );
93 Constructor1->setChecked( TRUE );
94 Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
95 Constructor1->setMinimumSize( QSize( 50, 0 ) );
96 GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
97 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
98 GroupConstructorsLayout->addItem( spacer, 0, 1 );
99 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupConstructors, 0, 0 );
101 /***************************************************************/
102 GroupButtons = new QGroupBox( this, "GroupButtons" );
103 GroupButtons->setGeometry( QRect( 10, 10, 281, 96 ) );
104 GroupButtons->setTitle( tr( "" ) );
105 GroupButtons->setColumnLayout(0, Qt::Vertical );
106 GroupButtons->layout()->setSpacing( 0 );
107 GroupButtons->layout()->setMargin( 0 );
108 GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
109 GroupButtonsLayout->setAlignment( Qt::AlignTop );
110 GroupButtonsLayout->setSpacing( 6 );
111 GroupButtonsLayout->setMargin( 11 );
112 buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
113 buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
114 buttonCancel->setAutoDefault( TRUE );
115 buttonCancel->setDefault( TRUE );
116 buttonCancel->setEnabled( TRUE ) ;
118 GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
119 buttonApply = new QPushButton( GroupButtons, "buttonApply" );
120 buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
121 buttonApply->setAutoDefault( TRUE );
122 buttonApply->setDefault( FALSE );
123 buttonApply->setEnabled( FALSE ) ;
125 GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
126 QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
127 GroupButtonsLayout->addItem( spacer_9, 0, 2 );
128 buttonOk = new QPushButton( GroupButtons, "buttonOk" );
129 buttonOk->setText( tr( "SMESH_BUT_OK" ) );
131 buttonOk->setAutoDefault( TRUE );
132 buttonOk->setDefault( FALSE );
133 buttonOk->setEnabled( FALSE ) ;
135 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
136 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupButtons, 5, 0 );
138 /***************************************************************/
139 GroupC1 = new QGroupBox( this, "GroupC1" );
140 GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
141 GroupC1->setMinimumSize( QSize( 0, 0 ) );
142 GroupC1->setFrameShape( QGroupBox::Box );
143 GroupC1->setFrameShadow( QGroupBox::Sunken );
144 GroupC1->setColumnLayout(0, Qt::Vertical );
145 GroupC1->layout()->setSpacing( 0 );
146 GroupC1->layout()->setMargin( 0 );
147 GroupC1Layout = new QGridLayout( GroupC1->layout() );
148 GroupC1Layout->setAlignment( Qt::AlignTop );
149 GroupC1Layout->setSpacing( 6 );
150 GroupC1Layout->setMargin( 11 );
152 TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
153 TextLabelC1A1->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) );
154 TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
155 TextLabelC1A1->setFrameShape( QLabel::NoFrame );
156 TextLabelC1A1->setFrameShadow( QLabel::Plain );
157 GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
158 SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
159 SelectButtonC1A1->setText( tr( "" ) );
160 SelectButtonC1A1->setPixmap( image0 );
161 SelectButtonC1A1->setToggleButton( FALSE );
162 GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
163 LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
164 GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
166 TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
167 TextLabelC1A2->setText( tr( "SMESH_OBJECT_GEOM" ) );
168 TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
169 TextLabelC1A2->setFrameShape( QLabel::NoFrame );
170 TextLabelC1A2->setFrameShadow( QLabel::Plain );
171 GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
172 SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
173 SelectButtonC1A2->setText( tr( "" ) );
174 SelectButtonC1A2->setPixmap( image0 );
175 SelectButtonC1A2->setToggleButton( FALSE );
176 GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
177 LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
178 GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
180 GroupHypotheses = new QGroupBox( this, "GroupHypotheses" );
181 GroupHypotheses->setTitle( tr( "SMESH_HYPOTHESES" ) );
182 GroupHypotheses->setColumnLayout(0, Qt::Vertical );
183 GroupHypotheses->layout()->setSpacing( 0 );
184 GroupHypotheses->layout()->setMargin( 0 );
185 grid_3 = new QGridLayout( GroupHypotheses->layout() );
186 grid_3->setGeometry( QRect( 12, 18, 139, 110 ) );
187 grid_3->setAlignment( Qt::AlignTop );
188 grid_3->setSpacing( 6 );
189 grid_3->setMargin( 11 );
191 hbox_2 = new QHBoxLayout;
192 hbox_2->setSpacing( 6 );
193 hbox_2->setMargin( 0 );
195 vbox = new QVBoxLayout;
196 vbox->setSpacing( 6 );
197 vbox->setMargin( 0 );
199 TextHypDefinition = new QLabel( GroupHypotheses, "TextHypDefinition" );
200 TextHypDefinition->setText( tr( "SMESH_AVAILABLE" ) );
201 vbox->addWidget( TextHypDefinition );
203 ListHypDefinition = new QListBox( GroupHypotheses, "ListHypDefinition" );
204 ListHypDefinition->setMinimumSize( 100, 50);
205 // ListHypDefinition->setRowMode(4);
206 // ListHypDefinition->setRowMode( QListBox::FixedNumber );
207 // ListHypDefinition->setLineWidth( 4 );
208 // ListHypDefinition->setColumnMode( QListBox::Variable );
209 // ListHypDefinition->setVariableHeight( FALSE );
210 // ListHypDefinition->insertItem( tr( "New Item" ) );
211 vbox->addWidget( ListHypDefinition );
212 hbox_2->addLayout( vbox );
214 vbox_2 = new QVBoxLayout;
215 vbox_2->setSpacing( 6 );
216 vbox_2->setMargin( 0 );
218 TextHypAssignation = new QLabel( GroupHypotheses, "TextHypAssignation" );
219 TextHypAssignation->setText( tr( "SMESH_EDIT_USED" ) );
220 vbox_2->addWidget( TextHypAssignation );
222 ListHypAssignation = new QListBox( GroupHypotheses, "ListHypAssignation" );
223 ListHypAssignation->setMinimumSize( 100, 50);
224 // ListHypAssignation->setRowMode(4);
225 // ListHypAssignation->setRowMode( QListBox::FixedNumber );
226 // ListHypAssignation->setLineWidth( 4 );
227 // ListHypAssignation->setColumnMode( QListBox::Variable );
228 // ListHypAssignation->setVariableHeight( FALSE );
229 // ListHypAssignation->insertItem( tr( "New Item" ) );
230 vbox_2->addWidget( ListHypAssignation );
231 hbox_2->addLayout( vbox_2 );
233 grid_3->addLayout( hbox_2, 0, 0 );
235 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupHypotheses, 2, 0 );
237 GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" );
238 GroupAlgorithms->setTitle( tr( "SMESH_ADD_ALGORITHM" ) );
239 GroupAlgorithms->setColumnLayout(0, Qt::Vertical );
240 GroupAlgorithms->layout()->setSpacing( 0 );
241 GroupAlgorithms->layout()->setMargin( 0 );
242 grid_4 = new QGridLayout( GroupAlgorithms->layout() );
243 grid_4->setGeometry( QRect( 12, 18, 139, 110 ) );
244 grid_4->setAlignment( Qt::AlignTop );
245 grid_4->setSpacing( 6 );
246 grid_4->setMargin( 11 );
248 hbox_3 = new QHBoxLayout;
249 hbox_3->setSpacing( 6 );
250 hbox_3->setMargin( 0 );
252 vbox_3 = new QVBoxLayout;
253 vbox_3->setSpacing( 6 );
254 vbox_3->setMargin( 0 );
256 TextAlgoDefinition = new QLabel( GroupAlgorithms, "TextAlgoDefinition" );
257 TextAlgoDefinition->setText( tr( "SMESH_AVAILABLE" ) );
258 vbox_3->addWidget( TextAlgoDefinition );
260 ListAlgoDefinition = new QListBox( GroupAlgorithms, "ListAlgoDefinition" );
261 ListAlgoDefinition->setMinimumSize( 100, 50);
262 // ListAlgoDefinition->setRowMode(4);
263 // ListAlgoDefinition->setRowMode( QListBox::FixedNumber );
264 // ListAlgoDefinition->setLineWidth( 4 );
265 // ListAlgoDefinition->setColumnMode( QListBox::Variable );
266 // ListAlgoDefinition->setVariableHeight( FALSE );
267 // ListAlgoDefinition->insertItem( tr( "New Item" ) );
268 vbox_3->addWidget( ListAlgoDefinition );
269 hbox_3->addLayout( vbox_3 );
271 vbox_4 = new QVBoxLayout;
272 vbox_4->setSpacing( 6 );
273 vbox_4->setMargin( 0 );
275 TextAlgoAssignation = new QLabel( GroupAlgorithms, "TextAlgoAssignation" );
276 TextAlgoAssignation->setText( tr( "SMESH_EDIT_USED" ) );
277 vbox_4->addWidget( TextAlgoAssignation );
279 ListAlgoAssignation = new QListBox( GroupAlgorithms, "ListAlgoAssignation" );
280 ListAlgoAssignation ->setMinimumSize( 100, 50);
281 // ListAlgoAssignation->setRowMode(4);
282 // ListAlgoAssignation->setRowMode( QListBox::FixedNumber );
283 // ListAlgoAssignation->setLineWidth( 4 );
284 // ListAlgoAssignation->setColumnMode( QListBox::Variable );
285 // ListAlgoAssignation->setVariableHeight( FALSE );
286 // ListAlgoAssignation->insertItem( tr( "New Item" ) );
287 vbox_4->addWidget( ListAlgoAssignation );
288 hbox_3->addLayout( vbox_4 );
290 grid_4->addLayout( hbox_3, 0, 0 );
291 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupAlgorithms, 3, 0 );
293 SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 1, 0 );
294 /***************************************************************/
301 //=================================================================================
302 // function : ~SMESHGUI_EditHypothesesDlg()
303 // purpose : Destroys the object and frees any allocated resources
304 //=================================================================================
305 SMESHGUI_EditHypothesesDlg::~SMESHGUI_EditHypothesesDlg()
307 // no need to delete child widgets, Qt does it all for us
311 //=================================================================================
314 //=================================================================================
315 void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel )
318 myConstructorId = 0 ;
319 Constructor1->setChecked( TRUE );
320 myEditCurrentArgument = LineEditC1A1 ;
322 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
323 mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
326 InitAlgoDefinition();
328 InitHypAssignation();
329 InitAlgoAssignation();
331 myGeomFilter = new SALOME_TypeFilter( "GEOM" );
332 myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
334 myGeomShape = GEOM::GEOM_Shape::_nil();
335 myMesh = SMESH::SMESH_Mesh::_nil();
336 mySubMesh = SMESH::SMESH_subMesh::_nil();
338 /* signals and slots connections */
339 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
340 connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
342 connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
343 connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
345 connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
346 connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
347 connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
349 connect( ListHypAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
350 connect( ListAlgoAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
352 connect( ListHypDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
353 connect( ListAlgoDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
356 mySMESHGUI->DefineDlgPosition( this, x, y ) ;
359 SelectionIntoArgument();
365 //=================================================================================
366 // function : ConstructorsClicked()
367 // purpose : Radio button management
368 //=================================================================================
369 void SMESHGUI_EditHypothesesDlg::ConstructorsClicked(int constructorId)
374 //=================================================================================
375 // function : ClickOnCancel()
377 //=================================================================================
378 void SMESHGUI_EditHypothesesDlg::ClickOnCancel()
380 disconnect( mySelection, 0, this, 0 );
381 mySMESHGUI->ResetState() ;
382 mySelection->ClearFilters() ;
388 //=================================================================================
389 // function : SelectionIntoArgument()
390 // purpose : Called when selection as changed or other case
391 //=================================================================================
392 void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
394 myEditCurrentArgument->setText("") ;
395 QString aString = "";
397 int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
399 switch (myConstructorId)
403 if ( myEditCurrentArgument == LineEditC1A1 ) {
405 myOkHypothesis = false;
406 myOkAlgorithm = false;
407 myMesh = SMESH::SMESH_Mesh::_nil();
408 mySubMesh = SMESH::SMESH_subMesh::_nil();
409 InitHypAssignation();
410 InitAlgoAssignation();
414 Standard_Boolean testResult ;
415 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
416 myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
418 myMesh = SMESH::SMESH_Mesh::_nil();
420 mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IO, testResult) ;
422 mySubMesh = SMESH::SMESH_subMesh::_nil();
423 InitHypAssignation();
424 InitAlgoAssignation();
429 InitHypAssignation();
430 InitAlgoAssignation();
433 } else if ( myEditCurrentArgument == LineEditC1A2 ) {
435 myOkHypothesis = false;
436 myOkAlgorithm = false;
437 myGeomShape = GEOM::GEOM_Shape::_nil();
438 InitHypAssignation();
439 InitAlgoAssignation();
443 Standard_Boolean testResult ;
444 Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
445 myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
447 myGeomShape = GEOM::GEOM_Shape::_nil();
448 InitHypAssignation();
449 InitAlgoAssignation();
453 InitHypAssignation();
454 InitAlgoAssignation();
462 myEditCurrentArgument->setText(aString) ;
466 //=================================================================================
467 // function : SetEditCurrentArgument()
469 //=================================================================================
470 void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument()
472 QPushButton* send = (QPushButton*)sender();
473 switch (myConstructorId)
475 case 0: /* default constructor */
477 if(send == SelectButtonC1A1) {
478 LineEditC1A1->setFocus() ;
479 myEditCurrentArgument = LineEditC1A1;
480 mySelection->ClearFilters() ;
481 mySelection->AddFilter(myMeshOrSubMeshFilter) ;
482 } else if (send == SelectButtonC1A2) {
483 LineEditC1A2->setFocus() ;
484 myEditCurrentArgument = LineEditC1A2;
485 mySelection->ClearFilters() ;
486 mySelection->AddFilter(myGeomFilter) ;
488 SelectionIntoArgument() ;
495 //=================================================================================
496 // function : DeactivateActiveDialog()
498 //=================================================================================
499 void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog()
501 if ( GroupConstructors->isEnabled() ) {
502 disconnect( mySelection, 0, this, 0 );
503 GroupConstructors->setEnabled(false) ;
504 GroupC1->setEnabled(false) ;
505 GroupButtons->setEnabled(false) ;
510 //=================================================================================
511 // function : ActivateThisDialog()
513 //=================================================================================
514 void SMESHGUI_EditHypothesesDlg::ActivateThisDialog()
516 mySMESHGUI->EmitSignalDeactivateDialog() ;
517 GroupConstructors->setEnabled(true) ;
518 GroupC1->setEnabled(true) ;
519 GroupButtons->setEnabled(true) ;
520 connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
525 //=================================================================================
526 // function : enterEvent()
528 //=================================================================================
529 void SMESHGUI_EditHypothesesDlg::enterEvent(QEvent* e)
531 if ( GroupConstructors->isEnabled() )
533 ActivateThisDialog() ;
538 //=================================================================================
539 // function : closeEvent()
541 //=================================================================================
542 void SMESHGUI_EditHypothesesDlg::closeEvent( QCloseEvent* e )
544 this->ClickOnCancel() ;
548 //=================================================================================
549 // function : TextChangedInLineEdit()
551 //=================================================================================
552 void SMESHGUI_EditHypothesesDlg::TextChangedInLineEdit(const QString& newText)
554 QLineEdit* send = (QLineEdit*)sender();
555 QString newT = strdup(newText) ;
560 void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* i)
564 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
565 int index = ListHypAssignation->index( i );
567 if (mapNameIOR.find( string((const char*)(i->text())) ) != mapNameIOR.end()) {
568 SMESH::SMESH_Hypothesis_var Hyp =
569 SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR( mapNameIOR[ string((const char*)(i->text())) ].c_str() ) );
571 if ( !myMesh->_is_nil() ) {
572 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh);
573 mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp);
574 // mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false );
575 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
577 if ( !mySubMesh->_is_nil() ) {
578 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh);
579 mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp);
580 // mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false );
581 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
584 ListHypAssignation->removeItem( index );
588 index = ListAlgoAssignation->index( i );
590 if (mapNameIOR.find( string((const char*)(i->text())) ) != mapNameIOR.end()) {
591 SMESH::SMESH_Hypothesis_var Hyp =
592 SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string((const char*)(i->text())) ].c_str()) );
594 if ( !myMesh->_is_nil() ) {
595 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh);
596 mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp);
597 // mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false );
598 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
600 if ( !mySubMesh->_is_nil() ) {
601 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh);
602 mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp);
603 // mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false );
604 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
607 ListAlgoAssignation->removeItem( index );
613 //=================================================================================
614 // function : addItem()
616 //=================================================================================
617 void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* i)
621 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
622 if ( ListHypDefinition->findItem( i->text() ) ) {
623 if ( !ListHypAssignation->findItem( i->text() ) ) {
624 ListHypAssignation->insertItem( i->text() );
626 if (mapNameIOR.find( string((const char*)(i->text())) ) != mapNameIOR.end()) {
627 SMESH::SMESH_Hypothesis_var Hyp =
628 SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string((const char*)(i->text())) ].c_str()) );
630 if ( !myMesh->_is_nil() )
631 mySMESHGUI->AddHypothesisOnMesh(myMesh, Hyp);
632 if ( !mySubMesh->_is_nil() )
633 mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, Hyp);
638 if ( ListAlgoDefinition->findItem( i->text() ) ) {
639 if ( !ListAlgoAssignation->findItem( i->text() ) ) {
640 ListAlgoAssignation->insertItem( i->text() );
642 if (mapNameIOR.find( string((const char*)(i->text())) ) != mapNameIOR.end()) {
643 SMESH::SMESH_Hypothesis_var Hyp =
644 SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string((const char*)(i->text())) ].c_str()) );
646 if ( !myMesh->_is_nil() )
647 mySMESHGUI->AddAlgorithmOnMesh(myMesh, Hyp);
648 if ( !mySubMesh->_is_nil() )
649 mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, Hyp);
653 mySMESHGUI->GetActiveStudy()->updateObjBrowser();
657 //=================================================================================
658 // function : InitHypDefinition()
660 //=================================================================================
661 void SMESHGUI_EditHypothesesDlg::InitHypDefinition()
663 SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
664 SALOMEDS::SObject_var HypothesisRoot;
665 SALOMEDS::GenericAttribute_var anAttr;
666 SALOMEDS::AttributeName_var aName;
667 SALOMEDS::AttributeIOR_var anIOR;
669 int Tag_HypothesisRoot = 1;
670 if (father->FindSubObject (1, HypothesisRoot)) {
671 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(HypothesisRoot);
672 for (; it->More();it->Next()) {
673 SALOMEDS::SObject_var Obj = it->Value();
674 if (Obj->FindAttribute(anAttr, "AttributeName") ) {
675 aName = SALOMEDS::AttributeName::_narrow(anAttr);
676 ListHypDefinition->insertItem(aName->Value());
678 if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
679 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
680 mapNameIOR[ aName->Value() ] = anIOR->Value();
687 //=================================================================================
688 // function : InitHypAssignation()
690 //=================================================================================
691 void SMESHGUI_EditHypothesesDlg::InitHypAssignation()
693 MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() )
694 MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() )
695 ListHypAssignation->clear();
696 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
697 int Tag_RefOnAppliedHypothesis = 2;
698 SALOMEDS::SObject_var AHR, aRef;
699 SALOMEDS::GenericAttribute_var anAttr;
700 SALOMEDS::AttributeName_var aName;
702 if ( !myMesh->_is_nil() ) {
703 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
704 if ( aMesh->FindSubObject (2, AHR)) {
705 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
706 for (; it->More();it->Next()) {
707 SALOMEDS::SObject_var Obj = it->Value();
708 if ( Obj->ReferencedObject(aRef) ) {
709 if (aRef->FindAttribute(anAttr, "AttributeName") ) {
710 aName = SALOMEDS::AttributeName::_narrow(anAttr);
711 ListHypAssignation->insertItem(aName->Value());
717 if ( !mySubMesh->_is_nil() ) {
718 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
719 if ( aSubMesh->FindSubObject (2, AHR)) {
720 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
721 for (; it->More();it->Next()) {
722 SALOMEDS::SObject_var Obj = it->Value();
723 if ( Obj->ReferencedObject(aRef) ) {
724 if (aRef->FindAttribute(anAttr, "AttributeName") ) {
725 aName = SALOMEDS::AttributeName::_narrow(anAttr);
726 ListHypAssignation->insertItem(aName->Value());
734 //=================================================================================
735 // function : InitAlgoDefinition()
737 //=================================================================================
738 void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition()
740 SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
741 SALOMEDS::SObject_var AlgorithmsRoot;
742 SALOMEDS::GenericAttribute_var anAttr;
743 SALOMEDS::AttributeName_var aName;
744 SALOMEDS::AttributeIOR_var anIOR;
746 int Tag_AlgorithmsRoot = 2;
747 if (father->FindSubObject (2, AlgorithmsRoot)) {
748 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AlgorithmsRoot);
749 for (; it->More();it->Next()) {
750 SALOMEDS::SObject_var Obj = it->Value();
751 if (Obj->FindAttribute(anAttr, "AttributeName") ) {
752 aName = SALOMEDS::AttributeName::_narrow(anAttr);
753 ListAlgoDefinition->insertItem(aName->Value());
755 if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
756 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
757 mapNameIOR[ aName->Value() ] = anIOR->Value();
765 //=================================================================================
766 // function : InitAlgoAssignation()
768 //=================================================================================
769 void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation()
771 MESSAGE ( " InitAlgoAssignation " << myMesh->_is_nil() )
772 MESSAGE ( " InitAlgoAssignation " << mySubMesh->_is_nil() )
773 ListAlgoAssignation->clear();
774 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
775 int Tag_RefOnAppliedAlgorithms = 3;
776 SALOMEDS::SObject_var AHR, aRef;
777 SALOMEDS::GenericAttribute_var anAttr;
778 SALOMEDS::AttributeName_var aName;
780 if ( !myMesh->_is_nil() ) {
781 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
782 if ( aMesh->FindSubObject (3, AHR) ) {
783 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
784 for (; it->More();it->Next()) {
785 SALOMEDS::SObject_var Obj = it->Value();
786 if ( Obj->ReferencedObject(aRef) ) {
787 if (aRef->FindAttribute(anAttr, "AttributeName") ) {
788 aName = SALOMEDS::AttributeName::_narrow(anAttr);
789 ListAlgoAssignation->insertItem(aName->Value());
795 if ( !mySubMesh->_is_nil() ) {
796 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
797 if ( aSubMesh->FindSubObject (3, AHR) ) {
798 SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
799 for (; it->More();it->Next()) {
800 SALOMEDS::SObject_var Obj = it->Value();
801 if ( Obj->ReferencedObject(aRef) ) {
802 if (aRef->FindAttribute(anAttr, "AttributeName") ) {
803 aName = SALOMEDS::AttributeName::_narrow(anAttr);
804 ListAlgoAssignation->insertItem(aName->Value());
812 //=================================================================================
813 // function : InitGeom()
815 //=================================================================================
816 void SMESHGUI_EditHypothesesDlg::InitGeom()
818 LineEditC1A2->setText("") ;
819 SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
821 if ( !myMesh->_is_nil() ) {
822 SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
823 if ( !aMesh->_is_nil() )
824 myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aMesh);
826 if ( !mySubMesh->_is_nil() ) {
827 SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
828 if ( !aSubMesh->_is_nil() )
829 myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aSubMesh);
832 SALOMEDS::GenericAttribute_var anAttr;
833 SALOMEDS::AttributeName_var aName;
834 if ( !myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil()) ) {
835 SALOMEDS::SObject_var aSO = mySMESHGUI->GetStudy()->FindObjectIOR( myGeomShape->Name() );
836 if ( !aSO->_is_nil() ) {
837 if (aSO->FindAttribute(anAttr, "AttributeName") ) {
838 aName = SALOMEDS::AttributeName::_narrow(anAttr);
839 LineEditC1A2->setText( QString(aName->Value()) ) ;