1 // Copyright (C) 2009-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <OCCViewer_ViewWindow.h>
21 #include "HEXABLOCKGUI_DocumentPanel.hxx"
22 #include "HEXABLOCKGUI_DocumentGraphicView.hxx"
23 #include "HEXABLOCKGUI_SalomeTools.hxx"
24 #include "HEXABLOCKGUI.hxx"
31 #include <SalomeApp_Application.h>
32 #include <SalomeApp_Study.h>
33 #include <PyConsole_Console.h>
34 #include <SalomeApp_Tools.h>
36 #include <Standard_GUID.hxx>
37 #include <TDF_Label.hxx>
39 #include <OCCViewer_ViewWindow.h>
40 #include <OCCViewer_ViewManager.h>
41 // #include <OCCViewer_ViewModel.h>
45 #include <TopExp_Explorer.hxx>
46 #include <TopoDS_Iterator.hxx>
47 #include <TopTools_MapOfShape.hxx>
48 #include <TopTools_IndexedMapOfShape.hxx>
49 #include <TColStd_IndexedMapOfInteger.hxx>
52 #include <SUIT_Session.h>
53 #include <SUIT_Desktop.h>
54 #include <SUIT_OverrideCursor.h>
55 #include <SUIT_MessageBox.h>
56 #include <SUIT_Session.h>
57 #include "SVTK_Selection.h"
58 #include <SVTK_ViewModel.h>
59 #include <VTKViewer_ViewModel.h>
61 #include <SUIT_ResourceMgr.h>
64 // #include <GeometryGUI.h>
67 #include <GEOMImpl_Types.hxx>
71 #include "MyGEOMBase_Helper.hxx"
73 #include "GEOM_Operation.h"
76 #define VERTEX_COORD_MIN -1000000
77 #define VERTEX_COORD_MAX 1000000
81 using namespace HEXABLOCK::GUI;
84 Q_DECLARE_METATYPE(HEXABLOCK::GUI::HexaTreeRole);
85 Q_DECLARE_METATYPE(TopAbs_ShapeEnum);
87 //General SpinBox Delegate
88 class HexaDoubleSpinBoxDelegate : public QStyledItemDelegate {
90 HexaDoubleSpinBoxDelegate(QObject *parent=0) : QStyledItemDelegate (parent){}
92 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
93 const QModelIndex &index) const{
94 return new QDoubleSpinBox( parent );
98 //Angle SpinBox Delegate
99 class HexaAngleDoubleSpinBoxDelegate : public QStyledItemDelegate {
101 HexaAngleDoubleSpinBoxDelegate(QObject *parent=0) : QStyledItemDelegate (parent){}
103 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
104 const QModelIndex &index) const{
105 QDoubleSpinBox *sb = new QDoubleSpinBox( parent );
113 //Positive DoubleSpinBox Delegate (for heigth, radius, ...)
114 class HexaPositiveDoubleSpinBoxDelegate : public QStyledItemDelegate {
116 HexaPositiveDoubleSpinBoxDelegate(QObject *parent=0) : QStyledItemDelegate (parent){}
118 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
119 const QModelIndex &index) const{
120 QDoubleSpinBox *sb = new QDoubleSpinBox( parent );
122 /////// sb->setMaximum(1000000000000000); //10e15 Abu : Pb en 32 bits
123 sb->setMaximum(1000000000); //10e9
129 // ======================================================== Constructeur
130 HexaBaseDialog::HexaBaseDialog( QWidget * parent, Mode editmode, Qt::WindowFlags f ):
132 // _selectionModel(0),
134 MyGEOMBase_Helper( dynamic_cast<SUIT_Desktop*>(parent->parent()) ),
135 _editMode( editmode ),
137 // _patternDataModel(0),
138 // _patternBuilderModel(0),
139 _patternDataSelectionModel(0),
140 _patternBuilderSelectionModel(0),
141 _groupsSelectionModel(0),
142 _meshSelectionModel(0),
147 _expectedSelection(-1),
148 _selectionMutex( false ),
149 // _applyCloseButton(0),
152 MESSAGE("HexaBaseDialog::HexaBaseDialog() dynamic_cast<SUIT_Desktop*>(parent->parent()) =>" << dynamic_cast<SUIT_Desktop*>(parent->parent()) );
153 _strHexaWidgetType[VERTEX_TREE] = tr( "VERTEX" );
154 _strHexaWidgetType[EDGE_TREE] = tr( "EDGE" );
155 _strHexaWidgetType[QUAD_TREE] = tr( "QUAD" );
156 _strHexaWidgetType[HEXA_TREE] = tr( "HEXA" );
158 _strHexaWidgetType[VECTOR_TREE] = tr( "VECTOR" );
159 _strHexaWidgetType[CYLINDER_TREE] = tr( "CYLINDER" );
160 _strHexaWidgetType[PIPE_TREE] = tr( "PIPE" );
161 _strHexaWidgetType[ELEMENTS_TREE] = tr( "ELEMENTS" );
162 _strHexaWidgetType[CROSSELEMENTS_TREE]= tr( "CROSSELEMENTS" );
164 _strHexaWidgetType[GROUP_TREE] = tr( "GROUP" );
165 _strHexaWidgetType[LAW_TREE] = tr( "LAW" );
166 _strHexaWidgetType[PROPAGATION_TREE]= tr( "PROPAGATION" );
170 // ============================================================= Destructeur
171 HexaBaseDialog::~HexaBaseDialog()
173 // _mgr->clearSelectionCache();
174 // _mgr->clearSelected();
175 // globalSelection();
179 // ============================================================== _initButtonBox
180 QGroupBox* HexaBaseDialog::_initButtonBox( Mode editmode )
182 if ( editmode == INFO_MODE )
185 //QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
186 QGroupBox* buttonBox = new QGroupBox();
187 buttonBox->setMinimumWidth(5);
188 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
189 //buttonBox->setOrientation(Qt::Horizontal);
190 QHBoxLayout* buttonsHLayout = new QHBoxLayout();
191 _applyButton = new QPushButton(tr("Apply"));
192 QPushButton* closeButton = new QPushButton(tr("Close"));
193 QPushButton* helpButton = new QPushButton(tr("Help"));
194 //_applyCloseButton = new QPushButton(tr("Apply And Close"));
196 //connect( buttonBox, SIGNAL(clicked()), this, SLOT(applyAndClose()) );
197 connect( _applyButton, SIGNAL(clicked()), this, SLOT(apply()) );
198 connect( closeButton, SIGNAL(clicked()), this, SLOT(close()) );
199 connect( helpButton, SIGNAL(clicked()), this, SLOT(onHelpRequested()) );
201 buttonsHLayout->addWidget( _applyButton );
202 buttonsHLayout->addWidget( closeButton );
203 buttonsHLayout->addStretch(1);
204 buttonsHLayout->addWidget( helpButton );
205 //buttonsHLayout->addButton( _applyCloseButton );
206 buttonBox->setLayout(buttonsHLayout);
207 layout()->addWidget(buttonBox);
212 // ============================================================== _initWidget
213 void HexaBaseDialog::_initWidget( Mode editmode )
215 _initInputWidget( editmode );
216 _initButtonBox( editmode );
220 // ============================================================== _initViewManager
221 void HexaBaseDialog::_initViewManager()
223 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
224 _mgr = dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
225 _vtkVm = anApp->getViewManager( SVTK_Viewer::Type(), true );
226 _occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true );
227 SUIT_ViewManager* activeVm = anApp->activeViewManager();
229 onWindowActivated ( activeVm );
233 // ============================================================== apply
234 bool HexaBaseDialog::apply()
236 MESSAGE("HexaBaseDialog::apply()");
238 bool applied = apply(iNew);
240 // clear all selection
241 if (_patternDataSelectionModel) _patternDataSelectionModel->clearSelection();
242 if (_patternBuilderSelectionModel) _patternBuilderSelectionModel->clearSelection();
243 if (_groupsSelectionModel) _groupsSelectionModel->clearSelection();
244 if (_meshSelectionModel) _meshSelectionModel->clearSelection();
245 // select and highlight in vtk view the result
246 _selectAndHighlight( iNew );
253 // ============================================================== accept
254 //void HexaBaseDialog::accept()
256 // bool applied = apply();
258 // QDialog::accept();
259 // _disallowSelection();
263 // ============================================================== close
264 void HexaBaseDialog::close()
267 _disallowSelection();
272 // ============================================================== onHelpRequested
273 void HexaBaseDialog::onHelpRequested()
275 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
277 // app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), _helpFileName );
278 app->onHelpContextModule( "HEXABLOCK", _helpFileName );
283 platform = "winapplication";
285 platform = "application";
288 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
289 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
290 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( _helpFileName ),
291 QObject::tr( "BUT_OK" ) );
296 // ============================================================== _selectAndHighlight
297 void HexaBaseDialog::_selectAndHighlight( const QModelIndex& i )
299 if ( !i.isValid() ) return;
300 setProperty("QModelIndex", QVariant::fromValue(i));
305 // ============================================================== _allowSelection
306 void HexaBaseDialog::_allowSelection()
308 MESSAGE("HexaBaseDialog::_allowSelection(){");
309 if ( _documentModel ){
310 _documentModel->disallowEdition();
315 // ============================================================== _disallowSelection
316 void HexaBaseDialog::_disallowSelection()
318 MESSAGE("HexaBaseDialog::_disallowSelection(){");
319 if ( _documentModel ){
320 _documentModel->allowEdition();
322 if ( _patternDataSelectionModel ){
323 _patternDataSelectionModel->setAllSelection();
329 // ============================================================== _allowVTKSelection
330 bool HexaBaseDialog::_allowVTKSelection( QObject* obj )
332 MESSAGE("HexaBaseDialog::_allowModelSelection(){");
333 if ( !_patternDataSelectionModel ) return false;
336 HexaWidgetType wType;
337 QVariant v = obj->property("HexaWidgetType");
338 if ( !v.isValid() ) {
339 MESSAGE("* no HexaWidgetType property");
342 MESSAGE("* HEXABLOCKGUI::currentVtkView->raise()");
343 HEXABLOCKGUI::currentVtkView->raise();
344 // HEXABLOCKGUI::currentVtkView->setFocus();
345 wType = v.value<HexaWidgetType>();
346 MESSAGE("* HexaWidgetType property is " << wType );
350 _patternDataSelectionModel->setVertexSelection(); isOk = true;
353 _patternDataSelectionModel->setEdgeSelection(); isOk = true;
356 _patternDataSelectionModel->setQuadSelection(); isOk = true;
359 _patternDataSelectionModel->setHexaSelection(); isOk = true;
362 // case CYLINDER_TREE:
364 // case ELEMENTS_TREE:
365 // case CROSSELEMENTS_TREE: //selector = _patternBuilderSelectionModel;
366 // case GROUP_TREE: //selector = _groupsSelectionModel;
368 // case PROPAGATION_TREE: // selector = _meshSelectionModel;
369 default : MESSAGE("NOT YET");
375 // ============================================================== _allowOCCSelection
376 bool HexaBaseDialog::_allowOCCSelection( QObject* obj )
378 MESSAGE("HexaBaseDialog::_allowOCCCSelection(){");
379 if ( !HEXABLOCKGUI::currentOccView ) return false;
381 //We do not allow occ selection when the occ viewer is not activated
382 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
383 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
384 if (!isOCC) return false;
387 GeomWidgetType wType;
388 QVariant v = obj->property("GeomWidgetType");
389 if ( !v.isValid() ) {
390 MESSAGE("* no GeomWidgetType property");
393 MESSAGE("* HEXABLOCKGUI::currentOccView->raise()");
394 HEXABLOCKGUI::currentOccView->raise();
395 wType = v.value<GeomWidgetType>();
396 MESSAGE("* GeomWidgetType property is " << wType );
397 MESSAGE("* TopAbs_VERTEX is " << TopAbs_VERTEX );
398 MESSAGE("* TopAbs_EDGE is " << TopAbs_EDGE );
399 MESSAGE("* TopAbs_FACE is " << TopAbs_FACE );
401 globalSelection(); // close local contexts, if any
402 localSelection(GEOM::GEOM_Object::_nil(), wType/*TopAbs_EDGE*/);
407 // ============================================================== _getSelector
408 QItemSelectionModel* HexaBaseDialog::_getSelector( QObject* obj )
410 QItemSelectionModel* selector = NULL;
411 MESSAGE("HexaBaseDialog::getSelector(){");
413 QString objectName = obj->objectName();
414 QString className = obj->metaObject()->className();
415 MESSAGE("* obj->objectName() is "<< objectName.toStdString() ); //toStdString()
416 MESSAGE("* obj->metaObject()->className() is "<< className.toStdString() );
418 HexaWidgetType wtype;
419 QVariant v = obj->property("HexaWidgetType");
420 if ( !v.isValid() ) {
421 MESSAGE("* no HexaWidgetType property");
425 wtype = v.value<HexaWidgetType>();
426 MESSAGE("* HexaWidgetType property is " << wtype);
433 selector = _patternDataSelectionModel; break;
438 case CROSSELEMENTS_TREE:
439 selector = _patternBuilderSelectionModel; break;
441 selector = _groupsSelectionModel; break;
443 case PROPAGATION_TREE:
444 selector = _meshSelectionModel; break;
445 default : MESSAGE("NOT YET");
452 // ============================================================== _onSelectionChanged
454 bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QLineEdit* le )
456 MESSAGE("HexaBaseDialog::_onSelectionChanged(const QItemSelection& sel, QLineEdit* le)");
457 MESSAGE("* le is "<< le->objectName().toStdString() );
458 QModelIndexList l = sel.indexes();
459 if ( l.count() == 0 ) return false;
461 //type from selection (first)
462 QModelIndex selected = l[0];
463 int selType = selected.data(HEXA_TREE_ROLE).toInt();
466 QVariant v = le->property("HexaWidgetType");
467 if ( !v.isValid() ) return false;
468 HexaWidgetType wType = v.value<HexaWidgetType>();
470 // check selection compatibility between selection and widget
471 if ( selType != wType ){
472 MESSAGE("* bad selection : " << selType << " is not " << wType );
473 SUIT_MessageBox::information( 0,
475 tr("%1: Bad type selected\nPlease select a %2.").arg(windowTitle()).arg( _strHexaWidgetType[wType]) );
479 //fill the lineEdit if selection is OK
480 le->setText( selected.data().toString() );// name
481 le->setProperty("QModelIndex", QVariant::fromValue(selected) );
482 _index[le] = selected;
488 // ============================================================== _onSelectionChanged
489 bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QListWidget* lw )
491 MESSAGE("HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QListWidget* lw )");
492 MESSAGE("* lw is "<< lw->objectName().toStdString() );
493 QModelIndexList l = sel.indexes();
495 if ( l.count() == 0 ) return false;
498 QVariant v = lw->property("HexaWidgetType");
499 if ( !v.isValid() ) return false;
500 HexaWidgetType wType = v.value<HexaWidgetType>();
502 //fill the listWidget
503 QListWidgetItem* item = NULL;
507 foreach( const QModelIndex& isel, l ){
508 // if ( lw->count() == maxSize) break;
509 selType = isel.data(HEXA_TREE_ROLE).toInt();
510 if ( selType != wType ){ // check selection compatibility between selection and widget
511 MESSAGE("* bad selection : " << selType<< " is not " << wType );
512 SUIT_MessageBox::information( 0,
514 tr("%1: Bad type selected\nPlease select a %2.").arg(windowTitle()).arg( _strHexaWidgetType[wType]) );
517 // add selection to listWidget if selection is OK
518 selName = isel.data().toString();
519 QList<QListWidgetItem *> twice = lw->findItems( selName, Qt::MatchExactly);
520 if ( twice.count() == 0 ){
521 item = new QListWidgetItem( selName );
522 item->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(isel) );
531 // ============================================================== onCurrentSelectionChanged
532 void HexaBaseDialog::onCurrentSelectionChanged()
537 // ============================================================== setDocumentModel
538 void HexaBaseDialog::setDocumentModel(DocumentModel* m)
543 // ============================================================== clear
544 void HexaBaseDialog::clear()
549 // ============================================================== setPatternDataSelectionModel
550 void HexaBaseDialog::setPatternDataSelectionModel(PatternDataSelectionModel* s)
552 _patternDataSelectionModel = s;
556 // ============================================================== setPatternBuilderSelectionModel
557 void HexaBaseDialog::setPatternBuilderSelectionModel(PatternBuilderSelectionModel* s)
559 _patternBuilderSelectionModel = s;
562 // ============================================================== setGroupsSelectionModel
563 void HexaBaseDialog::setGroupsSelectionModel( GroupsSelectionModel* s )
565 _groupsSelectionModel = s;
569 // ============================================================== setMeshSelectionModel
570 void HexaBaseDialog::setMeshSelectionModel( MeshSelectionModel* s )
572 _meshSelectionModel = s;
576 // ============================================================== onSelectionChanged
577 void HexaBaseDialog::onSelectionChanged( const QItemSelection& sel, const QItemSelection& unsel )
579 MESSAGE( "HexaBaseDialog::onSelectionChanged(){" );
580 QString className = metaObject()->className();
581 MESSAGE( "* I am : " << className.toStdString() );
582 MESSAGE( "* sender is : " << sender() );
583 MESSAGE( "* _patternDataSelectionModel : " << _patternDataSelectionModel );
584 MESSAGE( "* _patternBuilderSelectionModel : " << _patternBuilderSelectionModel );
585 MESSAGE( "* _groupsSelectionModel : " << _groupsSelectionModel );
586 MESSAGE( "* _meshSelectionModel : " << _meshSelectionModel );
589 QItemSelectionModel* selector = dynamic_cast<QItemSelectionModel*>(sender());
590 MESSAGE( "* selector : " << selector);
592 foreach( const QModelIndex& isel, sel.indexes() ){
593 MESSAGE("* selected : " << isel.data().toString().toStdString());
595 foreach( const QModelIndex& iunsel, unsel.indexes() ){
596 MESSAGE("* unselected : " << iunsel.data().toString().toStdString());
599 if ( _selectionMutex )
604 QLineEdit* aLineEdit = 0;
605 QListWidget* aListWidget = 0;
606 aLineEdit = dynamic_cast<QLineEdit*>(_currentObj);
607 if ( aLineEdit){ //fill the lineedit with selection
608 selOk = _onSelectionChanged( sel, aLineEdit );
610 aListWidget = dynamic_cast<QListWidget*>(_currentObj);
611 if ( aListWidget){ //fill the listWidget with selection
612 selOk = _onSelectionChanged( sel, aListWidget );
615 if ( !selOk && selector && ( aLineEdit || aListWidget ) ){
616 selector->clearSelection();
622 // ============================================================== onWindowActivated
623 void HexaBaseDialog::onWindowActivated( SUIT_ViewManager* vm )
627 // ============================================================== hideEvent
628 void HexaBaseDialog::hideEvent ( QHideEvent * event )
630 MESSAGE("HexaBaseDialog::hideEvent(){");
631 QString className = metaObject()->className();
632 MESSAGE( "* I am : " << className.toStdString() );
634 if ( _patternDataSelectionModel )
635 disconnect( _patternDataSelectionModel, SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ),
636 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
637 if ( _patternBuilderSelectionModel )
638 disconnect( _patternBuilderSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
639 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
640 if ( _groupsSelectionModel )
641 disconnect( _groupsSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
642 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
643 if ( _meshSelectionModel )
644 disconnect( _meshSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
645 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
647 // disconnect( _mgr, 0/*SIGNAL(currentSelectionChanged())*/, this, 0/*SLOT(onCurrentSelectionChanged())*/ );
648 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) );
650 disconnect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
652 disconnect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
654 _documentModel->allowEdition();
656 QDialog::hideEvent( event );
660 // ============================================================== showEvent
661 void HexaBaseDialog::showEvent( QShowEvent * event )
663 MESSAGE("HexaBaseDialog::showEvent(){");
664 QString className = metaObject()->className();
665 MESSAGE( "* I am : " << className.toStdString() );
667 if ( _editMode == INFO_MODE ){
668 _documentModel->allowEdition();
670 _documentModel->disallowEdition();
673 if ( _patternDataSelectionModel ){
674 _patternDataSelectionModel->clearSelection();
675 connect( _patternDataSelectionModel, SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ),
676 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
678 if ( _patternBuilderSelectionModel ){
679 _patternBuilderSelectionModel->clearSelection();
680 connect( _patternBuilderSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
681 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
683 if ( _groupsSelectionModel ){
684 _groupsSelectionModel->clearSelection();
685 connect( _groupsSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
686 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
688 if ( _meshSelectionModel ){
689 _meshSelectionModel->clearSelection();
690 connect( _meshSelectionModel, SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
691 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
694 connect( _mgr, SIGNAL(currentSelectionChanged()), this, SLOT(onCurrentSelectionChanged()) );
697 connect( _vtkVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
699 connect( _occVm, SIGNAL( activated(SUIT_ViewManager*) ), this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
701 QDialog::showEvent ( event );
707 // ============================================================== updateButtonBox
708 void HexaBaseDialog::updateButtonBox()
712 void HexaBaseDialog::updateName()
714 if (!_documentModel) return;
715 if ( !_patternDataSelectionModel ) return;
716 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
718 QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(sender());
719 if (!lineEdit) return;
720 QString newName = lineEdit->text();
721 if ( newName.isEmpty() ) return;
723 QVariant v = lineEdit->property("QModelIndex");
724 if ( !v.isValid() ) return;
726 QModelIndex index = v.value<QModelIndex>();
727 if ( index.isValid() )
728 _documentModel->setName( patternDataModel->mapToSource(index), newName );
733 // ============================================================== selectElementOfModel
734 void HexaBaseDialog::selectElementOfModel()
736 MESSAGE("HexaBaseDialog::selectElementOfModel()");
737 if (!_patternDataSelectionModel) return;
739 QListWidget* currentListWidget = dynamic_cast<QListWidget*>( sender() );
740 if ( !currentListWidget ) return;
742 _selectionMutex = true;
744 QList<QListWidgetItem *> sel = currentListWidget->selectedItems();
746 _patternDataSelectionModel->clearSelection();
747 foreach ( QListWidgetItem *item, sel ){
748 MESSAGE( "* selecting the element : " << index.data().toString().toStdString() );
749 index = item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>();
750 if ( index.isValid() )
751 _patternDataSelectionModel->select( index, QItemSelectionModel::Select );
753 _selectionMutex = false;
758 // ============================================================== eventFilter
759 bool HexaBaseDialog::eventFilter(QObject *obj, QEvent *event)
761 QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(obj);
762 QListWidget *listWidget = dynamic_cast<QListWidget*>(obj);
763 HexaBaseDialog *dialog = dynamic_cast<HexaBaseDialog*>(obj);
765 if ( event->type() == QEvent::FocusIn ){
766 QString className = obj->metaObject()->className();
767 QString objectName = obj->objectName();
768 MESSAGE("QEvent::FocusIn : I am "<< objectName.toStdString() );
769 MESSAGE("QEvent::FocusIn : I am "<< className.toStdString() );
771 // Highlight the input widget
772 if ( lineEdit || listWidget ){
773 QWidget* w = dynamic_cast<QWidget*>(obj);
774 QPalette palette1 = w->palette();
775 palette1.setColor(w->backgroundRole(), Qt::yellow);
776 w->setPalette(palette1);
780 if ( event->type() == QEvent::FocusOut ){
781 QString className = obj->metaObject()->className();
782 QString objectName = obj->objectName();
783 MESSAGE("QEvent::FocusOut : I am "<< objectName.toStdString() );
784 MESSAGE("QEvent::FocusOut : I am "<< className.toStdString() );
786 // UnHighlight the input widget
787 if ( lineEdit || listWidget ){
788 QWidget* w = dynamic_cast<QWidget*>(obj);
789 QPalette palette1 = w->palette();
790 palette1.setColor(w->backgroundRole(), Qt::white);
791 w->setPalette(palette1);
795 if ( event->type() != QEvent::FocusIn ){ //QEvent::KeyPress) {
797 // return QObject::eventFilter(obj, event);
800 MESSAGE("HexaBaseDialog::eventFilter{");
801 MESSAGE("* QEvent::FocusIn");
803 /* ON FOCUS ON A WIDGET*/
808 QItemSelectionModel *selector = 0;
809 _allowVTKSelection( obj );
812 _allowOCCSelection( obj );
814 //Depending of focused widget type, get the right selector for it
815 selector = _getSelector( obj );
816 if ( !selector ) return false;
818 // Highlight the input widget
819 if ( _currentObj != obj && (lineEdit || listWidget) ){
820 selector->clearSelection();
825 //If there is a current selection fill the widget with it
826 if ( selector->hasSelection() ){
827 QItemSelection currentSelection = selector->selection();
829 if ( lineEdit ){ //element can be from lineEdit
830 selOk = _onSelectionChanged( currentSelection, lineEdit );
831 } else if ( listWidget ){
832 selOk = _onSelectionChanged( currentSelection, listWidget );
834 if ( !selOk && ( lineEdit || listWidget ) ){
835 selector->clearSelection();
838 } else { //If the widget contains an hexa element, select it in model/view
839 if ( lineEdit ){ //element can be from lineEdit
840 MESSAGE("* on QLineEdit");
841 v = lineEdit->property("QModelIndex");
842 if ( !v.isValid() ) {
843 //return QObject::eventFilter(obj, event);
846 index = v.value<QModelIndex>();
848 _selectionMutex = true;
849 MESSAGE("* selecting the element : " << index.data().toString().toStdString());
850 MESSAGE("* with selector : " << selector);
851 MESSAGE( "* _patternDataSelectionModel : " << _patternDataSelectionModel );
852 MESSAGE( "* _patternBuilderSelectionModel : " << _patternBuilderSelectionModel );
853 MESSAGE( "* _groupsSelectionModel : " << _groupsSelectionModel );
854 MESSAGE( "* _meshSelectionModel : " << _meshSelectionModel );
855 selector->select( index, QItemSelectionModel::Clear );
856 selector->select( index, QItemSelectionModel::Select );
857 _selectionMutex = false;
861 if ( dialog ){ //element can be from a dialog box
862 MESSAGE("* on Dialog");
863 v = dialog->property("QModelIndex");
864 if ( !v.isValid() ) {
865 //return QObject::eventFilter(obj, event);
868 index = v.value<QModelIndex>();
869 _selectionMutex = true;
870 MESSAGE("* selecting the element : " << index.data().toString().toStdString());
871 selector->select( index, QItemSelectionModel::Clear );
872 selector->select( index, QItemSelectionModel::Select );
873 _selectionMutex = false;
882 // ------------------------- VERTEX ----------------------------------
884 // ============================================================== Constructeur
885 VertexDialog::VertexDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
886 HexaBaseDialog(parent, editmode, f),
889 _helpFileName = "gui_vertex.html";
891 _initWidget(editmode);
892 // setFocusProxy( name_le );
894 if ( editmode == NEW_MODE ){
895 setWindowTitle( tr("Vertex Construction") );
896 } else if ( editmode == UPDATE_MODE ){
897 setWindowTitle( tr("Vertex Modification") );
901 // ============================================================== Destructeur
902 VertexDialog::~VertexDialog()
907 // ============================================================== _initInputWidget
908 void VertexDialog::_initInputWidget( Mode editmode )
910 x_spb->setRange(VERTEX_COORD_MIN, VERTEX_COORD_MAX);
911 y_spb->setRange(VERTEX_COORD_MIN, VERTEX_COORD_MAX);
912 z_spb->setRange(VERTEX_COORD_MIN, VERTEX_COORD_MAX);
914 setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
915 installEventFilter(this);
916 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
917 name_le->installEventFilter(this);
919 connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()));
922 // ============================================================== clear
923 void VertexDialog::clear()
928 // ============================================================== setValue
929 void VertexDialog::setValue(HEXA_NS::Vertex* v)
931 MESSAGE("* setValue : " << v);
933 name_le->setText( v->getName() );
936 x_spb->setValue( v->getX() );
937 y_spb->setValue( v->getY() );
938 z_spb->setValue( v->getZ() );
940 MESSAGE("* _patternDataSelectionModel : " << _patternDataSelectionModel );
941 if ( _patternDataSelectionModel ){
942 QModelIndex iv = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v) );
943 MESSAGE("* selecting the element : " << iv.data().toString().toStdString());
945 setProperty( "QModelIndex", QVariant::fromValue<QModelIndex>(iv) );
946 name_le->setProperty( "QModelIndex", QVariant::fromValue<QModelIndex>(iv) );
952 // ============================================================== getValue
953 HEXA_NS::Vertex* VertexDialog::getValue()
960 // ============================================================== apply
961 bool VertexDialog::apply(QModelIndex& result)
963 SUIT_OverrideCursor wc;
964 if ( !_documentModel ) return false;
965 if ( !_patternDataSelectionModel ) return false;
966 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
967 if ( !patternDataModel ) return false;
973 double newX = x_spb->value();
974 double newY = y_spb->value();
975 double newZ = z_spb->value();
977 if ( _editMode == UPDATE_MODE){
978 QVariant v = property("QModelIndex");
980 iVertex = patternDataModel->mapToSource( v.value<QModelIndex>() );
981 if ( iVertex.isValid() )
982 isOk = _documentModel->updateVertex( iVertex, newX, newY, newZ );
984 } else if ( _editMode == NEW_MODE){
985 iVertex = _documentModel->addVertex( newX, newY, newZ );
986 if ( iVertex.isValid() )
990 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "VERTEX UPDATE/CONSTRUCTION" ) );
994 QString newName = name_le->text();
995 if ( !newName.isEmpty() )/*{*/
996 _documentModel->setName( iVertex, newName );
998 // to select/highlight result
999 result = patternDataModel->mapFromSource(iVertex);
1005 // ------------------------- EDGE ----------------------------------
1007 // ============================================================== Constructeur
1008 EdgeDialog::EdgeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1009 HexaBaseDialog(parent, editmode, f),
1012 _helpFileName = "gui_edge.html";
1014 _initWidget(editmode);
1016 rb0->setFocusProxy( v0_le_rb0 );
1017 rb1->setFocusProxy( vex_le_rb1 );
1020 if ( editmode == INFO_MODE ){
1021 setWindowTitle( tr("Edge Information") );
1028 // ============================================================== Destructeur
1029 EdgeDialog::~EdgeDialog()
1034 // ============================================================== _initInputWidget
1035 void EdgeDialog::_initInputWidget( Mode editmode )
1038 QValidator *validator = new QRegExpValidator(rx, this);
1040 setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1041 installEventFilter(this);
1043 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1044 name_le->installEventFilter(this);
1046 v0_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1047 v1_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1048 v0_le_rb0->setValidator( validator );
1049 v1_le_rb0->setValidator( validator );
1050 v0_le_rb0->installEventFilter(this);
1051 v1_le_rb0->installEventFilter(this);
1053 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1054 vec_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
1055 vex_le_rb1->setValidator( validator );
1056 vec_le_rb1->setValidator( validator );
1057 vex_le_rb1->installEventFilter(this);
1058 vec_le_rb1->installEventFilter(this);
1060 connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) );
1064 // ============================================================== Clear
1065 void EdgeDialog::clear()
1070 vex_le_rb1->clear();
1071 vec_le_rb1->clear();
1076 // ============================================================== setValue
1077 void EdgeDialog::setValue(HEXA_NS::Edge* e)
1079 HEXA_NS::Vertex* v0 = e->getVertex(0);
1080 HEXA_NS::Vertex* v1 = e->getVertex(1);
1082 name_le->setText( e->getName() );
1083 v0_le_rb0->setText( v0->getName() );
1084 v1_le_rb0->setText( v1->getName() );
1086 if ( _patternDataSelectionModel ){
1087 QModelIndex ie = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e) );
1088 QModelIndex iv0 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v0) );
1089 QModelIndex iv1 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v1) );
1091 name_le->setProperty( "QModelIndex", QVariant::fromValue(ie) );
1092 v0_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv0) );
1093 v1_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv1) );
1099 // ============================================================== getValue
1100 HEXA_NS::Edge* EdgeDialog::getValue()
1105 // ============================================================== apply
1106 bool EdgeDialog::apply(QModelIndex& result)
1108 SUIT_OverrideCursor wc;
1109 //if ( !_documentModel ) return;
1110 if ( !_patternDataSelectionModel ) return false;
1111 if ( !_patternBuilderSelectionModel ) return false;
1112 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
1113 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
1114 if ( !patternDataModel ) return false;
1115 if ( !patternBuilderModel ) return false;
1120 if ( rb0->isChecked() ){
1121 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb0] );
1122 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb0] );
1123 if ( iv0.isValid()&& iv1.isValid() ){
1124 iEdge = _documentModel->addEdgeVertices( iv0, iv1 );
1126 } else if ( rb1->isChecked() ){
1127 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
1128 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb1] );
1129 if ( ivex.isValid() && ivec.isValid() ){
1130 iEdge = _documentModel->addEdgeVector( ivex, ivec );
1134 if ( !iEdge.isValid() ){
1135 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT BUILD EDGE" ) );
1138 _value = iEdge.model()->data(iEdge, HEXA_DATA_ROLE).value<HEXA_NS::Edge*>();
1140 QString newName = name_le->text();
1141 if ( !newName.isEmpty() )/*{*/
1142 _documentModel->setName( iEdge, newName );
1144 result = patternDataModel->mapFromSource(iEdge);
1150 // ------------------------- QUAD ----------------------------------
1152 // ============================================================== Constructeur
1153 QuadDialog::QuadDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1154 HexaBaseDialog(parent, editmode, f),
1157 _helpFileName = "gui_quadrangle.html";
1159 _initWidget(editmode);
1160 rb0->setFocusProxy( v0_le_rb0 );
1161 rb1->setFocusProxy( e0_le_rb1 );
1164 if ( editmode == INFO_MODE ){
1165 setWindowTitle( tr("Quad Information") );
1169 // ============================================================== Destructeur
1170 QuadDialog::~QuadDialog()
1174 // ============================================================== _initInputWidget
1175 void QuadDialog::_initInputWidget( Mode editmode )
1178 QValidator *validator = new QRegExpValidator(rx, this);
1180 setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
1181 installEventFilter(this);
1183 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
1184 name_le->installEventFilter(this);
1186 v0_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1187 v1_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1188 v2_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1189 v3_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1191 v0_le_rb0->setValidator( validator );
1192 v1_le_rb0->setValidator( validator );
1193 v2_le_rb0->setValidator( validator );
1194 v3_le_rb0->setValidator( validator );
1195 v0_le_rb0->installEventFilter(this);
1196 v1_le_rb0->installEventFilter(this);
1197 v2_le_rb0->installEventFilter(this);
1198 v3_le_rb0->installEventFilter(this);
1200 e0_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1201 e1_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1202 e2_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1203 e3_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1205 e0_le_rb1->setValidator( validator );
1206 e1_le_rb1->setValidator( validator );
1207 e2_le_rb1->setValidator( validator );
1208 e3_le_rb1->setValidator( validator );
1210 e0_le_rb1->installEventFilter(this);
1211 e1_le_rb1->installEventFilter(this);
1212 e2_le_rb1->installEventFilter(this);
1213 e3_le_rb1->installEventFilter(this);
1215 connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) );
1219 // ============================================================== clear
1220 void QuadDialog::clear()
1236 // ============================================================== setValue
1237 void QuadDialog::setValue(HEXA_NS::Quad* q)
1239 Q_ASSERT( q->countEdge() == 4 );
1240 Q_ASSERT( q->countVertex() == 4 );
1243 name_le->setText( q->getName() );
1246 HEXA_NS::Vertex* v0 = q->getVertex(0);
1247 HEXA_NS::Vertex* v1 = q->getVertex(1);
1248 HEXA_NS::Vertex* v2 = q->getVertex(2);
1249 HEXA_NS::Vertex* v3 = q->getVertex(3);
1251 v0_le_rb0->setText( v0->getName() );
1252 v1_le_rb0->setText( v1->getName() );
1253 v2_le_rb0->setText( v2->getName() );
1254 v3_le_rb0->setText( v3->getName() );
1258 HEXA_NS::Edge* e0 = q->getEdge(0);
1259 HEXA_NS::Edge* e1 = q->getEdge(1);
1260 HEXA_NS::Edge* e2 = q->getEdge(2);
1261 HEXA_NS::Edge* e3 = q->getEdge(3);
1263 e0_le_rb1->setText( e0->getName() );
1264 e1_le_rb1->setText( e1->getName() );
1265 e2_le_rb1->setText( e2->getName() );
1266 e3_le_rb1->setText( e3->getName() );
1268 if ( _patternDataSelectionModel ){
1269 QModelIndex iq = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(q) );
1271 QModelIndex iv0 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v0) );
1272 QModelIndex iv1 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v1) );
1273 QModelIndex iv2 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v2) );
1274 QModelIndex iv3 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v3) );
1276 QModelIndex ie0 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e0) );
1277 QModelIndex ie1 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e1) );
1278 QModelIndex ie2 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e2) );
1279 QModelIndex ie3 = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e3) );
1281 name_le->setProperty( "QModelIndex", QVariant::fromValue(iq) );
1283 v0_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv0) );
1284 v1_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv1) );
1285 v2_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv2) );
1286 v3_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv3) );
1288 e0_le_rb1->setProperty( "QModelIndex", QVariant::fromValue(ie0) );
1289 e1_le_rb1->setProperty( "QModelIndex", QVariant::fromValue(ie1) );
1290 e2_le_rb1->setProperty( "QModelIndex", QVariant::fromValue(ie2) );
1291 e3_le_rb1->setProperty( "QModelIndex", QVariant::fromValue(ie3) );
1297 // ============================================================== getValue
1298 HEXA_NS::Quad* QuadDialog::getValue()
1304 // ============================================================== apply
1305 bool QuadDialog::apply(QModelIndex& result)
1307 SUIT_OverrideCursor wc;
1308 //if ( !_documentModel ) return;
1309 if ( !_patternDataSelectionModel ) return false;
1310 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
1311 if ( !patternDataModel ) return false;
1316 if ( rb0->isChecked() ){ //vertices
1317 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb0] );
1318 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb0] );
1319 QModelIndex iv2 = patternDataModel->mapToSource( _index[v2_le_rb0] );
1320 QModelIndex iv3 = patternDataModel->mapToSource( _index[v3_le_rb0] );
1326 iQuad = _documentModel->addQuadVertices( iv0, iv1, iv2, iv3 );
1328 } else if ( rb1->isChecked() ){ //edges
1329 QModelIndex ie0 = patternDataModel->mapToSource( _index[e0_le_rb1] );
1330 QModelIndex ie1 = patternDataModel->mapToSource( _index[e1_le_rb1] );
1331 QModelIndex ie2 = patternDataModel->mapToSource( _index[e2_le_rb1] );
1332 QModelIndex ie3 = patternDataModel->mapToSource( _index[e3_le_rb1] );
1338 iQuad = _documentModel->addQuadEdges( ie0, ie1, ie2, ie3 );
1342 if ( !iQuad.isValid() ){
1343 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT BUILD QUAD" ) );
1346 _value = iQuad.model()->data(iQuad, HEXA_DATA_ROLE).value<HEXA_NS::Quad *>();
1348 QString newName = name_le->text();
1349 if ( !newName.isEmpty() )/*{*/
1350 _documentModel->setName( iQuad, newName );
1352 // to select/highlight result
1353 result = patternDataModel->mapFromSource(iQuad);
1360 // ------------------------- HEXA ----------------------------------
1362 // ============================================================== HexaDialog
1364 HexaDialog::HexaDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1365 HexaBaseDialog(parent, editmode, f),
1368 _helpFileName = "gui_hexahedron.html";
1370 _initWidget(editmode);
1371 quads_rb->setFocusProxy( quads_lw );
1372 vertices_rb->setFocusProxy( vertices_lw );
1374 // quads_rb->setFocus();
1376 if ( editmode == INFO_MODE ){
1377 setWindowTitle( tr("Hexahedron Information") );
1381 // ============================================================== Destructeur
1382 HexaDialog::~HexaDialog()
1387 // ============================================================== _initInputWidget
1388 void HexaDialog::_initInputWidget( Mode editmode )
1391 QValidator *validator = new QRegExpValidator(rx, this);
1393 setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
1394 installEventFilter(this);
1396 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
1397 name_le->installEventFilter(this);
1399 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
1400 quads_lw->installEventFilter(this);
1402 vertices_lw->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1403 vertices_lw->installEventFilter(this);
1406 if ( editmode != INFO_MODE ) {
1407 // delete item from listwidget
1408 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
1409 QShortcut* delVertexShortcut = new QShortcut( QKeySequence(Qt::Key_X), vertices_lw );
1410 delQuadShortcut->setContext( Qt::WidgetShortcut );
1411 delVertexShortcut->setContext( Qt::WidgetShortcut );
1412 connect(delQuadShortcut, SIGNAL(activated()), this, SLOT(deleteQuadItem()));
1413 connect(delVertexShortcut, SIGNAL(activated()), this, SLOT(deleteVertexItem()));
1416 connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) );
1417 // highlight item on model view (VTK) from listwidget
1418 connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) );
1419 connect( vertices_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) );
1422 // ============================================================== clear
1423 void HexaDialog::clear()
1427 vertices_lw->clear();
1430 // ============================================================== updateButtonBox
1431 void HexaDialog::updateButtonBox()
1433 if ( quads_rb->isChecked() ){ // build from quads count() must be between [2,6]
1434 int nbQuads = quads_lw->count();
1435 //std::cout << "nbQuads => " << nbQuads << std::endl;
1436 if ( nbQuads >= 2 && nbQuads <= 6 ){
1437 //_applyCloseButton->setEnabled(true);
1438 _applyButton->setEnabled(true);
1439 // _applyCloseButton->setFlat( false );
1440 // _applyButton->setFlat( false );
1442 //_applyCloseButton->setEnabled(false);
1443 _applyButton->setEnabled(false);
1444 // _applyCloseButton->setFlat( true );
1445 // _applyButton->setFlat( true );
1447 } else if ( vertices_rb->isChecked() ){ // build from vertices count() must be equals to 8
1448 int nbVertices = vertices_lw->count();
1449 //std::cout << "nbVertices => " << nbVertices << std::endl;
1450 if ( nbVertices == 8 ){
1451 //_applyCloseButton->setEnabled(true);
1452 _applyButton->setEnabled(true);
1453 // _applyCloseButton->setFlat( false );
1454 // _applyButton->setFlat( false );
1456 //_applyCloseButton->setEnabled(false);
1457 _applyButton->setEnabled(false);
1458 // _applyCloseButton->setFlat( true );
1459 // _applyButton->setFlat( true );
1464 // ============================================================== deleteQuadItem
1465 void HexaDialog::deleteQuadItem()
1467 delete quads_lw->currentItem();
1471 // ============================================================== deleteVertexItem
1472 void HexaDialog::deleteVertexItem()
1474 delete vertices_lw->currentItem();
1478 // ============================================================== _setValueQuads
1479 void HexaDialog::_setValueQuads( HEXA_NS::Hexa* h )
1481 QListWidgetItem *qItem = NULL;
1482 HEXA_NS::Quad *q = NULL;
1486 for( int i = 0; i <= 5; ++i ){
1488 qIndex = _patternDataSelectionModel->indexBy( HEXA_ENTRY_ROLE, QString::number(reinterpret_cast<intptr_t>(q)) );
1489 qItem = new QListWidgetItem( q->getName() );
1490 qItem->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(qIndex) );
1491 quads_lw->addItem( qItem );
1495 // ============================================================== _setValueVertices
1496 void HexaDialog::_setValueVertices( HEXA_NS::Hexa* h )
1498 QListWidgetItem *vItem = NULL;
1499 HEXA_NS::Vertex* v = NULL;
1502 vertices_lw->clear();
1503 for( int i = 0; i <= 7; ++i ){
1504 v = h->getVertex(i);
1505 vIndex = _patternDataSelectionModel->indexBy( HEXA_ENTRY_ROLE, QString::number(reinterpret_cast<intptr_t>(v)) );
1506 vItem = new QListWidgetItem( v->getName() );
1507 vItem->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(vIndex) );
1508 vertices_lw->addItem( vItem );
1512 // ============================================================== setValue
1513 void HexaDialog::setValue(HEXA_NS::Hexa* h)
1516 name_le->setText( h->getName() );
1518 if ( _patternDataSelectionModel){
1519 QModelIndex hIndex = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(h) );
1520 _setValueVertices(h);
1522 name_le->setProperty( "QModelIndex", QVariant::fromValue(hIndex) );
1527 // ============================================================== getValue
1528 HEXA_NS::Hexa* HexaDialog::getValue()
1533 // ============================================================== apply
1534 bool HexaDialog::apply(QModelIndex& result)
1536 SUIT_OverrideCursor wc;
1537 if ( !_documentModel ) return false;
1538 if ( !_patternDataSelectionModel ) return false;
1539 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
1540 if ( !patternDataModel ) return false;
1545 QListWidget* currentLw = NULL;
1546 QListWidgetItem* item = NULL;
1548 if ( quads_rb->isChecked() )
1549 currentLw = dynamic_cast<QListWidget*>( quads_lw );
1550 else if ( vertices_rb->isChecked() )
1551 currentLw = dynamic_cast<QListWidget*>( vertices_lw );
1554 QModelIndexList iElts;
1555 for ( int r = 0; r < currentLw->count(); ++r){
1556 item = currentLw->item(r);
1557 iElt = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
1558 if ( iElt.isValid() )
1562 if ( quads_rb->isChecked() and (iElts.count()>=2 and iElts.count()<=6) ){ // build from quads iElts.count() should be between [2,6]
1563 iHexa = _documentModel->addHexaQuads( iElts );
1564 } else if ( vertices_rb->isChecked() and iElts.count()== 8 ){ // build from vertices
1565 iHexa = _documentModel->addHexaVertices( iElts[0], iElts[1], iElts[2], iElts[3],
1566 iElts[4], iElts[5], iElts[6], iElts[7] );
1569 if ( !iHexa.isValid() ){
1570 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT BUILD HEXA" ) );
1573 _value = iHexa.model()->data(iHexa, HEXA_DATA_ROLE).value<HEXA_NS::Hexa*>();
1575 QString newName = name_le->text();
1576 if ( !newName.isEmpty() )/*{*/
1577 _documentModel->setName( iHexa, newName );
1579 // to select/highlight result
1580 result = patternDataModel->mapFromSource(iHexa);
1586 // ------------------------- VECTOR ----------------------------------
1588 // ============================================================== Constructeur
1590 VectorDialog::VectorDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1591 HexaBaseDialog(parent, editmode, f),
1594 _helpFileName = "gui_vector.html";
1596 _initWidget(editmode);
1598 rb0->setFocusProxy( dx_spb_rb0 );
1599 rb1->setFocusProxy( v0_le_rb1 );
1601 // setFocusProxy( rb0 );
1603 if ( editmode == INFO_MODE ){
1604 setWindowTitle( tr("Vector Information") );
1609 // ============================================================== Destructeur
1610 VectorDialog::~VectorDialog()
1614 // ============================================================== _initInputWidget
1615 void VectorDialog::_initInputWidget( Mode editmode )
1618 QValidator *validator = new QRegExpValidator(rx, this);
1620 setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
1621 installEventFilter(this);
1623 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
1624 name_le->installEventFilter(this);
1626 v0_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1627 v0_le_rb1->setValidator( validator );
1628 v0_le_rb1->installEventFilter(this);
1630 v1_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1631 v1_le_rb1->setValidator( validator );
1632 v1_le_rb1->installEventFilter(this);
1634 if ( editmode == INFO_MODE ){
1635 dx_spb_rb0->setReadOnly(true);
1636 dy_spb_rb0->setReadOnly(true);
1637 dz_spb_rb0->setReadOnly(true);
1640 connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) );
1643 // ============================================================== clear
1644 void VectorDialog::clear()
1647 dx_spb_rb0->clear();
1648 dy_spb_rb0->clear();
1649 dz_spb_rb0->clear();
1654 // ============================================================== setValue
1655 void VectorDialog::setValue(HEXA_NS::Vector* v)
1657 name_le->setText( v->getName() );
1658 dx_spb_rb0->setValue( v->getDx() );
1659 dy_spb_rb0->setValue( v->getDy() );
1660 dz_spb_rb0->setValue( v->getDz() );
1662 if ( _patternDataSelectionModel ){
1663 QModelIndex ivec = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v) );
1664 name_le->setProperty( "QModelIndex", QVariant::fromValue(ivec) );
1669 // ============================================================== getValue
1670 HEXA_NS::Vector* VectorDialog::getValue()
1675 // ============================================================== apply
1676 bool VectorDialog::apply(QModelIndex& result)
1678 SUIT_OverrideCursor wc;
1679 if ( !_documentModel ) return false;
1680 if ( !_patternDataSelectionModel ) return false;
1681 if ( !_patternBuilderSelectionModel ) return false;
1682 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
1683 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
1684 if ( !patternDataModel ) return false;
1685 if ( !patternBuilderModel ) return false;
1688 QModelIndex iVector;
1690 if ( rb0->isChecked() ){ //scalar
1691 double dx = dx_spb_rb0->value();
1692 double dy = dy_spb_rb0->value();
1693 double dz = dz_spb_rb0->value();
1695 iVector = _documentModel->addVector( dx, dy, dz );
1696 } else if ( rb1->isChecked() ){ //vertices
1697 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb1] );
1698 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb1] );
1702 iVector = _documentModel->addVectorVertices( iv0, iv1 );
1706 if ( !iVector.isValid() ){
1707 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT BUILD VECTOR" ) );
1711 _value = iVector.model()->data(iVector, HEXA_DATA_ROLE).value<HEXA_NS::Vector *>();
1713 QString newName = name_le->text();
1714 if ( !newName.isEmpty() )/*{*/
1715 _documentModel->setName( iVector, newName );
1717 // to select/highlight result
1718 result = patternBuilderModel->mapFromSource(iVector);
1724 // ============================================================== Constructeur
1725 CylinderDialog::CylinderDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
1726 : HexaBaseDialog(parent, editmode, f),
1729 _helpFileName = "gui_cyl.html";
1731 _initWidget(editmode);
1733 if ( editmode == INFO_MODE ){
1734 setWindowTitle( tr("Cylinder Information") );
1738 // ============================================================== Destructeur
1739 CylinderDialog::~CylinderDialog()
1743 // ============================================================== _initInputWidget
1744 void CylinderDialog::_initInputWidget( Mode editmode )
1747 QValidator *validator = new QRegExpValidator(rx, this);
1749 setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
1750 installEventFilter(this);
1752 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
1753 name_le->installEventFilter(this);
1755 vex_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1756 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
1758 vex_le->setValidator( validator );
1759 vec_le->setValidator( validator );
1761 vex_le->installEventFilter(this);
1762 vec_le->installEventFilter(this);
1764 connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()));
1767 // ============================================================== clear
1768 void CylinderDialog::clear()
1777 // ============================================================== setValue
1778 void CylinderDialog::setValue(HEXA_NS::Cylinder* c)
1780 HEXA_NS::Vertex* base = c->getBase();
1781 HEXA_NS::Vector* direction = c->getDirection();
1782 double r = c->getRadius();
1783 double h = c->getHeight();
1785 name_le->setText( c->getName() );
1786 vex_le->setText( base->getName() );
1787 vec_le->setText( direction->getName() );
1791 if ( _patternDataSelectionModel ){
1792 QModelIndex iCyl = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(c) );
1793 QModelIndex iBase = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(base) );
1794 QModelIndex iDirection = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(direction) );
1796 name_le->setProperty( "QModelIndex", QVariant::fromValue(iCyl) );
1797 vex_le->setProperty( "QModelIndex", QVariant::fromValue(iBase) );
1798 vec_le->setProperty( "QModelIndex", QVariant::fromValue(iDirection) );
1803 // ============================================================== getValue
1804 HEXA_NS::Cylinder* CylinderDialog::getValue()
1811 // ============================================================== apply
1812 bool CylinderDialog::apply(QModelIndex& result)
1814 SUIT_OverrideCursor wc;
1815 if ( !_documentModel ) return false;
1816 if ( !_patternDataSelectionModel ) return false;
1817 if ( !_patternBuilderSelectionModel ) return false;
1818 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
1819 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
1820 if ( !patternDataModel ) return false;
1821 if ( !patternBuilderModel ) return false;
1825 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le] );
1826 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
1827 double r = r_spb->value();
1828 double h = h_spb->value();
1831 && ivec.isValid() ){
1832 iCyl = _documentModel->addCylinder( ivex, ivec, r, h );
1835 if ( !iCyl.isValid() ){
1836 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD CYLINDER" ) );
1840 _value = iCyl.model()->data(iCyl, HEXA_DATA_ROLE).value<HEXA_NS::Cylinder *>();
1842 QString newName = name_le->text();
1843 if (!newName.isEmpty()) /*{*/
1844 _documentModel->setName( iCyl, newName );
1846 // to select/highlight result
1847 result = patternBuilderModel->mapFromSource(iCyl);
1853 //------------------------------- PipeDialog -----------------------------------
1855 // ============================================================== Constructeur
1857 PipeDialog::PipeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
1858 : HexaBaseDialog(parent, editmode, f),
1861 _helpFileName = "gui_pipe.html";
1863 _initWidget(editmode);
1864 // setFocusProxy( vex_le );
1866 if ( editmode == INFO_MODE ){
1867 setWindowTitle( tr("Pipe Information") );
1872 // ============================================================== Destructeur
1873 PipeDialog::~PipeDialog()
1877 // ============================================================== _initInputWidget
1878 void PipeDialog::_initInputWidget( Mode editmode )
1881 QValidator *validator = new QRegExpValidator(rx, this);
1884 setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
1885 installEventFilter(this);
1887 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
1888 name_le->installEventFilter(this);
1890 //Vertex Field config
1891 vex_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1892 vex_le->installEventFilter(this);
1893 vex_le->setValidator( validator );
1895 //Vector Field config
1896 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
1897 vec_le->installEventFilter(this);
1898 vec_le->setValidator( validator );
1901 if ( editmode == INFO_MODE ){
1902 ir_spb->setReadOnly(true);
1903 er_spb->setReadOnly(true);
1904 h_spb->setReadOnly(true);
1907 connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()));
1911 // ============================================================== clear
1912 void PipeDialog::clear()
1919 // ============================================================== setValue
1920 void PipeDialog::setValue(HEXA_NS::Pipe* p)
1922 HEXA_NS::Vertex* base = p->getBase();
1923 HEXA_NS::Vector* direction = p->getDirection();
1924 double ir = p->getInternalRadius();
1925 double er = p->getRadius();
1926 double h = p->getHeight();
1928 name_le->setText( p->getName() );
1929 vex_le->setText( base->getName() );
1930 vec_le->setText( direction->getName() );
1931 ir_spb->setValue(ir);
1932 er_spb->setValue(er);
1935 if ( _patternDataSelectionModel ){
1936 QModelIndex iPipe = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(p) );
1937 QModelIndex iBase = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(base) );
1938 QModelIndex iDirection = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(direction) );
1940 name_le->setProperty( "QModelIndex", QVariant::fromValue(iPipe) );
1941 vex_le->setProperty( "QModelIndex", QVariant::fromValue(iBase) );
1942 vec_le->setProperty( "QModelIndex", QVariant::fromValue(iDirection) );
1947 // ============================================================== getValue
1948 HEXA_NS::Pipe* PipeDialog::getValue()
1954 // ============================================================== apply
1955 bool PipeDialog::apply(QModelIndex& result)
1957 SUIT_OverrideCursor wc;
1958 //if ( !_documentModel ) return;
1959 if ( !_patternDataSelectionModel ) return false;
1960 if ( !_patternBuilderSelectionModel ) return false;
1961 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
1962 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
1963 if ( !patternDataModel ) return false;
1964 if ( !patternBuilderModel ) return false;
1968 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le] );
1969 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
1970 double ir = ir_spb->value();
1971 double er = er_spb->value();
1972 double h = h_spb->value();
1975 SUIT_MessageBox::information( this, tr( "CANNOT ADD PIPE" ), tr( "External radius must be greather than Internal radius!" ) );
1981 && ivec.isValid() ){
1982 iPipe = _documentModel->addPipe( ivex, ivec, ir, er, h );
1985 if ( !iPipe.isValid() ){
1986 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD PIPE" ) );
1989 _value = iPipe.model()->data(iPipe, HEXA_DATA_ROLE).value<HEXA_NS::Pipe *>();
1991 QString newName = name_le->text();
1992 if ( !newName.isEmpty() )/*{*/
1993 _documentModel->setName( iPipe, newName );
1995 // to select/highlight result
1996 result = patternBuilderModel->mapFromSource(iPipe);
2002 // ------------------------- MakeGridDialog ----------------------------------
2003 // ( Cartesian, Cylindrical, Spherical )
2005 // ============================================================== Constructeur
2007 MakeGridDialog::MakeGridDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2008 : HexaBaseDialog(parent, editmode, f)
2011 _initWidget(editmode);
2012 rb0->click();// Default : cartesian grid
2013 uniform_rb->click();
2014 rb0->setFocusProxy( vex_le_rb0 );
2015 rb1->setFocusProxy( center_le_rb1 );
2016 rb2->setFocusProxy( vex_le_rb2 );
2017 // setFocusProxy( rb0 );
2019 _helpFileName = "creategrids.html#guicartgrid";
2020 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2021 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2022 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2026 // ============================================================== Destructeur
2027 MakeGridDialog::~MakeGridDialog()
2031 // ============================================================== _initInputWidget
2032 void MakeGridDialog::_initInputWidget( Mode editmode )
2036 QValidator *validator = new QRegExpValidator(rx, this);
2038 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
2039 installEventFilter(this);
2041 vex_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2042 vec_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2043 vex_le_rb0->setValidator( validator );
2044 vec_le_rb0->setValidator( validator );
2045 vex_le_rb0->installEventFilter(this);
2046 vec_le_rb0->installEventFilter(this);
2048 center_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2049 base_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2050 height_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2051 center_le_rb1->setValidator( validator );
2052 base_le_rb1->setValidator( validator );
2053 height_le_rb1->setValidator( validator );
2054 center_le_rb1->installEventFilter(this);
2055 base_le_rb1->installEventFilter(this);
2056 height_le_rb1->installEventFilter(this);
2058 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2059 vex_le_rb2->setValidator( validator );
2060 vex_le_rb2->installEventFilter(this);
2063 if ( editmode != INFO_MODE ){
2065 radius_lw->setItemDelegate(new HexaPositiveDoubleSpinBoxDelegate(radius_lw));
2066 radius_lw->setEditTriggers(QAbstractItemView::DoubleClicked);
2068 angle_lw->setItemDelegate(new HexaAngleDoubleSpinBoxDelegate(angle_lw));
2069 angle_lw->setEditTriggers(QAbstractItemView::DoubleClicked);
2071 height_lw->setItemDelegate(new HexaPositiveDoubleSpinBoxDelegate(height_lw));
2072 height_lw->setEditTriggers(QAbstractItemView::DoubleClicked);
2074 connect( add_radius_pb, SIGNAL(clicked()), this, SLOT(addRadiusItem()) );
2075 connect( del_radius_pb, SIGNAL(clicked()), this, SLOT(delRadiusItem()) );
2076 connect( add_angle_pb, SIGNAL(clicked()), this, SLOT(addAngleItem()) );
2077 connect( del_angle_pb, SIGNAL(clicked()), this, SLOT(delAngleItem()) );
2078 connect( add_height_pb, SIGNAL(clicked()), this, SLOT(addHeightItem()) );
2079 connect( del_height_pb, SIGNAL(clicked()), this, SLOT(delHeightItem()) );
2084 // ============================================================== clear
2085 void MakeGridDialog::clear()
2087 vex_le_rb0->clear();
2088 vec_le_rb0->clear();
2089 base_le_rb1->clear();
2090 center_le_rb1->clear();
2091 height_le_rb1->clear();
2092 random_param_w->clear();
2096 vex_le_rb2->clear();
2099 // ============================================================== updateHelpFileName
2100 void MakeGridDialog::updateHelpFileName()
2102 if ( sender() == rb0 ){
2103 _helpFileName = "creategrids.html#guicartgrid";
2104 } else if ( sender() == rb1 ){
2105 _helpFileName = "creategrids.html#guicylgrid";
2106 } else if ( sender() == rb2 ){
2107 _helpFileName = "creategrids.html#guisphergrid";
2112 // ============================================================== updateButtonBox
2113 void MakeGridDialog::updateButtonBox() //CS_TODO?
2115 // int nbQuads = quads_lw->count();
2116 // int nbAngles = angles_lw->count();
2118 // if ( nbQuads>0 && nbAngles> 0 ){
2119 // _applyCloseButton->setEnabled(true);
2120 // _applyButton->setEnabled(true);
2122 // _applyCloseButton->setEnabled(false);
2123 // _applyButton->setEnabled(false);
2126 // if ( rb0->isChecked() ){ //cartesian
2127 // } else if ( rb1->isChecked() ){ //cylindrical
2128 // nb_radius = radius_lw->item(r);
2129 // nb_angle = angle_lw->item(r);
2130 // nb_height = height_lw->item(r);
2131 // } else if ( rb2->isChecked() ){ //spherical
2135 // ============================================================== addRadiusItem
2136 void MakeGridDialog::addRadiusItem()
2138 QListWidgetItem* previousItem = radius_lw->currentItem();
2139 QListWidgetItem* newItem = new QListWidgetItem();
2141 double defaultValue = 0.;
2143 defaultValue = previousItem->data(Qt::EditRole).toDouble();
2145 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
2146 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
2147 radius_lw->addItem(newItem);
2152 // ============================================================== delRadiusItem
2153 void MakeGridDialog::delRadiusItem()
2155 delete radius_lw->currentItem();
2159 // ============================================================== addAngleItem
2160 void MakeGridDialog::addAngleItem()
2162 QListWidgetItem* previousItem = angle_lw->currentItem();
2163 QListWidgetItem* newItem = new QListWidgetItem();
2165 double defaultValue = 0.;
2167 defaultValue = previousItem->data(Qt::EditRole).toDouble();
2169 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
2170 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
2171 angle_lw->addItem(newItem);
2176 // ============================================================== delAngleItem
2177 void MakeGridDialog::delAngleItem()
2179 //std::cout << "delAngleItem()" << std::endl;
2180 delete angle_lw->currentItem();
2184 // ============================================================== addHeightItem
2185 void MakeGridDialog::addHeightItem()
2187 QListWidgetItem* previousItem = height_lw->currentItem();
2188 QListWidgetItem* newItem = new QListWidgetItem();
2190 double defaultValue = 0.;
2192 defaultValue = previousItem->data(Qt::EditRole).toDouble();
2194 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
2195 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
2196 height_lw->addItem(newItem);
2201 // ============================================================== delHeightItem
2202 void MakeGridDialog::delHeightItem()
2204 //std::cout << "delHeightItem()" << std::endl;
2205 delete height_lw->currentItem();
2209 // ============================================================== apply
2210 bool MakeGridDialog::apply(QModelIndex& result)
2212 SUIT_OverrideCursor wc;
2213 //if ( !_documentModel ) return;
2214 if ( !_patternDataSelectionModel ) return false;
2215 if ( !_patternBuilderSelectionModel ) return false;
2216 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
2217 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
2218 if ( !patternDataModel ) return false;
2219 if ( !patternBuilderModel ) return false;
2222 QModelIndex iNewElts;
2223 if ( rb0->isChecked() ){ //cartesian
2224 QModelIndex ivex_rb0 = patternDataModel->mapToSource( _index[vex_le_rb0] );
2225 QModelIndex ivec_rb0 = patternBuilderModel->mapToSource( _index[vec_le_rb0] );
2226 long nx = nx_spb_rb0->value();
2227 long ny = ny_spb_rb0->value();
2228 long nz = nz_spb_rb0->value();
2230 if ( ivex_rb0.isValid()
2231 && ivec_rb0.isValid() ){
2232 iNewElts = _documentModel->makeCartesian( ivex_rb0, ivec_rb0, nx, ny, nz );
2235 } else if ( rb1->isChecked() ){ //cylindrical
2236 QModelIndex icenter_rb1 = patternDataModel->mapToSource( _index[center_le_rb1] );
2237 QModelIndex ibase_rb1 = patternBuilderModel->mapToSource( _index[base_le_rb1] );
2238 QModelIndex iheight_rb1 = patternBuilderModel->mapToSource( _index[height_le_rb1] );
2240 if ( icenter_rb1.isValid()
2241 && ibase_rb1.isValid()
2242 && iheight_rb1.isValid() ){
2244 bool fill = fill_cb_rb1->isChecked();
2245 if ( uniform_rb->isChecked() ){
2246 double dr = dr_spb_rb1->value();
2247 double da = da_spb_rb1->value();
2248 double dl = dl_spb_rb1->value();
2249 double nr = nr_spb_rb1->value();
2250 double na = na_spb_rb1->value();
2251 double nl = nl_spb_rb1->value();
2253 iNewElts = _documentModel->makeCylindrical( icenter_rb1,
2254 ibase_rb1, iheight_rb1,
2255 dr, da, dl, nr, na, nl, fill );
2257 if ( random_rb->isChecked() ){
2258 QListWidgetItem* item = NULL;
2259 QDoubleSpinBox* spb = NULL;
2261 QList<double> radius;
2262 QList<double> angles;
2263 QList<double> heights;
2265 for ( int r = 0; r < radius_lw->count(); ++r){
2266 item = radius_lw->item(r);
2267 //std::cout << "radius : " << item->data(Qt::EditRole).toDouble()<< std::endl;
2268 radius << item->data(Qt::EditRole).toDouble();
2271 for ( int r = 0; r < angle_lw->count(); ++r){
2272 item = angle_lw->item(r);
2273 angles << item->data(Qt::EditRole).toDouble();
2276 for ( int r = 0; r < height_lw->count(); ++r){
2277 item = height_lw->item(r);
2278 heights << item->data(Qt::EditRole).toDouble();
2281 iNewElts = _documentModel->makeCylindricals(
2282 icenter_rb1, ibase_rb1, iheight_rb1,
2283 radius, angles, heights,
2289 } else if ( rb2->isChecked() ){ //spherical
2290 QModelIndex ivex_rb2 = patternDataModel->mapToSource( _index[vex_le_rb2] );
2291 // QModelIndex ivecx_rb2 = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
2292 double radius = radius_spb_rb2->value();
2293 int nb = nb_spb_rb2->value();
2294 int k = k_spb_rb2->value();
2296 if ( ivex_rb2.isValid() ){
2297 iNewElts = _documentModel->makeSpherical( ivex_rb2, radius, nb, k );
2301 if ( !iNewElts.isValid() ){
2302 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE GRID" ) );
2307 // to select/highlight result
2308 result = patternBuilderModel->mapFromSource( iNewElts );
2315 // ============================================================== Constructeur
2317 MakeCylinderDialog::MakeCylinderDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2318 : HexaBaseDialog(parent, editmode, f)
2320 _helpFileName = "gui_blocks_for_cyl_pipe.html#make-cylinder";
2322 _initWidget(editmode);
2323 // setFocusProxy( cyl_le );
2326 // ============================================================== Destructeur
2327 MakeCylinderDialog::~MakeCylinderDialog()
2331 void MakeCylinderDialog::_initInputWidget( Mode editmode )
2334 QValidator *validator = new QRegExpValidator(rx, this);
2336 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
2337 installEventFilter(this);
2339 cyl_le->setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
2340 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2341 cyl_le->setValidator( validator );
2342 vec_le->setValidator( validator );
2343 cyl_le->installEventFilter(this);
2344 vec_le->installEventFilter(this);
2347 // ============================================================== clear
2348 void MakeCylinderDialog::clear()
2355 // ============================================================== apply
2356 bool MakeCylinderDialog::apply(QModelIndex& result)
2358 SUIT_OverrideCursor wc;
2359 //if ( !_documentModel ) return;
2360 if ( !_patternBuilderSelectionModel ) return false;
2361 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
2362 if ( !patternBuilderModel ) return false;
2366 QModelIndex icyl = patternBuilderModel->mapToSource( _index[cyl_le] );
2367 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
2368 double nr = nr_spb->value();
2369 double na = na_spb->value();
2370 double nl = nl_spb->value();
2373 && ivec.isValid() ){
2374 iElts = _documentModel->makeCylinder( icyl, ivec, nr, na, nl );
2377 if ( !iElts.isValid() ){
2378 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE CYLINDER" ) );
2382 // to select/highlight result
2383 result = patternBuilderModel->mapFromSource(iElts);
2389 //---------------------------------- MakePipeDialog -----------------------------
2391 // ============================================================== Constructeur
2393 MakePipeDialog::MakePipeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2394 : HexaBaseDialog(parent, editmode, f)
2396 _helpFileName = "gui_blocks_for_cyl_pipe.html#make-pipe";
2398 _initWidget(editmode);
2399 // setFocusProxy( pipe_le );
2402 // ============================================================== Destructeur
2403 MakePipeDialog::~MakePipeDialog()
2407 // ============================================================== _initInputWidget
2408 void MakePipeDialog::_initInputWidget( Mode editmode )
2411 QValidator *validator = new QRegExpValidator(rx, this);
2413 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
2414 installEventFilter(this);
2416 pipe_le->setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
2417 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2419 pipe_le->setValidator( validator );
2420 vec_le->setValidator( validator );
2422 pipe_le->installEventFilter(this);
2423 vec_le->installEventFilter(this);
2427 // ============================================================== clear
2428 void MakePipeDialog::clear()
2435 // ============================================================== apply
2436 bool MakePipeDialog::apply(QModelIndex& result)
2438 SUIT_OverrideCursor wc;
2439 //if ( !_documentModel ) return;
2440 if ( !_patternBuilderSelectionModel ) return false;
2441 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
2442 if ( !patternBuilderModel ) return false;
2446 QModelIndex ipipe = patternBuilderModel->mapToSource( _index[pipe_le] );
2447 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
2448 double nr = nr_spb->value();
2449 double na = na_spb->value();
2450 double nl = nl_spb->value();
2452 if ( ipipe.isValid()
2453 && ivec.isValid() ){
2454 iElts = _documentModel->makePipe( ipipe, ivec, nr, na, nl );
2456 if ( !iElts.isValid() ){
2457 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE PIPE" ) );
2461 // to select/highlight result
2462 result = patternBuilderModel->mapFromSource(iElts);
2467 //---------------------------------- MakeCylindersDialog -----------------------------
2469 // ============================================================== Constructeur
2471 MakeCylindersDialog::MakeCylindersDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2472 : HexaBaseDialog(parent, editmode, f)
2474 _helpFileName = "gui_blocks_for_cyl_pipe.html#make-cylinders";
2476 _initWidget(editmode);
2477 // setFocusProxy( cyl1_le );
2480 // ============================================================== Destructeur
2481 MakeCylindersDialog::~MakeCylindersDialog()
2485 void MakeCylindersDialog::_initInputWidget( Mode editmode )
2488 QValidator *validator = new QRegExpValidator(rx, this);
2490 setProperty( "HexaWidgetType", QVariant::fromValue(CROSSELEMENTS_TREE) );
2491 installEventFilter(this);
2493 cyl1_le->setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
2494 cyl2_le->setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
2496 cyl1_le->setValidator( validator );
2497 cyl2_le->setValidator( validator );
2499 cyl1_le->installEventFilter(this);
2500 cyl2_le->installEventFilter(this);
2503 // ============================================================== clear
2504 void MakeCylindersDialog::clear()
2511 // ============================================================== apply
2512 bool MakeCylindersDialog::apply(QModelIndex& result)
2514 SUIT_OverrideCursor wc;
2515 //if ( !_documentModel ) return;
2516 if ( !_patternBuilderSelectionModel ) return false;
2517 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
2518 if ( !patternBuilderModel ) return false;
2521 QModelIndex iCrossElts;
2522 QModelIndex icyl1 = patternBuilderModel->mapToSource( _index[cyl1_le] );
2523 QModelIndex icyl2 = patternBuilderModel->mapToSource( _index[cyl2_le] );
2525 if ( icyl1.isValid()
2526 && icyl2.isValid() ){
2527 iCrossElts = _documentModel->makeCylinders( icyl1, icyl2 );
2530 if ( !iCrossElts.isValid() ){
2531 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE CYLINDERS" ) );
2535 // to select/highlight result
2536 result = patternBuilderModel->mapFromSource(iCrossElts);
2543 //---------------------------------- MakePipesDialog -----------------------------
2545 // ============================================================== Constructeur
2547 MakePipesDialog::MakePipesDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2548 : HexaBaseDialog(parent, editmode, f)
2550 _helpFileName = "gui_blocks_for_cyl_pipe.html#make-pipes";
2552 _initWidget(editmode);
2553 // setFocusProxy( pipe1_le );
2556 // ============================================================== Destructeur
2557 MakePipesDialog::~MakePipesDialog()
2561 // ============================================================== _initInputWidget
2562 void MakePipesDialog::_initInputWidget( Mode editmode )
2565 QValidator *validator = new QRegExpValidator(rx, this);
2567 pipe1_le->setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
2568 pipe2_le->setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
2570 pipe1_le->setValidator( validator );
2571 pipe2_le->setValidator( validator );
2573 pipe1_le->installEventFilter(this);
2574 pipe2_le->installEventFilter(this);
2578 // ============================================================== clear
2579 void MakePipesDialog::clear()
2586 // ============================================================== apply
2587 bool MakePipesDialog::apply(QModelIndex& result)
2589 SUIT_OverrideCursor wc;
2590 //if ( !_documentModel ) return;
2591 if ( !_patternBuilderSelectionModel ) return false;
2592 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
2593 if ( !patternBuilderModel ) return false;
2596 QModelIndex iCrossElts;
2597 QModelIndex ipipe1 = patternBuilderModel->mapToSource( _index[pipe1_le] );
2598 QModelIndex ipipe2 = patternBuilderModel->mapToSource( _index[pipe2_le] );
2600 if ( ipipe1.isValid()
2601 && ipipe2.isValid() ){
2602 iCrossElts = _documentModel->makePipes( ipipe1, ipipe2 );
2604 if ( !iCrossElts.isValid() ){
2605 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE PIPES" ) );
2608 result = patternBuilderModel->mapFromSource(iCrossElts);
2614 //---------------------------------- RemoveHexaDialog -----------------------------
2616 // ============================================================== Constructeur
2618 RemoveHexaDialog::RemoveHexaDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2619 : HexaBaseDialog(parent, editmode, f)
2621 _helpFileName = "gui_remove.html";
2623 _initWidget(editmode);
2624 // setFocusProxy( hexa_le );
2628 // ============================================================== Destructeur
2629 RemoveHexaDialog::~RemoveHexaDialog()
2633 // ============================================================== _initInputWidget
2634 void RemoveHexaDialog::_initInputWidget( Mode editmode )
2637 QValidator *validator = new QRegExpValidator(rx, this);
2639 hexa_le->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
2640 hexa_le->setValidator( validator );
2641 hexa_le->installEventFilter(this);
2644 // ============================================================== clear
2645 void RemoveHexaDialog::clear()
2651 // ============================================================== apply
2652 bool RemoveHexaDialog::apply(QModelIndex& result)
2654 SUIT_OverrideCursor wc;
2655 //if ( !_documentModel ) return;
2656 if ( !_patternDataSelectionModel ) return false;
2657 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
2658 if ( !patternDataModel ) return false;
2661 QModelIndex ihexa = patternDataModel->mapToSource( _index[hexa_le] );
2663 bool removed = false;
2664 if ( ihexa.isValid() ){
2665 if ( connected_cb->isChecked() ){
2666 removed = _documentModel->removeConnectedHexa( ihexa );
2668 removed = _documentModel->removeHexa( ihexa );
2672 if ( removed == false ){
2673 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT REMOVE HEXA" ) );
2680 //---------------------------------- PrismQuadDialog -----------------------------
2682 // ============================================================== Constructeur
2684 PrismQuadDialog::PrismQuadDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2685 : HexaBaseDialog(parent, editmode, f)
2687 _helpFileName = "gui_prism_join_quad.html#prism-quadrangles";
2689 _initWidget(editmode);
2690 setFocusProxy( quads_lw );
2694 // ============================================================== Destructeur
2695 PrismQuadDialog::~PrismQuadDialog()
2700 // ============================================================== _initInputWidget
2701 void PrismQuadDialog::_initInputWidget( Mode editmode )
2704 QValidator *validator = new QRegExpValidator(rx, this);
2706 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
2707 installEventFilter(this);
2709 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2710 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
2712 vec_le->setValidator( validator );
2714 vec_le->installEventFilter(this);
2715 quads_lw->installEventFilter(this);
2717 if ( editmode != INFO_MODE ){
2718 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
2719 delQuadShortcut->setContext( Qt::WidgetShortcut );
2720 connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(removeQuad()) );
2723 connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) );
2726 // ============================================================== clear
2727 void PrismQuadDialog::clear()
2733 // ============================================================== removeQuad
2734 void PrismQuadDialog::removeQuad()
2736 QListWidgetItem *item = quads_lw->currentItem();
2739 int r = quads_lw->row(item);
2740 quads_lw->takeItem(r);
2746 // void PrismQuadDialog::clearQuads()
2748 // if (quads_lw->count() != 0)
2749 // quads_lw->clear();
2753 // ============================================================== apply
2754 bool PrismQuadDialog::apply(QModelIndex& result)
2756 SUIT_OverrideCursor wc;
2757 //if ( !_documentModel ) return;
2758 if ( !_patternDataSelectionModel ) return false;
2759 if ( !_patternBuilderSelectionModel ) return false;
2760 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
2761 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
2762 if ( !patternDataModel ) return false;
2763 if ( !patternBuilderModel ) return false;
2767 QModelIndexList iquads;
2769 QListWidgetItem* item = NULL;
2770 for ( int r = 0; r < quads_lw->count(); ++r){
2771 item = quads_lw->item(r);
2772 iquad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
2775 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
2778 if ( ivec.isValid() ){
2779 int nb = nb_spb->value();
2780 if ( iquads.count() == 1 ){
2781 iElts = _documentModel->prismQuad( iquads[0], ivec, nb );
2782 } else if ( iquads.count() > 1 ){
2783 iElts = _documentModel->prismQuads( iquads, ivec, nb );
2787 if ( !iElts.isValid() ){
2788 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT PRISM QUAD(S)" ) );
2792 result = patternBuilderModel->mapFromSource(iElts);
2797 //---------------------------------- JoinQuadDialog -----------------------------
2799 // ============================================================== Constructeur
2801 JoinQuadDialog::JoinQuadDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2802 : HexaBaseDialog(parent, editmode, f)
2804 _helpFileName = "gui_prism_join_quad.html#join-quadrangles";
2806 _initWidget(editmode);
2807 // setFocusProxy( quads_lw );
2811 // ============================================================== Destructeur
2812 JoinQuadDialog::~JoinQuadDialog()
2816 // ============================================================== _initInputWidget
2817 void JoinQuadDialog::_initInputWidget( Mode editmode )
2820 QValidator *validator = new QRegExpValidator(rx, this);
2822 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
2823 installEventFilter(this);
2825 vex0_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2826 vex1_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2827 vex2_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2828 vex3_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2829 quad_dest_le->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
2830 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
2832 vex0_le->setValidator( validator );
2833 vex1_le->setValidator( validator );
2834 vex2_le->setValidator( validator );
2835 vex3_le->setValidator( validator );
2836 quad_dest_le->setValidator( validator );
2838 vex0_le->installEventFilter(this);
2839 vex1_le->installEventFilter(this);
2840 vex2_le->installEventFilter(this);
2841 vex3_le->installEventFilter(this);
2842 quad_dest_le->installEventFilter(this);
2843 quads_lw->installEventFilter(this);
2845 if ( editmode != INFO_MODE ){
2846 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
2847 delQuadShortcut->setContext( Qt::WidgetShortcut );
2848 connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(removeQuad()) );
2850 connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) );
2854 // ============================================================== clear
2855 void JoinQuadDialog::clear()
2862 quad_dest_le->clear();
2868 // ============================================================== removeQuad
2869 void JoinQuadDialog::removeQuad()
2871 QListWidgetItem *item = quads_lw->currentItem();
2874 int r = quads_lw->row(item);
2875 quads_lw->takeItem(r);
2881 // void JoinQuadDialog::clearQuads()
2883 // if (quads_lw->count() != 0)
2884 // quads_lw->clear();
2888 // ============================================================== apply
2889 bool JoinQuadDialog::apply(QModelIndex& result)
2891 SUIT_OverrideCursor wc;
2892 //if ( !_documentModel ) return;
2893 if ( !_patternDataSelectionModel ) return false;
2894 if ( !_patternBuilderSelectionModel ) return false;
2895 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
2896 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
2897 if ( !patternDataModel ) return false;
2898 if ( !patternBuilderModel ) return false;
2902 QModelIndexList iquads;
2904 QListWidgetItem* item = NULL;
2905 for ( int r = 0; r < quads_lw->count(); ++r){
2906 item = quads_lw->item(r);
2907 iquad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
2908 if ( iquad.isValid() ) iquads << iquad;
2910 QModelIndex iquaddest = patternDataModel->mapToSource( _index[quad_dest_le] );
2911 QModelIndex ivex0 = patternDataModel->mapToSource( _index[vex0_le] );
2912 QModelIndex ivex1 = patternDataModel->mapToSource( _index[vex1_le] );
2913 QModelIndex ivex2 = patternDataModel->mapToSource( _index[vex2_le] );
2914 QModelIndex ivex3 = patternDataModel->mapToSource( _index[vex3_le] );
2917 if ( iquaddest.isValid()
2921 && ivex3.isValid() ){
2922 int nb = nb_spb->value();
2923 if ( iquads.count() == 1 ){
2924 iElts = _documentModel->joinQuad( iquads[0], iquaddest,
2925 ivex0, ivex1, ivex2, ivex3,
2927 } else if ( iquads.count() > 1 ){
2928 iElts = _documentModel->joinQuads( iquads, iquaddest,
2929 ivex0, ivex1, ivex2, ivex3,
2934 if ( !iElts.isValid() ){
2935 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT JOIN QUAD(S)" ) );
2939 result = patternBuilderModel->mapFromSource(iElts);
2945 // void JoinQuadDialog::reject()
2947 // QDialog::reject();
2948 // _disallowSelection();
2953 // ------------------------- MergeDialog ----------------------------------
2955 // ============================================================== Constructeur
2957 MergeDialog::MergeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2958 : HexaBaseDialog(parent, editmode, f)
2961 _initWidget(editmode);
2962 rb0->setFocusProxy( v0_le_rb0 );
2963 rb1->setFocusProxy( e0_le_rb1 );
2964 rb2->setFocusProxy( q0_le_rb2 );
2965 // setFocusProxy( rb0 );
2968 _helpFileName = "gui_merge_elmts.html#merge-2-vertices";
2969 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2970 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2971 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2974 // ============================================================== Destructeur
2975 MergeDialog::~MergeDialog()
2979 // ============================================================== _initInputWidget
2980 void MergeDialog::_initInputWidget( Mode editmode )
2983 QValidator *validator = new QRegExpValidator(rx, this);
2986 v0_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2987 v1_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2988 v0_le_rb0->setValidator( validator );
2989 v1_le_rb0->setValidator( validator );
2990 v0_le_rb0->installEventFilter(this);
2991 v1_le_rb0->installEventFilter(this);
2993 v0_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2994 v1_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2995 e0_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
2996 e1_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
2998 v0_le_rb1->setValidator( validator );
2999 v1_le_rb1->setValidator( validator );
3000 e0_le_rb1->setValidator( validator );
3001 e1_le_rb1->setValidator( validator );
3003 v0_le_rb1->installEventFilter(this);
3004 v1_le_rb1->installEventFilter(this);
3005 e0_le_rb1->installEventFilter(this);
3006 e1_le_rb1->installEventFilter(this);
3009 v0_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3010 v1_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3011 v2_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3012 v3_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3013 q0_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3014 q1_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3017 v0_le_rb2->setValidator( validator );
3018 v1_le_rb2->setValidator( validator );
3019 v2_le_rb2->setValidator( validator );
3020 v3_le_rb2->setValidator( validator );
3021 q0_le_rb2->setValidator( validator );
3022 q1_le_rb2->setValidator( validator );
3024 v0_le_rb2->installEventFilter(this);
3025 v1_le_rb2->installEventFilter(this);
3026 v2_le_rb2->installEventFilter(this);
3027 v3_le_rb2->installEventFilter(this);
3028 q0_le_rb2->installEventFilter(this);
3029 q1_le_rb2->installEventFilter(this);
3033 // ============================================================== clear
3034 void MergeDialog::clear()
3050 // ============================================================== updateHelpFileName
3051 void MergeDialog::updateHelpFileName()
3053 if ( sender() == rb0 ){
3054 _helpFileName = "gui_merge_elmts.html#merge-2-vertices";
3055 } else if ( sender() == rb1 ){
3056 _helpFileName = "gui_merge_elmts.html#merge-2-edges";
3057 } else if ( sender() == rb2 ){
3058 _helpFileName = "gui_merge_elmts.html#merge-2-quadrangles";
3063 // ============================================================== apply
3064 bool MergeDialog::apply(QModelIndex& result)
3066 SUIT_OverrideCursor wc;
3067 if ( !_patternDataSelectionModel ) return false;
3068 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
3069 if ( !patternDataModel ) return false;
3072 bool merged = false;
3074 if ( rb0->isChecked() ){
3075 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb0] );
3076 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb0] );
3080 merged = _documentModel->mergeVertices( iv0, iv1 );
3082 } else if ( rb1->isChecked() ){
3083 QModelIndex ie0 = patternDataModel->mapToSource( _index[e0_le_rb1] );
3084 QModelIndex ie1 = patternDataModel->mapToSource( _index[e1_le_rb1] );
3085 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb1] );
3086 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb1] );
3092 merged = _documentModel->mergeEdges( ie0, ie1, iv0, iv1);
3094 } else if ( rb2->isChecked() ){
3096 QModelIndex iq0 = patternDataModel->mapToSource( _index[q0_le_rb2] );
3097 QModelIndex iq1 = patternDataModel->mapToSource( _index[q1_le_rb2] );
3098 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb2] );
3099 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb2] );
3100 QModelIndex iv2 = patternDataModel->mapToSource( _index[v2_le_rb2] );
3101 QModelIndex iv3 = patternDataModel->mapToSource( _index[v3_le_rb2] );
3109 merged = _documentModel->mergeQuads( iq0, iq1,
3110 iv0, iv1, iv2, iv3 );
3114 if ( merged == false ){
3115 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MERGE" ) );
3123 // ------------------------- DisconnectDialog ----------------------------------
3125 // ============================================================== Constructeur
3127 DisconnectDialog::DisconnectDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
3128 : HexaBaseDialog(parent, editmode, f)
3131 _initWidget(editmode);
3132 rb0->setFocusProxy( v_le_rb0 );
3133 rb1->setFocusProxy( e_le_rb1 );
3134 rb2->setFocusProxy( q_le_rb2 );
3135 rb3->setFocusProxy( d_edges_lw);
3137 // setFocusProxy( rb0 );
3139 _helpFileName = "gui_disc_elmts.html#disconnect-a-vertex";
3141 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3142 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3143 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3144 connect( rb3, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3147 // ============================================================== Destructeur
3148 DisconnectDialog::~DisconnectDialog()
3152 // ============================================================== _initInputWidget
3153 void DisconnectDialog::_initInputWidget( Mode editmode )
3156 QValidator *validator = new QRegExpValidator(rx, this);
3158 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3159 installEventFilter(this);
3162 v_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3163 h_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3164 v_le_rb0->setValidator( validator );
3165 h_le_rb0->setValidator( validator );
3166 v_le_rb0->installEventFilter(this);
3167 h_le_rb0->installEventFilter(this);
3170 e_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
3171 h_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3172 e_le_rb1->setValidator( validator );
3173 h_le_rb1->setValidator( validator );
3174 e_le_rb1->installEventFilter(this);
3175 h_le_rb1->installEventFilter(this);
3178 q_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3179 h_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3180 q_le_rb2->setValidator( validator );
3181 h_le_rb2->setValidator( validator );
3182 q_le_rb2->installEventFilter(this);
3183 h_le_rb2->installEventFilter(this);
3186 d_edges_lw->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
3187 hexas_lw->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3188 d_edges_lw->installEventFilter(this);
3189 hexas_lw->installEventFilter(this);
3191 QShortcut* delEdgeShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X/*Qt::Key_Alt*//*Qt::Key_Space*/), d_edges_lw);
3192 QShortcut* delHexaShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X/*Qt::Key_Alt*//*Qt::Key_Space*/), hexas_lw);
3193 delEdgeShortcut->setContext( Qt::WidgetShortcut );
3194 delHexaShortcut->setContext( Qt::WidgetShortcut );
3196 connect( d_edges_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) );
3197 connect( hexas_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) );
3198 connect( delEdgeShortcut, SIGNAL(activated()), this, SLOT(deleteEdgeItem()) );
3199 connect( delHexaShortcut, SIGNAL(activated()), this, SLOT(deleteHexaItem()) );
3204 // ============================================================== clear
3205 void DisconnectDialog::clear()
3213 d_edges_lw->clear();
3217 // ============================================================== deleteEdgeItem
3218 void DisconnectDialog::deleteEdgeItem()
3220 delete d_edges_lw->currentItem();
3223 // ============================================================== deleteHexaItem
3224 void DisconnectDialog::deleteHexaItem()
3226 delete hexas_lw->currentItem();
3230 // ============================================================== updateHelpFileName
3231 void DisconnectDialog::updateHelpFileName()
3233 if ( sender() == rb0 ){
3234 _helpFileName = "gui_disc_elmts.html#disconnect-a-vertex";
3235 } else if ( sender() == rb1 ){
3236 _helpFileName = "gui_disc_elmts.html#disconnect-an-edge";
3237 } else if ( sender() == rb2 ){
3238 _helpFileName = "gui_disc_elmts.html#disconnect-a-quadrangle";
3239 } else if (sender() == rb3 ){
3240 _helpFileName = "gui_disc_elmts.html#disconnect-edges";
3245 // ============================================================== apply
3246 bool DisconnectDialog::apply(QModelIndex& result)
3248 SUIT_OverrideCursor wc;
3250 if ( !_patternDataSelectionModel ) return false;
3251 if ( !_patternBuilderSelectionModel ) return false;
3252 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
3253 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
3254 if ( !patternDataModel ) return false;
3255 if ( !patternBuilderModel ) return false;
3260 if ( rb0->isChecked() ){
3261 QModelIndex ihexa = patternDataModel->mapToSource( _index[h_le_rb0] );
3262 QModelIndex ivex = patternDataModel->mapToSource( _index[v_le_rb0] );
3264 if ( ihexa.isValid()
3265 && ivex.isValid() ){
3266 iElts = _documentModel->disconnectVertex( ihexa, ivex );
3268 } else if ( rb1->isChecked() ){
3269 QModelIndex ihexa = patternDataModel->mapToSource( _index[h_le_rb1] );
3270 QModelIndex iedge = patternDataModel->mapToSource( _index[e_le_rb1] );
3272 if ( ihexa.isValid()
3273 && iedge.isValid() ){
3274 iElts = _documentModel->disconnectEdge( ihexa, iedge );
3276 } else if ( rb2->isChecked() ){
3277 QModelIndex ihexa = patternDataModel->mapToSource( _index[h_le_rb2] );
3278 QModelIndex iquad = patternDataModel->mapToSource( _index[q_le_rb2] );
3280 if ( ihexa.isValid()
3281 && iquad.isValid() ){
3282 iElts = _documentModel->disconnectQuad( ihexa, iquad );
3284 } else if ( rb3->isChecked() ){ //
3286 QModelIndex iedge, ihexa;
3287 QModelIndexList iedges, ihexas;
3288 QListWidgetItem* item = NULL;
3291 for (int r = 0; r < d_edges_lw->count(); ++r){
3292 item = d_edges_lw->item(r);
3293 iedge = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
3294 if ( iedge.isValid() )
3299 for (int r = 0; r < hexas_lw->count(); ++r){
3300 item = hexas_lw->item(r);
3301 ihexa = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
3302 if ( ihexa.isValid() )
3306 iElts = _documentModel->disconnectEdges( ihexas, iedges );
3309 if ( !iElts.isValid() ){
3310 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT DISCONNECT" ) );
3314 result = patternBuilderModel->mapFromSource(iElts);
3322 // ------------------------- CutEdgeDialog ----------------------------------
3324 // ============================================================== Constructeur
3326 CutEdgeDialog::CutEdgeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
3327 HexaBaseDialog(parent, editmode, f)
3329 _helpFileName = "gui_cut_hexa.html";
3331 _initWidget(editmode);
3332 // setFocusProxy( e_le );
3335 // ============================================================== Destructeur
3336 CutEdgeDialog::~CutEdgeDialog()
3340 // ============================================================== _initInputWidget
3341 void CutEdgeDialog::_initInputWidget( Mode editmode )
3344 QValidator *validator = new QRegExpValidator(rx, this);
3346 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3347 installEventFilter(this);
3349 e_le->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
3350 e_le->setValidator( validator );
3351 e_le->installEventFilter(this);
3354 // ============================================================== clear
3355 void CutEdgeDialog::clear()
3361 // ============================================================== apply
3362 bool CutEdgeDialog::apply(QModelIndex& result)
3364 SUIT_OverrideCursor wc;
3365 //if ( !_documentModel ) return;
3366 if ( !_patternDataSelectionModel ) return false;
3367 if ( !_patternBuilderSelectionModel ) return false;
3368 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
3369 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
3370 if ( !patternDataModel ) return false;
3371 if ( !patternBuilderModel ) return false;
3374 int nbCut = nb_cut_spb->value();
3375 QModelIndex iedge = patternDataModel->mapToSource( _index[e_le] );
3378 if ( iedge.isValid() ){
3379 iElts = _documentModel->cutEdge( iedge, nbCut );
3382 if ( !iElts.isValid() ){
3383 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT CUT EDGE" ) );
3387 result = patternBuilderModel->mapFromSource(iElts);
3395 // // ------------------------- MakeTransformationDialog ----------------------------------
3397 // ============================================================== Constructeur
3399 MakeTransformationDialog::MakeTransformationDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
3400 : HexaBaseDialog(parent, editmode, f)
3403 _initWidget(editmode);
3404 rb0->setFocusProxy( elts_le_rb0 );
3405 rb1->setFocusProxy( elts_le_rb1 );
3406 rb2->setFocusProxy( elts_le_rb2 );
3407 setFocusProxy( rb0 );
3410 _helpFileName = "gui_make_elmts.html#make-elements-by-translation";
3411 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3412 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3413 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3416 // ============================================================== Destructeur
3417 MakeTransformationDialog::~MakeTransformationDialog()
3421 // ============================================================== _initInputWidget
3422 void MakeTransformationDialog::_initInputWidget( Mode editmode )
3425 QValidator *validator = new QRegExpValidator(rx, this);
3427 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3428 installEventFilter(this);
3430 vec_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3431 elts_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3433 vec_le_rb0->setValidator( validator );
3434 elts_le_rb0->setValidator( validator );
3435 vec_le_rb0->installEventFilter(this);
3436 elts_le_rb0->installEventFilter(this);
3438 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3439 elts_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3440 vex_le_rb1->setValidator( validator );
3441 elts_le_rb1->setValidator( validator );
3442 vex_le_rb1->installEventFilter(this);
3443 elts_le_rb1->installEventFilter(this);
3445 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3446 vec_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3447 elts_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3448 vex_le_rb2->setValidator( validator );
3449 vec_le_rb2->setValidator( validator );
3450 elts_le_rb2->setValidator( validator );
3451 vex_le_rb2->installEventFilter(this);
3452 vec_le_rb2->installEventFilter(this);
3453 elts_le_rb2->installEventFilter(this);
3457 // ============================================================== clear
3458 void MakeTransformationDialog::clear()
3460 vex_le_rb1->clear();
3461 vex_le_rb2->clear();
3462 vec_le_rb0->clear();
3463 vec_le_rb2->clear();
3464 elts_le_rb0->clear();
3465 elts_le_rb1->clear();
3466 elts_le_rb2->clear();
3470 // ============================================================== updateHelpFileName
3471 void MakeTransformationDialog::updateHelpFileName()
3473 if ( sender() == rb0 ){
3474 _helpFileName = "gui_make_elmts.html#make-elements-by-translation";
3475 } else if ( sender() == rb1 ){
3476 _helpFileName = "gui_make_elmts.html#make-elements-by-scaling";
3477 } else if ( sender() == rb2 ){
3478 _helpFileName = "gui_make_elmts.html#make-elements-by-rotation";
3482 // ============================================================== apply
3483 bool MakeTransformationDialog::apply(QModelIndex& result)
3485 SUIT_OverrideCursor wc;
3486 if ( !_patternDataSelectionModel ) return false;
3487 if ( !_patternBuilderSelectionModel ) return false;
3488 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
3489 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
3490 if ( !patternDataModel ) return false;
3491 if ( !patternBuilderModel ) return false;
3494 QModelIndex iNewElts;
3496 if ( rb0->isChecked() ){
3497 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] );
3498 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb0] );
3500 if ( ielts.isValid()
3502 iNewElts = _documentModel->makeTranslation( ielts, ivec );
3504 } else if ( rb1->isChecked() ){
3505 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] );
3506 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
3507 double k = k_spb->value();
3509 if ( ielts.isValid()
3511 iNewElts = _documentModel->makeScale( ielts, ivex, k );
3513 } else if ( rb2->isChecked() ){
3514 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb2] );
3515 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb2] );
3516 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
3517 double angle = angle_spb->value();
3519 if ( ielts.isValid()
3522 iNewElts = _documentModel->makeRotation( ielts, ivex, ivec, angle );
3525 if ( !iNewElts.isValid() ){
3526 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE TRANSFORMATION" ) );
3530 result = patternBuilderModel->mapFromSource(iNewElts);
3537 // // ------------------------- MakeSymmetryDialog ----------------------------------
3539 // ============================================================== Constructeur
3541 MakeSymmetryDialog::MakeSymmetryDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
3542 HexaBaseDialog(parent, editmode, f)
3545 _initWidget(editmode);
3546 rb0->setFocusProxy( elts_le_rb0 );
3547 rb1->setFocusProxy( elts_le_rb1 );
3548 rb2->setFocusProxy( elts_le_rb2 );
3550 // setFocusProxy( rb0 );
3552 _helpFileName = "gui_make_symmetry.html#make-elements-by-point-symmetry";
3553 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3554 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3555 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3559 // ============================================================== Destructeur
3560 MakeSymmetryDialog::~MakeSymmetryDialog()
3564 // ============================================================== _initInputWidget
3565 void MakeSymmetryDialog::_initInputWidget( Mode editmode )
3568 QValidator *validator = new QRegExpValidator(rx, this);
3570 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3571 installEventFilter(this);
3573 vex_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3574 elts_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3575 vex_le_rb0->setValidator( validator );
3576 elts_le_rb0->setValidator( validator );
3577 vex_le_rb0->installEventFilter(this);
3578 elts_le_rb0->installEventFilter(this);
3580 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3581 vec_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3582 elts_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3583 vex_le_rb1->setValidator( validator );
3584 vec_le_rb1->setValidator( validator );
3585 elts_le_rb1->setValidator( validator );
3586 vex_le_rb1->installEventFilter(this);
3587 vec_le_rb1->installEventFilter(this);
3588 elts_le_rb1->installEventFilter(this);
3591 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3592 vec_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3593 elts_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3594 vex_le_rb2->setValidator( validator );
3595 vec_le_rb2->setValidator( validator );
3596 elts_le_rb2->setValidator( validator );
3597 vex_le_rb2->installEventFilter(this);
3598 vec_le_rb2->installEventFilter(this);
3599 elts_le_rb2->installEventFilter(this);
3603 // ============================================================== clear
3604 void MakeSymmetryDialog::clear()
3606 vex_le_rb0->clear();
3607 vex_le_rb1->clear();
3608 vex_le_rb2->clear();
3610 vec_le_rb1->clear();
3611 vec_le_rb2->clear();
3613 elts_le_rb0->clear();
3614 elts_le_rb1->clear();
3615 elts_le_rb2->clear();
3619 // ============================================================== updateHelpFileName
3620 void MakeSymmetryDialog::updateHelpFileName()
3622 if ( sender() == rb0 ){
3623 _helpFileName = "gui_make_symmetry.html#make-elements-by-point-symmetry";
3624 } else if ( sender() == rb1 ){
3625 _helpFileName = "gui_make_symmetry.html#make-elements-by-line-symmetry";
3626 } else if ( sender() == rb2 ){
3627 _helpFileName = "gui_make_symmetry.html#make-elements-by-plan-symmetry";
3632 // ============================================================== apply
3633 bool MakeSymmetryDialog::apply(QModelIndex& result)
3635 SUIT_OverrideCursor wc;
3636 if ( !_patternDataSelectionModel ) return false;
3637 if ( !_patternBuilderSelectionModel ) return false;
3638 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
3639 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
3640 if ( !patternDataModel ) return false;
3641 if ( !patternBuilderModel ) return false;
3644 QModelIndex iNewElts;
3646 if ( rb0->isChecked() ){
3647 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] );
3648 QModelIndex ivex = patternBuilderModel->mapToSource( _index[vex_le_rb0] );
3650 if ( ielts.isValid()
3652 iNewElts = _documentModel->makeSymmetryPoint( ielts, ivex );
3654 } else if ( rb1->isChecked() ){
3655 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] );
3656 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
3657 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb1] );
3659 if ( ielts.isValid()
3662 iNewElts = _documentModel->makeSymmetryLine( ielts, ivex, ivec );
3664 } else if ( rb2->isChecked() ){
3665 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb2] );
3666 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb2] );
3667 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
3669 if ( ielts.isValid()
3672 iNewElts = _documentModel->makeSymmetryPlane( ielts, ivex, ivec );
3675 if ( !iNewElts.isValid() ){
3676 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE TRANSFORMATION" ) );
3680 result = patternBuilderModel->mapFromSource(iNewElts);
3689 // // ------------------------- PerformTransformationDialog ----------------------------------
3691 // ============================================================== Constructeur
3693 PerformTransformationDialog::PerformTransformationDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
3694 HexaBaseDialog(parent, editmode, f)
3697 _initWidget(editmode);
3698 rb0->setFocusProxy( elts_le_rb0 );
3699 rb1->setFocusProxy( elts_le_rb1 );
3700 rb2->setFocusProxy( elts_le_rb2 );
3701 // setFocusProxy( rb0 );
3704 _helpFileName = "gui_modify_elmts.html#modify-elements-by-translation";
3705 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3706 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3707 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3711 // ============================================================== Destructeur
3712 PerformTransformationDialog::~PerformTransformationDialog()
3716 // ============================================================== _initInputWidget
3717 void PerformTransformationDialog::_initInputWidget( Mode editmode )
3720 QValidator *validator = new QRegExpValidator(rx, this);
3722 vec_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3723 elts_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3724 vec_le_rb0->setValidator( validator );
3725 elts_le_rb0->setValidator( validator );
3726 vec_le_rb0->installEventFilter(this);
3727 elts_le_rb0->installEventFilter(this);
3729 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3730 elts_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3731 vex_le_rb1->setValidator( validator );
3732 elts_le_rb1->setValidator( validator );
3733 vex_le_rb1->installEventFilter(this);
3734 elts_le_rb1->installEventFilter(this);
3737 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3738 vec_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3739 elts_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3740 vex_le_rb2->setValidator( validator );
3741 vec_le_rb2->setValidator( validator );
3742 elts_le_rb2->setValidator( validator );
3743 vex_le_rb2->installEventFilter(this);
3744 vec_le_rb2->installEventFilter(this);
3745 elts_le_rb2->installEventFilter(this);
3749 // ============================================================== clear
3750 void PerformTransformationDialog::clear()
3752 vex_le_rb1->clear(); vex_le_rb2->clear();
3753 vec_le_rb0->clear(); vec_le_rb2->clear();
3754 elts_le_rb0->clear(); elts_le_rb1->clear(); elts_le_rb2->clear();
3757 // ============================================================== updateHelpFileName
3758 void PerformTransformationDialog::updateHelpFileName()
3760 if ( sender() == rb0 ){
3761 _helpFileName = "gui_modify_elmts.html#modify-elements-by-translation";
3762 } else if ( sender() == rb1 ){
3763 _helpFileName = "gui_modify_elmts.html#modify-elements-by-scaling";
3764 } else if ( sender() == rb2 ){
3765 _helpFileName = "gui_modify_elmts.html#modify-elements-by-rotation";
3770 // ============================================================== apply
3771 bool PerformTransformationDialog::apply(QModelIndex& result)
3773 SUIT_OverrideCursor wc;
3774 if ( !_patternDataSelectionModel ) return false;
3775 if ( !_patternBuilderSelectionModel ) return false;
3776 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
3777 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
3778 if ( !patternDataModel ) return false;
3779 if ( !patternBuilderModel ) return false;
3782 bool performed = false;
3784 if ( rb0->isChecked() ){
3785 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] );
3786 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb0] );
3788 if ( ielts.isValid()
3790 performed = _documentModel->performTranslation( ielts, ivec );
3792 } else if ( rb1->isChecked() ){
3793 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] );
3794 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
3795 double k = k_spb->value();
3797 if ( ielts.isValid()
3799 performed = _documentModel->performScale( ielts, ivex, k );
3801 } else if ( rb2->isChecked() ){
3802 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb2] );
3803 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb2] );
3804 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
3805 double angle = angle_spb->value();
3807 if ( ielts.isValid()
3810 performed = _documentModel->performRotation( ielts, ivex, ivec, angle );
3813 if ( performed == false){
3814 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT PERFORM TRANSFORMATION" ) );
3826 // // ------------------------- PerformSymmetryDialog ----------------------------------
3828 // ============================================================== Constructeur
3830 PerformSymmetryDialog::PerformSymmetryDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
3831 : HexaBaseDialog(parent, editmode, f)
3834 _initWidget( editmode );
3835 rb0->setFocusProxy( elts_le_rb0 );
3836 rb1->setFocusProxy( elts_le_rb1 );
3837 rb2->setFocusProxy( elts_le_rb2 );
3838 // setFocusProxy( rb0 );
3841 _helpFileName = "gui_modify_symmetry.html#modify-elements-by-point-symmetry";
3842 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3843 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3844 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3847 // ============================================================== Destructeur
3848 PerformSymmetryDialog::~PerformSymmetryDialog()
3852 // ============================================================== _initInputWidget
3853 void PerformSymmetryDialog::_initInputWidget( Mode editmode )
3856 QValidator *validator = new QRegExpValidator(rx, this);
3858 vex_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3859 elts_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3860 vex_le_rb0->setValidator( validator );
3861 elts_le_rb0->setValidator( validator );
3862 vex_le_rb0->installEventFilter(this);
3863 elts_le_rb0->installEventFilter(this);
3865 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3866 vec_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3867 elts_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3868 vex_le_rb1->setValidator( validator );
3869 vec_le_rb1->setValidator( validator );
3870 elts_le_rb1->setValidator( validator );
3871 vex_le_rb1->installEventFilter(this);
3872 vec_le_rb1->installEventFilter(this);
3873 elts_le_rb1->installEventFilter(this);
3876 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3877 vec_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3878 elts_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3879 vex_le_rb2->setValidator( validator );
3880 vec_le_rb2->setValidator( validator );
3881 elts_le_rb2->setValidator( validator );
3882 vex_le_rb2->installEventFilter(this);
3883 vec_le_rb2->installEventFilter(this);
3884 elts_le_rb2->installEventFilter(this);
3888 // ============================================================== clear
3889 void PerformSymmetryDialog::clear()
3891 vex_le_rb0->clear(); vex_le_rb1->clear(); vex_le_rb2->clear();
3892 vec_le_rb1->clear(); vec_le_rb2->clear();
3893 elts_le_rb0->clear(); elts_le_rb1->clear(); elts_le_rb2->clear();
3896 // ============================================================== updateHelpFileName
3897 void PerformSymmetryDialog::updateHelpFileName()
3899 if ( sender() == rb0 ){
3900 _helpFileName = "gui_modify_symmetry.html#modify-elements-by-point-symmetry";
3901 } else if ( sender() == rb1 ){
3902 _helpFileName = "gui_modify_symmetry.html#modify-elements-by-line-symmetry";
3903 } else if ( sender() == rb2 ){
3904 _helpFileName = "gui_modify_symmetry.html#modify-elements-by-plan-symmetry";
3908 // ============================================================== apply
3909 bool PerformSymmetryDialog::apply(QModelIndex& result)
3911 SUIT_OverrideCursor wc;
3912 if ( !_patternDataSelectionModel ) return false;
3913 if ( !_patternBuilderSelectionModel ) return false;
3914 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
3915 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
3916 if ( !patternDataModel ) return false;
3917 if ( !patternBuilderModel ) return false;
3920 bool performed = false;
3922 if ( rb0->isChecked() ){
3923 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] );
3924 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb0] );
3926 if ( ielts.isValid()
3928 performed = _documentModel->performSymmetryPoint( ielts, ivex );
3930 } else if ( rb1->isChecked() ){
3931 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] );
3932 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
3933 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb1] );
3935 if ( ielts.isValid()
3938 performed = _documentModel->performSymmetryLine( ielts, ivex, ivec );
3940 } else if ( rb2->isChecked() ){
3941 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb2] );
3942 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb2] );
3943 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
3945 if ( ielts.isValid()
3948 performed = _documentModel->performSymmetryPlane( ielts, ivex, ivec );
3951 if ( performed == false ){
3952 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT PERFORM SYMMETRY" ) );
3961 // // ------------------------- EdgeAssocDialog ----------------------------------
3963 // ============================================================== Constructeur
3965 EdgeAssocDialog::EdgeAssocDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
3966 HexaBaseDialog( parent, editmode, f )
3968 _helpFileName ="gui_asso_quad_to_geom.html#associate-to-edges-or-wires-of-the-geometry";
3970 _initWidget(editmode);
3972 setFocusProxy( edges_lw );
3976 _currentParameter = 0.;
3980 // ============================================================== Destructeur
3981 EdgeAssocDialog::~EdgeAssocDialog()
3983 // disconnect( delEdgeShortcut, SIGNAL(activated()), this, SLOT(deleteEdgeItem()) );
3984 // disconnect( delLineShortcut, SIGNAL(activated()), this, SLOT(deleteLineItem()) );
3985 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(addLine()) );
3986 disconnect( pstart_spb, SIGNAL(valueChanged(double)), this, SLOT( pstartChanged(double)) );
3987 disconnect( pend_spb, SIGNAL(valueChanged(double)), this, SLOT( pendChanged(double)) );
3991 // ============================================================== _initInputWidget
3992 void EdgeAssocDialog::_initInputWidget( Mode editmode )
3995 QValidator *validator = new QRegExpValidator(rx, this);
3998 first_vex_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3999 first_vex_le->installEventFilter(this);
4000 first_vex_le->setValidator( validator );
4002 single_edge_le->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
4003 single_edge_le->installEventFilter(this);
4005 edges_lw->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
4006 edges_lw->installEventFilter(this);
4010 lines_lw->setProperty( "GeomWidgetType", QVariant::fromValue(TopAbs_EDGE) );
4011 lines_lw->installEventFilter(this);
4013 single_line_le->setProperty( "GeomWidgetType", QVariant::fromValue(TopAbs_EDGE) );
4014 single_line_le->installEventFilter(this);
4017 QShortcut* delEdgeShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X), edges_lw);
4018 QShortcut* delLineShortcut = new QShortcut(QKeySequence(Qt::Key_X), lines_lw);
4019 delLineShortcut->setContext( Qt::WidgetWithChildrenShortcut );
4020 delEdgeShortcut->setContext( Qt::WidgetWithChildrenShortcut );
4022 pend_spb->setValue(1.);
4024 connect( delEdgeShortcut, SIGNAL(activated()), this, SLOT(deleteEdgeItem()) );
4025 connect( delLineShortcut, SIGNAL(activated()), this, SLOT(deleteLineItem()) );
4026 connect( pstart_spb, SIGNAL(valueChanged(double)), this, SLOT( pstartChanged(double)) );
4027 connect( pend_spb, SIGNAL(valueChanged(double)), this, SLOT( pendChanged(double)) );
4028 connect( edges_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) );
4032 // ============================================================== clear
4033 void EdgeAssocDialog::clear()
4035 first_vex_le->clear();
4038 single_edge_le->setText("");
4039 single_line_le->setText("");
4042 // ============================================================== deleteEdgeItem
4043 void EdgeAssocDialog::deleteEdgeItem()
4045 delete edges_lw->currentItem();
4048 // ============================================================== deleteLineItem
4049 void EdgeAssocDialog::deleteLineItem()
4051 delete lines_lw->currentItem();
4055 // ============================================================== setGeomEngine
4056 void EdgeAssocDialog::setGeomEngine( GEOM::GEOM_Gen_var geomEngine )
4058 _geomEngine = geomEngine;
4061 // ============================================================== onWindowActivated
4062 void EdgeAssocDialog::onWindowActivated(SUIT_ViewManager* vm)
4064 SUIT_ViewWindow* v = vm->getActiveView();
4065 QString vmType = vm->getType();
4066 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ){
4067 edges_lw->setFocus();
4068 } else if ( vmType == OCCViewer_Viewer::Type() ){
4069 lines_lw->setFocus();
4073 // ============================================================== createOperation
4074 GEOM::GEOM_IOperations_ptr EdgeAssocDialog::createOperation()
4076 return _geomEngine->GetIBasicOperations(getStudyId());
4079 // ============================================================== execute
4080 bool EdgeAssocDialog::execute(ObjectList& objects)
4082 MESSAGE("execute(){");
4083 MESSAGE("* objects.size()" << objects.size() );
4087 GEOM::GEOM_Object_var anObj;
4088 QStringList aParameters;
4090 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
4091 anObj = anOper->MakePointOnCurve( _currentLine.get(), _currentParameter );
4092 if ( !anObj->_is_nil() ) {
4093 objects.push_back(anObj._retn());
4096 MESSAGE("}execute()");
4100 // ============================================================== pstartChanged
4101 void EdgeAssocDialog::pstartChanged( double val )
4103 MESSAGE("pstartChanged("<<val<<") { ");
4104 QListWidgetItem* lineItem = lines_lw->item( 0 );
4105 if (!lineItem) return;
4106 // MESSAGE("data : "<<lineItem->text().toStdString());
4107 _currentLine = lineItem->data(LW_GEOM_OBJ_ROLE).value<GEOM::GeomObjPtr>();
4108 _currentParameter = pstart_spb->value();
4109 displayPreview(true);
4110 MESSAGE("}pstartChanged()");
4113 // ============================================================== pendChanged
4114 void EdgeAssocDialog::pendChanged( double val )
4116 MESSAGE("pendChanged("<<val<<") { ");
4117 // if ( _lastLine->_is_nil() ) return;
4118 QListWidgetItem* lineItem = lines_lw->item( lines_lw->count()-1 );
4119 if (!lineItem) return;
4120 // MESSAGE("data : "<<lineItem->text().toStdString());
4121 _currentLine = lineItem->data(LW_GEOM_OBJ_ROLE).value<GEOM::GeomObjPtr>();
4122 _currentParameter = pend_spb->value();
4123 displayPreview(true);
4124 MESSAGE("}pendChanged()");
4127 // ============================================================== onCurrentSelectionChanged
4128 void EdgeAssocDialog::onCurrentSelectionChanged()
4130 if ( !isVisible() ) return;
4132 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
4133 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
4135 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
4136 // bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
4141 GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_EDGE);
4142 TopoDS_Shape aShape;
4144 if ( !(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull()) )
4147 if (single_rb->isChecked()) {
4148 QString aName = GEOMBase::GetName(aSelectedObject.get());
4149 single_line_le->setText(aName);
4150 myLine = aSelectedObject;
4152 else if( multiple_rb->isChecked() ) {
4154 DocumentModel::GeomObj aLine;
4155 QListWidgetItem* item = NULL;
4156 QString mainShapeEntry;
4160 if ( aSelectedObject->IsMainShape() ){
4161 mainShapeEntry = aSelectedObject->GetStudyEntry();
4162 brep = shape2string( aShape ).c_str();
4165 TopoDS_Shape subshape;
4166 GEOM::GEOM_Object_var mainShape = aSelectedObject->GetMainShape();
4167 mainShapeEntry = mainShape->GetStudyEntry();
4168 // CS_TODO : à optimiser
4169 bool okShape = GEOMBase::GetShape( mainShape , shape);//,const TopAbs_ShapeEnum type = TopAbs_SHAPE );
4170 bool oksubShape = GEOMBase::GetShape( aSelectedObject.get(), subshape );//,const TopAbs_ShapeEnum type = TopAbs_SHAPE );
4171 if ( okShape && oksubShape ){
4172 brep = shape2string( subshape ).c_str();
4173 subId = GEOMBase::GetIndex( subshape, shape );
4176 aLine.name = GEOMBase::GetName( aSelectedObject.get() );
4177 aLine.entry = mainShapeEntry;
4178 aLine.subid = QString::number(subId);
4183 item = new QListWidgetItem( aLine.name );
4184 item->setData( LW_ASSOC_ROLE, QVariant::fromValue<DocumentModel::GeomObj>(aLine) );
4185 item->setData( LW_GEOM_OBJ_ROLE, QVariant::fromValue<GEOM::GeomObjPtr>(aSelectedObject) );
4186 lines_lw->addItem(item);
4191 // ============================================================== apply
4192 bool EdgeAssocDialog::apply(QModelIndex& result)
4194 SUIT_OverrideCursor wc;
4195 bool assocOk = false;
4197 if ( !_patternDataSelectionModel ) return false;
4198 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
4199 if ( !patternDataModel ) return false;
4202 QListWidgetItem* item = NULL;
4205 QModelIndexList iEdges;
4206 QList<DocumentModel::GeomObj> assocs;
4207 DocumentModel::GeomObj aLine;
4209 if (single_rb->isChecked()){ //Single edge and/or line association
4211 QString mainShapeEntry;
4214 GEOM::GeomObjPtr aSelectedObject = myLine;
4215 TopoDS_Shape aShape;
4217 if ( aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull() ){
4218 if ( aSelectedObject->IsMainShape() ){
4219 mainShapeEntry = aSelectedObject->GetStudyEntry();
4220 brep = shape2string( aShape ).c_str();
4224 TopoDS_Shape subshape;
4225 GEOM::GEOM_Object_var mainShape = aSelectedObject->GetMainShape();
4226 mainShapeEntry = mainShape->GetStudyEntry();
4227 // CS_TODO : à optimiser
4228 bool okShape = GEOMBase::GetShape( mainShape , shape);//,const TopAbs_ShapeEnum type = TopAbs_SHAPE );
4229 bool oksubShape = GEOMBase::GetShape( aSelectedObject.get(), subshape );//,const TopAbs_ShapeEnum type = TopAbs_SHAPE );
4230 if ( okShape && oksubShape ){
4231 brep = shape2string( subshape ).c_str();
4232 subId = GEOMBase::GetIndex( subshape, shape );
4235 aLine.name = GEOMBase::GetName( aSelectedObject.get() );
4236 aLine.entry = mainShapeEntry;
4237 aLine.subid = QString::number(subId);
4239 aLine.start = pstart_spb->value();
4240 aLine.end = pend_spb->value();
4241 iEdge = patternDataModel->mapToSource( _index[single_edge_le] );
4242 if (!iEdge.isValid()) return false;
4243 _documentModel->addAssociation(iEdge, aLine);
4247 else { //Multiple edge and/or line association
4250 for ( int r = 0; r < edges_lw->count(); ++r){
4251 item = edges_lw->item(r);
4252 iEdge = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
4253 if ( iEdge.isValid() )
4258 for ( int r = 0; r < lines_lw->count(); ++r){
4259 item = lines_lw->item(r);
4260 aLine = item->data(LW_ASSOC_ROLE).value<DocumentModel::GeomObj>();
4261 //std::cout << " line added : " << aLine.name.toStdString() << std::endl;
4262 MESSAGE(" assocs => " << aLine.name.toStdString() );
4263 MESSAGE(" assocs => " << aLine.brep.toStdString() );
4267 if ( close_cb->isChecked() ){ //closed line
4268 QModelIndex iFirstVertex = patternDataModel->mapToSource( _index[first_vex_le] );
4269 // if (inverse_cb->isChecked())
4270 // assocOk = _documentModel->associateClosedLine( iFirstVertex, iEdges, assocs, pstart_spb->value(), true );
4272 assocOk = _documentModel->associateClosedLine( iFirstVertex, iEdges, assocs, pstart_spb->value() );
4275 assocOk = _documentModel->associateOpenedLine( iEdges, assocs, pstart_spb->value(), pend_spb->value() );
4280 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE EDGE ASSOCIATION" ) );
4289 // // ------------------------- QuadAssocDialog ----------------------------------
4291 // ============================================================== Constructeur
4293 QuadAssocDialog::QuadAssocDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
4294 HexaBaseDialog(parent, editmode, f)
4296 _helpFileName = "gui_asso_quad_to_geom.html#associate-to-a-face-or-a-shell-of-the-geometry";
4298 _initWidget(editmode);
4300 setFocusProxy( quad_le );
4303 // ============================================================== Destructeur
4304 QuadAssocDialog::~QuadAssocDialog()
4306 disconnect( _delFaceShortcut, SIGNAL(activated()), this, SLOT(deleteFaceItem()) );
4307 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(addFace()) );
4308 delete _delFaceShortcut;
4311 // ============================================================== _initInputWidget
4312 void QuadAssocDialog::_initInputWidget( Mode editmode )
4315 QValidator *validator = new QRegExpValidator(rx, this);
4317 quad_le->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
4318 quad_le->installEventFilter(this);
4319 quad_le->setValidator( validator );
4322 faces_lw->setProperty( "GeomWidgetType", QVariant::fromValue(TopAbs_FACE) );
4323 faces_lw->installEventFilter(this);
4324 _delFaceShortcut = new QShortcut( QKeySequence(Qt::Key_X/*Qt::Key_Delete*/), faces_lw );
4325 _delFaceShortcut->setContext( Qt::WidgetShortcut );
4327 connect( _delFaceShortcut, SIGNAL(activated()), this, SLOT(deleteFaceItem()) );
4330 // ============================================================== clear
4331 void QuadAssocDialog::clear()
4337 // ============================================================== onCurrentSelectionChanged
4338 void QuadAssocDialog::onCurrentSelectionChanged()
4341 if ( !isVisible() ) return;
4343 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
4344 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
4346 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
4347 // bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
4351 GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_FACE);
4352 TopoDS_Shape aShape;
4354 if ( aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape) && !aShape.IsNull() ){
4355 DocumentModel::GeomObj aFace;
4356 QListWidgetItem* item = NULL;
4357 QString mainShapeEntry;
4361 if ( aSelectedObject->IsMainShape() ){
4362 mainShapeEntry = aSelectedObject->GetStudyEntry();
4363 brep = shape2string( aShape ).c_str();
4366 TopoDS_Shape subshape;
4367 GEOM::GEOM_Object_var mainShape = aSelectedObject->GetMainShape();
4368 mainShapeEntry = mainShape->GetStudyEntry();
4369 // CS_TODO : à optimiser
4370 bool okShape = GEOMBase::GetShape( mainShape , shape);//,const TopAbs_ShapeEnum type = TopAbs_SHAPE );
4371 bool oksubShape = GEOMBase::GetShape( aSelectedObject.get(), subshape );//,const TopAbs_ShapeEnum type = TopAbs_SHAPE );
4372 if ( okShape && oksubShape ){
4373 brep = shape2string( subshape ).c_str();
4374 subId = GEOMBase::GetIndex( subshape, shape );
4377 aFace.name = GEOMBase::GetName( aSelectedObject.get() );
4378 aFace.entry = mainShapeEntry;
4379 aFace.subid = QString::number(subId);
4384 item = new QListWidgetItem( aFace.name );
4385 item->setData( LW_ASSOC_ROLE, QVariant::fromValue<DocumentModel::GeomObj>(aFace) );
4386 faces_lw->addItem(item);
4387 // faces_lw->setCurrentRow( faces_lw->count() - 1 );
4392 // ============================================================== onWindowActivated
4393 void QuadAssocDialog::onWindowActivated(SUIT_ViewManager* vm)
4395 SUIT_ViewWindow* v = vm->getActiveView();
4396 QString vmType = vm->getType();
4397 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ){
4398 quad_le->setFocus();
4399 } else if ( vmType == OCCViewer_Viewer::Type() ){
4400 faces_lw->setFocus();
4404 // ============================================================== deleteFaceItem
4405 void QuadAssocDialog::deleteFaceItem()
4407 delete faces_lw->currentItem();
4411 // ============================================================== apply
4412 bool QuadAssocDialog::apply(QModelIndex& result)
4414 SUIT_OverrideCursor wc;
4415 //if ( !_documentModel ) return;
4416 if ( !_patternDataSelectionModel ) return false;
4417 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
4418 if ( !patternDataModel ) return false;
4422 QModelIndex iQuad = patternDataModel->mapToSource( _index[quad_le] );
4425 QListWidgetItem* item = NULL;
4426 DocumentModel::GeomObj aFace;
4427 for ( int r = 0; r < faces_lw->count(); ++r ){
4428 item = faces_lw->item(r);
4429 aFace = item->data(LW_ASSOC_ROLE).value<DocumentModel::GeomObj>();
4430 _documentModel->addAssociation( iQuad, aFace );
4433 result = patternDataModel->mapFromSource(iQuad);
4440 // ------------------------- GroupDialog ----------------------------------
4442 // ============================================================== Constructeur
4444 GroupDialog::GroupDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
4445 HexaBaseDialog(parent, editmode, f),
4448 _helpFileName = "gui_groups.html#add-group";
4450 _initWidget(editmode);
4451 // setFocusProxy( name_le/*eltBase_lw */);
4453 if ( editmode == NEW_MODE ){
4454 setWindowTitle( tr("Group Construction") );
4455 } else if ( editmode == UPDATE_MODE ){
4456 setWindowTitle( tr("Group Modification") );
4457 } else if ( editmode == INFO_MODE ){
4458 setWindowTitle( tr("Group Information") );
4462 // ============================================================== Destructeur
4463 GroupDialog::~GroupDialog()
4468 // ============================================================== _initInputWidget
4469 void GroupDialog::_initInputWidget( Mode editmode )
4471 setProperty( "HexaWidgetType", QVariant::fromValue(GROUP_TREE) );
4472 installEventFilter(this);
4474 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(GROUP_TREE) );
4475 name_le->installEventFilter(this);
4478 strKind[ HEXA_NS::HexaCell ] = "HexaCell";
4479 strKind[ HEXA_NS::QuadCell ] = "QuadCell";
4480 strKind[ HEXA_NS::EdgeCell ] = "EdgeCell";
4481 strKind[ HEXA_NS::HexaNode ] = "HexaNode";
4482 strKind[ HEXA_NS::QuadNode ] = "QuadNode";
4483 strKind[ HEXA_NS::EdgeNode ] = "EdgeNode";
4484 strKind[ HEXA_NS::VertexNode ] = "VertexNode";
4486 QMap<HEXA_NS::EnumGroup, QString>::ConstIterator iKind;
4487 for( iKind = strKind.constBegin(); iKind != strKind.constEnd(); ++iKind )
4488 kind_cb->addItem( iKind.value(), QVariant(iKind.key()) );
4490 onKindChanged( kind_cb->currentIndex() );
4491 eltBase_lw->installEventFilter(this);
4493 if ( editmode != INFO_MODE ){
4494 QShortcut* delEltShortcut = new QShortcut( QKeySequence(Qt::Key_X), eltBase_lw );
4495 delEltShortcut->setContext( Qt::WidgetShortcut );
4496 connect(delEltShortcut, SIGNAL(activated()), this, SLOT(removeEltBase()));
4497 connect(kind_cb, SIGNAL(activated(int)), this, SLOT(onKindChanged(int)) );
4500 connect(eltBase_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()));
4503 // ============================================================== clear
4504 void GroupDialog::clear()
4507 eltBase_lw->clear();
4510 // ============================================================== onKindChanged
4511 void GroupDialog::onKindChanged(int index)
4514 MESSAGE("GroupDialog::onKindChanged(" << index << ") ");
4515 switch ( kind_cb->itemData(index).toInt() ){
4516 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(HEXA_TREE)); MESSAGE("====>HEXA_TREE"); break;
4517 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(QUAD_TREE)); MESSAGE("====>QUAD_TREE"); break;
4518 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(EDGE_TREE)); MESSAGE("====>EDGE_TREE"); break;
4519 case HEXA_NS::VertexNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(VERTEX_TREE)); MESSAGE("====>VERTEX_TREE"); break;
4520 default:Q_ASSERT( false );
4522 eltBase_lw->clear();
4523 eltBase_lw->setFocus();
4526 // ============================================================== setValue
4527 void GroupDialog::setValue(HEXA_NS::Group* g)
4530 name_le->setText( g->getName() );
4534 kind_cb->addItem ( strKind[g->getKind()], QVariant( g->getKind() ) );
4535 // onKindChanged( kind_cb->currentIndex() );
4538 HEXA_NS::EltBase* eltBase = NULL;
4539 QListWidgetItem* item = NULL;
4540 QModelIndex iEltBase;
4541 QList<QStandardItem *> eltBaseItems;
4544 if ( !_patternDataSelectionModel ) return;
4545 if ( !_groupsSelectionModel ) return;
4547 QModelIndex iGroup = _groupsSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(g) );
4548 name_le->setProperty( "QModelIndex", QVariant::fromValue(iGroup) );
4551 for ( int nr = 0; nr < g->countElement(); ++nr ){
4552 eltBase = g->getElement( nr );
4553 switch ( g->getKind() ){
4554 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: v = QVariant::fromValue( (HEXA_NS::Hexa *)eltBase ); break;
4555 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: v = QVariant::fromValue( (HEXA_NS::Quad *)eltBase ); break;
4556 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: v = QVariant::fromValue( (HEXA_NS::Edge *)eltBase ); break;
4557 case HEXA_NS::VertexNode: v = QVariant::fromValue( (HEXA_NS::Vertex *)eltBase ); break;
4559 iEltBase = _patternDataSelectionModel->indexBy( HEXA_DATA_ROLE, v);
4560 if ( iEltBase.isValid() ){
4561 item = new QListWidgetItem( eltBase->getName() );
4562 item->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(iEltBase) );
4563 eltBase_lw->addItem( item );
4570 // ============================================================== getValue
4571 HEXA_NS::Group* GroupDialog::getValue()
4577 // ============================================================== removeEltBase
4578 void GroupDialog::removeEltBase()
4580 QListWidgetItem *item = eltBase_lw->currentItem();
4583 int r = eltBase_lw->row(item);
4584 eltBase_lw->takeItem(r);
4590 // ============================================================== apply
4591 bool GroupDialog::apply(QModelIndex& result)
4593 SUIT_OverrideCursor wc;
4595 if ( !_documentModel ) return false;
4596 if ( !_patternDataSelectionModel ) return false;
4597 if ( !_groupsSelectionModel ) return false;
4598 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
4599 const GroupsModel* groupsModel = dynamic_cast<const GroupsModel*>( _groupsSelectionModel->model() );
4602 QString grpName = name_le->text();
4603 DocumentModel::Group grpKind = static_cast<DocumentModel::Group>( kind_cb->itemData( kind_cb->currentIndex() ).toInt());
4605 if ( _value == NULL ){ // create group
4606 iGrp = _documentModel->addGroup( grpName, grpKind );
4608 QModelIndexList iGrps = _documentModel->match(
4609 _documentModel->index(0, 0),
4611 QVariant::fromValue( _value ),
4613 Qt::MatchRecursive );
4614 if ( !iGrps.isEmpty() )
4619 if ( !iGrp.isValid() ){
4620 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD GROUP" ) );
4624 //fill it and select it
4625 QModelIndex iEltBase;
4626 QListWidgetItem* item = NULL;
4627 bool eltAdded = false;
4628 _documentModel->clearGroupElement(iGrp);
4629 for ( int r = 0; r < eltBase_lw->count(); ++r){
4630 item = eltBase_lw->item(r);
4631 iEltBase = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
4632 if ( iEltBase.isValid() )
4633 eltAdded = _documentModel->addGroupElement( iGrp, iEltBase );
4634 // if ( eltAdded == false ){
4635 // //SUIT_MessageBox::information( this, tr( "HEXA_INFO" ), tr( "ELEMENT NOT ADDED : %1" ).arg( iEltBase.data().toString() ));
4639 QString newName = name_le->text();
4640 if ( !newName.isEmpty() )/*{*/
4641 _documentModel->setName( iGrp, newName );
4643 result = groupsModel->mapFromSource(iGrp);
4650 // ------------------------- LawDialog ----------------------------------
4652 // ============================================================== Constructeur
4654 LawDialog::LawDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
4655 : HexaBaseDialog(parent, editmode, f),
4658 _helpFileName = "gui_discret_law.html#add-law";
4660 _initWidget(editmode);
4661 if ( editmode == NEW_MODE ){
4662 setWindowTitle( tr("Law Construction") );
4663 } else if ( editmode == UPDATE_MODE ){
4664 setWindowTitle( tr("Law Modification") );
4668 // ============================================================== Destructeur
4669 LawDialog::~LawDialog()
4673 // ============================================================== _initInputWidget
4674 void LawDialog::_initInputWidget( Mode editmode )
4677 QValidator *validator = new QRegExpValidator(rx, this);
4679 setProperty( "HexaWidgetType", QVariant::fromValue(LAW_TREE) );
4680 installEventFilter(this);
4682 name_le->setProperty( "HexaWidgetType", QVariant::fromValue(LAW_TREE) );
4683 name_le->installEventFilter(this);
4686 strKind[ HEXA_NS::Uniform ] = "Uniform";
4687 strKind[ HEXA_NS::Arithmetic ] = "Arithmetic";
4688 strKind[ HEXA_NS::Geometric ] = "Geometric";
4691 QMap<HEXA_NS::KindLaw, QString>::ConstIterator iKind;
4692 for( iKind = strKind.constBegin(); iKind != strKind.constEnd(); ++iKind )
4693 kind_cb->addItem( iKind.value(), QVariant(iKind.key()) );
4697 // ============================================================== clear
4698 void LawDialog::clear()
4703 // ============================================================== setValue
4704 void LawDialog::setValue(HEXA_NS::Law* l)
4707 name_le->setText( l->getName() );
4709 nb_nodes_spb->setValue( l->getNodes() );
4710 coeff_spb->setValue( l->getCoefficient() );
4712 HEXA_NS::KindLaw k = l->getKind();
4713 kind_cb->setCurrentIndex( kind_cb->findData(k) );
4718 // ============================================================== getValue
4719 HEXA_NS::Law* LawDialog::getValue()
4726 // ============================================================== apply
4727 bool LawDialog::apply(QModelIndex& result)
4729 SUIT_OverrideCursor wc;
4730 if ( !_documentModel ) return false;
4731 if ( !_meshSelectionModel ) return false;
4734 const MeshModel* meshModel = dynamic_cast<const MeshModel*>( _meshSelectionModel->model() );
4736 QString lawName = name_le->text();
4737 int nbnodes = nb_nodes_spb->value();
4738 double coeff = coeff_spb->value();
4739 DocumentModel::KindLaw lawKind = static_cast<DocumentModel::KindLaw>( kind_cb->itemData( kind_cb->currentIndex() ).toInt());
4743 if ( _value == NULL ){ // create Law
4744 iLaw = _documentModel->addLaw( lawName, nbnodes );
4746 QModelIndexList iLaws = _documentModel->match(
4747 _documentModel->index(0, 0),
4749 QVariant::fromValue( _value ),
4751 Qt::MatchRecursive );
4752 if ( !iLaws.isEmpty() )
4756 if ( !iLaw.isValid() ){
4757 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD LAW" ) );
4760 //fill it and select it
4761 bool setOk = _documentModel->setLaw( iLaw, nbnodes, coeff, lawKind );
4763 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD LAW" ) );
4767 QString newName = name_le->text();
4768 if ( !newName.isEmpty() )/*{*/
4769 _documentModel->setName( iLaw, newName );
4771 result = meshModel->mapFromSource(iLaw);
4779 // ------------------------- PropagationDialog ----------------------------------
4781 // ============================================================== Constructeur
4783 PropagationDialog::PropagationDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
4784 : HexaBaseDialog(parent, editmode, f),
4787 _helpFileName = "gui_propag.html";
4789 _initWidget(editmode);
4790 // setFocusProxy( law_le );
4791 setFocusProxy( propagations_lw );
4793 if ( editmode == INFO_MODE ){
4794 setWindowTitle( tr("Propagation Information") );
4797 } else if ( editmode == UPDATE_MODE ){
4798 setWindowTitle( tr("Propagation Modification") );
4801 } else if ( editmode == NEW_MODE ){
4802 setWindowTitle( tr("Propagation(s) Setting") );
4807 // ============================================================== Destructeur
4808 PropagationDialog::~PropagationDialog()
4813 // ============================================================== _initInputWidget
4814 void PropagationDialog::_initInputWidget( Mode editmode )
4817 QValidator *validator = new QRegExpValidator(rx, this);
4819 setProperty( "HexaWidgetType", QVariant::fromValue(PROPAGATION_TREE) );
4820 installEventFilter(this);
4823 law_le->setProperty( "HexaWidgetType", QVariant::fromValue(LAW_TREE) );
4824 law_le->installEventFilter(this);
4825 law_le->setValidator( validator );
4827 propagations_lw->setProperty( "HexaWidgetType", QVariant::fromValue(PROPAGATION_TREE) );
4828 propagations_lw->installEventFilter(this);
4830 QShortcut* delPropagationShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X/*Qt::Key_Alt*//*Qt::Key_Space*/), propagations_lw);
4831 delPropagationShortcut->setContext( Qt::WidgetShortcut );
4833 connect( delPropagationShortcut, SIGNAL(activated()), this, SLOT(deletePropagationItem()) );
4834 connect( propagations_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()) );
4838 // ============================================================== clear
4839 void PropagationDialog::clear()
4841 propagations_lw->clear();
4845 // ============================================================== deletePropagationItem
4846 void PropagationDialog::deletePropagationItem()
4848 delete propagations_lw->currentItem();
4852 // ============================================================== setValue
4853 void PropagationDialog::setValue(HEXA_NS::Propagation* p)
4855 HEXA_NS::Law* l = p->getLaw();
4856 bool way = p->getWay();
4859 QModelIndex ip = _meshSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(p) );
4860 setProperty( "QModelIndex", QVariant::fromValue<QModelIndex>(ip) );
4863 // law on propagation
4865 law_le->setText( l->getName() );
4866 QModelIndex il = _meshSelectionModel->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(l) );
4867 law_le->setProperty( "QModelIndex", QVariant::fromValue<QModelIndex>(il) );
4870 // way of propagation
4871 way_cb->setChecked(way);
4876 // ============================================================== getValue
4877 HEXA_NS::Propagation* PropagationDialog::getValue()
4883 // ============================================================== apply
4884 bool PropagationDialog::apply(QModelIndex& result)
4887 SUIT_OverrideCursor wc;
4888 if ( !_documentModel ) return false;
4889 if ( !_meshSelectionModel ) return false;
4892 const MeshModel* meshModel = dynamic_cast<const MeshModel*>( _meshSelectionModel->model() );
4893 bool way = way_cb->isChecked();
4894 QListWidgetItem* item = NULL;
4896 QModelIndex iPropagation;
4897 QModelIndex iLaw = meshModel->mapToSource( law_le->property("QModelIndex").value<QModelIndex>() );
4898 if (!iLaw.isValid() ){
4899 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT SET PROPAGATION" ) );
4902 MESSAGE("iLaw.isValid() => " << iLaw.isValid() );
4904 for (int r = 0; r < propagations_lw->count(); ++r){
4905 item = propagations_lw->item(r);
4906 iPropagation = meshModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
4907 if ( !iPropagation.isValid() ){
4908 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT SET PROPAGATION" ) );
4911 MESSAGE("iPropagation.isValid() => " << iPropagation.isValid() );
4913 //fill it and select it
4914 isOk = _documentModel->setPropagation( iPropagation, iLaw, way );
4916 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT SET PROPAGATION" ) );
4920 result = meshModel->mapFromSource(iPropagation);
4927 // ------------------------- ComputeMeshDialog ----------------------------------
4929 // ============================================================== Constructeur
4931 ComputeMeshDialog::ComputeMeshDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
4932 HexaBaseDialog(parent, editmode, f)
4934 _helpFileName = "gui_mesh.html";
4935 setWindowTitle( tr("Compute mesh") );
4936 QVBoxLayout* layout = new QVBoxLayout;
4939 QHBoxLayout* up = new QHBoxLayout;
4940 QHBoxLayout* down = new QHBoxLayout;
4942 layout->addLayout(up);
4943 layout->addLayout(down);
4945 QVBoxLayout* vlg = new QVBoxLayout;
4946 QVBoxLayout* vld = new QVBoxLayout;
4951 vlg->addWidget(new QLabel("Name"));
4952 vlg->addWidget(new QLabel("Dimension"));
4953 vlg->addWidget(new QLabel("Container"));
4955 _name = new QLineEdit("Mesh");
4956 _dim = new QSpinBox();
4957 _fact = new QLineEdit("FactoryServer");
4959 vld->addWidget(_name);
4960 vld->addWidget(_dim);
4961 vld->addWidget(_fact);
4963 _dim->setRange(1, 3);
4966 _initWidget(editmode);
4970 // ============================================================== Destructeur
4971 ComputeMeshDialog::~ComputeMeshDialog()
4976 // ============================================================== _initInputWidget
4977 void ComputeMeshDialog::_initInputWidget( Mode editmode )
4981 // ============================================================== setDocumentModel
4982 void ComputeMeshDialog::setDocumentModel(DocumentModel* m)
4984 HexaBaseDialog::setDocumentModel(m);
4985 _name->setText(_documentModel->getName());
4988 // ============================================================== clear
4989 void ComputeMeshDialog::clear()
4993 // ============================================================== apply
4994 bool ComputeMeshDialog::apply(QModelIndex& result)
4996 SUIT_OverrideCursor wc;
4998 QString command = QString("import hexablock ; %1 = hexablock.mesh(\"%2\", \"%1\", %3, \"%4\")")
4999 .arg( _name->text() )
5000 .arg( _documentModel->documentEntry() )
5001 .arg( _dim->value() )
5002 .arg( _fact->text() );
5003 //std::cout << "command: " << command.toStdString() << std::endl;
5005 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
5006 PyConsole_Console* pyConsole = app->pythonConsole();
5009 pyConsole->exec( command );
5017 // void ComputeMeshDialog::accept() {
5018 // _disallowSelection();
5019 // QDialog::accept();
5021 // QString command = QString("import hexablock ; %1 = hexablock.mesh(\"%1\", \"%2\", %3, \"%4\")")
5022 // .arg( _name->text() )
5023 // .arg( _documentModel->documentEntry() )
5024 // .arg( _dim->value() )
5025 // .arg( _fact->text() );
5026 // std::cout << "command: " << command.toStdString() << std::endl;
5028 // SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
5029 // PyConsole_Console* pyConsole = app->pythonConsole();
5031 // if ( pyConsole ) pyConsole->exec( command );
5034 // void ComputeMeshDialog::reject() {
5035 // _disallowSelection();
5036 // QDialog::reject();
5041 // ------------------------- ReplaceHexaDialog ----------------------------------
5043 // ============================================================== Constructeur
5045 ReplaceHexaDialog::ReplaceHexaDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
5046 HexaBaseDialog(parent, editmode, f)
5048 _helpFileName = "gui_replace_hexa.html";
5050 _initWidget(editmode);
5051 setFocusProxy( quads_lw );
5054 // ============================================================== Destructeur
5055 ReplaceHexaDialog::~ReplaceHexaDialog()
5059 // ============================================================== _initInputWidget
5060 void ReplaceHexaDialog::_initInputWidget( Mode editmode )
5063 QValidator *validator = new QRegExpValidator(rx, this);
5065 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
5066 installEventFilter(this);
5068 c1_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5069 c2_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5070 c3_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5072 p1_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5073 p2_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5074 p3_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5076 c1_le->installEventFilter(this);
5077 c2_le->installEventFilter(this);
5078 c3_le->installEventFilter(this);
5080 p1_le->installEventFilter(this);
5081 p2_le->installEventFilter(this);
5082 p3_le->installEventFilter(this);
5084 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
5085 quads_lw->installEventFilter(this);
5087 if ( editmode == NEW_MODE ){
5088 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
5089 delQuadShortcut->setContext( Qt::WidgetShortcut );
5091 connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(deleteQuadItem()) );
5092 connect( quads_lw, SIGNAL(currentRowChanged(int)), this, SLOT(updateButtonBox(int)) );
5095 connect(quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()));
5098 // ============================================================== clear
5099 void ReplaceHexaDialog::clear()
5103 // ============================================================== updateButtonBox
5104 void ReplaceHexaDialog::updateButtonBox()
5106 int nbQuad = quads_lw->count();
5109 //_applyCloseButton->setEnabled(true);
5110 _applyButton->setEnabled(true);
5112 //_applyCloseButton->setEnabled(false);
5113 _applyButton->setEnabled(false);
5117 // ============================================================== deleteQuadItem
5118 void ReplaceHexaDialog::deleteQuadItem()
5120 delete quads_lw->currentItem();
5124 // ============================================================== apply
5125 bool ReplaceHexaDialog::apply(QModelIndex& result)
5127 SUIT_OverrideCursor wc;
5128 if ( !_documentModel ) return false;
5129 if ( !_patternDataSelectionModel ) return false;
5130 if ( !_patternBuilderSelectionModel ) return false;
5131 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
5132 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
5133 if ( !patternDataModel ) return false;
5134 if ( !patternBuilderModel ) return false;
5137 QModelIndex ielts; //result
5139 QListWidgetItem* item = NULL;
5140 QModelIndexList iquads;
5142 for ( int r = 0; r < quads_lw->count(); ++r){
5143 item = quads_lw->item(r);
5144 iquad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
5145 //std::cout << "iquad => " << iquad.data().toString().toStdString() << std::endl;
5146 if ( iquad.isValid() )
5150 QModelIndex ic1 = patternDataModel->mapToSource( _index[c1_le] );
5151 QModelIndex ic2 = patternDataModel->mapToSource( _index[c2_le] );
5152 QModelIndex ic3 = patternDataModel->mapToSource( _index[c3_le] );
5154 QModelIndex ip1 = patternDataModel->mapToSource( _index[p1_le] );
5155 QModelIndex ip2 = patternDataModel->mapToSource( _index[p2_le] );
5156 QModelIndex ip3 = patternDataModel->mapToSource( _index[p3_le] );
5158 // std::cout << "nbHexa => " << nbHexa << std::endl;
5160 if ( ic1.isValid() && ic2.isValid() && ic3.isValid()
5161 && ip1.isValid() && ip2.isValid() && ip3.isValid() ){
5162 ielts = _documentModel->replace( iquads,
5168 if ( !ielts.isValid() ){
5169 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT REPLACE HEXA" ) );
5172 _value = ielts.model()->data(ielts, HEXA_DATA_ROLE).value<HEXA_NS::Elements*>();
5174 QString newName = name_le->text();
5175 if ( !newName.isEmpty() )/*{*/
5176 _documentModel->setName( ielts, newName );
5178 result = patternBuilderModel->mapFromSource(ielts);
5186 // ------------------------- QuadRevolutionDialog ----------------------------------
5188 // ============================================================== Constructeur
5190 QuadRevolutionDialog::QuadRevolutionDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
5191 HexaBaseDialog(parent, editmode, f)
5193 _helpFileName = "gui_quad_revolution.html";
5195 _initWidget(editmode);
5196 setFocusProxy( quads_lw );
5199 // ============================================================== Destructeur
5200 QuadRevolutionDialog::~QuadRevolutionDialog()
5204 // ============================================================== _initInputWidget
5205 void QuadRevolutionDialog::_initInputWidget( Mode editmode )
5208 QValidator *validator = new QRegExpValidator(rx, this);
5210 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
5211 installEventFilter(this);
5213 center_pt_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5214 axis_vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
5215 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
5217 center_pt_le->setValidator( validator );
5218 axis_vec_le->setValidator( validator );
5219 // quads_lw->setValidator( validator );
5221 center_pt_le->installEventFilter(this);
5222 axis_vec_le->installEventFilter(this);
5223 quads_lw->installEventFilter(this);
5225 if ( editmode == NEW_MODE ){
5226 angles_lw->setItemDelegate( new HexaAngleDoubleSpinBoxDelegate(angles_lw) );
5227 angles_lw->setEditTriggers( QAbstractItemView::DoubleClicked );
5229 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
5230 delQuadShortcut->setContext( Qt::WidgetShortcut );
5231 connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(delQuadItem()) );
5232 connect( add_angle_pb, SIGNAL(clicked()), this, SLOT(addAngleItem()));
5233 connect( del_angle_pb, SIGNAL(clicked()), this, SLOT(delAngleItem()));
5234 // connect(clear_pb, SIGNAL(clicked()), this, SLOT(clearQuads()));
5237 connect(quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()));
5240 // ============================================================== clear
5241 void QuadRevolutionDialog::clear()
5246 // ============================================================== updateButtonBox
5247 void QuadRevolutionDialog::updateButtonBox() //CS_TODO? : check center, axis
5249 int nbQuads = quads_lw->count();
5250 int nbAngles = angles_lw->count();
5252 if ( nbQuads>0 && nbAngles> 0 ){
5253 //_applyCloseButton->setEnabled(true);
5254 _applyButton->setEnabled(true);
5256 //_applyCloseButton->setEnabled(false);
5257 _applyButton->setEnabled(false);
5262 // ============================================================== addAngleItem
5263 void QuadRevolutionDialog::addAngleItem() //CS_TODO
5265 QListWidgetItem* previousItem = angles_lw->currentItem();
5266 QListWidgetItem* newItem = new QListWidgetItem();
5268 double defaultValue = 0.;
5270 defaultValue = previousItem->data(Qt::EditRole).toDouble();
5272 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
5273 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
5274 angles_lw->addItem(newItem);
5279 // ============================================================== delAngleItem
5280 void QuadRevolutionDialog::delAngleItem()
5282 delete angles_lw->currentItem();
5286 // ============================================================== delQuadItem
5287 void QuadRevolutionDialog::delQuadItem()
5289 delete quads_lw->currentItem();
5293 // ============================================================== apply
5294 bool QuadRevolutionDialog::apply(QModelIndex& result)
5296 SUIT_OverrideCursor wc;
5297 if ( !_documentModel ) return false;
5298 if ( !_patternDataSelectionModel ) return false;
5299 if ( !_patternBuilderSelectionModel ) return false;
5300 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
5301 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
5302 if ( !patternDataModel ) return false;
5303 if ( !patternBuilderModel ) return false;
5306 QModelIndex ielts; //result
5307 QListWidgetItem* item = NULL;
5309 QModelIndexList istartquads;
5311 for ( int r = 0; r < quads_lw->count(); ++r){
5312 item = quads_lw->item(r);
5313 iquad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
5314 if ( iquad.isValid() )
5315 istartquads << iquad;
5318 QModelIndex icenter_pt = patternDataModel->mapToSource( _index[center_pt_le] );
5319 QModelIndex iaxis_vec = patternBuilderModel->mapToSource( _index[axis_vec_le] );
5321 QList<double> angles;
5322 for ( int r = 0; r < angles_lw->count(); ++r){
5323 item = angles_lw->item(r);
5324 angles << item->data(Qt::EditRole).toDouble();
5327 if ( icenter_pt.isValid() && iaxis_vec.isValid() ){
5328 ielts = _documentModel->revolutionQuads( istartquads, icenter_pt, iaxis_vec, angles );
5331 if ( !ielts.isValid() ){
5332 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE QUAD REVOLUTION" ) );
5335 _value = ielts.model()->data(ielts, HEXA_DATA_ROLE).value<HEXA_NS::Elements*>();
5337 QString newName = name_le->text();
5338 if ( !newName.isEmpty() )/*{*/
5339 _documentModel->setName( ielts, newName );
5341 result = patternBuilderModel->mapFromSource(ielts);
5348 // ------------------------- QuadRevolutionDialog ----------------------------------
5350 // ============================================================== Constructeur
5352 MakeHemiSphereDialog::MakeHemiSphereDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
5353 HexaBaseDialog(parent, editmode, f)
5355 _helpFileName = "gui_hemisphere.html";
5357 _initWidget(editmode);
5360 // ============================================================== Destructeur
5361 MakeHemiSphereDialog::~MakeHemiSphereDialog()
5365 // ============================================================== _initInputWidget
5366 void MakeHemiSphereDialog::_initInputWidget( Mode editmode )
5369 QValidator *validator = new QRegExpValidator(rx, this);
5371 setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
5372 installEventFilter(this);
5374 sphere_center_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5375 cross_pt_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
5376 hole_axis_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
5377 cross_vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
5378 radial_vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
5380 sphere_center_le->setValidator( validator );
5381 cross_pt_le->setValidator( validator );
5382 hole_axis_le->setValidator( validator );
5383 cross_vec_le->setValidator( validator );
5384 radial_vec_le->setValidator( validator );
5387 sphere_center_le->installEventFilter(this);
5388 cross_pt_le->installEventFilter(this);
5389 hole_axis_le->installEventFilter(this);
5390 cross_vec_le->installEventFilter(this);
5391 radial_vec_le->installEventFilter(this);
5394 // ============================================================== clear
5395 void MakeHemiSphereDialog::clear()
5399 // ============================================================== apply
5400 bool MakeHemiSphereDialog::apply(QModelIndex& result)
5402 SUIT_OverrideCursor wc;
5403 if ( !_documentModel ) return false;
5404 if ( !_patternBuilderSelectionModel ) return false;
5405 if ( !_patternDataSelectionModel ) return false;
5406 const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
5407 const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
5408 if ( !patternBuilderModel ) return false;
5409 if ( !patternDataModel ) return false;
5413 QModelIndex icenter = patternDataModel->mapToSource( _index[sphere_center_le] );
5414 QModelIndex iplorig = patternDataModel->mapToSource( _index[cross_pt_le] );
5415 QModelIndex ivecx = patternBuilderModel->mapToSource( _index[radial_vec_le] );
5416 QModelIndex ivecz = patternBuilderModel->mapToSource( _index[hole_axis_le] );
5418 double radext = sphere_radext_spb->value();
5419 double radhole = hole_rad_spb->value();
5421 int nrad = ngrid_rad_spb->value();
5422 int nang = ngrid_ang_spb->value();
5423 int nhaut = ngrid_height_spb->value();
5426 if ( icenter.isValid() && ivecx.isValid() && ivecz.isValid() && iplorig.isValid() ){
5427 if ( sphere_rind_cb->isChecked() ){ // rind
5428 double radint = sphere_radint_spb->value();
5429 if ( radial_partial_cb->isChecked() ){
5430 double angle = radial_angle_spb->value();
5431 iElts = _documentModel->makePartRind( icenter, ivecx, ivecz,
5432 radext, radint, radhole,
5434 nrad, nang, nhaut );
5436 iElts = _documentModel->makeRind( icenter,
5438 radext, radint, radhole,
5440 nrad, nang, nhaut );
5443 if ( radial_partial_cb->isChecked() ){
5444 double angle = radial_angle_spb->value();
5445 iElts = _documentModel->makePartSphere( icenter, ivecx, ivecz,
5448 nrad, nang, nhaut );
5450 iElts = _documentModel->makeSphere( icenter,
5454 nrad, nang, nhaut );
5460 if ( !iElts.isValid() ){
5461 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE RIND" ) );
5464 _value = iElts.model()->data(iElts, HEXA_DATA_ROLE).value<HEXA_NS::Elements*>();
5466 QString newName = name_le->text();
5467 if ( !newName.isEmpty() )/*{*/
5468 _documentModel->setName( iElts, newName );
5470 result = patternBuilderModel->mapFromSource(iElts);
5474 // ==============================================================
5477 // MakeRindDialog::MakeRindDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
5478 // HexaBaseDialog(parent, editmode, f)
5480 // // _helpFileName()
5482 // setWindowTitle( tr("MAKE RIND") );
5484 // if ( editmode == NEW_MODE ){
5485 // _initButtonBox( editmode );
5487 // //selection management
5488 // _vertexLineEdits << center_le << plorig_le;
5489 // _vectorLineEdits << vx_le << vz_le;
5491 // center_le->installEventFilter(this);
5492 // plorig_le->installEventFilter(this);
5493 // vx_le->installEventFilter(this);
5494 // vz_le->installEventFilter(this);
5499 // MakeRindDialog::~MakeRindDialog()
5505 // bool MakeRindDialog::apply(QModelIndex& result)
5507 // SUIT_OverrideCursor wc;
5508 // if ( !_documentModel ) return false;
5509 // if ( !_patternBuilderSelectionModel ) return false;
5510 // if ( !_patternDataSelectionModel ) return false;
5511 // const PatternBuilderModel* patternBuilderModel = dynamic_cast<const PatternBuilderModel*>( _patternBuilderSelectionModel->model() );
5512 // const PatternDataModel* patternDataModel = dynamic_cast<const PatternDataModel*>( _patternDataSelectionModel->model() );
5513 // if ( !patternBuilderModel ) return false;
5514 // if ( !patternDataModel ) return false;
5516 // QModelIndex iElts;
5517 // QModelIndex icenter = patternDataModel->mapToSource( _index[center_le] );
5518 // QModelIndex iplorig = patternDataModel->mapToSource( _index[plorig_le] );
5519 // QModelIndex ivecx = patternBuilderModel->mapToSource( _index[vx_le] );
5520 // QModelIndex ivecz = patternBuilderModel->mapToSource( _index[vz_le] );
5522 // double radext = radext_spb->value();
5523 // double radint = radint_spb->value();
5524 // double radhole = radhole_spb->value();
5526 // int nrad = nrad_spb->value();
5527 // int nang = nang_spb->value();
5528 // int nhaut = nhaut_spb->value();
5530 // if ( icenter.isValid() && ivecx.isValid() && ivecz.isValid() && iplorig.isValid() ){
5531 // if ( partial_cb->isChecked() ){
5532 // double angle = angle_spb->value(); // Part Rind only
5533 // iElts = _documentModel->makePartRind( icenter, ivecx, ivecz,
5534 // radext, radint, radhole,
5536 // nrad, nang, nhaut );
5538 // iElts = _documentModel->makeRind( icenter,
5540 // radext, radint, radhole,
5542 // nrad, nang, nhaut );
5546 // if ( !iElts.isValid() ){
5547 // SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE RIND" ) );
5551 // QString newName = name_le->text();
5552 // if (!newName.isEmpty()) _documentModel->setName( iElts, newName );
5557 // QVariant v = lineEdit->property("index");
5558 // if ( v.isValid() ){
5559 // MESSAGE("* get index ... " );
5560 // QModelIndex i = v.value<QModelIndex>();
5561 // _selectionMutex = true;
5562 // _patternDataSelectionModel->select( i, QItemSelectionModel::Clear );
5563 // _patternDataSelectionModel->select( i, QItemSelectionModel::Select );
5564 // _selectionMutex = false;