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_VtkDocumentGraphicView.hxx"
23 #include "HEXABLOCKGUI_OccGraphicView.hxx"
24 #include "HEXABLOCKGUI_SalomeTools.hxx"
25 //#include "HEXABLOCKGUI.hxx"
32 #include <SalomeApp_Application.h>
33 #include <SalomeApp_Study.h>
34 #include <PyConsole_Console.h>
35 #include <SalomeApp_Tools.h>
37 #include <Standard_GUID.hxx>
38 #include <TDF_Label.hxx>
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>
60 #include <SVTK_View.h>
62 #include <SUIT_ResourceMgr.h>
65 // #include <GeometryGUI.h>
68 #include <GEOMImpl_Types.hxx>
72 #include "MyGEOMBase_Helper.hxx"
74 #include "GEOM_Operation.h"
76 #define BUTTON_BOX_MIN_WIDTH 5
77 #define VERTEX_COORD_MIN -1000000
78 #define VERTEX_COORD_MAX 1000000
79 #define SPINBOX_ANGLE_MAX 360
80 #define SPINBOX_DOUBLE_MAX 1000000000
81 #define SPINBOX_POSITIVE_DOUBLE_MIN 0
86 using namespace HEXABLOCK::GUI;
89 Q_DECLARE_METATYPE(HEXABLOCK::GUI::HexaTreeRole);
90 Q_DECLARE_METATYPE(TopAbs_ShapeEnum);
92 //General SpinBox Delegate
93 class HexaDoubleSpinBoxDelegate : public QStyledItemDelegate {
95 HexaDoubleSpinBoxDelegate(QObject *parent=0) : QStyledItemDelegate (parent){}
97 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
98 const QModelIndex &index) const{
99 QDoubleSpinBox *sb = new QDoubleSpinBox( parent );
100 sb->setDecimals(NB_DECIMALS);
105 //Angle SpinBox Delegate
106 class HexaAngleDoubleSpinBoxDelegate : public QStyledItemDelegate {
108 HexaAngleDoubleSpinBoxDelegate(QObject *parent=0) : QStyledItemDelegate (parent){}
110 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
111 const QModelIndex &index) const{
112 QDoubleSpinBox *sb = new QDoubleSpinBox( parent );
113 sb->setMinimum(SPINBOX_POSITIVE_DOUBLE_MIN);
114 sb->setMaximum(SPINBOX_ANGLE_MAX);
115 sb->setDecimals(NB_DECIMALS);
121 //Positive DoubleSpinBox Delegate (for heigth, radius, ...)
122 class HexaPositiveDoubleSpinBoxDelegate : public QStyledItemDelegate {
124 HexaPositiveDoubleSpinBoxDelegate(QObject *parent=0) : QStyledItemDelegate (parent){}
126 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
127 const QModelIndex &index) const{
128 QDoubleSpinBox *sb = new QDoubleSpinBox( parent );
129 sb->setMinimum(SPINBOX_POSITIVE_DOUBLE_MIN);
130 /////// sb->setMaximum(1000000000000000); //10e15 Abu : Pb en 32 bits
131 sb->setMaximum(SPINBOX_DOUBLE_MAX); //10e9
132 sb->setDecimals(NB_DECIMALS);
137 // ======================================================== Constructeur
138 HexaBaseDialog::HexaBaseDialog( QWidget * parent, Mode editmode, Qt::WindowFlags f ):
140 MyGEOMBase_Helper( dynamic_cast<SUIT_Desktop*>(parent->parent()) ),
141 _editMode( editmode ),
143 _expectedSelection(-1),
144 _selectionMutex( false ),
145 // _applyCloseButton(0),
147 debugEdgeAssoc(false),
148 autoFocusSwitch(true)
150 _strHexaWidgetType[VERTEX_TREE] = tr( "VERTEX" );
151 _strHexaWidgetType[EDGE_TREE] = tr( "EDGE" );
152 _strHexaWidgetType[QUAD_TREE] = tr( "QUAD" );
153 _strHexaWidgetType[HEXA_TREE] = tr( "HEXA" );
155 _strHexaWidgetType[VECTOR_TREE] = tr( "VECTOR" );
156 _strHexaWidgetType[CYLINDER_TREE] = tr( "CYLINDER" );
157 _strHexaWidgetType[PIPE_TREE] = tr( "PIPE" );
158 _strHexaWidgetType[ELEMENTS_TREE] = tr( "ELEMENTS" );
159 _strHexaWidgetType[CROSSELEMENTS_TREE]= tr( "CROSSELEMENTS" );
162 _strHexaWidgetType[GEOMSHAPE_TREE] = tr( "GEOMSHAPE" );
163 _strHexaWidgetType[GEOMPOINT_TREE] = tr( "GEOMPOINT" );
164 _strHexaWidgetType[GEOMEDGE_TREE] = tr( "GEOMEDGE" );
165 _strHexaWidgetType[GEOMFACE_TREE] = tr( "GEOMFACE" );
168 _strHexaWidgetType[GROUP_TREE] = tr( "GROUP" );
169 _strHexaWidgetType[LAW_TREE] = tr( "LAW" );
170 _strHexaWidgetType[PROPAGATION_TREE]= tr( "PROPAGATION" );
173 // ============================================================= getIndexList
174 QModelIndexList HexaBaseDialog::getIndexList(QListWidget* itemsList)
176 QModelIndexList iItems;
178 QListWidgetItem* item = NULL;
180 const PatternDataModel* patternDataModel = getPatternDataModel();
181 if (patternDataModel == NULL || itemsList == NULL) return iItems;
183 unsigned int nbItems = itemsList->count();
184 for ( int r = 0; r < nbItems; ++r){
185 item = itemsList->item(r);
186 iItem = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
192 // ============================================================= lockSizeToSizeHint
193 void HexaBaseDialog::lockSizeToSizeHint()
195 setMaximumHeight(sizeHint().height());
196 // setMaximumWidth(sizeHint().width());
197 // setMinimumHeight(sizeHint().height());
198 // setMinimumWidth(sizeHint().width());
201 // ============================================================= unlockSizeModification
202 void HexaBaseDialog::unlockSizeModification()
204 setMaximumHeight(MAX_HEIGHT);
205 // setMaximumWidth(MAX_WIDTH);
206 // setMinimumHeight(MIN_HEIGHT);
207 // setMinimumWidth(MIN_WIDTH);
210 // ============================================================= resetSizeAndShow
211 void HexaBaseDialog::resetSizeAndShow(QDockWidget* parent)
213 //force the dialog to fit its contain
214 lockSizeToSizeHint();
216 //set the dialog in the dockwidget
217 parent->setWidget(this);
218 parent->setWindowTitle(windowTitle());
219 parent->setVisible(true);
222 unlockSizeModification();
225 //unlink the widget from the model
226 void HexaBaseDialog::modelUnregister(QWidget* widget)
228 if (widget == NULL) return;
230 //Update the line edit
231 widget->setProperty("QModelIndex", QVariant());
232 _index[widget] = QModelIndex();
235 // ============================================================= connectDocumentGraphicView
236 void HexaBaseDialog::connectDocumentGraphicView(VtkDocumentGraphicView* docGView)
238 if (docGView == NULL) docGView = HEXABLOCKGUI::currentDocGView;
239 if (docGView == NULL) return;
241 disconnectDocumentGraphicView(docGView); //to avoid double connect
243 //Connect the graphic view and its model to the dialog box
244 connect( docGView->getPatternDataSelectionModel(), SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ),
245 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
246 connect( docGView->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
247 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
248 connect( docGView->getPatternGeomSelectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
249 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
250 connect( docGView->getGroupsSelectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
251 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
252 connect( docGView->getMeshSelectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
253 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ), Qt::UniqueConnection );
256 // ============================================================= disconnectDocumentGraphicView
257 void HexaBaseDialog::disconnectDocumentGraphicView(VtkDocumentGraphicView* docGView)
259 if (docGView == NULL) docGView = HEXABLOCKGUI::currentDocGView;
260 if (docGView == NULL) return;
263 //Disconnect graphic view signals form the dialog box
264 disconnect(docGView->getPatternDataSelectionModel(), SIGNAL( selectionChanged ( const QItemSelection &, const QItemSelection &) ),
265 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
267 disconnect(docGView->getPatternBuilderSelectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
268 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
270 disconnect(docGView->getPatternGeomSelectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
271 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
273 disconnect( docGView->getGroupsSelectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
274 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
276 disconnect( docGView->getMeshSelectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection &) ),
277 this, SLOT( onSelectionChanged(const QItemSelection &, const QItemSelection &) ) );
281 // ============================================================= onCurrentSelectionChanged
282 void HexaBaseDialog::onCurrentSelectionChanged()
284 highlightSelectedAssocs();
287 void HexaBaseDialog::clearCurrentObjectFocus()
289 QWidget* currentWidget = dynamic_cast<QWidget*>(_currentObj);
290 if (currentWidget != NULL)
292 currentWidget->clearFocus();
297 // ============================================================= setFocusToNextField
298 //Sets focus to the next field of the current object
299 void HexaBaseDialog::setFocusToNextField()
303 if (!HEXABLOCKGUI::assocInProgress && autoFocusSwitch)
305 _highlightWidget(_currentObj, Qt::white);
309 if (!_isLineOrListWidget(focusWidget())) clearVTKSelection();
313 // ============================================================== _initButtonBox
314 QGroupBox* HexaBaseDialog::_initButtonBox( Mode editmode )
316 if ( editmode == INFO_MODE )
319 //QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
320 QGroupBox* buttonBox = new QGroupBox();
321 buttonBox->setMinimumWidth(BUTTON_BOX_MIN_WIDTH);
322 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
323 //buttonBox->setOrientation(Qt::Horizontal);
324 QHBoxLayout* buttonsHLayout = new QHBoxLayout();
325 _applyButton = new QPushButton(tr("Apply"));
326 QPushButton* closeButton = new QPushButton(tr("Close"));
327 QPushButton* helpButton = new QPushButton(tr("Help"));
328 //_applyCloseButton = new QPushButton(tr("Apply And Close"));
330 //connect( buttonBox, SIGNAL(clicked()), this, SLOT(applyAndClose()) );
331 connect( _applyButton, SIGNAL(clicked()), this, SLOT(apply()), Qt::UniqueConnection );
332 connect( closeButton, SIGNAL(clicked()), this, SLOT(close()), Qt::UniqueConnection );
333 connect( helpButton, SIGNAL(clicked()), this, SLOT(onHelpRequested()), Qt::UniqueConnection );
335 buttonsHLayout->addWidget( _applyButton );
336 buttonsHLayout->addWidget( closeButton );
337 buttonsHLayout->addStretch(1);
338 buttonsHLayout->addWidget( helpButton );
339 //buttonsHLayout->addButton( _applyCloseButton );
340 buttonBox->setLayout(buttonsHLayout);
341 layout()->addWidget(buttonBox);
342 buttonBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
346 // ============================================================== _initWidget
347 void HexaBaseDialog::_initWidget( Mode editmode )
349 _initInputWidget( editmode );
350 _initButtonBox( editmode );
353 // ============================================================== _initViewManager
354 void HexaBaseDialog::_initViewManager()
356 // SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
357 // if (anApp == NULL) return;
358 // _mgr = dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
359 // _occVm = anApp->getViewManager( OCCViewer_Viewer::Type(), true );
360 // _vtkVm = anApp->getViewManager( SVTK_Viewer::Type(), true );
361 // SUIT_ViewManager* activeVm = anApp->activeViewManager();
362 // onWindowActivated ( activeVm );
365 // ============================================================== apply
366 bool HexaBaseDialog::apply()
369 bool applied = apply(iNew);
371 // clear all selection
372 if (getPatternDataSelectionModel() != NULL) getPatternDataSelectionModel()->clearSelection();
373 if (getPatternBuilderSelectionModel() != NULL) getPatternBuilderSelectionModel()->clearSelection();
374 if (getPatternGeomSelectionModel() != NULL) getPatternGeomSelectionModel()->clearSelection();
375 if (getGroupsSelectionModel() != NULL) getGroupsSelectionModel()->clearSelection();
376 if (getMeshSelectionModel() != NULL) getMeshSelectionModel()->clearSelection();
377 // select and highlight in vtk view the result
378 _selectAndHighlight( iNew );
380 // _currentObj = NULL;
385 // ============================================================== accept
386 //void HexaBaseDialog::accept()
388 // bool applied = apply();
390 // QDialog::accept();
391 // _disallowSelection();
395 void HexaBaseDialog::clearVTKSelection()
397 HEXABLOCKGUI::currentDocGView->clearSelection();
399 _highlightWidget(_currentObj, Qt::white);
400 // _disallowSelection();
403 void HexaBaseDialog::clearOCCSelection()
405 if (HEXABLOCKGUI::currentOccGView != NULL)
406 HEXABLOCKGUI::currentOccGView->clearSelection();
409 // ============================================================== close
410 void HexaBaseDialog::close()
413 //Clear vtk selection
414 // clearVTKSelection();
416 //reset the data selection pattern (forget all selections of the current context)
417 // if (getPatternDataSelectionModel() != NULL)
418 // getPatternDataSelectionModel()->reset();
420 // if (getPatternGeomSelectionModel() != NULL)
421 // getPatternGeomSelectionModel()->reset();
423 //Clear occ selection
424 // clearOCCSelection();
426 //Close the dialog box
427 if (parentWidget()) parentWidget()->close();
430 // ============================================================== onHelpRequested
431 void HexaBaseDialog::onHelpRequested()
433 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
435 // app->onHelpContextModule( myGeometryGUI ? app->moduleName( myGeometryGUI->moduleName() ) : QString( "" ), _helpFileName );
436 app->onHelpContextModule( "HEXABLOCK", _helpFileName );
441 platform = "winapplication";
443 platform = "application";
446 SUIT_MessageBox::warning( 0, QObject::tr( "WRN_WARNING" ),
447 QObject::tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
448 arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( _helpFileName ),
449 QObject::tr( "BUT_OK" ) );
453 // ============================================================== highlightSelectedAssocs
454 void HexaBaseDialog::highlightSelectedAssocs()
456 if (getPatternDataSelectionModel() == NULL ||
457 HEXABLOCKGUI::selectionMgr() == NULL ||
458 HEXABLOCKGUI::currentDocGView->getViewWindow() == NULL) return;
460 QMultiMap<QString, int> geomAssocs = getAssocsGEOM();
461 QModelIndexList vtkAssocs = getAssocsVTK();
463 //highlight geom selected elts
464 if (geomAssocs.size() > 0)
466 HEXABLOCKGUI::selectionMgr()->clearSelected();
467 HEXABLOCKGUI::currentOccGView->highlight(geomAssocs);
470 //highlight vtk selected elts
471 if (!vtkAssocs.isEmpty())
472 HEXABLOCKGUI::currentDocGView->highlight(vtkAssocs);
475 // ============================================================== refreshHighlight
476 void HexaBaseDialog::refreshHighlight()
478 if (HEXABLOCKGUI::selectionMgr() != NULL)
479 HEXABLOCKGUI::selectionMgr()->clearSelected();
480 highlightSelectedAssocs();
483 // ============================================================== getObjectViewType
484 HEXABLOCKGUI::ViewType HexaBaseDialog::getObjectViewType(QObject* obj)
486 if (obj == NULL) return HEXABLOCKGUI::UNKNOWN;
487 QVariant v = obj->property("HexaWidgetType");
488 if ( v.isValid() ) return HEXABLOCKGUI::VTK;
489 v = obj->property("GeomWidgetType");
490 if ( v.isValid() ) return HEXABLOCKGUI::OCC;
491 return HEXABLOCKGUI::UNKNOWN;
494 // ============================================================== _selectAndHighlight
495 void HexaBaseDialog::_selectAndHighlight( const QModelIndex& i )
497 if ( !i.isValid() ) return;
498 setProperty("QModelIndex", QVariant::fromValue(i));
502 // ============================================================== _allowSelection
503 void HexaBaseDialog::_allowSelection()
505 if ( getDocumentModel() ){
506 getDocumentModel()->disallowEdition();
510 // ============================================================== _disallowSelection
511 void HexaBaseDialog::_disallowSelection()
513 if ( getDocumentModel() ){
514 getDocumentModel()->allowEdition();
516 HEXABLOCKGUI::currentDocGView->setAllSelection();
520 // ============================================================== _allowVTKSelection
521 bool HexaBaseDialog::_allowVTKSelection( QObject* obj )
526 QVariant v = obj->property("HexaWidgetType");
527 HexaWidgetType wType = v.value<HexaWidgetType>();
531 HEXABLOCKGUI::currentDocGView->setVertexSelection(); isOk = true;
534 HEXABLOCKGUI::currentDocGView->setEdgeSelection(); isOk = true;
537 HEXABLOCKGUI::currentDocGView->setQuadSelection(); isOk = true;
540 HEXABLOCKGUI::currentDocGView->setHexaSelection(); isOk = true;
543 // case CYLINDER_TREE:
545 // case ELEMENTS_TREE:
546 // case CROSSELEMENTS_TREE: //selector = getPatternDataSelectionModel();
547 // case GROUP_TREE: //selector = getGroupsSelectionModel();
549 // case PROPAGATION_TREE: // selector = getMeshSelectionModel();
550 default: HEXABLOCKGUI::currentDocGView->setAllSelection();
555 // ============================================================== _allowOCCSelection
556 bool HexaBaseDialog::_allowOCCSelection( QObject* obj )
558 QVariant v = obj->property("GeomWidgetType");
559 GeomWidgetType wType = v.value<GeomWidgetType>();
560 HEXABLOCKGUI::currentOccGView->setSelectionMode(wType);
565 // ============================================================== _getSelector
566 QItemSelectionModel* HexaBaseDialog::_getSelector( QObject* obj )
568 QItemSelectionModel* selector = NULL;
570 QString objectName = obj->objectName();
571 QString className = obj->metaObject()->className();
573 HexaWidgetType wtype;
574 QVariant v = obj->property("HexaWidgetType");
575 if ( !v.isValid() ) {
579 wtype = v.value<HexaWidgetType>();
585 case HEXA_TREE: selector = getPatternDataSelectionModel(); break;
590 case CROSSELEMENTS_TREE: selector = getPatternBuilderSelectionModel(); break;
593 case GEOMFACE_TREE: selector = getPatternGeomSelectionModel(); break;
594 case GROUP_TREE: selector = getGroupsSelectionModel(); break;
596 case PROPAGATION_TREE: selector = getMeshSelectionModel(); break;
602 DocumentModel::GeomObj* HexaBaseDialog::getGeomObj(const QModelIndex& index)
604 HEXA_NS::NewShape* aSh = getDocumentModel()->getHexaPtr<HEXA_NS::NewShape*>(index);
605 DocumentModel::GeomObj* geomObj = NULL;
608 geomObj = new DocumentModel::GeomObj;
609 geomObj->shapeName = aSh->getName();
610 geomObj->subid = QString::number(-1);
614 HEXA_NS::EltBase* aSShElt = getDocumentModel()->getHexaPtr(index);
615 HEXA_NS::SubShape* aSSh = dynamic_cast<HEXA_NS::SubShape*>(aSShElt);
618 geomObj = new DocumentModel::GeomObj;
620 if (aSSh->getParentShape() != NULL)
621 shapeName = aSSh->getParentShape()->getName();
622 geomObj->shapeName = shapeName;
623 geomObj->subid = QString::number(aSSh->getIdent());
629 // ============================================================== _onSelectionChanged
631 * Puts elements selected in the model (treeview) in the corresponding
632 * line edit widget (the one that has the focus) of the current dialog box.
634 bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QLineEdit* le )
636 QModelIndexList l = sel.indexes();
637 if ( l.count() == 0 ) return false;
639 //type from selection (first)
640 QModelIndex selected = l[0];
641 int selType = selected.data(HEXA_TREE_ROLE).toInt();
644 QVariant v = le->property("HexaWidgetType");
645 if ( !v.isValid() ) return false;
646 HexaWidgetType wType = v.value<HexaWidgetType>();
648 // check selection compatibility between selection and widget
649 if ( selType != wType ){
650 SUIT_MessageBox::information( 0,
652 tr("%1: Bad type selected\nPlease select a %2.").arg(windowTitle()).arg(_strHexaWidgetType[wType]));
655 if (le->property("GeomWidgetType").isValid())
657 DocumentModel::GeomObj* geomObj = getGeomObj(selected);
660 le->setProperty("GeomObj", QVariant::fromValue<DocumentModel::GeomObj>(*geomObj));
661 setCurrentGeomObj(geomObj);
665 //fill the lineEdit if selection is OK
666 le->setText( selected.data().toString() );// namee
667 le->setProperty("QModelIndex", QVariant::fromValue(selected) );
668 _index[le] = selected;
670 QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(_currentObj);
671 if (selected.isValid() && lineEdit != NULL)
672 setFocusToNextField();
677 // ============================================================== _onSelectionChanged
679 * Puts elements selected in the model (treeview) in the corresponding list widget
680 * of the current dialog box.
682 bool HexaBaseDialog::_onSelectionChanged( const QItemSelection& sel, QListWidget* lw )
684 QModelIndexList l = sel.indexes();
686 if ( l.count() == 0 ) return false;
689 QVariant v = lw->property("HexaWidgetType");
690 if ( !v.isValid() ) return false;
691 HexaWidgetType wType = v.value<HexaWidgetType>();
693 //fill the listWidget
694 QListWidgetItem* item = NULL;
698 foreach( const QModelIndex& isel, l ){
699 // if ( lw->count() == maxSize) break;
700 selType = isel.data(HEXA_TREE_ROLE).toInt();
701 if ( selType != wType ){ // check selection compatibility between selection and widget
702 SUIT_MessageBox::information( 0,
704 tr("%1: Bad type selected\nPlease select a %2.").arg(windowTitle()).arg( _strHexaWidgetType[wType]) );
707 // add selection to listWidget if selection is OK
708 selName = isel.data().toString();
709 QList<QListWidgetItem *> twice = lw->findItems( selName, Qt::MatchExactly);
710 if ( twice.count() == 0 ){
711 item = new QListWidgetItem( selName );
712 item->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(isel) );
713 item->setData(LW_DATA_ROLE, isel.data(HEXA_DATA_ROLE));
714 if (lw->property("GeomWidgetType").isValid())
716 DocumentModel::GeomObj* geomObj = getGeomObj(isel);
718 item->setData(LW_ASSOC_ROLE, QVariant::fromValue<DocumentModel::GeomObj>(*geomObj));
727 // ============================================================== onSelectionChanged
729 * Puts elements selected in the model in the corresponding widget (list widget or line edit)
730 * of the current dialog box.
732 void HexaBaseDialog::onSelectionChanged( const QItemSelection& sel, const QItemSelection& unsel )
734 QString className = metaObject()->className();
736 // highlightSelectedAssocs();
737 QItemSelectionModel* selector = dynamic_cast<QItemSelectionModel*>(sender());
739 if ( _selectionMutex ) return;
741 QLineEdit* aLineEdit = NULL;
742 QListWidget* aListWidget = NULL;
743 aLineEdit = dynamic_cast<QLineEdit*>(_currentObj);
745 if ( aLineEdit){ //fill the lineedit with selection
746 selOk = _onSelectionChanged( sel, aLineEdit );
748 aListWidget = dynamic_cast<QListWidget*>(_currentObj);
749 if ( aListWidget){ //fill the listWidget with selection
750 selOk = _onSelectionChanged( sel, aListWidget );
753 if ( !selOk && selector && ( aLineEdit || aListWidget ) ){
754 selector->clearSelection();
758 // ============================================================== showEvent
759 void HexaBaseDialog::showEvent( QShowEvent * event )
761 QString className = metaObject()->className();
763 if (getDocumentModel() == NULL)
765 QDialog::showEvent ( event );
769 if ( _editMode == INFO_MODE ){
770 getDocumentModel()->allowEdition();
772 getDocumentModel()->disallowEdition();
775 //Connect to salome selection signals
776 if (HEXABLOCKGUI::selectionMgr() != NULL)
778 connect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()),
779 this, SLOT(onCurrentSelectionChanged()), Qt::UniqueConnection );
782 //Connect to vtk window activation signals
783 if (HEXABLOCKGUI::currentDocGView->getViewWindow() != NULL)
785 connect( HEXABLOCKGUI::currentDocGView->getViewWindow()->getViewManager(), SIGNAL( activated(SUIT_ViewManager*) ),
786 this, SLOT( onWindowActivated(SUIT_ViewManager*) ), Qt::UniqueConnection );
789 //connect to occ window activation signals
790 if (HEXABLOCKGUI::currentOccGView->getViewWindow() != NULL)
792 connect( HEXABLOCKGUI::currentOccGView->getViewWindow()->getViewManager(),
793 SIGNAL( activated(SUIT_ViewManager*) ),
794 this, SLOT( onWindowActivated(SUIT_ViewManager*) ), Qt::UniqueConnection );
797 //connect model selection signals
798 connectDocumentGraphicView();
800 QDialog::showEvent ( event );
804 // ============================================================== hideEvent
805 void HexaBaseDialog::hideEvent ( QHideEvent * event )
807 QString className = metaObject()->className();
808 if (getDocumentModel() == NULL) return;
810 //Disconnection salome selection signals
811 if (HEXABLOCKGUI::selectionMgr() != NULL)
812 disconnect( HEXABLOCKGUI::selectionMgr() , SIGNAL(currentSelectionChanged()),
813 this, SLOT(onCurrentSelectionChanged()) );
815 //Disconnect vtk window activation signals
816 if (HEXABLOCKGUI::currentDocGView->getViewWindow() != NULL)
817 disconnect( HEXABLOCKGUI::currentDocGView->getViewWindow()->getViewManager(),
818 SIGNAL( activated(SUIT_ViewManager*) ),
819 this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
821 //Disconnect occ window activation signals
822 if (HEXABLOCKGUI::currentOccGView->getViewWindow() != NULL)
823 disconnect( HEXABLOCKGUI::currentOccGView->getViewWindow()->getViewManager(),
824 SIGNAL( activated(SUIT_ViewManager*) ),
825 this, SLOT( onWindowActivated(SUIT_ViewManager*) ) );
827 //Disconnect model selection signals
828 disconnectDocumentGraphicView();
830 getDocumentModel()->allowEdition();
832 QDialog::hideEvent( event );
835 // ============================================================== updateButtonBox
836 void HexaBaseDialog::updateButtonBox()
840 // ============================================================== updateName
841 void HexaBaseDialog::updateName()
843 if (!getDocumentModel()) return;
844 if ( getPatternDataSelectionModel() == NULL ) return;
845 const PatternDataModel* patternDataModel = getPatternDataModel();
846 if (patternDataModel == NULL) return;
848 QLineEdit* lineEdit = dynamic_cast<QLineEdit*>(sender());
849 if (!lineEdit) return;
850 QString newName = lineEdit->text();
851 if ( newName.isEmpty() ) return;
853 QVariant v = lineEdit->property("QModelIndex");
854 if ( !v.isValid() ) return;
856 QModelIndex index = v.value<QModelIndex>();
857 if ( index.isValid() )
858 getDocumentModel()->setName( patternDataModel->mapToSource(index), newName );
861 // ============================================================== updateDefaultName
862 void HexaBaseDialog::updateDefaultName(QLineEdit* name_field, HEXA_NS::EnumElt type)
864 if (getDocumentModel() == NULL || name_field == NULL) return;
866 HEXA_NS::Document* doc = getDocumentModel()->getHexaDocument();
867 if (doc == NULL) return;
869 name_field->setText(doc->getNextName(type).c_str());
872 // ============================================================== selectElementOfModel
873 /*Selects in the model (treeview) elements selected in a listwidget,
874 * or an element in a line edit.*/
876 void HexaBaseDialog::selectElementOfModel()
878 if (getPatternDataSelectionModel() == NULL) return;
880 QListWidget* currentListWidget = dynamic_cast<QListWidget*>( sender() );
881 if ( !currentListWidget ) return;
883 _selectionMutex = true;
885 QList<QListWidgetItem *> sel = currentListWidget->selectedItems();
887 getPatternDataSelectionModel()->clearSelection();
888 foreach ( QListWidgetItem *item, sel ){
889 // index = item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>(); //unsafe: index can change in the tree
890 index = getPatternDataSelectionModel()->indexBy(HEXA_DATA_ROLE, item->data(LW_DATA_ROLE));
891 if ( index.isValid() )
893 getPatternDataSelectionModel()->select( index, QItemSelectionModel::Select );
896 _selectionMutex = false;
900 // ============================================================== _isLineOrListWidget
902 * Return true is the widget is a line or a list
905 bool HexaBaseDialog::_isLineOrListWidget(QObject *widget)
907 if (widget == NULL) return false;
909 QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(widget);
910 QListWidget *listWidget = dynamic_cast<QListWidget*>(widget);
911 return (lineEdit != NULL) || (listWidget != NULL);
913 }//_isLineOrListWidget
916 // ============================================================== _highlightWidget
918 * Highlight the given widget with the given color.
920 void HexaBaseDialog::_highlightWidget(QObject *obj, Qt::GlobalColor clr)
922 if (!_isLineOrListWidget(obj)) return;
924 QWidget *widget = dynamic_cast<QWidget*>(obj); //sure it's not NULL (_isLineOrListWidget(obj))
925 QPalette palette1 = widget->palette();
926 palette1.setColor(widget->backgroundRole(), clr);
927 widget->setPalette(palette1);
932 // ============================================================== _updateCurrentObject
933 void HexaBaseDialog::_updateCurrentObject(QObject* obj)
935 _highlightWidget(_currentObj, Qt::white);
937 _highlightWidget(obj, Qt::yellow);
940 // ============================================================== eventFilter
942 * Handles events from the treeview and the dialog boxes.
944 bool HexaBaseDialog::eventFilter(QObject *obj, QEvent *event)
946 // highlightSelectedAssocs();
947 QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(obj);
948 QListWidget *listWidget = dynamic_cast<QListWidget*>(obj);
949 HexaBaseDialog *dialog = dynamic_cast<HexaBaseDialog*>(obj);
951 if ( event->type() == QEvent::KeyPress )
953 if ( ((QKeyEvent*)event)->key() == Qt::Key_Return)
955 setFocusToNextField();
960 if ( event->type() == QEvent::FocusOut ){
961 QString className = obj->metaObject()->className();
962 QString objectName = obj->objectName();
965 if ( event->type() == QEvent::FocusIn ){
966 QString className = obj->metaObject()->className();
967 QString objectName = obj->objectName();
974 /* ON FOCUS ON A WIDGET*/
979 QItemSelectionModel *selector = 0;
982 if (getObjectViewType(obj) == HEXABLOCKGUI::VTK)
983 _allowVTKSelection( obj );
986 if (getObjectViewType(obj) == HEXABLOCKGUI::OCC)
987 _allowOCCSelection( obj );
989 //If the widget is a geom line edit highlight its content in the occ view
990 if (lineEdit != NULL && getPatternDataSelectionModel() != NULL &&
991 getObjectViewType(obj) == HEXABLOCKGUI::OCC && !lineEdit->text().isEmpty())
993 //highlight element in the OCC View
994 QMultiMap<QString, int> geomElts;
995 DocumentModel::GeomObj geomObj;
996 QVariant v = lineEdit->property("GeomObj");
999 geomObj = v.value<DocumentModel::GeomObj>();
1000 geomElts.insert( geomObj.shapeName, geomObj.subid.toInt() );
1002 HEXABLOCKGUI::currentOccGView->highlight(geomElts);
1005 //Depending of focused widget type, get the right selector for it
1006 selector = _getSelector( obj );
1007 if ( selector == NULL )
1009 _updateCurrentObject(obj);
1013 if ( _currentObj != obj && (lineEdit || listWidget) )
1014 selector->clearSelection();
1016 _updateCurrentObject(obj);
1018 //If there is a current selection fill the widget with it
1019 if ( selector->hasSelection() ){
1020 // QItemSelection currentSelection = selector->selection();
1021 // bool selOk = false;
1022 // if ( lineEdit ){ //element can be from lineEdit
1023 // selOk = _onSelectionChanged( currentSelection, lineEdit );
1024 // } else if ( listWidget ){
1025 // selOk = _onSelectionChanged( currentSelection, listWidget );
1027 // if ( !selOk && ( lineEdit || listWidget ) ){
1028 // selector->clearSelection();
1031 } else { //If the widget contains an hexa element, select it in model/view
1032 if ( lineEdit ){ //element can be from lineEdit
1033 v = lineEdit->property("QModelIndex");
1034 if ( !v.isValid() ) {
1035 //return QObject::eventFilter(obj, event);
1038 index = v.value<QModelIndex>();
1040 _selectionMutex = true;
1041 selector->select( index, QItemSelectionModel::Clear );
1042 selector->select( index, QItemSelectionModel::Select );
1043 _selectionMutex = false;
1046 if ( dialog ){ //element can be from a dialog box
1047 v = dialog->property("QModelIndex");
1048 if ( !v.isValid() ) {
1049 //return QObject::eventFilter(obj, event);
1052 index = v.value<QModelIndex>();
1053 _selectionMutex = true;
1054 selector->select( index, QItemSelectionModel::Clear );
1055 selector->select( index, QItemSelectionModel::Select );
1056 _selectionMutex = false;
1063 // ------------------------- VERTEX ----------------------------------
1064 // ============================================================== Constructeur
1065 VertexDialog::VertexDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1066 HexaBaseDialog(parent, editmode, f),
1069 _helpFileName = "gui_vertex.html";
1071 _initWidget(editmode);
1072 // setFocusProxy( name_le );
1074 if ( editmode == NEW_MODE ){
1075 setWindowTitle( tr("Vertex Construction") );
1076 } else if ( editmode == UPDATE_MODE ){
1077 setWindowTitle( tr("Vertex Modification") );
1079 else if ( editmode == INFO_MODE){
1080 setWindowTitle( tr("Vertex Information") );
1084 // ============================================================== Destructeur
1085 VertexDialog::~VertexDialog()
1090 // ============================================================== _initInputWidget
1091 void VertexDialog::_initInputWidget( Mode editmode )
1093 x_spb->setRange(VERTEX_COORD_MIN, VERTEX_COORD_MAX);
1094 y_spb->setRange(VERTEX_COORD_MIN, VERTEX_COORD_MAX);
1095 z_spb->setRange(VERTEX_COORD_MIN, VERTEX_COORD_MAX);
1097 // setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1098 installEventFilter(this);
1099 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1100 name_le->installEventFilter(this);
1102 if (editmode == INFO_MODE)
1104 name_le->setReadOnly(true);
1105 x_spb->setReadOnly(true);
1106 y_spb->setReadOnly(true);
1107 z_spb->setReadOnly(true);
1110 //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()));
1113 // ============================================================== clear
1114 void VertexDialog::clear()
1118 modelUnregister(this);
1121 // ============================================================== setValue
1122 void VertexDialog::setValue(HEXA_NS::Vertex* v)
1125 name_le->setText( v->getName() );
1128 x_spb->setValue( v->getX() );
1129 y_spb->setValue( v->getY() );
1130 z_spb->setValue( v->getZ() );
1132 if ( getPatternDataSelectionModel() != NULL ){
1133 QModelIndex iv = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v) );
1135 setProperty( "QModelIndex", QVariant::fromValue<QModelIndex>(iv) );
1136 name_le->setProperty( "QModelIndex", QVariant::fromValue<QModelIndex>(iv) );
1142 // ============================================================== getValue
1143 HEXA_NS::Vertex* VertexDialog::getValue()
1149 // ============================================================== apply
1150 bool VertexDialog::apply(QModelIndex& result)
1152 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
1155 SUIT_OverrideCursor wc;
1156 if ( !getDocumentModel() ) return false;
1157 if ( !getPatternDataSelectionModel() ) return false;
1158 const PatternDataModel* patternDataModel = getPatternDataModel();
1159 if ( !patternDataModel ) return false;
1163 QModelIndex iVertex;
1164 double newX = x_spb->value();
1165 double newY = y_spb->value();
1166 double newZ = z_spb->value();
1168 if ( _editMode == UPDATE_MODE){
1169 QVariant v = property("QModelIndex");
1171 iVertex = patternDataModel->mapToSource( v.value<QModelIndex>() );
1172 if ( iVertex.isValid() )
1173 isOk = getDocumentModel()->updateVertex( iVertex, newX, newY, newZ );
1175 } else if ( _editMode == NEW_MODE){
1176 iVertex = getDocumentModel()->addVertex( newX, newY, newZ );
1177 if ( iVertex.isValid() )
1183 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "VERTEX UPDATE/CONSTRUCTION" ) );
1187 QString newName = name_le->text();
1188 if ( !newName.isEmpty() )/*{*/
1189 getDocumentModel()->setName( iVertex, newName );
1191 //the default name in the dialog box
1192 HEXA_NS::Vertex* v = getDocumentModel()->getHexaPtr<HEXA_NS::Vertex*>(iVertex);
1194 updateDefaultName(name_le, v->getType());
1196 // to select/highlight result
1197 result = patternDataModel->mapFromSource(iVertex);
1199 // updateDialogBoxName(name_le, result);
1200 // const char *defaultName = getDocumentModel()->getHexaPtr(last)->getName();
1205 // ------------------------- EDGE ----------------------------------
1207 // ============================================================== Constructeur
1208 EdgeDialog::EdgeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1209 HexaBaseDialog(parent, editmode, f),
1212 _helpFileName = "gui_edge.html";
1214 _initWidget(editmode);
1216 // rb0->setFocusProxy( v0_le_rb0 );
1217 // rb1->setFocusProxy( vex_le_rb1 );
1219 if ( editmode == INFO_MODE ){
1220 setWindowTitle( tr("Edge Information") );
1223 else if ( editmode == UPDATE_MODE ){
1224 setWindowTitle( tr("Edge Modification") );
1231 // ============================================================== Destructeur
1232 EdgeDialog::~EdgeDialog()
1237 // ============================================================== _initInputWidget
1238 void EdgeDialog::_initInputWidget( Mode editmode )
1241 QValidator *validator = new QRegExpValidator(rx, this);
1243 // setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1244 installEventFilter(this);
1246 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1247 name_le->installEventFilter(this);
1249 v0_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1250 v1_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1251 v0_le_rb0->setValidator( validator );
1252 v1_le_rb0->setValidator( validator );
1253 v0_le_rb0->installEventFilter(this);
1254 v1_le_rb0->installEventFilter(this);
1256 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1257 vec_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
1258 vex_le_rb1->setValidator( validator );
1259 vec_le_rb1->setValidator( validator );
1260 vex_le_rb1->installEventFilter(this);
1261 vec_le_rb1->installEventFilter(this);
1263 v0_le_rb0->setReadOnly(true);
1264 v1_le_rb0->setReadOnly(true);
1265 vex_le_rb1->setReadOnly(true);
1266 vec_le_rb1->setReadOnly(true);
1268 if (editmode == INFO_MODE)
1269 name_le->setReadOnly(true);
1271 //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) );
1276 // ============================================================== Clear
1277 void EdgeDialog::clear()
1282 modelUnregister(v0_le_rb0);
1285 modelUnregister(v1_le_rb0);
1287 vex_le_rb1->clear();
1288 modelUnregister(vex_le_rb1);
1290 vec_le_rb1->clear();
1291 modelUnregister(vec_le_rb1);
1293 modelUnregister(this);
1298 // ============================================================== setValue
1299 void EdgeDialog::setValue(HEXA_NS::Edge* e)
1301 HEXA_NS::Vertex* v0 = e->getVertex(0);
1302 HEXA_NS::Vertex* v1 = e->getVertex(1);
1303 // HEXA_NS::EltBase* e0 = e;
1304 // HEXA_NS::EltBase* v0 = e->getVertex(0);
1305 // HEXA_NS::EltBase* v1 = e->getVertex(1);
1307 name_le->setText( e->getName() );
1308 v0_le_rb0->setText( v0->getName() );
1309 v1_le_rb0->setText( v1->getName() );
1311 if ( getPatternDataSelectionModel() ){
1312 QModelIndex ie = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e) );
1313 QModelIndex iv0 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v0) );
1314 QModelIndex iv1 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v1) );
1316 name_le->setProperty( "QModelIndex", QVariant::fromValue(ie) );
1317 v0_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv0) );
1318 v1_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv1) );
1324 // ============================================================== getValue
1325 HEXA_NS::Edge* EdgeDialog::getValue()
1330 // ============================================================== apply
1331 bool EdgeDialog::apply(QModelIndex& result)
1333 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
1336 SUIT_OverrideCursor wc;
1337 if ( !getDocumentModel() ) return false;
1338 const PatternDataModel* patternDataModel = getPatternDataModel();
1339 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
1340 if ( !patternDataModel || !patternBuilderModel ) return false;
1344 if ( rb0->isChecked() ){
1345 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb0] );
1346 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb0] );
1347 if ( iv0.isValid()&& iv1.isValid() ){
1348 iEdge = getDocumentModel()->addEdgeVertices( iv0, iv1 );
1350 } else if ( rb1->isChecked() ){
1351 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
1352 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb1] );
1353 if ( ivex.isValid() && ivec.isValid() ){
1354 iEdge = getDocumentModel()->addEdgeVector( ivex, ivec );
1358 if ( !iEdge.isValid() ){
1359 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT BUILD EDGE" ) );
1362 _value = iEdge.model()->data(iEdge, HEXA_DATA_ROLE).value<HEXA_NS::Edge*>();
1364 QString newName = name_le->text();
1365 if ( !newName.isEmpty() )/*{*/
1366 getDocumentModel()->setName( iEdge, newName );
1368 //update the default name in the dialog box
1370 updateDefaultName(name_le, _value->getType());
1372 result = patternDataModel->mapFromSource(iEdge);
1378 // ------------------------- QUAD ----------------------------------
1380 // ============================================================== Constructeur
1381 QuadDialog::QuadDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1382 HexaBaseDialog(parent, editmode, f),
1385 _helpFileName = "gui_quadrangle.html";
1387 _initWidget(editmode);
1388 // rb0->setFocusProxy( v0_le_rb0 );
1389 // rb1->setFocusProxy( e0_le_rb1 );
1392 if ( editmode == INFO_MODE ){
1393 setWindowTitle( tr("Quad Information") );
1397 // ============================================================== Destructeur
1398 QuadDialog::~QuadDialog()
1402 // ============================================================== _initInputWidget
1403 void QuadDialog::_initInputWidget( Mode editmode )
1406 QValidator *validator = new QRegExpValidator(rx, this);
1408 // setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
1409 installEventFilter(this);
1411 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
1412 name_le->installEventFilter(this);
1414 v0_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1415 v1_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1416 v2_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1417 v3_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1419 v0_le_rb0->setValidator( validator );
1420 v1_le_rb0->setValidator( validator );
1421 v2_le_rb0->setValidator( validator );
1422 v3_le_rb0->setValidator( validator );
1423 v0_le_rb0->installEventFilter(this);
1424 v1_le_rb0->installEventFilter(this);
1425 v2_le_rb0->installEventFilter(this);
1426 v3_le_rb0->installEventFilter(this);
1428 e0_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1429 e1_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1430 e2_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1431 e3_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
1433 e0_le_rb1->setValidator( validator );
1434 e1_le_rb1->setValidator( validator );
1435 e2_le_rb1->setValidator( validator );
1436 e3_le_rb1->setValidator( validator );
1438 e0_le_rb1->installEventFilter(this);
1439 e1_le_rb1->installEventFilter(this);
1440 e2_le_rb1->installEventFilter(this);
1441 e3_le_rb1->installEventFilter(this);
1443 v0_le_rb0->setReadOnly(true);
1444 v1_le_rb0->setReadOnly(true);
1445 v2_le_rb0->setReadOnly(true);
1446 v3_le_rb0->setReadOnly(true);
1448 e0_le_rb1->setReadOnly(true);
1449 e1_le_rb1->setReadOnly(true);
1450 e2_le_rb1->setReadOnly(true);
1451 e3_le_rb1->setReadOnly(true);
1453 if (editmode == INFO_MODE)
1454 name_le->setReadOnly(true);
1456 //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) );
1460 // ============================================================== clear
1461 void QuadDialog::clear()
1463 //Clear the dialog and unregister it from the model
1464 QModelIndex invalidIndex;
1469 modelUnregister(v0_le_rb0);
1472 modelUnregister(v1_le_rb0);
1475 modelUnregister(v2_le_rb0);
1478 modelUnregister(v3_le_rb0);
1481 modelUnregister(e0_le_rb1);
1484 modelUnregister(e1_le_rb1);
1487 modelUnregister(e2_le_rb1);
1490 modelUnregister(e3_le_rb1);
1492 modelUnregister(this);
1497 // ============================================================== setValue
1498 void QuadDialog::setValue(HEXA_NS::Quad* q)
1500 Q_ASSERT( q->countEdge() == 4 );
1501 Q_ASSERT( q->countVertex() == 4 );
1504 name_le->setText( q->getName() );
1507 HEXA_NS::Vertex* v0 = q->getVertex(0);
1508 HEXA_NS::Vertex* v1 = q->getVertex(1);
1509 HEXA_NS::Vertex* v2 = q->getVertex(2);
1510 HEXA_NS::Vertex* v3 = q->getVertex(3);
1512 v0_le_rb0->setText( v0->getName() );
1513 v1_le_rb0->setText( v1->getName() );
1514 v2_le_rb0->setText( v2->getName() );
1515 v3_le_rb0->setText( v3->getName() );
1519 HEXA_NS::Edge* e0 = q->getEdge(0);
1520 HEXA_NS::Edge* e1 = q->getEdge(1);
1521 HEXA_NS::Edge* e2 = q->getEdge(2);
1522 HEXA_NS::Edge* e3 = q->getEdge(3);
1524 e0_le_rb1->setText( e0->getName() );
1525 e1_le_rb1->setText( e1->getName() );
1526 e2_le_rb1->setText( e2->getName() );
1527 e3_le_rb1->setText( e3->getName() );
1529 if ( getPatternDataSelectionModel() ){
1530 QModelIndex iq = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(q) );
1532 QModelIndex iv0 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v0) );
1533 QModelIndex iv1 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v1) );
1534 QModelIndex iv2 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v2) );
1535 QModelIndex iv3 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v3) );
1537 QModelIndex ie0 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e0) );
1538 QModelIndex ie1 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e1) );
1539 QModelIndex ie2 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e2) );
1540 QModelIndex ie3 = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(e3) );
1542 name_le->setProperty( "QModelIndex", QVariant::fromValue(iq) );
1544 v0_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv0) );
1545 v1_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv1) );
1546 v2_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv2) );
1547 v3_le_rb0->setProperty( "QModelIndex", QVariant::fromValue(iv3) );
1549 e0_le_rb1->setProperty( "QModelIndex", QVariant::fromValue(ie0) );
1550 e1_le_rb1->setProperty( "QModelIndex", QVariant::fromValue(ie1) );
1551 e2_le_rb1->setProperty( "QModelIndex", QVariant::fromValue(ie2) );
1552 e3_le_rb1->setProperty( "QModelIndex", QVariant::fromValue(ie3) );
1558 // ============================================================== getValue
1559 HEXA_NS::Quad* QuadDialog::getValue()
1565 // ============================================================== apply
1566 bool QuadDialog::apply(QModelIndex& result)
1568 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
1571 SUIT_OverrideCursor wc;
1572 if ( !getDocumentModel() ) return false;
1573 const PatternDataModel* patternDataModel = getPatternDataModel();
1574 if ( !patternDataModel ) return false;
1578 if ( rb0->isChecked() ){ //vertices
1579 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb0] );
1580 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb0] );
1581 QModelIndex iv2 = patternDataModel->mapToSource( _index[v2_le_rb0] );
1582 QModelIndex iv3 = patternDataModel->mapToSource( _index[v3_le_rb0] );
1588 iQuad = getDocumentModel()->addQuadVertices( iv0, iv1, iv2, iv3 );
1590 } else if ( rb1->isChecked() ){ //edges
1591 QModelIndex ie0 = patternDataModel->mapToSource( _index[e0_le_rb1] );
1592 QModelIndex ie1 = patternDataModel->mapToSource( _index[e1_le_rb1] );
1593 QModelIndex ie2 = patternDataModel->mapToSource( _index[e2_le_rb1] );
1594 QModelIndex ie3 = patternDataModel->mapToSource( _index[e3_le_rb1] );
1600 iQuad = getDocumentModel()->addQuadEdges( ie0, ie1, ie2, ie3 );
1604 if ( !iQuad.isValid() ){
1605 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT BUILD QUAD" ) );
1608 _value = iQuad.model()->data(iQuad, HEXA_DATA_ROLE).value<HEXA_NS::Quad *>();
1610 QString newName = name_le->text();
1611 if ( !newName.isEmpty() )/*{*/
1612 getDocumentModel()->setName( iQuad, newName );
1614 //the default name in the dialog box
1616 updateDefaultName(name_le, _value->getType());
1618 // to select/highlight result
1619 result = patternDataModel->mapFromSource(iQuad);
1626 // ------------------------- HEXA ----------------------------------
1628 // ============================================================== HexaDialog
1630 HexaDialog::HexaDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1631 HexaBaseDialog(parent, editmode, f),
1634 _helpFileName = "gui_hexahedron.html";
1636 _initWidget(editmode);
1637 // quads_rb->setFocusProxy( quads_lw );
1638 // vertices_rb->setFocusProxy( vertices_lw );
1640 // quads_rb->setFocus();
1642 if ( editmode == INFO_MODE ){
1643 setWindowTitle( tr("Hexahedron Information") );
1647 // ============================================================== Destructeur
1648 HexaDialog::~HexaDialog()
1653 // ============================================================== _initInputWidget
1654 void HexaDialog::_initInputWidget( Mode editmode )
1658 // setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
1659 installEventFilter(this);
1661 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
1662 name_le->installEventFilter(this);
1664 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
1665 quads_lw->installEventFilter(this);
1667 vertices_lw->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1668 vertices_lw->installEventFilter(this);
1671 if ( editmode != INFO_MODE ) {
1672 // delete item from listwidget
1673 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
1674 QShortcut* delVertexShortcut = new QShortcut( QKeySequence(Qt::Key_X), vertices_lw );
1675 delQuadShortcut->setContext( Qt::WidgetShortcut );
1676 delVertexShortcut->setContext( Qt::WidgetShortcut );
1677 connect(delQuadShortcut, SIGNAL(activated()), this, SLOT(deleteQuadItem()));
1678 connect(delVertexShortcut, SIGNAL(activated()), this, SLOT(deleteVertexItem()));
1681 //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) );
1682 // highlight item on model view (VTK) from listwidget
1683 connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection );
1684 connect( vertices_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection );
1686 if ( editmode != INFO_MODE)
1688 connect( vertices_rb, SIGNAL(clicked()), vertices_lw, SLOT(setFocus()));
1689 connect( quads_rb, SIGNAL(clicked()), quads_lw, SLOT(setFocus()));
1692 connect( vertices_rb, SIGNAL(clicked()), this, SLOT(refreshHighlight()), Qt::UniqueConnection);
1693 connect( quads_rb, SIGNAL(clicked()), this, SLOT(refreshHighlight()), Qt::UniqueConnection);
1695 if (editmode == INFO_MODE)
1696 name_le->setReadOnly(true);
1700 // ============================================================== clear
1701 void HexaDialog::clear()
1706 modelUnregister(quads_lw);
1708 vertices_lw->clear();
1709 modelUnregister(vertices_lw);
1711 modelUnregister(this);
1714 // ============================================================== getAssocsVTK
1716 * Returns elements currently associated to vtk
1718 QModelIndexList HexaDialog::getAssocsVTK()
1720 QModelIndexList assocs;
1721 QModelIndex iQuad, iVertex;
1722 QListWidgetItem* item = NULL;
1724 const PatternDataModel* patternDataModel = getPatternDataModel();
1725 if (patternDataModel == NULL) return assocs;
1726 if (quads_rb->isChecked())
1728 //ListWidget content
1729 for ( int r = 0; r < quads_lw->count(); ++r ){
1730 item = quads_lw->item(r);
1731 iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
1732 if ( iQuad.isValid() )
1737 else if (vertices_rb->isChecked())
1739 //ListWidget content
1740 for ( int r = 0; r < vertices_lw->count(); ++r ){
1741 item = vertices_lw->item(r);
1742 iVertex = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
1743 if ( iVertex.isValid() )
1752 // ============================================================== updateButtonBox
1753 void HexaDialog::updateButtonBox()
1755 if ( quads_rb->isChecked() ){ // build from quads count() must be between [2,6]
1756 int nbQuads = quads_lw->count();
1757 //std::cout << "nbQuads => " << nbQuads << std::endl;
1758 if ( nbQuads >= 2 && nbQuads <= 6 ){
1759 //_applyCloseButton->setEnabled(true);
1760 _applyButton->setEnabled(true);
1761 // _applyCloseButton->setFlat( false );
1762 // _applyButton->setFlat( false );
1764 //_applyCloseButton->setEnabled(false);
1765 _applyButton->setEnabled(false);
1766 // _applyCloseButton->setFlat( true );
1767 // _applyButton->setFlat( true );
1769 } else if ( vertices_rb->isChecked() ){ // build from vertices count() must be equals to 8
1770 int nbVertices = vertices_lw->count();
1771 //std::cout << "nbVertices => " << nbVertices << std::endl;
1772 if ( nbVertices == 8 ){
1773 //_applyCloseButton->setEnabled(true);
1774 _applyButton->setEnabled(true);
1775 // _applyCloseButton->setFlat( false );
1776 // _applyButton->setFlat( false );
1778 //_applyCloseButton->setEnabled(false);
1779 _applyButton->setEnabled(false);
1780 // _applyCloseButton->setFlat( true );
1781 // _applyButton->setFlat( true );
1786 // ============================================================== deleteQuadItem
1787 void HexaDialog::deleteQuadItem()
1789 delete quads_lw->currentItem();
1793 // ============================================================== deleteVertexItem
1794 void HexaDialog::deleteVertexItem()
1796 delete vertices_lw->currentItem();
1800 // ============================================================== _setValueQuads
1801 void HexaDialog::_setValueQuads( HEXA_NS::Hexa* h )
1803 QListWidgetItem *qItem = NULL;
1804 HEXA_NS::Quad *q = NULL;
1806 if (getPatternDataSelectionModel() == NULL) return;
1808 for( int i = 0; i <= 5; ++i ){
1810 qIndex = getPatternDataSelectionModel()->indexBy( HEXA_ENTRY_ROLE, QString::number(reinterpret_cast<intptr_t>(q)) );
1811 qItem = new QListWidgetItem( q->getName() );
1812 qItem->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(qIndex) );
1813 qItem->setData(LW_DATA_ROLE, qIndex.data(HEXA_DATA_ROLE));
1814 quads_lw->addItem( qItem );
1818 // ============================================================== _setValueVertices
1819 void HexaDialog::_setValueVertices( HEXA_NS::Hexa* h )
1821 QListWidgetItem *vItem = NULL;
1822 HEXA_NS::Vertex* v = NULL;
1824 if (getPatternDataSelectionModel() == NULL) return;
1825 vertices_lw->clear();
1826 for( int i = 0; i <= 7; ++i ){
1827 v = h->getVertex(i);
1828 vIndex = getPatternDataSelectionModel()->indexBy( HEXA_ENTRY_ROLE, QString::number(reinterpret_cast<intptr_t>(v)) );
1829 vItem = new QListWidgetItem( v->getName() );
1830 vItem->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(vIndex) );
1831 vItem->setData(LW_DATA_ROLE, vIndex.data(HEXA_DATA_ROLE));
1832 vertices_lw->addItem( vItem );
1836 // ============================================================== setValue
1837 void HexaDialog::setValue(HEXA_NS::Hexa* h)
1840 name_le->setText( h->getName() );
1842 if ( getPatternDataSelectionModel()){
1843 QModelIndex hIndex = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(h) );
1844 _setValueVertices(h);
1846 name_le->setProperty( "QModelIndex", QVariant::fromValue(hIndex) );
1851 // ============================================================== getValue
1852 HEXA_NS::Hexa* HexaDialog::getValue()
1857 // ============================================================== apply
1858 bool HexaDialog::apply(QModelIndex& result)
1860 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
1863 SUIT_OverrideCursor wc;
1864 if ( !getDocumentModel() ) return false;
1865 const PatternDataModel* patternDataModel = getPatternDataModel();
1866 if ( !patternDataModel ) return false;
1870 QListWidget* currentLw = NULL;
1871 QListWidgetItem* item = NULL;
1873 if ( quads_rb->isChecked() )
1874 currentLw = dynamic_cast<QListWidget*>( quads_lw );
1875 else if ( vertices_rb->isChecked() )
1876 currentLw = dynamic_cast<QListWidget*>( vertices_lw );
1879 QModelIndexList iElts;
1880 for ( int r = 0; r < currentLw->count(); ++r){
1881 item = currentLw->item(r);
1882 iElt = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
1883 if ( iElt.isValid() )
1887 if ( quads_rb->isChecked() and (iElts.count()>=2 and iElts.count()<=6) ){ // build from quads iElts.count() should be between [2,6]
1888 iHexa = getDocumentModel()->addHexaQuads( iElts );
1889 } else if ( vertices_rb->isChecked() and iElts.count()== 8 ){ // build from vertices
1890 iHexa = getDocumentModel()->addHexaVertices( iElts[0], iElts[1], iElts[2], iElts[3],
1891 iElts[4], iElts[5], iElts[6], iElts[7] );
1894 if ( !iHexa.isValid() ){
1895 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT BUILD HEXA" ) );
1898 _value = iHexa.model()->data(iHexa, HEXA_DATA_ROLE).value<HEXA_NS::Hexa*>();
1900 QString newName = name_le->text();
1901 if ( !newName.isEmpty() )/*{*/
1902 getDocumentModel()->setName( iHexa, newName );
1904 //update the default name in the dialog box
1906 updateDefaultName(name_le, _value->getType());
1908 // to select/highlight result
1909 result = patternDataModel->mapFromSource(iHexa);
1915 // ------------------------- VECTOR ----------------------------------
1917 // ============================================================== Constructeur
1919 VectorDialog::VectorDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
1920 HexaBaseDialog(parent, editmode, f),
1923 _helpFileName = "gui_vector.html";
1925 _initWidget(editmode);
1927 // rb0->setFocusProxy( dx_spb_rb0 );
1928 // rb1->setFocusProxy( v0_le_rb1 );
1930 // setFocusProxy( rb0 );
1932 if ( editmode == INFO_MODE ){
1933 setWindowTitle( tr("Vector Information") );
1938 // ============================================================== Destructeur
1939 VectorDialog::~VectorDialog()
1943 // ============================================================== _initInputWidget
1944 void VectorDialog::_initInputWidget( Mode editmode )
1947 QValidator *validator = new QRegExpValidator(rx, this);
1949 // setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
1950 installEventFilter(this);
1952 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
1953 name_le->installEventFilter(this);
1955 v0_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1956 v0_le_rb1->setValidator( validator );
1957 v0_le_rb1->installEventFilter(this);
1959 v1_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
1960 v1_le_rb1->setValidator( validator );
1961 v1_le_rb1->installEventFilter(this);
1963 if ( editmode == INFO_MODE ){
1964 name_le->setReadOnly(true);
1965 dx_spb_rb0->setReadOnly(true);
1966 dy_spb_rb0->setReadOnly(true);
1967 dz_spb_rb0->setReadOnly(true);
1970 v0_le_rb1->setReadOnly(true);
1971 v1_le_rb1->setReadOnly(true);
1973 //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()) );
1976 // ============================================================== clear
1977 void VectorDialog::clear()
1980 // dx_spb_rb0->clear();
1981 // dy_spb_rb0->clear();
1982 // dz_spb_rb0->clear();
1984 modelUnregister(v0_le_rb1);
1987 modelUnregister(v1_le_rb1);
1989 modelUnregister(this);
1992 // ============================================================== setValue
1993 void VectorDialog::setValue(HEXA_NS::Vector* v)
1995 name_le->setText( v->getName() );
1996 dx_spb_rb0->setValue( v->getDx() );
1997 dy_spb_rb0->setValue( v->getDy() );
1998 dz_spb_rb0->setValue( v->getDz() );
2000 if ( getPatternDataSelectionModel() ){
2001 QModelIndex ivec = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(v) );
2002 name_le->setProperty( "QModelIndex", QVariant::fromValue(ivec) );
2007 // ============================================================== getValue
2008 HEXA_NS::Vector* VectorDialog::getValue()
2013 // ============================================================== apply
2014 bool VectorDialog::apply(QModelIndex& result)
2016 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
2019 SUIT_OverrideCursor wc;
2020 if ( !getDocumentModel() ) return false;
2021 const PatternDataModel* patternDataModel = getPatternDataModel();
2022 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
2023 if ( !patternDataModel || !patternBuilderModel) return false;
2025 QModelIndex iVector;
2027 if ( rb0->isChecked() ){ //scalar
2028 double dx = dx_spb_rb0->value();
2029 double dy = dy_spb_rb0->value();
2030 double dz = dz_spb_rb0->value();
2032 iVector = getDocumentModel()->addVector( dx, dy, dz );
2033 } else if ( rb1->isChecked() ){ //vertices
2034 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb1] );
2035 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb1] );
2039 iVector = getDocumentModel()->addVectorVertices( iv0, iv1 );
2043 if ( !iVector.isValid() ){
2044 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT BUILD VECTOR" ) );
2048 _value = iVector.model()->data(iVector, HEXA_DATA_ROLE).value<HEXA_NS::Vector *>();
2050 QString newName = name_le->text();
2051 if ( !newName.isEmpty() )/*{*/
2052 getDocumentModel()->setName( iVector, newName );
2054 //update the default name in the dialog box
2056 updateDefaultName(name_le, _value->getType());
2058 // to select/highlight result
2059 result = patternBuilderModel->mapFromSource(iVector);
2065 // ============================================================== Constructeur
2066 CylinderDialog::CylinderDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2067 : HexaBaseDialog(parent, editmode, f),
2070 _helpFileName = "gui_cyl.html";
2072 _initWidget(editmode);
2074 if ( editmode == INFO_MODE ){
2075 setWindowTitle( tr("Cylinder Information") );
2079 // ============================================================== Destructeur
2080 CylinderDialog::~CylinderDialog()
2084 // ============================================================== _initInputWidget
2085 void CylinderDialog::_initInputWidget( Mode editmode )
2088 QValidator *validator = new QRegExpValidator(rx, this);
2090 // setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
2091 installEventFilter(this);
2093 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
2094 name_le->installEventFilter(this);
2096 vex_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2097 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2099 vex_le->setValidator( validator );
2100 vec_le->setValidator( validator );
2102 vex_le->installEventFilter(this);
2103 vec_le->installEventFilter(this);
2105 vex_le->setReadOnly(true);
2106 vec_le->setReadOnly(true);
2108 if (editmode == INFO_MODE)
2110 name_le->setReadOnly(true);
2111 r_spb->setReadOnly(true);
2112 h_spb->setReadOnly(true);
2115 //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()));
2118 // ============================================================== clear
2119 void CylinderDialog::clear()
2124 modelUnregister(vex_le);
2127 modelUnregister(vec_le);
2132 modelUnregister(this);
2136 // ============================================================== setValue
2137 void CylinderDialog::setValue(HEXA_NS::Cylinder* c)
2139 HEXA_NS::Vertex* base = c->getBase();
2140 HEXA_NS::Vector* direction = c->getDirection();
2141 double r = c->getRadius();
2142 double h = c->getHeight();
2144 name_le->setText( c->getName() );
2145 vex_le->setText( base->getName() );
2146 vec_le->setText( direction->getName() );
2150 if ( getPatternDataSelectionModel() ){
2151 QModelIndex iCyl = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(c) );
2152 QModelIndex iBase = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(base) );
2153 QModelIndex iDirection = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(direction) );
2155 name_le->setProperty( "QModelIndex", QVariant::fromValue(iCyl) );
2156 vex_le->setProperty( "QModelIndex", QVariant::fromValue(iBase) );
2157 vec_le->setProperty( "QModelIndex", QVariant::fromValue(iDirection) );
2162 // ============================================================== getValue
2163 HEXA_NS::Cylinder* CylinderDialog::getValue()
2170 // ============================================================== apply
2171 bool CylinderDialog::apply(QModelIndex& result)
2173 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
2176 SUIT_OverrideCursor wc;
2177 if ( !getDocumentModel() ) return false;
2178 const PatternDataModel* patternDataModel = getPatternDataModel();
2179 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
2180 if ( !patternDataModel || !patternBuilderModel) return false;
2183 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le] );
2184 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
2185 double r = r_spb->value();
2186 double h = h_spb->value();
2189 && ivec.isValid() ){
2190 iCyl = getDocumentModel()->addCylinder( ivex, ivec, r, h );
2193 if ( !iCyl.isValid() ){
2194 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD CYLINDER" ) );
2198 _value = iCyl.model()->data(iCyl, HEXA_DATA_ROLE).value<HEXA_NS::Cylinder *>();
2200 QString newName = name_le->text();
2201 if (!newName.isEmpty()) /*{*/
2202 getDocumentModel()->setName( iCyl, newName );
2204 //update the default name in the dialog box
2206 updateDefaultName(name_le, _value->getType());
2208 // to select/highlight result
2209 result = patternBuilderModel->mapFromSource(iCyl);
2215 //------------------------------- PipeDialog -----------------------------------
2217 // ============================================================== Constructeur
2219 PipeDialog::PipeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2220 : HexaBaseDialog(parent, editmode, f),
2223 _helpFileName = "gui_pipe.html";
2225 _initWidget(editmode);
2226 // setFocusProxy( vex_le );
2228 if ( editmode == INFO_MODE ){
2229 setWindowTitle( tr("Pipe Information") );
2234 // ============================================================== Destructeur
2235 PipeDialog::~PipeDialog()
2239 // ============================================================== _initInputWidget
2240 void PipeDialog::_initInputWidget( Mode editmode )
2243 QValidator *validator = new QRegExpValidator(rx, this);
2246 // setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
2247 installEventFilter(this);
2249 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
2250 name_le->installEventFilter(this);
2252 //Vertex Field config
2253 vex_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2254 vex_le->installEventFilter(this);
2255 vex_le->setValidator( validator );
2257 //Vector Field config
2258 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2259 vec_le->installEventFilter(this);
2260 vec_le->setValidator( validator );
2263 if ( editmode == INFO_MODE ){
2264 name_le->setReadOnly(true);
2265 ir_spb->setReadOnly(true);
2266 er_spb->setReadOnly(true);
2267 h_spb->setReadOnly(true);
2270 vex_le->setReadOnly(true);
2271 vec_le->setReadOnly(true);
2273 //connect( name_le, SIGNAL(returnPressed()), this, SLOT(updateName()));
2277 // ============================================================== clear
2278 void PipeDialog::clear()
2283 modelUnregister(vex_le);
2286 modelUnregister(vec_le);
2288 modelUnregister(this);
2291 // ============================================================== setValue
2292 void PipeDialog::setValue(HEXA_NS::Pipe* p)
2294 HEXA_NS::Vertex* base = p->getBase();
2295 HEXA_NS::Vector* direction = p->getDirection();
2296 double ir = p->getInternalRadius();
2297 double er = p->getRadius();
2298 double h = p->getHeight();
2300 name_le->setText( p->getName() );
2301 vex_le->setText( base->getName() );
2302 vec_le->setText( direction->getName() );
2303 ir_spb->setValue(ir);
2304 er_spb->setValue(er);
2307 if ( getPatternDataSelectionModel() ){
2308 QModelIndex iPipe = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(p) );
2309 QModelIndex iBase = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(base) );
2310 QModelIndex iDirection = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(direction) );
2312 name_le->setProperty( "QModelIndex", QVariant::fromValue(iPipe) );
2313 vex_le->setProperty( "QModelIndex", QVariant::fromValue(iBase) );
2314 vec_le->setProperty( "QModelIndex", QVariant::fromValue(iDirection) );
2319 // ============================================================== getValue
2320 HEXA_NS::Pipe* PipeDialog::getValue()
2326 // ============================================================== apply
2327 bool PipeDialog::apply(QModelIndex& result)
2329 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
2332 SUIT_OverrideCursor wc;
2333 if ( !getDocumentModel() ) return false;
2334 const PatternDataModel* patternDataModel = getPatternDataModel();
2335 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
2336 if ( !patternDataModel || !patternBuilderModel) return false;
2339 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le] );
2340 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
2341 double ir = ir_spb->value();
2342 double er = er_spb->value();
2343 double h = h_spb->value();
2346 SUIT_MessageBox::information( this, tr( "CANNOT ADD PIPE" ), tr( "External radius must be greather than Internal radius!" ) );
2352 && ivec.isValid() ){
2353 iPipe = getDocumentModel()->addPipe( ivex, ivec, ir, er, h );
2356 if ( !iPipe.isValid() ){
2357 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD PIPE" ) );
2360 _value = iPipe.model()->data(iPipe, HEXA_DATA_ROLE).value<HEXA_NS::Pipe *>();
2362 QString newName = name_le->text();
2363 if ( !newName.isEmpty() )/*{*/
2364 getDocumentModel()->setName( iPipe, newName );
2366 //update the default name in the dialog box
2368 updateDefaultName(name_le, _value->getType());
2370 // to select/highlight result
2371 result = patternBuilderModel->mapFromSource(iPipe);
2377 // ------------------------- MakeGridDialog ----------------------------------
2378 // ( Cartesian, Cylindrical, Spherical )
2380 // ============================================================== Constructeur
2382 MakeGridDialog::MakeGridDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2383 : HexaBaseDialog(parent, editmode, f)
2386 _initWidget(editmode);
2387 rb0->click();// Default : cartesian grid
2388 uniform_rb->click();
2389 // rb0->setFocusProxy( vex_le_rb0 );
2390 // rb1->setFocusProxy( center_le_rb1 );
2391 // rb2->setFocusProxy( vex_le_rb2 );
2392 // setFocusProxy( rb0 );
2394 _helpFileName = "creategrids.html#guicartgrid";
2395 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2396 connect( rb0, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
2397 connect( rb0, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
2399 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2400 connect( rb1, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
2401 connect( rb1, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
2403 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
2404 connect( rb2, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
2405 connect( rb2, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
2409 // ============================================================== Destructeur
2410 MakeGridDialog::~MakeGridDialog()
2414 // ============================================================== _initInputWidget
2415 void MakeGridDialog::_initInputWidget( Mode editmode )
2419 QValidator *validator = new QRegExpValidator(rx, this);
2421 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
2422 installEventFilter(this);
2424 vex_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2425 vec_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2426 vex_le_rb0->setValidator( validator );
2427 vec_le_rb0->setValidator( validator );
2428 vex_le_rb0->installEventFilter(this);
2429 vec_le_rb0->installEventFilter(this);
2431 center_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2432 base_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2433 height_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2434 center_le_rb1->setValidator( validator );
2435 base_le_rb1->setValidator( validator );
2436 height_le_rb1->setValidator( validator );
2437 center_le_rb1->installEventFilter(this);
2438 base_le_rb1->installEventFilter(this);
2439 height_le_rb1->installEventFilter(this);
2441 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
2442 vex_le_rb2->setValidator( validator );
2443 vex_le_rb2->installEventFilter(this);
2445 if ( editmode != INFO_MODE ){
2447 radius_lw->setItemDelegate(new HexaPositiveDoubleSpinBoxDelegate(radius_lw));
2448 radius_lw->setEditTriggers(QAbstractItemView::DoubleClicked);
2450 angle_lw->setItemDelegate(new HexaAngleDoubleSpinBoxDelegate(angle_lw));
2451 angle_lw->setEditTriggers(QAbstractItemView::DoubleClicked);
2453 height_lw->setItemDelegate(new HexaPositiveDoubleSpinBoxDelegate(height_lw));
2454 height_lw->setEditTriggers(QAbstractItemView::DoubleClicked);
2456 connect( add_radius_pb, SIGNAL(clicked()), this, SLOT(addRadiusItem()) );
2457 connect( del_radius_pb, SIGNAL(clicked()), this, SLOT(delRadiusItem()) );
2458 connect( add_angle_pb, SIGNAL(clicked()), this, SLOT(addAngleItem()) );
2459 connect( del_angle_pb, SIGNAL(clicked()), this, SLOT(delAngleItem()) );
2460 connect( add_height_pb, SIGNAL(clicked()), this, SLOT(addHeightItem()) );
2461 connect( del_height_pb, SIGNAL(clicked()), this, SLOT(delHeightItem()) );
2464 vex_le_rb0->setReadOnly(true);
2465 vec_le_rb0->setReadOnly(true);
2466 vex_le_rb2->setReadOnly(true);
2467 center_le_rb1->setReadOnly(true);
2468 base_le_rb1->setReadOnly(true);
2469 height_le_rb1->setReadOnly(true);
2474 // ============================================================== clear
2475 void MakeGridDialog::clear()
2477 vex_le_rb0->clear();
2478 modelUnregister(vex_le_rb0);
2480 vec_le_rb0->clear();
2481 modelUnregister(vec_le_rb0);
2483 base_le_rb1->clear();
2484 modelUnregister(base_le_rb1);
2486 center_le_rb1->clear();
2487 modelUnregister(center_le_rb1);
2489 height_le_rb1->clear();
2490 modelUnregister(height_le_rb1);
2492 vex_le_rb2->clear();
2493 modelUnregister(vex_le_rb2);
2495 modelUnregister(this);
2498 // ============================================================== updateHelpFileName
2499 void MakeGridDialog::updateHelpFileName()
2501 if ( sender() == rb0 ){
2502 _helpFileName = "creategrids.html#guicartgrid";
2503 } else if ( sender() == rb1 ){
2504 _helpFileName = "creategrids.html#guicylgrid";
2505 } else if ( sender() == rb2 ){
2506 _helpFileName = "creategrids.html#guisphergrid";
2511 // ============================================================== updateButtonBox
2512 void MakeGridDialog::updateButtonBox() //CS_TODO?
2514 // int nbQuads = quads_lw->count();
2515 // int nbAngles = angles_lw->count();
2517 // if ( nbQuads>0 && nbAngles> 0 ){
2518 // _applyCloseButton->setEnabled(true);
2519 // _applyButton->setEnabled(true);
2521 // _applyCloseButton->setEnabled(false);
2522 // _applyButton->setEnabled(false);
2525 // if ( rb0->isChecked() ){ //cartesian
2526 // } else if ( rb1->isChecked() ){ //cylindrical
2527 // nb_radius = radius_lw->item(r);
2528 // nb_angle = angle_lw->item(r);
2529 // nb_height = height_lw->item(r);
2530 // } else if ( rb2->isChecked() ){ //spherical
2534 // ============================================================== addRadiusItem
2535 void MakeGridDialog::addRadiusItem()
2537 QListWidgetItem* previousItem = radius_lw->currentItem();
2538 QListWidgetItem* newItem = new QListWidgetItem();
2540 double defaultValue = 1.;
2542 defaultValue = previousItem->data(Qt::EditRole).toDouble();
2544 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
2545 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
2546 radius_lw->addItem(newItem);
2551 // ============================================================== delRadiusItem
2552 void MakeGridDialog::delRadiusItem()
2554 delete radius_lw->currentItem();
2558 // ============================================================== addAngleItem
2559 void MakeGridDialog::addAngleItem()
2561 QListWidgetItem* previousItem = angle_lw->currentItem();
2562 QListWidgetItem* newItem = new QListWidgetItem();
2564 double defaultValue = 180.;
2566 defaultValue = previousItem->data(Qt::EditRole).toDouble();
2568 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
2569 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
2570 angle_lw->addItem(newItem);
2575 // ============================================================== delAngleItem
2576 void MakeGridDialog::delAngleItem()
2578 //std::cout << "delAngleItem()" << std::endl;
2579 delete angle_lw->currentItem();
2583 // ============================================================== addHeightItem
2584 void MakeGridDialog::addHeightItem()
2586 QListWidgetItem* previousItem = height_lw->currentItem();
2587 QListWidgetItem* newItem = new QListWidgetItem();
2589 double defaultValue = 1.;
2591 defaultValue = previousItem->data(Qt::EditRole).toDouble();
2593 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
2594 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
2595 height_lw->addItem(newItem);
2600 // ============================================================== delHeightItem
2601 void MakeGridDialog::delHeightItem()
2603 //std::cout << "delHeightItem()" << std::endl;
2604 delete height_lw->currentItem();
2608 // ============================================================== apply
2609 bool MakeGridDialog::apply(QModelIndex& result)
2611 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
2614 SUIT_OverrideCursor wc;
2615 if ( !getDocumentModel() ) return false;
2616 const PatternDataModel* patternDataModel = getPatternDataModel();
2617 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
2618 if ( !patternDataModel || !patternBuilderModel) return false;
2620 QModelIndex iNewElts;
2621 if ( rb0->isChecked() ){ //cartesian
2622 QModelIndex ivex_rb0 = patternDataModel->mapToSource( _index[vex_le_rb0] );
2623 QModelIndex ivec_rb0 = patternBuilderModel->mapToSource( _index[vec_le_rb0] );
2624 long nx = nx_spb_rb0->value();
2625 long ny = ny_spb_rb0->value();
2626 long nz = nz_spb_rb0->value();
2628 if ( ivex_rb0.isValid()
2629 && ivec_rb0.isValid() ){
2630 iNewElts = getDocumentModel()->makeCartesian( ivex_rb0, ivec_rb0, nx, ny, nz );
2633 } else if ( rb1->isChecked() ){ //cylindrical
2634 QModelIndex icenter_rb1 = patternDataModel->mapToSource( _index[center_le_rb1] );
2635 QModelIndex ibase_rb1 = patternBuilderModel->mapToSource( _index[base_le_rb1] );
2636 QModelIndex iheight_rb1 = patternBuilderModel->mapToSource( _index[height_le_rb1] );
2638 if ( icenter_rb1.isValid()
2639 && ibase_rb1.isValid()
2640 && iheight_rb1.isValid() ){
2642 bool fill = fill_cb_rb1->isChecked();
2643 if ( uniform_rb->isChecked() ){
2644 double dr = dr_spb_rb1->value();
2645 double da = da_spb_rb1->value();
2646 double dl = dl_spb_rb1->value();
2647 double nr = nr_spb_rb1->value();
2648 double na = na_spb_rb1->value();
2649 double nl = nl_spb_rb1->value();
2651 iNewElts = getDocumentModel()->makeCylindrical( icenter_rb1,
2652 ibase_rb1, iheight_rb1,
2653 dr, da, dl, nr, na, nl, fill );
2655 if ( random_rb->isChecked() ){
2656 QListWidgetItem* item = NULL;
2657 // QDoubleSpinBox* spb = NULL;
2659 QList<double> radius;
2660 QList<double> angles;
2661 QList<double> heights;
2664 for ( int r = 0; r < angle_lw->count(); ++r){
2665 item = angle_lw->item(r);
2666 angles << item->data(Qt::EditRole).toDouble();
2667 somme += item->data(Qt::EditRole).toDouble();
2671 SUIT_MessageBox::information( 0,
2673 tr("The sum of the picked angles has to be \nless or equal than %1 degrees.").arg(360));
2677 for ( int r = 0; r < radius_lw->count(); ++r){
2678 item = radius_lw->item(r);
2679 //std::cout << "radius : " << item->data(Qt::EditRole).toDouble()<< std::endl;
2680 radius << item->data(Qt::EditRole).toDouble();
2683 for ( int r = 0; r < height_lw->count(); ++r){
2684 item = height_lw->item(r);
2685 heights << item->data(Qt::EditRole).toDouble();
2688 iNewElts = getDocumentModel()->makeCylindricals(
2689 icenter_rb1, ibase_rb1, iheight_rb1,
2690 radius, angles, heights,
2695 } else if ( rb2->isChecked() ){ //spherical
2696 QModelIndex ivex_rb2 = patternDataModel->mapToSource( _index[vex_le_rb2] );
2697 // QModelIndex ivecx_rb2 = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
2698 double radius = radius_spb_rb2->value();
2699 int nb = nb_spb_rb2->value();
2700 int k = k_spb_rb2->value();
2702 if ( ivex_rb2.isValid() ){
2703 iNewElts = getDocumentModel()->makeSpherical( ivex_rb2, radius, nb, k );
2707 if ( !iNewElts.isValid() ){
2708 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE GRID" ) );
2712 // to select/highlight result
2713 result = patternBuilderModel->mapFromSource( iNewElts );
2720 // ============================================================== Constructeur
2722 MakeCylinderDialog::MakeCylinderDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2723 : HexaBaseDialog(parent, editmode, f)
2725 _helpFileName = "gui_blocks_for_cyl_pipe.html#make-cylinder";
2727 _initWidget(editmode);
2728 // setFocusProxy( cyl_le );
2731 // ============================================================== Destructeur
2732 MakeCylinderDialog::~MakeCylinderDialog()
2736 void MakeCylinderDialog::_initInputWidget( Mode editmode )
2739 QValidator *validator = new QRegExpValidator(rx, this);
2741 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
2742 installEventFilter(this);
2744 cyl_le->setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
2745 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2746 cyl_le->setValidator( validator );
2747 vec_le->setValidator( validator );
2748 cyl_le->installEventFilter(this);
2749 vec_le->installEventFilter(this);
2751 cyl_le->setReadOnly(true);
2752 vec_le->setReadOnly(true);
2755 // ============================================================== clear
2756 void MakeCylinderDialog::clear()
2759 modelUnregister(cyl_le);
2762 modelUnregister(vec_le);
2764 modelUnregister(this);
2768 // ============================================================== apply
2769 bool MakeCylinderDialog::apply(QModelIndex& result)
2771 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
2774 SUIT_OverrideCursor wc;
2775 if ( !getDocumentModel() ) return false;
2776 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
2777 if ( !patternBuilderModel ) return false;
2780 QModelIndex icyl = patternBuilderModel->mapToSource( _index[cyl_le] );
2781 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
2782 double nr = nr_spb->value();
2783 double na = na_spb->value();
2784 double nl = nl_spb->value();
2787 && ivec.isValid() ){
2788 iElts = getDocumentModel()->makeCylinder( icyl, ivec, nr, na, nl );
2791 if ( !iElts.isValid() ){
2792 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE CYLINDER" ) );
2796 // to select/highlight result
2797 result = patternBuilderModel->mapFromSource(iElts);
2803 //---------------------------------- MakePipeDialog -----------------------------
2805 // ============================================================== Constructeur
2807 MakePipeDialog::MakePipeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2808 : HexaBaseDialog(parent, editmode, f)
2810 _helpFileName = "gui_blocks_for_cyl_pipe.html#make-pipe";
2812 _initWidget(editmode);
2813 // setFocusProxy( pipe_le );
2816 // ============================================================== Destructeur
2817 MakePipeDialog::~MakePipeDialog()
2821 // ============================================================== _initInputWidget
2822 void MakePipeDialog::_initInputWidget( Mode editmode )
2825 QValidator *validator = new QRegExpValidator(rx, this);
2827 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
2828 installEventFilter(this);
2830 pipe_le->setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
2831 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
2833 pipe_le->setValidator( validator );
2834 vec_le->setValidator( validator );
2836 pipe_le->installEventFilter(this);
2837 vec_le->installEventFilter(this);
2839 pipe_le->setReadOnly(true);
2840 vec_le->setReadOnly(true);
2846 // ============================================================== clear
2847 void MakePipeDialog::clear()
2850 modelUnregister(pipe_le);
2853 modelUnregister(vec_le);
2855 modelUnregister(this);
2859 // ============================================================== apply
2860 bool MakePipeDialog::apply(QModelIndex& result)
2862 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
2865 SUIT_OverrideCursor wc;
2866 if ( !getDocumentModel() ) return false;
2867 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
2868 if ( !patternBuilderModel ) return false;
2871 QModelIndex ipipe = patternBuilderModel->mapToSource( _index[pipe_le] );
2872 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
2873 double nr = nr_spb->value();
2874 double na = na_spb->value();
2875 double nl = nl_spb->value();
2877 if ( ipipe.isValid()
2878 && ivec.isValid() ){
2879 iElts = getDocumentModel()->makePipe( ipipe, ivec, nr, na, nl );
2881 if ( !iElts.isValid() ){
2882 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE PIPE" ) );
2886 // to select/highlight result
2887 result = patternBuilderModel->mapFromSource(iElts);
2892 //---------------------------------- MakeCylindersDialog -----------------------------
2894 // ============================================================== Constructeur
2896 MakeCylindersDialog::MakeCylindersDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2897 : HexaBaseDialog(parent, editmode, f)
2899 _helpFileName = "gui_blocks_for_cyl_pipe.html#make-cylinders";
2901 _initWidget(editmode);
2902 // setFocusProxy( cyl1_le );
2905 // ============================================================== Destructeur
2906 MakeCylindersDialog::~MakeCylindersDialog()
2910 void MakeCylindersDialog::_initInputWidget( Mode editmode )
2913 QValidator *validator = new QRegExpValidator(rx, this);
2915 // setProperty( "HexaWidgetType", QVariant::fromValue(CROSSELEMENTS_TREE) );
2916 installEventFilter(this);
2918 cyl1_le->setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
2919 cyl2_le->setProperty( "HexaWidgetType", QVariant::fromValue(CYLINDER_TREE) );
2921 cyl1_le->setValidator( validator );
2922 cyl2_le->setValidator( validator );
2924 cyl1_le->installEventFilter(this);
2925 cyl2_le->installEventFilter(this);
2927 cyl1_le->setReadOnly(true);
2928 cyl2_le->setReadOnly(true);
2931 // ============================================================== clear
2932 void MakeCylindersDialog::clear()
2935 modelUnregister(cyl1_le);
2938 modelUnregister(cyl2_le);
2940 modelUnregister(this);
2944 // ============================================================== apply
2945 bool MakeCylindersDialog::apply(QModelIndex& result)
2947 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
2950 SUIT_OverrideCursor wc;
2951 if ( !getDocumentModel() ) return false;
2952 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
2953 if ( !patternBuilderModel ) return false;
2955 QModelIndex iCrossElts;
2956 QModelIndex icyl1 = patternBuilderModel->mapToSource( _index[cyl1_le] );
2957 QModelIndex icyl2 = patternBuilderModel->mapToSource( _index[cyl2_le] );
2959 if ( icyl1.isValid()
2960 && icyl2.isValid() ){
2961 iCrossElts = getDocumentModel()->makeCylinders( icyl1, icyl2 );
2964 if ( !iCrossElts.isValid() ){
2965 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE CYLINDERS" ) );
2969 // to select/highlight result
2970 result = patternBuilderModel->mapFromSource(iCrossElts);
2977 //---------------------------------- MakePipesDialog -----------------------------
2979 // ============================================================== Constructeur
2981 MakePipesDialog::MakePipesDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
2982 : HexaBaseDialog(parent, editmode, f)
2984 _helpFileName = "gui_blocks_for_cyl_pipe.html#make-pipes";
2986 _initWidget(editmode);
2987 // setFocusProxy( pipe1_le );
2990 // ============================================================== Destructeur
2991 MakePipesDialog::~MakePipesDialog()
2995 // ============================================================== _initInputWidget
2996 void MakePipesDialog::_initInputWidget( Mode editmode )
2999 QValidator *validator = new QRegExpValidator(rx, this);
3001 pipe1_le->setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
3002 pipe2_le->setProperty( "HexaWidgetType", QVariant::fromValue(PIPE_TREE) );
3004 pipe1_le->setValidator( validator );
3005 pipe2_le->setValidator( validator );
3007 pipe1_le->installEventFilter(this);
3008 pipe2_le->installEventFilter(this);
3010 pipe1_le->setReadOnly(true);
3011 pipe2_le->setReadOnly(true);
3015 // ============================================================== clear
3016 void MakePipesDialog::clear()
3019 modelUnregister(pipe1_le);
3022 modelUnregister(pipe2_le);
3024 modelUnregister(this);
3028 // ============================================================== apply
3029 bool MakePipesDialog::apply(QModelIndex& result)
3031 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
3034 SUIT_OverrideCursor wc;
3035 if ( !getDocumentModel() ) return false;
3036 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
3037 if ( !patternBuilderModel ) return false;
3039 QModelIndex iCrossElts;
3040 QModelIndex ipipe1 = patternBuilderModel->mapToSource( _index[pipe1_le] );
3041 QModelIndex ipipe2 = patternBuilderModel->mapToSource( _index[pipe2_le] );
3043 if ( ipipe1.isValid()
3044 && ipipe2.isValid() ){
3045 iCrossElts = getDocumentModel()->makePipes( ipipe1, ipipe2 );
3047 if ( !iCrossElts.isValid() ){
3048 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE PIPES" ) );
3051 result = patternBuilderModel->mapFromSource(iCrossElts);
3057 //---------------------------------- RemoveHexaDialog -----------------------------
3059 // ============================================================== Constructeur
3061 RemoveHexaDialog::RemoveHexaDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
3062 : HexaBaseDialog(parent, editmode, f)
3064 _helpFileName = "gui_remove.html";
3066 _initWidget(editmode);
3067 // setFocusProxy( hexa_le );
3070 // ============================================================== Destructeur
3071 RemoveHexaDialog::~RemoveHexaDialog()
3075 // ============================================================== _initInputWidget
3076 void RemoveHexaDialog::_initInputWidget( Mode editmode )
3079 QValidator *validator = new QRegExpValidator(rx, this);
3081 hexa_le->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3082 hexa_le->setValidator( validator );
3083 hexa_le->installEventFilter(this);
3084 hexa_le->setReadOnly(true);
3085 autoFocusSwitch = false;
3088 // ============================================================== clear
3089 void RemoveHexaDialog::clear()
3092 modelUnregister(hexa_le);
3094 modelUnregister(this);
3098 // ============================================================== apply
3099 bool RemoveHexaDialog::apply(QModelIndex& result)
3101 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
3104 SUIT_OverrideCursor wc;
3105 if ( !getDocumentModel() ) return false;
3106 const PatternDataModel* patternDataModel = getPatternDataModel();
3107 if ( !patternDataModel ) return false;
3109 QModelIndex ihexa = patternDataModel->mapToSource( _index[hexa_le] );
3111 bool removed = false;
3112 if ( ihexa.isValid() ){
3113 if ( connected_cb->isChecked() ){
3114 removed = getDocumentModel()->removeConnectedHexa( ihexa );
3116 removed = getDocumentModel()->removeHexa( ihexa );
3120 if ( removed == false ){
3121 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT REMOVE HEXA" ) );
3131 //---------------------------------- PrismQuadDialog -----------------------------
3133 // ============================================================== Constructeur
3135 PrismQuadDialog::PrismQuadDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
3136 : HexaBaseDialog(parent, editmode, f)
3138 _helpFileName = "gui_prism_join_quad.html#prism-quadrangles";
3140 _initWidget(editmode);
3141 // setFocusProxy( quads_lw );
3142 // connect( regular_rb, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3143 // connect( irregular_rb, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3144 regular_rb->click();
3148 // ============================================================== Destructeur
3149 PrismQuadDialog::~PrismQuadDialog()
3153 // ============================================================== getAssocsVTK
3155 * Returns elements currently associated to vtk
3157 QModelIndexList PrismQuadDialog::getAssocsVTK()
3159 QModelIndexList assocs;
3161 QListWidgetItem* item = NULL;
3163 //ListWidget content
3164 const PatternDataModel* patternDataModel = getPatternDataModel();
3165 if ( !patternDataModel ) return assocs;
3166 for ( int r = 0; r < quads_lw->count(); ++r ){
3167 item = quads_lw->item(r);
3168 iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
3169 if ( iQuad.isValid() )
3176 // ============================================================== _initInputWidget
3177 void PrismQuadDialog::_initInputWidget( Mode editmode )
3180 QValidator *validator = new QRegExpValidator(rx, this);
3182 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3183 installEventFilter(this);
3185 vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
3186 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3188 vec_le->setValidator( validator );
3190 vec_le->installEventFilter(this);
3191 quads_lw->installEventFilter(this);
3193 if ( editmode != INFO_MODE ){
3194 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
3195 delQuadShortcut->setContext( Qt::WidgetShortcut );
3196 connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(removeQuad()) );
3199 vec_le->setReadOnly(true);
3201 connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection );
3202 height_lw->setItemDelegate(new HexaPositiveDoubleSpinBoxDelegate(height_lw));
3203 height_lw->setEditTriggers(QAbstractItemView::DoubleClicked);
3204 connect( add_height_pb, SIGNAL(clicked()), this, SLOT(addHeightItem()) );
3205 connect( del_height_pb, SIGNAL(clicked()), this, SLOT(delHeightItem()) );
3208 // ============================================================== clear
3209 void PrismQuadDialog::clear()
3212 modelUnregister(quads_lw);
3215 modelUnregister(vec_le);
3217 modelUnregister(this);
3220 // ============================================================== removeQuad
3221 void PrismQuadDialog::removeQuad()
3223 QListWidgetItem *item = quads_lw->currentItem();
3226 int r = quads_lw->row(item);
3227 quads_lw->takeItem(r);
3233 // void PrismQuadDialog::clearQuads()
3235 // if (quads_lw->count() != 0)
3236 // quads_lw->clear();
3239 // ============================================================== addHeightItem
3240 void PrismQuadDialog::addHeightItem()
3242 QListWidgetItem* previousItem = height_lw->currentItem();
3243 QListWidgetItem* newItem = new QListWidgetItem();
3245 double defaultValue = 1.;
3247 defaultValue = previousItem->data(Qt::EditRole).toDouble();
3249 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
3250 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
3251 height_lw->addItem(newItem);
3253 // updateButtonBox();
3256 // ============================================================== delHeightItem
3257 void PrismQuadDialog::delHeightItem()
3259 delete height_lw->currentItem();
3260 // updateButtonBox();
3265 // ============================================================== apply
3266 bool PrismQuadDialog::apply(QModelIndex& result)
3268 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
3271 SUIT_OverrideCursor wc;
3272 if ( !getDocumentModel() ) return false;
3273 const PatternDataModel* patternDataModel = getPatternDataModel();
3274 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
3275 if ( !patternDataModel || !patternBuilderModel) return false;
3278 QModelIndexList iquads = getIndexList(quads_lw);
3279 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le] );
3282 if ( ivec.isValid() ){
3283 if (regular_rb->isChecked())
3285 int nb = nb_spb->value();
3286 if ( iquads.count() == 1 ){
3287 iElts = getDocumentModel()->prismQuad( iquads[0], ivec, nb );
3288 } else if ( iquads.count() > 1 ){
3289 iElts = getDocumentModel()->prismQuads( iquads, ivec, nb );
3292 else //irregular_rb is checked
3294 QVector<double> heights;
3295 QListWidgetItem* item = NULL;
3296 unsigned int nbItems = height_lw->count();
3298 for ( int r = 0; r < nbItems; ++r){
3299 item = height_lw->item(r);
3300 heights << item->data(Qt::EditRole).toDouble();
3302 if (iquads.count() == 0 || heights.size() == 0)
3304 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ),
3305 tr( "Parameters are invalid!" ) );
3308 iElts = getDocumentModel()->prismQuads( iquads, ivec, heights.toStdVector()/*, nb*/ );
3312 if ( !iElts.isValid() ){
3313 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT PRISM QUAD(S)" ) );
3317 result = patternBuilderModel->mapFromSource(iElts);
3322 //---------------------------------- JoinQuadDialog -----------------------------
3324 // ============================================================== Constructeur
3326 JoinQuadDialog::JoinQuadDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
3327 : HexaBaseDialog(parent, editmode, f)
3329 _helpFileName = "gui_prism_join_quad.html#join-quadrangles";
3331 _initWidget(editmode);
3332 // setFocusProxy( quads_lw );
3336 // ============================================================== Destructeur
3337 JoinQuadDialog::~JoinQuadDialog()
3341 // ============================================================== getAssocsVTK
3343 * Returns elements currently associated to vtk
3345 QModelIndexList JoinQuadDialog::getAssocsVTK()
3347 QModelIndexList assocs;
3349 QListWidgetItem* item = NULL;
3351 if (getPatternDataSelectionModel() == NULL) return assocs;
3353 //ListWidget content
3354 const PatternDataModel* patternDataModel = getPatternDataModel();
3355 if ( !patternDataModel ) return assocs;
3356 for ( int r = 0; r < quads_lw->count(); ++r ){
3357 item = quads_lw->item(r);
3358 // iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() ); //unsafe
3359 iQuad = getPatternDataSelectionModel()->indexBy(HEXA_DATA_ROLE, item->data(LW_DATA_ROLE));
3360 if ( iQuad.isValid() ) assocs << iQuad;
3365 // ============================================================== _initInputWidget
3366 void JoinQuadDialog::_initInputWidget( Mode editmode )
3369 QValidator *validator = new QRegExpValidator(rx, this);
3371 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3372 installEventFilter(this);
3374 vex0_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3375 vex1_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3376 vex2_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3377 vex3_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3378 quad_dest_le->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3379 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3381 vex0_le->setValidator( validator );
3382 vex1_le->setValidator( validator );
3383 vex2_le->setValidator( validator );
3384 vex3_le->setValidator( validator );
3385 quad_dest_le->setValidator( validator );
3387 vex0_le->installEventFilter(this);
3388 vex1_le->installEventFilter(this);
3389 vex2_le->installEventFilter(this);
3390 vex3_le->installEventFilter(this);
3391 quad_dest_le->installEventFilter(this);
3392 quads_lw->installEventFilter(this);
3394 if ( editmode != INFO_MODE ){
3395 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
3396 delQuadShortcut->setContext( Qt::WidgetShortcut );
3397 connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(removeQuad()) );
3400 vex0_le->setReadOnly(true);
3401 vex1_le->setReadOnly(true);
3402 vex2_le->setReadOnly(true);
3403 vex3_le->setReadOnly(true);
3404 quad_dest_le->setReadOnly(true);
3406 _currentObj = quads_lw;
3408 connect( quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection );
3412 // ============================================================== clear
3413 void JoinQuadDialog::clear()
3416 modelUnregister(quads_lw);
3419 modelUnregister(vex0_le);
3422 modelUnregister(vex2_le);
3424 quad_dest_le->clear();
3425 modelUnregister(quad_dest_le);
3428 modelUnregister(vex1_le);
3431 modelUnregister(vex3_le);
3433 modelUnregister(this);
3437 // ============================================================== removeQuad
3438 void JoinQuadDialog::removeQuad()
3440 QListWidgetItem *item = quads_lw->currentItem();
3443 int r = quads_lw->row(item);
3444 quads_lw->takeItem(r);
3450 // void JoinQuadDialog::clearQuads()
3452 // if (quads_lw->count() != 0)
3453 // quads_lw->clear();
3457 // ============================================================== apply
3458 bool JoinQuadDialog::apply(QModelIndex& result)
3460 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
3463 SUIT_OverrideCursor wc;
3464 if ( !getDocumentModel() ) return false;
3465 const PatternDataModel* patternDataModel = getPatternDataModel();
3466 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
3467 if ( !patternDataModel || !patternBuilderModel) return false;
3470 QModelIndexList iquads;
3472 QListWidgetItem* item = NULL;
3473 for ( int r = 0; r < quads_lw->count(); ++r){
3474 item = quads_lw->item(r);
3475 iquad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
3476 if ( iquad.isValid() ) iquads << iquad;
3478 QModelIndex iquaddest = patternDataModel->mapToSource( _index[quad_dest_le] );
3479 QModelIndex ivex0 = patternDataModel->mapToSource( _index[vex0_le] );
3480 QModelIndex ivex1 = patternDataModel->mapToSource( _index[vex1_le] );
3481 QModelIndex ivex2 = patternDataModel->mapToSource( _index[vex2_le] );
3482 QModelIndex ivex3 = patternDataModel->mapToSource( _index[vex3_le] );
3485 if ( iquaddest.isValid()
3489 && ivex3.isValid() ){
3490 int nb = nb_spb->value();
3491 if ( iquads.count() == 1 ){
3492 iElts = getDocumentModel()->joinQuad( iquads[0], iquaddest,
3493 ivex0, ivex1, ivex2, ivex3,
3495 } else if ( iquads.count() > 1 ){
3496 iElts = getDocumentModel()->joinQuads( iquads, iquaddest,
3497 ivex0, ivex1, ivex2, ivex3,
3502 if ( !iElts.isValid() ){
3503 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT JOIN QUAD(S)" ) );
3507 result = patternBuilderModel->mapFromSource(iElts);
3513 // void JoinQuadDialog::reject()
3515 // QDialog::reject();
3516 // _disallowSelection();
3521 // ------------------------- MergeDialog ----------------------------------
3523 // ============================================================== Constructeur
3525 MergeDialog::MergeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
3526 : HexaBaseDialog(parent, editmode, f)
3529 _initWidget(editmode);
3530 // rb0->setFocusProxy( v0_le_rb0 );
3531 // rb1->setFocusProxy( e0_le_rb1 );
3532 // rb2->setFocusProxy( q0_le_rb2 );
3533 // setFocusProxy( rb0 );
3536 _helpFileName = "gui_merge_elmts.html#merge-two-vertices";
3537 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3538 connect( rb0, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
3539 connect( rb0, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
3541 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3542 connect( rb1, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
3543 connect( rb1, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
3545 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3546 connect( rb2, SIGNAL(cliked()), this, SLOT(clearVTKSelection()) );
3547 connect( rb2, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
3550 // ============================================================== Destructeur
3551 MergeDialog::~MergeDialog()
3555 // ============================================================== _initInputWidget
3556 void MergeDialog::_initInputWidget( Mode editmode )
3559 QValidator *validator = new QRegExpValidator(rx, this);
3562 v0_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3563 v1_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3564 v0_le_rb0->setValidator( validator );
3565 v1_le_rb0->setValidator( validator );
3566 v0_le_rb0->installEventFilter(this);
3567 v1_le_rb0->installEventFilter(this);
3569 v0_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3570 v1_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3571 e0_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
3572 e1_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
3574 v0_le_rb1->setValidator( validator );
3575 v1_le_rb1->setValidator( validator );
3576 e0_le_rb1->setValidator( validator );
3577 e1_le_rb1->setValidator( validator );
3579 v0_le_rb1->installEventFilter(this);
3580 v1_le_rb1->installEventFilter(this);
3581 e0_le_rb1->installEventFilter(this);
3582 e1_le_rb1->installEventFilter(this);
3585 v0_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3586 v1_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3587 v2_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3588 v3_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3589 q0_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3590 q1_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3593 v0_le_rb2->setValidator( validator );
3594 v1_le_rb2->setValidator( validator );
3595 v2_le_rb2->setValidator( validator );
3596 v3_le_rb2->setValidator( validator );
3597 q0_le_rb2->setValidator( validator );
3598 q1_le_rb2->setValidator( validator );
3600 v0_le_rb2->installEventFilter(this);
3601 v1_le_rb2->installEventFilter(this);
3602 v2_le_rb2->installEventFilter(this);
3603 v3_le_rb2->installEventFilter(this);
3604 q0_le_rb2->installEventFilter(this);
3605 q1_le_rb2->installEventFilter(this);
3607 v0_le_rb0->setReadOnly(true);
3608 v1_le_rb0->setReadOnly(true);
3610 v0_le_rb1->setReadOnly(true);
3611 v1_le_rb1->setReadOnly(true);
3612 e0_le_rb1->setReadOnly(true);
3613 e1_le_rb1->setReadOnly(true);
3615 v0_le_rb2->setReadOnly(true);
3616 v1_le_rb2->setReadOnly(true);
3617 v2_le_rb2->setReadOnly(true);
3618 v3_le_rb2->setReadOnly(true);
3619 q0_le_rb2->setReadOnly(true);
3620 q1_le_rb2->setReadOnly(true);
3624 // ============================================================== clear
3625 void MergeDialog::clear()
3628 modelUnregister(v0_le_rb0);
3631 modelUnregister(v1_le_rb0);
3634 modelUnregister(e0_le_rb1);
3637 modelUnregister(e1_le_rb1);
3640 modelUnregister(v0_le_rb1);
3643 modelUnregister(v1_le_rb1);
3646 modelUnregister(q0_le_rb2);
3649 modelUnregister(q1_le_rb2);
3652 modelUnregister(v0_le_rb2);
3655 modelUnregister(v1_le_rb2);
3658 modelUnregister(v2_le_rb2);
3661 modelUnregister(v3_le_rb2);
3663 modelUnregister(this);
3666 // ============================================================== updateHelpFileName
3667 void MergeDialog::updateHelpFileName()
3669 if ( sender() == rb0 ){
3670 _helpFileName = "gui_merge_elmts.html#merge-two-vertices";
3671 } else if ( sender() == rb1 ){
3672 _helpFileName = "gui_merge_elmts.html#merge-two-edges";
3673 } else if ( sender() == rb2 ){
3674 _helpFileName = "gui_merge_elmts.html#merge-two-quadrangles";
3679 // ============================================================== apply
3680 bool MergeDialog::apply(QModelIndex& result)
3682 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
3685 if (getDocumentModel() == NULL) return false;
3686 SUIT_OverrideCursor wc;
3687 const PatternDataModel* patternDataModel = getPatternDataModel();
3688 if ( !patternDataModel ) return false;
3690 bool merged = false;
3692 if ( rb0->isChecked() ){
3693 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb0] );
3694 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb0] );
3698 merged = getDocumentModel()->mergeVertices( iv0, iv1 );
3700 } else if ( rb1->isChecked() ){
3701 QModelIndex ie0 = patternDataModel->mapToSource( _index[e0_le_rb1] );
3702 QModelIndex ie1 = patternDataModel->mapToSource( _index[e1_le_rb1] );
3703 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb1] );
3704 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb1] );
3710 merged = getDocumentModel()->mergeEdges( ie0, ie1, iv0, iv1);
3712 } else if ( rb2->isChecked() ){
3714 QModelIndex iq0 = patternDataModel->mapToSource( _index[q0_le_rb2] );
3715 QModelIndex iq1 = patternDataModel->mapToSource( _index[q1_le_rb2] );
3716 QModelIndex iv0 = patternDataModel->mapToSource( _index[v0_le_rb2] );
3717 QModelIndex iv1 = patternDataModel->mapToSource( _index[v1_le_rb2] );
3718 QModelIndex iv2 = patternDataModel->mapToSource( _index[v2_le_rb2] );
3719 QModelIndex iv3 = patternDataModel->mapToSource( _index[v3_le_rb2] );
3727 merged = getDocumentModel()->mergeQuads( iq0, iq1,
3728 iv0, iv1, iv2, iv3 );
3732 if ( merged == false ){
3733 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MERGE" ) );
3741 // ------------------------- DisconnectDialog ----------------------------------
3743 // ============================================================== Constructeur
3745 DisconnectDialog::DisconnectDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
3746 : HexaBaseDialog(parent, editmode, f)
3749 _initWidget(editmode);
3750 // rb0->setFocusProxy( v_le_rb0 );
3751 // rb1->setFocusProxy( e_le_rb1 );
3752 // rb2->setFocusProxy( q_le_rb2 );
3753 // rb3->setFocusProxy( d_edges_lw);
3755 // setFocusProxy( rb0 );
3757 _helpFileName = "gui_disc_elmts.html#disconnect-a-vertex";
3759 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3760 connect( rb0, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
3761 connect( rb0, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
3763 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3764 connect( rb1, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
3765 connect( rb1, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
3767 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3768 connect( rb2, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
3769 connect( rb2, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
3771 connect( rb3, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
3772 connect( rb3, SIGNAL(clicked()), this, SLOT(clearVTKSelection()) );
3773 connect( rb3, SIGNAL(clicked()), this, SLOT(clearCurrentObjectFocus()) );
3777 // ============================================================== Destructeur
3778 DisconnectDialog::~DisconnectDialog()
3782 // ============================================================== _initInputWidget
3783 void DisconnectDialog::_initInputWidget( Mode editmode )
3786 QValidator *validator = new QRegExpValidator(rx, this);
3788 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
3789 installEventFilter(this);
3792 v_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
3793 h_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3794 v_le_rb0->setValidator( validator );
3795 h_le_rb0->setValidator( validator );
3796 v_le_rb0->installEventFilter(this);
3797 h_le_rb0->installEventFilter(this);
3800 e_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
3801 h_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3802 e_le_rb1->setValidator( validator );
3803 h_le_rb1->setValidator( validator );
3804 e_le_rb1->installEventFilter(this);
3805 h_le_rb1->installEventFilter(this);
3808 q_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
3809 h_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3810 q_le_rb2->setValidator( validator );
3811 h_le_rb2->setValidator( validator );
3812 q_le_rb2->installEventFilter(this);
3813 h_le_rb2->installEventFilter(this);
3816 d_edges_lw->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
3817 hexas_lw->setProperty( "HexaWidgetType", QVariant::fromValue(HEXA_TREE) );
3818 d_edges_lw->installEventFilter(this);
3819 hexas_lw->installEventFilter(this);
3821 QShortcut* delEdgeShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X/*Qt::Key_Alt*//*Qt::Key_Space*/), d_edges_lw);
3822 QShortcut* delHexaShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X/*Qt::Key_Alt*//*Qt::Key_Space*/), hexas_lw);
3823 delEdgeShortcut->setContext( Qt::WidgetShortcut );
3824 delHexaShortcut->setContext( Qt::WidgetShortcut );
3826 v_le_rb0->setReadOnly(true);
3827 h_le_rb0->setReadOnly(true);
3829 e_le_rb1->setReadOnly(true);
3830 h_le_rb1->setReadOnly(true);
3832 q_le_rb2->setReadOnly(true);
3833 h_le_rb2->setReadOnly(true);
3835 connect( d_edges_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection );
3836 connect( hexas_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection );
3837 connect( delEdgeShortcut, SIGNAL(activated()), this, SLOT(deleteEdgeItem()) );
3838 connect( delHexaShortcut, SIGNAL(activated()), this, SLOT(deleteHexaItem()) );
3839 autoFocusSwitch = false;
3843 // =============================================== getAssocsVTK
3845 * Returns elements in the list
3847 QModelIndexList DisconnectDialog::getAssocsVTK()
3849 QModelIndexList iElts;
3851 QListWidgetItem* item = NULL;
3853 const PatternDataModel* patternDataModel = getPatternDataModel();
3854 if (patternDataModel == NULL) return iElts;
3855 if (rb3->isChecked())
3857 //ListWidget content
3858 if (HEXABLOCKGUI::currentDocGView->getSelectionMode() == EDGE_TREE)
3860 for ( int r = 0; r < d_edges_lw->count(); ++r )
3862 item = d_edges_lw->item(r);
3863 index = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
3864 if ( index.isValid() )
3868 else if (HEXABLOCKGUI::currentDocGView->getSelectionMode() == HEXA_TREE)
3870 for ( int r = 0; r < hexas_lw->count(); ++r )
3872 item = hexas_lw->item(r);
3873 index = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
3874 if ( index.isValid() )
3884 // ============================================================== clear
3885 void DisconnectDialog::clear()
3888 modelUnregister(v_le_rb0);
3891 modelUnregister(h_le_rb0);
3894 modelUnregister(e_le_rb1);
3897 modelUnregister(h_le_rb1);
3899 d_edges_lw->clear();
3900 modelUnregister(d_edges_lw);
3903 modelUnregister(hexas_lw);
3906 modelUnregister(q_le_rb2);
3909 modelUnregister(h_le_rb2);
3911 modelUnregister(this);
3914 // ============================================================== deleteEdgeItem
3915 void DisconnectDialog::deleteEdgeItem()
3917 delete d_edges_lw->currentItem();
3920 // ============================================================== deleteHexaItem
3921 void DisconnectDialog::deleteHexaItem()
3923 delete hexas_lw->currentItem();
3926 // ============================================================== updateHelpFileName
3927 void DisconnectDialog::updateHelpFileName()
3929 if ( sender() == rb0 ){
3930 _helpFileName = "gui_disc_elmts.html#disconnect-a-vertex";
3931 } else if ( sender() == rb1 ){
3932 _helpFileName = "gui_disc_elmts.html#disconnect-an-edge";
3933 } else if ( sender() == rb2 ){
3934 _helpFileName = "gui_disc_elmts.html#disconnect-a-quadrangle";
3935 } else if (sender() == rb3 ){
3936 _helpFileName = "gui_disc_elmts.html#disconnect-edges";
3940 // ============================================================== apply
3941 bool DisconnectDialog::apply(QModelIndex& result)
3943 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
3945 if (getDocumentModel() == NULL) return false;
3946 const PatternDataModel* patternDataModel = getPatternDataModel();
3947 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
3948 if ( !patternDataModel || !patternBuilderModel) return false;
3950 SUIT_OverrideCursor wc;
3953 if ( rb0->isChecked() ){
3954 QModelIndex ihexa = patternDataModel->mapToSource( _index[h_le_rb0] );
3955 QModelIndex ivex = patternDataModel->mapToSource( _index[v_le_rb0] );
3957 if ( ihexa.isValid()
3958 && ivex.isValid() ){
3959 iElts = getDocumentModel()->disconnectVertex( ihexa, ivex );
3961 } else if ( rb1->isChecked() ){
3962 QModelIndex ihexa = patternDataModel->mapToSource( _index[h_le_rb1] );
3963 QModelIndex iedge = patternDataModel->mapToSource( _index[e_le_rb1] );
3965 if ( ihexa.isValid()
3966 && iedge.isValid() ){
3967 iElts = getDocumentModel()->disconnectEdge( ihexa, iedge );
3969 } else if ( rb2->isChecked() ){
3970 QModelIndex ihexa = patternDataModel->mapToSource( _index[h_le_rb2] );
3971 QModelIndex iquad = patternDataModel->mapToSource( _index[q_le_rb2] );
3973 if ( ihexa.isValid()
3974 && iquad.isValid() ){
3975 iElts = getDocumentModel()->disconnectQuad( ihexa, iquad );
3977 } else if ( rb3->isChecked() ){ //
3979 QModelIndex iedge, ihexa;
3980 QModelIndexList iedges, ihexas;
3981 QListWidgetItem* item = NULL;
3984 for (int r = 0; r < d_edges_lw->count(); ++r){
3985 item = d_edges_lw->item(r);
3986 iedge = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
3987 if ( iedge.isValid() )
3992 for (int r = 0; r < hexas_lw->count(); ++r){
3993 item = hexas_lw->item(r);
3994 ihexa = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
3995 if ( ihexa.isValid() )
3999 iElts = getDocumentModel()->disconnectEdges( ihexas, iedges );
4002 if ( !iElts.isValid() ){
4003 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT DISCONNECT" ) );
4007 result = patternBuilderModel->mapFromSource(iElts);
4015 // ------------------------- CutEdgeDialog ----------------------------------
4017 // ============================================================== Constructeur
4019 CutEdgeDialog::CutEdgeDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
4020 HexaBaseDialog(parent, editmode, f)
4022 _helpFileName = "gui_cut_hexa.html";
4024 _initWidget(editmode);
4025 // setFocusProxy( e_le );
4028 // ============================================================== Destructeur
4029 CutEdgeDialog::~CutEdgeDialog()
4033 // ============================================================== _initInputWidget
4034 void CutEdgeDialog::_initInputWidget( Mode editmode )
4037 QValidator *validator = new QRegExpValidator(rx, this);
4039 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4040 installEventFilter(this);
4042 e_le->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
4043 e_le->setValidator( validator );
4044 e_le->installEventFilter(this);
4046 e_le->setReadOnly(true);
4049 // ============================================================== clear
4050 void CutEdgeDialog::clear()
4053 modelUnregister(e_le);
4055 modelUnregister(this);
4059 // ============================================================== apply
4060 bool CutEdgeDialog::apply(QModelIndex& result)
4062 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
4065 SUIT_OverrideCursor wc;
4066 if ( !getDocumentModel() ) return false;
4067 const PatternDataModel* patternDataModel = getPatternDataModel();
4068 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
4069 if ( !patternDataModel || !patternBuilderModel) return false;
4071 int nbCut = nb_cut_spb->value();
4072 QModelIndex iedge = patternDataModel->mapToSource( _index[e_le] );
4075 if ( iedge.isValid() ){
4076 iElts = getDocumentModel()->cutEdge( iedge, nbCut );
4079 if ( !iElts.isValid() ){
4080 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT CUT EDGE" ) );
4084 result = patternBuilderModel->mapFromSource(iElts);
4086 //Update the line edit
4088 e_le->setProperty("QModelIndex", invalid );
4090 QModelIndex invalidIndex;
4091 _index[e_le] = invalidIndex;
4098 // // ------------------------- MakeTransformationDialog ----------------------------------
4100 // ============================================================== Constructeur
4102 MakeTransformationDialog::MakeTransformationDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
4103 : HexaBaseDialog(parent, editmode, f)
4106 _initWidget(editmode);
4107 // rb0->setFocusProxy( elts_le_rb0 );
4108 // rb1->setFocusProxy( elts_le_rb1 );
4109 // rb2->setFocusProxy( elts_le_rb2 );
4110 // setFocusProxy( rb0 );
4113 _helpFileName = "gui_make_elmts.html#make-elements-by-translation";
4114 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4115 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4116 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4119 // ============================================================== Destructeur
4120 MakeTransformationDialog::~MakeTransformationDialog()
4124 // ============================================================== _initInputWidget
4125 void MakeTransformationDialog::_initInputWidget( Mode editmode )
4128 QValidator *validator = new QRegExpValidator(rx, this);
4130 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4131 installEventFilter(this);
4133 vec_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
4134 elts_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4136 vec_le_rb0->setValidator( validator );
4137 elts_le_rb0->setValidator( validator );
4138 vec_le_rb0->installEventFilter(this);
4139 elts_le_rb0->installEventFilter(this);
4141 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4142 elts_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4143 vex_le_rb1->setValidator( validator );
4144 elts_le_rb1->setValidator( validator );
4145 vex_le_rb1->installEventFilter(this);
4146 elts_le_rb1->installEventFilter(this);
4148 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4149 vec_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
4150 elts_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4151 vex_le_rb2->setValidator( validator );
4152 vec_le_rb2->setValidator( validator );
4153 elts_le_rb2->setValidator( validator );
4154 vex_le_rb2->installEventFilter(this);
4155 vec_le_rb2->installEventFilter(this);
4156 elts_le_rb2->installEventFilter(this);
4158 vec_le_rb0->setReadOnly(true);
4159 elts_le_rb0->setReadOnly(true);
4161 vex_le_rb1->setReadOnly(true);
4162 elts_le_rb1->setReadOnly(true);
4164 vex_le_rb2->setReadOnly(true);
4165 vec_le_rb2->setReadOnly(true);
4166 elts_le_rb2->setReadOnly(true);
4170 // ============================================================== clear
4171 void MakeTransformationDialog::clear()
4173 elts_le_rb0->clear();
4174 modelUnregister(elts_le_rb0);
4176 vec_le_rb0->clear();
4177 modelUnregister(vec_le_rb0);
4179 elts_le_rb1->clear();
4180 modelUnregister(elts_le_rb1);
4182 vex_le_rb1->clear();
4183 modelUnregister(vex_le_rb1);
4185 elts_le_rb2->clear();
4186 modelUnregister(elts_le_rb2);
4188 vex_le_rb2->clear();
4189 modelUnregister(vex_le_rb2);
4191 vec_le_rb2->clear();
4192 modelUnregister(vec_le_rb2);
4194 modelUnregister(this);
4198 // ============================================================== updateHelpFileName
4199 void MakeTransformationDialog::updateHelpFileName()
4201 if ( sender() == rb0 ){
4202 _helpFileName = "gui_make_elmts.html#make-elements-by-translation";
4203 } else if ( sender() == rb1 ){
4204 _helpFileName = "gui_make_elmts.html#make-elements-by-scaling";
4205 } else if ( sender() == rb2 ){
4206 _helpFileName = "gui_make_elmts.html#make-elements-by-rotation";
4210 // ============================================================== apply
4211 bool MakeTransformationDialog::apply(QModelIndex& result)
4213 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
4216 SUIT_OverrideCursor wc;
4217 if (getDocumentModel() == NULL) return false;
4218 const PatternDataModel* patternDataModel = getPatternDataModel();
4219 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
4220 if ( !patternDataModel || !patternBuilderModel) return false;
4222 QModelIndex iNewElts;
4224 if ( rb0->isChecked() ){
4225 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] );
4226 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb0] );
4228 if ( ielts.isValid()
4230 iNewElts = getDocumentModel()->makeTranslation( ielts, ivec );
4232 } else if ( rb1->isChecked() ){
4233 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] );
4234 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
4235 double k = k_spb->value();
4237 if ( ielts.isValid()
4239 iNewElts = getDocumentModel()->makeScale( ielts, ivex, k );
4241 } else if ( rb2->isChecked() ){
4242 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb2] );
4243 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb2] );
4244 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
4245 double angle = angle_spb->value();
4247 if ( ielts.isValid()
4250 iNewElts = getDocumentModel()->makeRotation( ielts, ivex, ivec, angle );
4253 if ( !iNewElts.isValid() ){
4254 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE TRANSFORMATION" ) );
4258 result = patternBuilderModel->mapFromSource(iNewElts);
4263 // // ------------------------- MakeSymmetryDialog ----------------------------------
4265 // ============================================================== Constructeur
4267 MakeSymmetryDialog::MakeSymmetryDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
4268 HexaBaseDialog(parent, editmode, f)
4271 _initWidget(editmode);
4272 // rb0->setFocusProxy( elts_le_rb0 );
4273 // rb1->setFocusProxy( elts_le_rb1 );
4274 // rb2->setFocusProxy( elts_le_rb2 );
4276 // setFocusProxy( rb0 );
4278 _helpFileName = "gui_make_symmetry.html#make-elements-by-point-symmetry";
4279 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4280 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4281 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4284 // ============================================================== Destructeur
4285 MakeSymmetryDialog::~MakeSymmetryDialog()
4289 // ============================================================== _initInputWidget
4290 void MakeSymmetryDialog::_initInputWidget( Mode editmode )
4293 QValidator *validator = new QRegExpValidator(rx, this);
4295 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4296 installEventFilter(this);
4298 vex_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4299 elts_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4300 vex_le_rb0->setValidator( validator );
4301 elts_le_rb0->setValidator( validator );
4302 vex_le_rb0->installEventFilter(this);
4303 elts_le_rb0->installEventFilter(this);
4305 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4306 vec_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
4307 elts_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4308 vex_le_rb1->setValidator( validator );
4309 vec_le_rb1->setValidator( validator );
4310 elts_le_rb1->setValidator( validator );
4311 vex_le_rb1->installEventFilter(this);
4312 vec_le_rb1->installEventFilter(this);
4313 elts_le_rb1->installEventFilter(this);
4316 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4317 vec_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
4318 elts_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4319 vex_le_rb2->setValidator( validator );
4320 vec_le_rb2->setValidator( validator );
4321 elts_le_rb2->setValidator( validator );
4322 vex_le_rb2->installEventFilter(this);
4323 vec_le_rb2->installEventFilter(this);
4324 elts_le_rb2->installEventFilter(this);
4326 vex_le_rb0->setReadOnly(true);
4327 elts_le_rb0->setReadOnly(true);
4328 vex_le_rb1->setReadOnly(true);
4329 vec_le_rb1->setReadOnly(true);
4330 elts_le_rb1->setReadOnly(true);
4331 vex_le_rb2->setReadOnly(true);
4332 vec_le_rb2->setReadOnly(true);
4333 elts_le_rb2->setReadOnly(true);
4336 // ============================================================== clear
4337 void MakeSymmetryDialog::clear()
4339 elts_le_rb0->clear();
4340 modelUnregister(elts_le_rb0);
4342 vex_le_rb0->clear();
4343 modelUnregister(vex_le_rb0);
4345 elts_le_rb1->clear();
4346 modelUnregister(elts_le_rb1);
4348 vex_le_rb1->clear();
4349 modelUnregister(vex_le_rb1);
4351 vec_le_rb1->clear();
4352 modelUnregister(vec_le_rb1);
4354 elts_le_rb2->clear();
4355 modelUnregister(elts_le_rb2);
4357 vex_le_rb2->clear();
4358 modelUnregister(vex_le_rb2);
4360 vec_le_rb2->clear();
4361 modelUnregister(vec_le_rb2);
4363 modelUnregister(this);
4366 // ============================================================== updateHelpFileName
4367 void MakeSymmetryDialog::updateHelpFileName()
4369 if ( sender() == rb0 ){
4370 _helpFileName = "gui_make_symmetry.html#make-elements-by-point-symmetry";
4371 } else if ( sender() == rb1 ){
4372 _helpFileName = "gui_make_symmetry.html#make-elements-by-line-symmetry";
4373 } else if ( sender() == rb2 ){
4374 _helpFileName = "gui_make_symmetry.html#make-elements-by-plane-symmetry";
4378 // ============================================================== apply
4379 bool MakeSymmetryDialog::apply(QModelIndex& result)
4381 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
4383 if (getDocumentModel() == NULL) return false;
4384 const PatternDataModel* patternDataModel = getPatternDataModel();
4385 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
4386 if ( !patternDataModel || !patternBuilderModel) return false;
4388 SUIT_OverrideCursor wc;
4389 QModelIndex iNewElts;
4391 if ( rb0->isChecked() ){
4392 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] );
4393 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb0] );
4395 if ( ielts.isValid()
4397 iNewElts = getDocumentModel()->makeSymmetryPoint( ielts, ivex );
4400 } else if ( rb1->isChecked() ){
4401 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] );
4402 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
4403 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb1] );
4405 if ( ielts.isValid()
4408 iNewElts = getDocumentModel()->makeSymmetryLine( ielts, ivex, ivec );
4410 } else if ( rb2->isChecked() ){
4411 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb2] );
4412 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb2] );
4413 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
4415 if ( ielts.isValid()
4418 iNewElts = getDocumentModel()->makeSymmetryPlane( ielts, ivex, ivec );
4421 if ( !iNewElts.isValid() ){
4422 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE TRANSFORMATION" ) );
4426 result = patternBuilderModel->mapFromSource(iNewElts);
4431 // // ------------------------- PerformTransformationDialog ----------------------------------
4432 // ============================================================== Constructeur
4434 PerformTransformationDialog::PerformTransformationDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
4435 HexaBaseDialog(parent, editmode, f)
4438 _initWidget(editmode);
4439 // rb0->setFocusProxy( elts_le_rb0 );
4440 // rb1->setFocusProxy( elts_le_rb1 );
4441 // rb2->setFocusProxy( elts_le_rb2 );
4442 // setFocusProxy( rb0 );
4445 _helpFileName = "gui_modify_elmts.html#modify-elements-by-translation";
4446 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4447 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4448 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4451 // ============================================================== Destructeur
4452 PerformTransformationDialog::~PerformTransformationDialog()
4456 // ============================================================== _initInputWidget
4457 void PerformTransformationDialog::_initInputWidget( Mode editmode )
4460 QValidator *validator = new QRegExpValidator(rx, this);
4462 vec_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
4463 elts_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4464 vec_le_rb0->setValidator( validator );
4465 elts_le_rb0->setValidator( validator );
4466 vec_le_rb0->installEventFilter(this);
4467 elts_le_rb0->installEventFilter(this);
4469 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4470 elts_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4471 vex_le_rb1->setValidator( validator );
4472 elts_le_rb1->setValidator( validator );
4473 vex_le_rb1->installEventFilter(this);
4474 elts_le_rb1->installEventFilter(this);
4477 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4478 vec_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
4479 elts_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4480 vex_le_rb2->setValidator( validator );
4481 vec_le_rb2->setValidator( validator );
4482 elts_le_rb2->setValidator( validator );
4483 vex_le_rb2->installEventFilter(this);
4484 vec_le_rb2->installEventFilter(this);
4485 elts_le_rb2->installEventFilter(this);
4487 vec_le_rb0->setReadOnly(true);
4488 elts_le_rb0->setReadOnly(true);
4489 vex_le_rb1->setReadOnly(true);
4490 elts_le_rb1->setReadOnly(true);
4491 vex_le_rb2->setReadOnly(true);
4492 vec_le_rb2->setReadOnly(true);
4493 elts_le_rb2->setReadOnly(true);
4497 // ============================================================== clear
4498 void PerformTransformationDialog::clear()
4500 vec_le_rb0->clear();
4501 modelUnregister(vec_le_rb0);
4503 elts_le_rb0->clear();
4504 modelUnregister(elts_le_rb0);
4506 vex_le_rb1->clear();
4507 modelUnregister(vex_le_rb1);
4509 elts_le_rb1->clear();
4510 modelUnregister(elts_le_rb1);
4512 vex_le_rb2->clear();
4513 modelUnregister(vex_le_rb2);
4515 vec_le_rb2->clear();
4516 modelUnregister(vec_le_rb2);
4518 elts_le_rb2->clear();
4519 modelUnregister(elts_le_rb2);
4521 modelUnregister(this);
4524 // ============================================================== updateHelpFileName
4525 void PerformTransformationDialog::updateHelpFileName()
4527 if ( sender() == rb0 ){
4528 _helpFileName = "gui_modify_elmts.html#modify-elements-by-translation";
4529 } else if ( sender() == rb1 ){
4530 _helpFileName = "gui_modify_elmts.html#modify-elements-by-scaling";
4531 } else if ( sender() == rb2 ){
4532 _helpFileName = "gui_modify_elmts.html#modify-elements-by-rotation";
4537 // ============================================================== apply
4538 bool PerformTransformationDialog::apply(QModelIndex& result)
4540 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
4543 SUIT_OverrideCursor wc;
4544 if (getDocumentModel() == NULL) return false;
4545 const PatternDataModel* patternDataModel = getPatternDataModel();
4546 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
4547 if ( !patternDataModel || !patternBuilderModel) return false;
4549 bool performed = false;
4551 if ( rb0->isChecked() ){
4552 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] );
4553 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb0] );
4555 if ( ielts.isValid()
4557 performed = getDocumentModel()->performTranslation( ielts, ivec );
4559 } else if ( rb1->isChecked() ){
4560 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] );
4561 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
4562 double k = k_spb->value();
4564 if ( ielts.isValid()
4566 performed = getDocumentModel()->performScale( ielts, ivex, k );
4568 } else if ( rb2->isChecked() ){
4569 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb2] );
4570 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb2] );
4571 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
4572 double angle = angle_spb->value();
4574 if ( ielts.isValid()
4577 performed = getDocumentModel()->performRotation( ielts, ivex, ivec, angle );
4580 if ( performed == false){
4581 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT PERFORM TRANSFORMATION" ) );
4590 // // ------------------------- PerformSymmetryDialog ----------------------------------
4592 // ============================================================== Constructeur
4594 PerformSymmetryDialog::PerformSymmetryDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
4595 : HexaBaseDialog(parent, editmode, f)
4598 _initWidget( editmode );
4599 // rb0->setFocusProxy( elts_le_rb0 );
4600 // rb1->setFocusProxy( elts_le_rb1 );
4601 // rb2->setFocusProxy( elts_le_rb2 );
4602 // setFocusProxy( rb0 );
4605 _helpFileName = "gui_modify_symmetry.html#modify-elements-by-point-symmetry";
4606 connect( rb0, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4607 connect( rb1, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4608 connect( rb2, SIGNAL(clicked()), this, SLOT(updateHelpFileName()) );
4611 // ============================================================== Destructeur
4612 PerformSymmetryDialog::~PerformSymmetryDialog()
4616 // ============================================================== _initInputWidget
4617 void PerformSymmetryDialog::_initInputWidget( Mode editmode )
4620 QValidator *validator = new QRegExpValidator(rx, this);
4622 vex_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4623 elts_le_rb0->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4624 vex_le_rb0->setValidator( validator );
4625 elts_le_rb0->setValidator( validator );
4626 vex_le_rb0->installEventFilter(this);
4627 elts_le_rb0->installEventFilter(this);
4629 vex_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4630 vec_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
4631 elts_le_rb1->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4632 vex_le_rb1->setValidator( validator );
4633 vec_le_rb1->setValidator( validator );
4634 elts_le_rb1->setValidator( validator );
4635 vex_le_rb1->installEventFilter(this);
4636 vec_le_rb1->installEventFilter(this);
4637 elts_le_rb1->installEventFilter(this);
4640 vex_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4641 vec_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
4642 elts_le_rb2->setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
4643 vex_le_rb2->setValidator( validator );
4644 vec_le_rb2->setValidator( validator );
4645 elts_le_rb2->setValidator( validator );
4646 vex_le_rb2->installEventFilter(this);
4647 vec_le_rb2->installEventFilter(this);
4648 elts_le_rb2->installEventFilter(this);
4650 vex_le_rb0->setReadOnly(true);
4651 elts_le_rb0->setReadOnly(true);
4652 vex_le_rb1->setReadOnly(true);
4653 vec_le_rb1->setReadOnly(true);
4654 elts_le_rb1->setReadOnly(true);
4655 vex_le_rb2->setReadOnly(true);
4656 vec_le_rb2->setReadOnly(true);
4657 elts_le_rb2->setReadOnly(true);
4661 // ============================================================== clear
4662 void PerformSymmetryDialog::clear()
4664 vex_le_rb0->clear();
4665 modelUnregister(vex_le_rb0);
4667 elts_le_rb0->clear();
4668 modelUnregister(elts_le_rb0);
4670 elts_le_rb1->clear();
4671 modelUnregister(elts_le_rb1);
4673 vex_le_rb1->clear();
4674 modelUnregister(vex_le_rb1);
4676 vec_le_rb1->clear();
4677 modelUnregister(vec_le_rb1);
4679 elts_le_rb2->clear();
4680 modelUnregister(elts_le_rb2);
4682 vex_le_rb2->clear();
4683 modelUnregister(vex_le_rb2);
4685 vec_le_rb2->clear();
4686 modelUnregister(vec_le_rb2);
4688 modelUnregister(this);
4691 // ============================================================== updateHelpFileName
4692 void PerformSymmetryDialog::updateHelpFileName()
4694 if ( sender() == rb0 ){
4695 _helpFileName = "gui_modify_symmetry.html#modify-elements-by-point-symmetry";
4696 } else if ( sender() == rb1 ){
4697 _helpFileName = "gui_modify_symmetry.html#modify-elements-by-line-symmetry";
4698 } else if ( sender() == rb2 ){
4699 _helpFileName = "gui_modify_symmetry.html#modify-elements-by-plane-symmetry";
4703 // ============================================================== apply
4704 bool PerformSymmetryDialog::apply(QModelIndex& result)
4706 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
4709 SUIT_OverrideCursor wc;
4710 if (getDocumentModel() == NULL) return false;
4711 const PatternDataModel* patternDataModel = getPatternDataModel();
4712 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
4713 if ( !patternDataModel || !patternBuilderModel) return false;
4715 bool performed = false;
4717 if ( rb0->isChecked() ){
4718 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb0] );
4719 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb0] );
4721 if ( ielts.isValid()
4723 performed = getDocumentModel()->performSymmetryPoint( ielts, ivex );
4725 } else if ( rb1->isChecked() ){
4726 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb1] );
4727 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb1] );
4728 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb1] );
4730 if ( ielts.isValid()
4733 performed = getDocumentModel()->performSymmetryLine( ielts, ivex, ivec );
4735 } else if ( rb2->isChecked() ){
4736 QModelIndex ielts = patternBuilderModel->mapToSource( _index[elts_le_rb2] );
4737 QModelIndex ivex = patternDataModel->mapToSource( _index[vex_le_rb2] );
4738 QModelIndex ivec = patternBuilderModel->mapToSource( _index[vec_le_rb2] );
4740 if ( ielts.isValid()
4743 performed = getDocumentModel()->performSymmetryPlane( ielts, ivex, ivec );
4746 if ( performed == false ){
4747 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT PERFORM SYMMETRY" ) );
4756 // // ------------------------- EdgeAssocDialog ----------------------------------
4758 // ============================================================== Constructeur
4760 EdgeAssocDialog::EdgeAssocDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
4761 HexaBaseDialog( parent, editmode, f )
4763 _helpFileName ="gui_asso_quad_to_geom.html#one-edge";
4765 _initWidget(editmode);
4767 // setFocusProxy( edges_lw );
4771 _currentParameter = 0.;
4775 // ============================================================== Destructeur
4776 EdgeAssocDialog::~EdgeAssocDialog()
4778 // disconnect( delEdgeShortcut, SIGNAL(activated()), this, SLOT(deleteEdgeItem()) );
4779 // disconnect( delLineShortcut, SIGNAL(activated()), this, SLOT(deleteLineItem()) );
4780 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(addLine()) );
4781 disconnect( pstart_spb, SIGNAL(valueChanged(double)), this, SLOT( pstartChanged(double)) );
4782 disconnect( pend_spb, SIGNAL(valueChanged(double)), this, SLOT( pendChanged(double)) );
4785 // ============================================================== close
4786 void EdgeAssocDialog::close()
4788 HEXABLOCKGUI::assocInProgress = false;
4789 HexaBaseDialog::close();
4792 // ============================================================== _initInputWidget
4793 void EdgeAssocDialog::_initInputWidget( Mode editmode )
4796 QValidator *validator = new QRegExpValidator(rx, this);
4799 first_vex_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
4800 first_vex_le->installEventFilter(this);
4801 first_vex_le->setValidator( validator );
4803 single_edge_le->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
4804 single_edge_le->installEventFilter(this);
4806 edges_lw->setProperty( "HexaWidgetType", QVariant::fromValue(EDGE_TREE) );
4807 edges_lw->installEventFilter(this);
4811 lines_lw->setProperty("HexaWidgetType", QVariant::fromValue(GEOMEDGE_TREE) );
4812 lines_lw->setProperty( "GeomWidgetType", QVariant::fromValue(TopAbs_EDGE) );
4813 lines_lw->installEventFilter(this);
4815 single_line_le->setProperty( "HexaWidgetType", QVariant::fromValue(GEOMEDGE_TREE) );
4816 single_line_le->setProperty( "GeomWidgetType", QVariant::fromValue(TopAbs_EDGE) );
4817 single_line_le->installEventFilter(this);
4820 QShortcut* delEdgeShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X), edges_lw);
4821 QShortcut* delLineShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X), lines_lw);
4822 delLineShortcut->setContext( Qt::WidgetWithChildrenShortcut );
4823 delEdgeShortcut->setContext( Qt::WidgetWithChildrenShortcut );
4825 pend_spb->setValue(1.);
4827 first_vex_le->setReadOnly(true);
4828 single_edge_le->setReadOnly(true);
4829 single_line_le->setReadOnly(true);
4831 connect( delEdgeShortcut, SIGNAL(activated()), this, SLOT(deleteEdgeItem()) );
4832 connect( delLineShortcut, SIGNAL(activated()), this, SLOT(deleteLineItem()) );
4833 connect( pstart_spb, SIGNAL(valueChanged(double)), this, SLOT( pstartChanged(double)) );
4834 connect( pend_spb, SIGNAL(valueChanged(double)), this, SLOT( pendChanged(double)) );
4835 connect( edges_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection );
4836 connect( lines_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfGeom()), Qt::UniqueConnection );
4837 connect( single_rb, SIGNAL(clicked()), this, SLOT( refreshHighlight()), Qt::UniqueConnection );
4838 connect( multiple_rb, SIGNAL(clicked()), this, SLOT(refreshHighlight()), Qt::UniqueConnection );
4839 connect( single_rb, SIGNAL(clicked()), this, SLOT( updateHelpFileName() ) );
4840 connect( multiple_rb, SIGNAL(clicked()), this, SLOT( updateHelpFileName() ) );
4843 // ============================================================== updateHelpFileName
4844 void EdgeAssocDialog::updateHelpFileName()
4846 if ( sender() == single_rb ){
4847 _helpFileName = "gui_asso_quad_to_geom.html#one-edge";
4848 } else if ( sender() == multiple_rb ){
4849 _helpFileName = "gui_asso_quad_to_geom.html#line";
4854 // ============================================================== getAssocsVTK
4856 * Returns elements currently being associated in vtk side
4858 QModelIndexList EdgeAssocDialog::getAssocsVTK()
4860 QModelIndexList assocs;
4862 QListWidgetItem* item = NULL;
4864 if (getPatternDataSelectionModel() == NULL) return assocs;
4865 if (single_rb->isChecked())
4868 QVariant v = single_edge_le->property("QModelIndex");
4869 if ( !v.isValid() ) return assocs;
4870 assocs << v.value<QModelIndex>();
4873 else if (multiple_rb->isChecked())
4875 //ListWidget content
4876 const PatternDataModel* patternDataModel = getPatternDataModel();
4877 if ( !patternDataModel ) return assocs;
4878 for ( int r = 0; r < edges_lw->count(); ++r){
4879 item = edges_lw->item(r);
4880 iEdge = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
4881 if ( iEdge.isValid() ) assocs << iEdge;
4888 // ============================================================== getAssocsGEOM
4890 * Returns elements currently being associated in geom side
4892 QMultiMap<QString, int> EdgeAssocDialog::getAssocsGEOM()
4894 QMultiMap<QString, int> assocs;
4895 QListWidgetItem* item = NULL;
4896 DocumentModel::GeomObj geomObj;
4898 if (single_rb->isChecked())
4901 QVariant v = single_line_le->property("GeomObj");
4902 if ( !v.isValid() ) return assocs;
4903 geomObj = v.value<DocumentModel::GeomObj>();
4904 assocs.insert( geomObj.shapeName, geomObj.subid.toInt() );
4907 else if (multiple_rb->isChecked())
4909 //ListWidget content
4910 unsigned int nbEdges = lines_lw->count();
4911 for ( int r = 0; r < nbEdges; ++r){
4912 item = lines_lw->item(r);
4913 geomObj = item->data(LW_ASSOC_ROLE).value<DocumentModel::GeomObj>();
4914 assocs.insert( geomObj.shapeName, geomObj.subid.toInt() );
4921 // ============================================================== selectElementOfGeom
4923 /*Highlight in the OCC view selected elements in a listwidget,
4924 * or an element in a line edit.*/
4926 void EdgeAssocDialog::selectElementOfGeom()
4928 QListWidget* currentListWidget = dynamic_cast<QListWidget*>( sender() );
4929 if ( !currentListWidget ) return;
4931 _selectionMutex = true;
4933 QMultiMap<QString, int> geomElts;
4934 DocumentModel::GeomObj geomObj;
4935 QList<QListWidgetItem *> sel = currentListWidget->selectedItems();
4936 foreach ( QListWidgetItem *item, sel ){
4937 geomObj = item->data(LW_ASSOC_ROLE).value<DocumentModel::GeomObj>();
4938 geomElts.insert( geomObj.shapeName, geomObj.subid.toInt() );
4940 _selectionMutex = false;
4942 //highlight geom selected elts
4943 if (geomElts.size() > 0 && getPatternDataSelectionModel() != NULL)
4944 HEXABLOCKGUI::currentOccGView->highlight(geomElts);
4948 // ============================================================== clear
4949 void EdgeAssocDialog::clear()
4951 first_vex_le->clear();
4952 modelUnregister(first_vex_le);
4955 modelUnregister(edges_lw);
4959 single_edge_le->clear();
4960 modelUnregister(single_edge_le);
4962 single_line_le->clear();
4964 single_line_le->setProperty("GeomObj", invalid);
4966 modelUnregister(this);
4968 // single_edge_le->setText("");
4969 // single_line_le->setText("");
4972 // ============================================================== deleteEdgeItem
4973 void EdgeAssocDialog::deleteEdgeItem()
4975 delete edges_lw->currentItem();
4978 // ============================================================== deleteLineItem
4979 void EdgeAssocDialog::deleteLineItem()
4981 delete lines_lw->currentItem();
4985 // ============================================================== setGeomEngine
4986 void EdgeAssocDialog::setGeomEngine( GEOM::GEOM_Gen_var geomEngine )
4988 _geomEngine = geomEngine;
4991 // ============================================================== onWindowActivated
4992 void EdgeAssocDialog::onWindowActivated(SUIT_ViewManager* vm)
4994 QString vmType = vm->getType();
4995 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) ){
4997 if (single_rb->isChecked())
4998 single_edge_le->setFocus();
4999 else if (multiple_rb->isChecked() && focusWidget() != first_vex_le )
5000 edges_lw->setFocus();
5002 else if ( vmType == OCCViewer_Viewer::Type() ){
5003 globalSelection(HEXABLOCKGUI::currentOccGView->getViewWindow()); // close local contexts, if any
5004 localSelection(HEXABLOCKGUI::currentOccGView->getViewWindow(), TopAbs_EDGE);
5006 if (single_rb->isChecked())
5007 single_line_le->setFocus();
5008 else if (multiple_rb->isChecked() && focusWidget() != first_vex_le)
5009 lines_lw->setFocus();
5013 // ============================================================== createOperation
5014 GEOM::GEOM_IOperations_ptr EdgeAssocDialog::createOperation()
5016 return _geomEngine->GetIBasicOperations(getStudyId());
5019 // ============================================================== execute
5020 bool EdgeAssocDialog::execute(ObjectList& objects)
5024 GEOM::GEOM_Object_var anObj;
5025 QStringList aParameters;
5027 GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
5028 anObj = anOper->MakePointOnCurve( _currentLine.get(), _currentParameter );
5029 if ( !anObj->_is_nil() ) {
5030 objects.push_back(anObj._retn());
5036 // ============================================================== pstartChanged
5037 void EdgeAssocDialog::pstartChanged( double val )
5039 QListWidgetItem* lineItem = lines_lw->item( 0 );
5040 if (!lineItem) return;
5041 _currentLine = lineItem->data(LW_GEOM_OBJ_ROLE).value<GEOM::GeomObjPtr>();
5042 _currentParameter = pstart_spb->value();
5045 // ============================================================== pendChanged
5046 void EdgeAssocDialog::pendChanged( double val )
5048 // if ( _lastLine->_is_nil() ) return;
5049 QListWidgetItem* lineItem = lines_lw->item( lines_lw->count()-1 );
5050 if (!lineItem) return;
5051 _currentLine = lineItem->data(LW_GEOM_OBJ_ROLE).value<GEOM::GeomObjPtr>();
5052 _currentParameter = pend_spb->value();
5053 // displayPreview(true);
5056 // ============================================================== onCurrentSelectionChanged
5057 void EdgeAssocDialog::onCurrentSelectionChanged()
5061 highlightSelectedAssocs();
5065 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
5067 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
5068 if (!isOCC || !getDocumentModel())
5070 highlightSelectedAssocs();
5074 GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_EDGE);
5075 DocumentModel::GeomObj* selectedLine = getDocumentModel()->convertToGeomObj(aSelectedObject);
5076 if ( selectedLine == NULL )
5078 highlightSelectedAssocs();
5081 myLine = selectedLine;
5083 //don't allow selection on a geometry not associated to the document
5084 QString mainShapeEntry;
5085 if ( aSelectedObject->IsMainShape() ){
5086 mainShapeEntry = aSelectedObject->GetStudyEntry();
5088 GEOM::GEOM_Object_var mainShape = aSelectedObject->GetMainShape();
5089 mainShapeEntry = mainShape->GetStudyEntry();
5091 if (getDocumentModel()->getGeomObjName(mainShapeEntry).isEmpty())
5094 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), HexaBaseDialog::tr( "UNKNOWN_GEOMETRY" ) );
5098 if (single_rb->isChecked()) {
5099 single_line_le->setText(myLine->name);
5100 single_line_le->setProperty("GeomObj", QVariant::fromValue<DocumentModel::GeomObj>(*myLine));
5101 setFocusToNextField();
5103 else if( multiple_rb->isChecked() ) {
5104 QList<QListWidgetItem *> twice = lines_lw->findItems( myLine->name, Qt::MatchExactly);
5105 if ( twice.count() == 0 ){
5106 QListWidgetItem* item = new QListWidgetItem( myLine->name );
5107 item->setData( LW_ASSOC_ROLE, QVariant::fromValue<DocumentModel::GeomObj>(*myLine) );
5108 item->setData( LW_GEOM_OBJ_ROLE, QVariant::fromValue<GEOM::GeomObjPtr>(aSelectedObject) );
5109 lines_lw->addItem(item);
5112 highlightSelectedAssocs();
5115 // ============================================================== apply
5116 bool EdgeAssocDialog::apply(QModelIndex& result)
5118 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
5121 SUIT_OverrideCursor wc;
5122 bool assocOk = false;
5124 highlightSelectedAssocs();
5126 PatternDataModel* patternDataModel = getPatternDataModel();
5127 PatternGeomModel* pgm = getPatternGeomModel();
5128 PatternGeomSelectionModel* pgsm = getPatternGeomSelectionModel();
5130 QModelIndex iEdge, iGeomEdge;
5131 QModelIndexList iEdges;
5132 QListWidgetItem* item = NULL;
5133 QList<DocumentModel::GeomObj> assocs;
5134 DocumentModel::GeomObj aLine;
5135 HEXA_NS::SubShape* ssh;
5136 HEXA_NS::EdgeShape* sh;
5137 HEXA_NS::NewShapes shapes;
5138 HEXA_NS::IntVector subIds;
5141 if (single_rb->isChecked()){ //Single edge and/or line association
5143 iEdge = patternDataModel->mapToSource( _index[single_edge_le] );
5144 if ( !iEdge.isValid() || myLine == NULL)
5146 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE EDGE ASSOCIATION" ) );
5147 highlightSelectedAssocs();
5150 id = myLine->shapeName+","+myLine->subid;
5151 MESSAGE("=====> Association with geom id: " << id.toStdString());
5152 ssh = getDocumentModel()->getGeomPtr(id);
5153 sh = dynamic_cast<HEXA_NS::EdgeShape*>(ssh);
5154 iGeomEdge = sh == NULL ? QModelIndex() : pgm->mapToSource(pgsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(sh)));
5155 if (!iGeomEdge.isValid())
5157 MESSAGE("iGeomEdge IS NOT VALID: ID = " << id.toStdString());
5158 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE EDGE ASSOCIATION" ) );
5159 highlightSelectedAssocs();
5162 assocOk = getDocumentModel()->addEdgeAssociation(iEdge, iGeomEdge, pstart_spb->value(), pend_spb->value());
5164 else { //Multiple edge and/or line association
5167 iEdges = getIndexList(edges_lw);
5168 if (iEdges.count() == 0 || lines_lw->count() == 0)
5170 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE EDGE ASSOCIATION" ) );
5171 highlightSelectedAssocs();
5176 for (int r = 0; r < lines_lw->count(); ++r){
5177 item = lines_lw->item(r);
5178 aLine = item->data(LW_ASSOC_ROLE).value<DocumentModel::GeomObj>();
5179 id = aLine.shapeName+","+aLine.subid;
5180 ssh = getDocumentModel()->getGeomPtr(id);
5181 sh = dynamic_cast<HEXA_NS::EdgeShape*>(ssh);
5184 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE EDGE ASSOCIATION" ) );
5185 highlightSelectedAssocs();
5188 shapes.push_back(sh->getParentShape());
5189 subIds.push_back(sh->getIdent());
5192 if ( close_cb->isChecked() ){ //closed line
5193 QModelIndex iFirstVertex = patternDataModel->mapToSource( _index[first_vex_le] );
5194 if ( !iFirstVertex.isValid() )
5196 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE EDGE ASSOCIATION" ) );
5197 highlightSelectedAssocs();
5200 bool inv = inverse_cb->isChecked();
5201 assocOk = getDocumentModel()->associateClosedLine( iFirstVertex, iEdges, shapes, subIds, pstart_spb->value(), inv );
5204 assocOk = getDocumentModel()->associateOpenedLine( iEdges, shapes, subIds, pstart_spb->value(), pend_spb->value() );
5208 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE EDGE ASSOCIATION" ) );
5209 highlightSelectedAssocs();
5213 highlightSelectedAssocs();
5217 // ------------------------- QuadAssocDialog ----------------------------------
5218 // ============================================================== Constructeur
5219 QuadAssocDialog::QuadAssocDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
5220 HexaBaseDialog(parent, editmode, f)
5222 _helpFileName = "gui_asso_quad_to_geom.html#associate-to-a-face-or-a-shell-of-the-geometry";
5224 _initWidget(editmode);
5226 // setFocusProxy( quad_le );
5229 // ============================================================== Destructeur
5230 QuadAssocDialog::~QuadAssocDialog()
5232 disconnect( _delFaceShortcut, SIGNAL(activated()), this, SLOT(deleteFaceItem()) );
5233 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(addFace()) );
5234 delete _delFaceShortcut;
5237 // ============================================================== close
5238 void QuadAssocDialog::close()
5240 HEXABLOCKGUI::assocInProgress = false;
5241 HexaBaseDialog::close();
5244 // ============================================================== _initInputWidget
5245 void QuadAssocDialog::_initInputWidget( Mode editmode )
5248 QValidator *validator = new QRegExpValidator(rx, this);
5250 quad_le->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
5251 quad_le->installEventFilter(this);
5252 quad_le->setValidator( validator );
5255 faces_lw->setProperty( "HexaWidgetType", QVariant::fromValue(GEOMFACE_TREE) );
5256 faces_lw->setProperty( "GeomWidgetType", QVariant::fromValue(TopAbs_FACE) );
5257 faces_lw->installEventFilter(this);
5258 _delFaceShortcut = new QShortcut( QKeySequence(Qt::Key_X/*Qt::Key_Delete*/), faces_lw );
5259 _delFaceShortcut->setContext( Qt::WidgetShortcut );
5261 quad_le->setReadOnly(true);
5263 connect( _delFaceShortcut, SIGNAL(activated()), this, SLOT(deleteFaceItem()) );
5264 connect( faces_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfGeom()), Qt::UniqueConnection );
5267 // ============================================================== getAssocsVTK
5269 * Returns elements currently being associated in vtk side
5271 QModelIndexList QuadAssocDialog::getAssocsVTK()
5273 QModelIndexList assocs;
5277 QVariant v = quad_le->property("QModelIndex");
5280 assocs << v.value<QModelIndex>();
5284 // ============================================================== getAssocsGEOM
5286 * Returns elements currently being associated in geom side
5288 QMultiMap<QString, int> QuadAssocDialog::getAssocsGEOM()
5290 QMultiMap<QString, int> assocs;
5291 QListWidgetItem* item = NULL;
5292 DocumentModel::GeomObj geomObj;
5294 //ListWidget content
5295 unsigned int nbFaces = faces_lw->count();
5296 for ( int r = 0; r < nbFaces; ++r){
5297 item = faces_lw->item(r);
5298 geomObj = item->data(LW_ASSOC_ROLE).value<DocumentModel::GeomObj>();
5299 assocs.insert( geomObj.shapeName, geomObj.subid.toInt() );
5304 // ============================================================== selectElementOfGeom
5305 /*Highlight in the OCC view selected elements in a listwidget,
5306 * or an element in a line edit.*/
5308 void QuadAssocDialog::selectElementOfGeom()
5310 QListWidget* currentListWidget = dynamic_cast<QListWidget*>( sender() );
5311 if ( !currentListWidget ) return;
5313 _selectionMutex = true;
5315 QMultiMap<QString, int> geomElts;
5316 DocumentModel::GeomObj geomObj;
5317 QList<QListWidgetItem *> sel = currentListWidget->selectedItems();
5318 foreach ( QListWidgetItem *item, sel ){
5319 geomObj = item->data(LW_ASSOC_ROLE).value<DocumentModel::GeomObj>();
5320 geomElts.insert( geomObj.shapeName, geomObj.subid.toInt() );
5322 _selectionMutex = false;
5324 //highlight geom selected elts
5325 if (geomElts.size() > 0 && getPatternDataSelectionModel() != NULL)
5326 HEXABLOCKGUI::currentOccGView->highlight(geomElts);
5330 void QuadAssocDialog::clear()
5333 modelUnregister(quad_le);
5337 modelUnregister(this);
5340 // ============================================================== onCurrentSelectionChanged
5341 void QuadAssocDialog::onCurrentSelectionChanged()
5346 highlightSelectedAssocs();
5350 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
5352 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
5353 // bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
5354 if (!isOCC || !getDocumentModel())
5356 highlightSelectedAssocs();
5360 GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_FACE);
5361 DocumentModel::GeomObj* aFace = getDocumentModel()->convertToGeomObj(aSelectedObject);
5364 highlightSelectedAssocs();
5368 //don't allow selection on a geometry not associated to the document
5369 QString mainShapeEntry;
5370 if ( aSelectedObject->IsMainShape() ){
5371 mainShapeEntry = aSelectedObject->GetStudyEntry();
5373 GEOM::GEOM_Object_var mainShape = aSelectedObject->GetMainShape();
5374 mainShapeEntry = mainShape->GetStudyEntry();
5376 if (getDocumentModel()->getGeomObjName(mainShapeEntry).isEmpty())
5379 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), HexaBaseDialog::tr( "UNKNOWN_GEOMETRY" ) );
5383 QList<QListWidgetItem *> twice = faces_lw->findItems( aFace->name, Qt::MatchExactly);
5384 if ( twice.count() == 0 ){
5385 QListWidgetItem* item = new QListWidgetItem( aFace->name );
5386 item->setData( LW_ASSOC_ROLE, QVariant::fromValue<DocumentModel::GeomObj>(*aFace) );
5387 faces_lw->addItem(item);
5388 // faces_lw->setCurrentRow( faces_lw->count() - 1 );
5391 highlightSelectedAssocs();
5394 // ============================================================== onWindowActivated
5395 void QuadAssocDialog::onWindowActivated(SUIT_ViewManager* vm)
5397 QString vmType = vm->getType();
5398 if ( (vmType == SVTK_Viewer::Type()) || (vmType == VTKViewer_Viewer::Type()) )
5399 quad_le->setFocus();
5400 else if ( vmType == OCCViewer_Viewer::Type() ){
5401 globalSelection(HEXABLOCKGUI::currentOccGView->getViewWindow()); // close local contexts, if any
5402 // localSelection(GEOM::GEOM_Object::_nil(), TopAbs_FACE);
5403 localSelection(HEXABLOCKGUI::currentOccGView->getViewWindow(), TopAbs_FACE);
5404 faces_lw->setFocus();
5408 // ============================================================== deleteFaceItem
5409 void QuadAssocDialog::deleteFaceItem()
5411 delete faces_lw->currentItem();
5415 // ============================================================== apply
5416 bool QuadAssocDialog::apply(QModelIndex& result)
5418 highlightSelectedAssocs();
5419 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
5422 SUIT_OverrideCursor wc;
5423 PatternDataModel* patternDataModel = getPatternDataModel();
5424 PatternGeomModel* pgm = getPatternGeomModel();
5425 PatternGeomSelectionModel* pgsm = getPatternGeomSelectionModel();
5428 QModelIndex iQuad, iGeomFace;
5429 HEXA_NS::SubShape* ssh;
5430 HEXA_NS::FaceShape* sh;
5434 iQuad = patternDataModel->mapToSource( _index[quad_le] );
5437 QListWidgetItem* item = NULL;
5438 DocumentModel::GeomObj aFace;
5439 for ( int r = 0; r < faces_lw->count(); ++r ){
5440 item = faces_lw->item(r);
5441 aFace = item->data(LW_ASSOC_ROLE).value<DocumentModel::GeomObj>();
5442 id = aFace.shapeName+","+aFace.subid;
5443 ssh = getDocumentModel()->getGeomPtr(id);
5444 sh = dynamic_cast<HEXA_NS::FaceShape*>(ssh);
5445 iGeomFace = sh == NULL ? QModelIndex() : pgm->mapToSource(pgsm->indexBy(HEXA_DATA_ROLE, QVariant::fromValue(sh)));
5446 if (!getDocumentModel()->addQuadAssociation(iQuad, iGeomFace))
5448 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE QUAD ASSOCIATION" ) );
5449 highlightSelectedAssocs();
5454 result = patternDataModel->mapFromSource(iQuad);
5456 highlightSelectedAssocs();
5462 // ------------------------- GroupDialog ----------------------------------
5464 // ============================================================== Constructeur
5466 GroupDialog::GroupDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
5467 HexaBaseDialog(parent, editmode, f),
5470 _helpFileName = "gui_groups.html#add-group";
5472 _initWidget(editmode);
5473 // setFocusProxy( name_le/*eltBase_lw */);
5475 if ( editmode == NEW_MODE ){
5476 setWindowTitle( tr("Group Construction") );
5477 } else if ( editmode == UPDATE_MODE ){
5478 setWindowTitle( tr("Group Modification") );
5479 } else if ( editmode == INFO_MODE ){
5480 setWindowTitle( tr("Group Information") );
5484 // ============================================================== Destructeur
5485 GroupDialog::~GroupDialog()
5489 // ============================================================== getAssocsVTK
5491 * Returns elements currently being associated in vtk side
5493 QModelIndexList GroupDialog::getAssocsVTK()
5495 QModelIndexList assocs;
5497 QListWidgetItem* item = NULL;
5498 if (getPatternDataSelectionModel() == NULL) return assocs;
5499 //ListWidget content
5500 const PatternDataModel* patternDataModel = getPatternDataModel();
5501 if ( !patternDataModel ) return assocs;
5502 for ( int r = 0; r < eltBase_lw->count(); ++r){
5503 item = eltBase_lw->item(r);
5504 iItem = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
5505 if ( iItem.isValid() ) assocs << iItem;
5510 // ============================================================== _initInputWidget
5511 void GroupDialog::_initInputWidget( Mode editmode )
5513 // setProperty( "HexaWidgetType", QVariant::fromValue(GROUP_TREE) );
5514 installEventFilter(this);
5516 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(GROUP_TREE) );
5517 name_le->installEventFilter(this);
5520 strKind[ HEXA_NS::HexaCell ] = "HexaCell";
5521 strKind[ HEXA_NS::QuadCell ] = "QuadCell";
5522 strKind[ HEXA_NS::EdgeCell ] = "EdgeCell";
5523 strKind[ HEXA_NS::HexaNode ] = "HexaNode";
5524 strKind[ HEXA_NS::QuadNode ] = "QuadNode";
5525 strKind[ HEXA_NS::EdgeNode ] = "EdgeNode";
5526 strKind[ HEXA_NS::VertexNode ] = "VertexNode";
5528 QMap<HEXA_NS::EnumGroup, QString>::ConstIterator iKind;
5529 for( iKind = strKind.constBegin(); iKind != strKind.constEnd(); ++iKind )
5530 kind_cb->addItem( iKind.value(), QVariant(iKind.key()) );
5532 onKindChanged( kind_cb->currentIndex() );
5533 eltBase_lw->installEventFilter(this);
5535 if ( editmode != INFO_MODE ){
5536 QShortcut* delEltShortcut = new QShortcut( QKeySequence(Qt::Key_X), eltBase_lw );
5537 delEltShortcut->setContext( Qt::WidgetShortcut );
5538 connect(delEltShortcut, SIGNAL(activated()), this, SLOT(removeEltBase()));
5539 connect(kind_cb, SIGNAL(activated(int)), this, SLOT(onKindChanged(int)) );
5542 if ( editmode == INFO_MODE)
5544 name_le->setReadOnly(true);
5545 kind_cb->setEnabled(false);
5548 connect(eltBase_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection);
5551 // ============================================================== clear
5552 void GroupDialog::clear()
5556 eltBase_lw->clear();
5557 modelUnregister(eltBase_lw);
5559 modelUnregister(this);
5562 // ============================================================== onKindChanged
5563 void GroupDialog::onKindChanged(int index)
5566 switch ( kind_cb->itemData(index).toInt() ){
5567 case HEXA_NS::HexaCell:
5568 case HEXA_NS::HexaNode:
5569 eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(HEXA_TREE));
5572 case HEXA_NS::QuadCell:
5573 case HEXA_NS::QuadNode:
5574 eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(QUAD_TREE));
5577 case HEXA_NS::EdgeCell:
5578 case HEXA_NS::EdgeNode: eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(EDGE_TREE));
5581 case HEXA_NS::VertexNode:
5582 eltBase_lw->setProperty("HexaWidgetType", QVariant::fromValue(VERTEX_TREE));
5585 default:Q_ASSERT(false);
5587 eltBase_lw->clear();
5588 eltBase_lw->setFocus();
5591 // ============================================================== setValue
5592 void GroupDialog::setValue(HEXA_NS::Group* g)
5595 name_le->setText( g->getName() );
5599 kind_cb->addItem ( strKind[g->getKind()], QVariant( g->getKind() ) );
5600 // onKindChanged( kind_cb->currentIndex() );
5603 HEXA_NS::EltBase* eltBase = NULL;
5604 QListWidgetItem* item = NULL;
5605 QModelIndex iEltBase;
5606 QList<QStandardItem *> eltBaseItems;
5609 if ( !getPatternDataSelectionModel() ) return;
5610 if ( !getGroupsSelectionModel() ) return;
5612 QModelIndex iGroup = getGroupsSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(g) );
5613 name_le->setProperty( "QModelIndex", QVariant::fromValue(iGroup) );
5616 for ( int nr = 0; nr < g->countElement(); ++nr ){
5617 eltBase = g->getElement( nr );
5618 switch ( g->getKind() ){
5619 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: v = QVariant::fromValue( (HEXA_NS::Hexa *)eltBase ); break;
5620 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: v = QVariant::fromValue( (HEXA_NS::Quad *)eltBase ); break;
5621 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: v = QVariant::fromValue( (HEXA_NS::Edge *)eltBase ); break;
5622 case HEXA_NS::VertexNode: v = QVariant::fromValue( (HEXA_NS::Vertex *)eltBase ); break;
5624 iEltBase = getPatternDataSelectionModel()->indexBy( HEXA_DATA_ROLE, v);
5625 if ( iEltBase.isValid() ){
5626 item = new QListWidgetItem( eltBase->getName() );
5627 item->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(iEltBase) );
5628 item->setData(LW_DATA_ROLE, iEltBase.data(HEXA_DATA_ROLE));
5629 eltBase_lw->addItem( item );
5636 // ============================================================== getValue
5637 HEXA_NS::Group* GroupDialog::getValue()
5643 // ============================================================== removeEltBase
5644 void GroupDialog::removeEltBase()
5646 QListWidgetItem *item = eltBase_lw->currentItem();
5649 int r = eltBase_lw->row(item);
5650 eltBase_lw->takeItem(r);
5656 // ============================================================== apply
5657 bool GroupDialog::apply(QModelIndex& result)
5659 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
5662 SUIT_OverrideCursor wc;
5664 if ( !getDocumentModel() ) return false;
5665 const PatternDataModel* patternDataModel = getPatternDataModel();
5666 const GroupsModel* groupsModel = getGroupsModel();
5667 if (patternDataModel == NULL || groupsModel == NULL) return false;
5669 QString grpName = name_le->text();
5670 DocumentModel::Group grpKind = static_cast<DocumentModel::Group>( kind_cb->itemData( kind_cb->currentIndex() ).toInt());
5672 if ( _value == NULL ){ // create group
5673 iGrp = getDocumentModel()->addGroup( grpName, grpKind );
5675 QModelIndexList iGrps = getDocumentModel()->match(
5676 getDocumentModel()->index(0, 0),
5678 QVariant::fromValue( _value ),
5680 Qt::MatchRecursive );
5681 if ( !iGrps.isEmpty() )
5686 if ( !iGrp.isValid() ){
5687 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD GROUP" ) );
5691 //fill it and select it
5692 QModelIndex iEltBase;
5693 QListWidgetItem* item = NULL;
5694 bool eltAdded = false;
5695 getDocumentModel()->clearGroupElement(iGrp);
5696 for ( int r = 0; r < eltBase_lw->count(); ++r){
5697 item = eltBase_lw->item(r);
5698 iEltBase = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
5699 if ( iEltBase.isValid() )
5700 eltAdded = getDocumentModel()->addGroupElement( iGrp, iEltBase );
5701 // if ( eltAdded == false ){
5702 // //SUIT_MessageBox::information( this, tr( "HEXA_INFO" ), tr( "ELEMENT NOT ADDED : %1" ).arg( iEltBase.data().toString() ));
5706 QString newName = name_le->text();
5707 if ( !newName.isEmpty() )/*{*/
5708 getDocumentModel()->setName( iGrp, newName );
5710 HEXA_NS::Group* hGroup = getDocumentModel()->data(iGrp, HEXA_DATA_ROLE).value<HEXA_NS::Group *>();
5714 name_le->setText(hGroup->getNextName(buffer));
5715 // updateDefaultName(name_le, hGroup->getType()); //to be tested to debug default name
5718 result = groupsModel->mapFromSource(iGrp);
5725 // ------------------------- LawDialog ----------------------------------
5727 // ============================================================== Constructeur
5729 LawDialog::LawDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
5730 : HexaBaseDialog(parent, editmode, f),
5733 _helpFileName = "gui_discret_law.html#add-law";
5735 _initWidget(editmode);
5736 if ( editmode == NEW_MODE ){
5737 setWindowTitle( tr("Law Construction") );
5738 } else if ( editmode == UPDATE_MODE ){
5739 setWindowTitle( tr("Law Modification") );
5741 else if ( editmode == INFO_MODE){
5742 setWindowTitle( tr("Law Information") );
5746 // ============================================================== Destructeur
5747 LawDialog::~LawDialog()
5751 // ============================================================== _initInputWidget
5752 void LawDialog::_initInputWidget( Mode editmode )
5756 // setProperty( "HexaWidgetType", QVariant::fromValue(LAW_TREE) );
5757 installEventFilter(this);
5759 // name_le->setProperty( "HexaWidgetType", QVariant::fromValue(LAW_TREE) );
5760 name_le->installEventFilter(this);
5763 strKind[ HEXA_NS::Uniform ] = "Uniform";
5764 strKind[ HEXA_NS::Arithmetic ] = "Arithmetic";
5765 strKind[ HEXA_NS::Geometric ] = "Geometric";
5768 QMap<HEXA_NS::KindLaw, QString>::ConstIterator iKind;
5769 for( iKind = strKind.constBegin(); iKind != strKind.constEnd(); ++iKind )
5770 kind_cb->addItem( iKind.value(), QVariant(iKind.key()) );
5772 if (editmode == INFO_MODE)
5774 name_le->setReadOnly(true);
5775 nb_nodes_spb->setReadOnly(true);
5776 coeff_spb->setReadOnly(true);
5777 kind_cb->setEnabled(false);
5782 // ============================================================== clear
5783 void LawDialog::clear()
5787 modelUnregister(this);
5790 // ============================================================== setValue
5791 void LawDialog::setValue(HEXA_NS::Law* l)
5794 name_le->setText( l->getName() );
5796 nb_nodes_spb->setValue( l->getNodes() );
5797 coeff_spb->setValue( l->getCoefficient() );
5799 HEXA_NS::KindLaw k = l->getKind();
5800 kind_cb->setCurrentIndex( kind_cb->findData(k) );
5805 // ============================================================== getValue
5806 HEXA_NS::Law* LawDialog::getValue()
5812 // ============================================================== apply
5813 bool LawDialog::apply(QModelIndex& result)
5815 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
5818 SUIT_OverrideCursor wc;
5819 if ( !getDocumentModel() ) return false;
5821 const MeshModel* meshModel = getMeshModel();
5822 if (meshModel == NULL) return false;
5824 QString lawName = name_le->text();
5825 int nbnodes = nb_nodes_spb->value();
5826 double coeff = coeff_spb->value();
5827 DocumentModel::KindLaw lawKind = static_cast<DocumentModel::KindLaw>( kind_cb->itemData( kind_cb->currentIndex() ).toInt());
5830 if ( _value == NULL ){ // create Law
5831 iLaw = getDocumentModel()->addLaw( lawName, nbnodes );
5833 QModelIndexList iLaws = getDocumentModel()->match(
5834 getDocumentModel()->index(0, 0),
5836 QVariant::fromValue( _value ),
5838 Qt::MatchRecursive );
5839 if ( !iLaws.isEmpty() )
5843 if ( !iLaw.isValid() ){
5844 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD LAW" ) );
5847 //fill it and select it
5848 bool setOk = getDocumentModel()->setLaw( iLaw, nbnodes, coeff, lawKind );
5850 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT ADD LAW" ) );
5854 QString newName = name_le->text();
5855 if ( !newName.isEmpty() )/*{*/
5856 getDocumentModel()->setName( iLaw, newName );
5858 HEXA_NS::Law* hLaw = getDocumentModel()->data(iLaw, HEXA_DATA_ROLE).value<HEXA_NS::Law *>();
5862 name_le->setText(hLaw->getNextName(buffer));
5863 // updateDefaultName(name_le, hLaw->getType()); //to be tested to debug default name
5867 result = meshModel->mapFromSource(iLaw);
5875 // ------------------------- PropagationDialog ----------------------------------
5877 // ============================================================== Constructeur
5879 PropagationDialog::PropagationDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f )
5880 : HexaBaseDialog(parent, editmode, f),
5883 _helpFileName = "gui_propag.html";
5885 _initWidget(editmode);
5886 // setFocusProxy( law_le );
5887 // setFocusProxy( propagations_lw );
5889 if ( editmode == INFO_MODE ){
5890 setWindowTitle( tr("Propagation Information") );
5893 } else if ( editmode == UPDATE_MODE ){
5894 setWindowTitle( tr("Propagation Modification") );
5897 } else if ( editmode == NEW_MODE ){
5898 setWindowTitle( tr("Propagation(s) Setting") );
5903 // ============================================================== Destructeur
5904 PropagationDialog::~PropagationDialog()
5909 // ============================================================== _initInputWidget
5910 void PropagationDialog::_initInputWidget( Mode editmode )
5913 QValidator *validator = new QRegExpValidator(rx, this);
5915 // setProperty( "HexaWidgetType", QVariant::fromValue(PROPAGATION_TREE) );
5916 installEventFilter(this);
5919 law_le->setProperty( "HexaWidgetType", QVariant::fromValue(LAW_TREE) );
5920 law_le->installEventFilter(this);
5921 law_le->setValidator( validator );
5923 propagations_lw->setProperty( "HexaWidgetType", QVariant::fromValue(PROPAGATION_TREE) );
5924 propagations_lw->installEventFilter(this);
5926 QShortcut* delPropagationShortcut = new QShortcut(QKeySequence(/*Qt::Key_Delete*/Qt::Key_X/*Qt::Key_Alt*//*Qt::Key_Space*/), propagations_lw);
5927 delPropagationShortcut->setContext( Qt::WidgetShortcut );
5929 law_le->setReadOnly(true);
5931 if ( editmode == INFO_MODE)
5932 way_cb->setEnabled(false);
5934 connect( delPropagationShortcut, SIGNAL(activated()), this, SLOT(deletePropagationItem()) );
5935 connect( propagations_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection );
5939 // ============================================================== clear
5940 void PropagationDialog::clear()
5942 propagations_lw->clear();
5943 modelUnregister(propagations_lw);
5946 modelUnregister(law_le);
5948 modelUnregister(this);
5951 // ============================================================== deletePropagationItem
5952 void PropagationDialog::deletePropagationItem()
5954 delete propagations_lw->currentItem();
5958 // ============================================================== setValue
5959 void PropagationDialog::setValue(HEXA_NS::Propagation* p)
5961 if (getMeshSelectionModel() == NULL) return;
5962 HEXA_NS::Law* l = p->getLaw();
5963 bool way = p->getWay();
5966 QModelIndex ip = getMeshSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(p) );
5967 setProperty( "QModelIndex", QVariant::fromValue<QModelIndex>(ip) );
5969 // law on propagation
5971 law_le->setText( l->getName() );
5972 QModelIndex il = getMeshSelectionModel()->indexBy( HEXA_DATA_ROLE, QVariant::fromValue(l) );
5973 law_le->setProperty( "QModelIndex", QVariant::fromValue<QModelIndex>(il) );
5976 // way of propagation
5977 way_cb->setChecked(way);
5982 // ============================================================== selectElementOfModel
5984 /*Selects in the model (treeview) elements selected in a listwidget,
5985 * or an element in a line edit.*/
5987 void PropagationDialog::selectElementOfModel()
5989 if (!getMeshSelectionModel()) return;
5991 QListWidget* currentListWidget = dynamic_cast<QListWidget*>( sender() );
5992 if ( !currentListWidget ) return;
5994 _selectionMutex = true;
5996 QList<QListWidgetItem *> sel = currentListWidget->selectedItems();
5998 getMeshSelectionModel()->clearSelection();
5999 foreach ( QListWidgetItem *item, sel ){
6000 index = item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>();
6001 if ( index.isValid() )
6003 getMeshSelectionModel()->select( index, QItemSelectionModel::Select );
6006 _selectionMutex = false;
6011 // ============================================================== getValue
6012 HEXA_NS::Propagation* PropagationDialog::getValue()
6018 // ============================================================== apply
6019 bool PropagationDialog::apply(QModelIndex& result)
6021 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
6025 SUIT_OverrideCursor wc;
6026 if ( !getDocumentModel() ) return false;
6027 const MeshModel* meshModel = getMeshModel();
6028 if (meshModel == NULL) return false;
6030 bool way = way_cb->isChecked();
6031 QListWidgetItem* item = NULL;
6033 QModelIndex iPropagation;
6034 QModelIndex iLaw = meshModel->mapToSource( law_le->property("QModelIndex").value<QModelIndex>() );
6035 if (!iLaw.isValid() ){
6036 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT SET PROPAGATION" ) );
6040 for (int r = 0; r < propagations_lw->count(); ++r){
6041 item = propagations_lw->item(r);
6042 iPropagation = meshModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
6043 if ( !iPropagation.isValid() ){
6044 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT SET PROPAGATION" ) );
6048 //fill it and select it
6049 isOk = getDocumentModel()->setPropagation( iPropagation, iLaw, way );
6051 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT SET PROPAGATION" ) );
6055 result = meshModel->mapFromSource(iPropagation);
6062 // ------------------------- ComputeMeshDialog ----------------------------------
6064 // ============================================================== Constructeur
6066 ComputeMeshDialog::ComputeMeshDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
6067 HexaBaseDialog(parent, editmode, f)
6069 _helpFileName = "gui_mesh.html";
6070 setWindowTitle( tr("Compute mesh") );
6071 QVBoxLayout* layout = new QVBoxLayout;
6074 QHBoxLayout* up = new QHBoxLayout;
6075 QHBoxLayout* down = new QHBoxLayout;
6077 layout->addLayout(up);
6078 layout->addLayout(down);
6080 QVBoxLayout* vlg = new QVBoxLayout;
6081 QVBoxLayout* vld = new QVBoxLayout;
6086 vlg->addWidget(new QLabel("Name"));
6087 vlg->addWidget(new QLabel("Dimension"));
6088 vlg->addWidget(new QLabel("Container"));
6090 _name = new QLineEdit("Mesh");
6091 _dim = new QSpinBox();
6092 _fact = new QLineEdit("FactoryServer");
6094 vld->addWidget(_name);
6095 vld->addWidget(_dim);
6096 vld->addWidget(_fact);
6098 _dim->setRange(1, 3);
6101 _initWidget(editmode);
6105 // ============================================================== Destructeur
6106 ComputeMeshDialog::~ComputeMeshDialog()
6111 // ============================================================== _initInputWidget
6112 void ComputeMeshDialog::_initInputWidget( Mode editmode )
6116 // ============================================================== setDocumentModel
6117 void ComputeMeshDialog::setDocumentModel(DocumentModel* m)
6119 // HexaBaseDialog::setDocumentModel(m);
6120 if (m == NULL) return;
6121 _name->setText(m->getName());
6124 // ============================================================== clear
6125 void ComputeMeshDialog::clear()
6127 modelUnregister(this);
6130 // ============================================================== apply
6131 bool ComputeMeshDialog::apply(QModelIndex& result)
6133 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
6136 SUIT_OverrideCursor wc;
6137 if (getDocumentModel() == NULL) return false;
6138 QString command = QString("import hexablock ; %1 = hexablock.mesh(\"%2\", \"%1\", %3, \"%4\")")
6139 .arg( _name->text() )
6140 .arg( getDocumentModel()->getName() )
6141 .arg( _dim->value() )
6142 .arg( _fact->text() );
6143 //std::cout << "command: " << command.toStdString() << std::endl;
6145 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
6146 PyConsole_Console* pyConsole = app->pythonConsole();
6149 pyConsole->exec( command );
6157 // void ComputeMeshDialog::accept() {
6158 // _disallowSelection();
6159 // QDialog::accept();
6161 // QString command = QString("import hexablock ; %1 = hexablock.mesh(\"%1\", \"%2\", %3, \"%4\")")
6162 // .arg( _name->text() )
6163 // .arg( getDocumentModel()->documentEntry() )
6164 // .arg( _dim->value() )
6165 // .arg( _fact->text() );
6166 // std::cout << "command: " << command.toStdString() << std::endl;
6168 // SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
6169 // PyConsole_Console* pyConsole = app->pythonConsole();
6171 // if ( pyConsole ) pyConsole->exec( command );
6174 // void ComputeMeshDialog::reject() {
6175 // _disallowSelection();
6176 // QDialog::reject();
6181 // ------------------------- ReplaceHexaDialog ----------------------------------
6183 // ============================================================== Constructeur
6185 ReplaceHexaDialog::ReplaceHexaDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
6186 HexaBaseDialog(parent, editmode, f)
6188 _helpFileName = "gui_replace_hexa.html";
6190 _initWidget(editmode);
6191 // setFocusProxy( quads_lw );
6194 // ============================================================== Destructeur
6195 ReplaceHexaDialog::~ReplaceHexaDialog()
6199 // ============================================================== getAssocsVTK
6201 * Returns elements currently associated to vtk
6203 QModelIndexList ReplaceHexaDialog::getAssocsVTK()
6205 QModelIndexList assocs;
6207 QListWidgetItem* item = NULL;
6209 //ListWidget content
6210 const PatternDataModel* patternDataModel = getPatternDataModel();
6211 if ( !patternDataModel ) return assocs;
6212 for ( int r = 0; r < quads_lw->count(); ++r ){
6213 item = quads_lw->item(r);
6214 // iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() ); //unsafe
6215 iQuad = getPatternDataSelectionModel()->indexBy(HEXA_DATA_ROLE, item->data(LW_DATA_ROLE));
6216 if ( iQuad.isValid() ) assocs << iQuad;
6221 // ============================================================== _initInputWidget
6222 void ReplaceHexaDialog::_initInputWidget( Mode editmode )
6226 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
6227 installEventFilter(this);
6229 c1_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6230 c2_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6231 c3_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6233 p1_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6234 p2_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6235 p3_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6237 // name_le->installEventFilter(this);
6238 c1_le->installEventFilter(this);
6239 c2_le->installEventFilter(this);
6240 c3_le->installEventFilter(this);
6242 p1_le->installEventFilter(this);
6243 p2_le->installEventFilter(this);
6244 p3_le->installEventFilter(this);
6246 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
6247 quads_lw->installEventFilter(this);
6249 if ( editmode == NEW_MODE ){
6250 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
6251 delQuadShortcut->setContext( Qt::WidgetShortcut );
6253 connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(deleteQuadItem()) );
6254 connect( quads_lw, SIGNAL(currentRowChanged(int)), this, SLOT(updateButtonBox(int)) );
6257 c1_le->setReadOnly(true);
6258 c2_le->setReadOnly(true);
6259 c3_le->setReadOnly(true);
6261 p1_le->setReadOnly(true);
6262 p2_le->setReadOnly(true);
6263 p3_le->setReadOnly(true);
6265 connect(quads_lw, SIGNAL(itemSelectionChanged()),
6266 this, SLOT(selectElementOfModel()), Qt::UniqueConnection);
6269 // ============================================================== clear
6270 void ReplaceHexaDialog::clear()
6272 // name_le->clear();
6275 modelUnregister(quads_lw);
6278 modelUnregister(p1_le);
6281 modelUnregister(p2_le);
6284 modelUnregister(p3_le);
6287 modelUnregister(c1_le);
6290 modelUnregister(c2_le);
6293 modelUnregister(c3_le);
6295 modelUnregister(this);
6298 // ============================================================== updateButtonBox
6299 void ReplaceHexaDialog::updateButtonBox()
6301 int nbQuad = quads_lw->count();
6304 //_applyCloseButton->setEnabled(true);
6305 _applyButton->setEnabled(true);
6307 //_applyCloseButton->setEnabled(false);
6308 _applyButton->setEnabled(false);
6312 // ============================================================== deleteQuadItem
6313 void ReplaceHexaDialog::deleteQuadItem()
6315 delete quads_lw->currentItem();
6319 // ============================================================== apply
6320 bool ReplaceHexaDialog::apply(QModelIndex& result)
6322 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
6325 SUIT_OverrideCursor wc;
6326 if ( !getDocumentModel() ) return false;
6327 const PatternDataModel* patternDataModel = getPatternDataModel();
6328 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
6329 if ( !patternDataModel || !patternBuilderModel) return false;
6331 QModelIndex ielts; //result
6333 QListWidgetItem* item = NULL;
6334 QModelIndexList iquads;
6336 for ( int r = 0; r < quads_lw->count(); ++r){
6337 item = quads_lw->item(r);
6338 iquad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
6339 //std::cout << "iquad => " << iquad.data().toString().toStdString() << std::endl;
6340 if ( iquad.isValid() )
6344 QModelIndex ic1 = patternDataModel->mapToSource( _index[c1_le] );
6345 QModelIndex ic2 = patternDataModel->mapToSource( _index[c2_le] );
6346 QModelIndex ic3 = patternDataModel->mapToSource( _index[c3_le] );
6348 QModelIndex ip1 = patternDataModel->mapToSource( _index[p1_le] );
6349 QModelIndex ip2 = patternDataModel->mapToSource( _index[p2_le] );
6350 QModelIndex ip3 = patternDataModel->mapToSource( _index[p3_le] );
6352 // std::cout << "nbHexa => " << nbHexa << std::endl;
6354 if ( ic1.isValid() && ic2.isValid() && ic3.isValid()
6355 && ip1.isValid() && ip2.isValid() && ip3.isValid() ){
6356 ielts = getDocumentModel()->replace( iquads,
6362 if ( !ielts.isValid() ){
6363 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT REPLACE HEXA" ) );
6366 _value = ielts.model()->data(ielts, HEXA_DATA_ROLE).value<HEXA_NS::Elements*>();
6368 // QString newName = name_le->text();
6369 // if ( !newName.isEmpty() )/*{*/
6370 // getDocumentModel()->setName( ielts, newName );
6372 // updateDefaultName(name_le, ielts);
6374 result = patternBuilderModel->mapFromSource(ielts);
6376 //update the list (indexes)
6377 for ( int r = 0; r < quads_lw->count(); ++r ){
6378 item = quads_lw->item(r);
6379 iquad = getPatternDataSelectionModel()->indexBy(HEXA_DATA_ROLE, item->data(LW_DATA_ROLE));
6380 item->setData( LW_QMODELINDEX_ROLE, QVariant::fromValue<QModelIndex>(iquad) );
6381 item->setData(LW_DATA_ROLE, iquad.data(HEXA_DATA_ROLE));
6390 // ------------------------- QuadRevolutionDialog ----------------------------------
6392 // ============================================================== Constructeur
6394 QuadRevolutionDialog::QuadRevolutionDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
6395 HexaBaseDialog(parent, editmode, f)
6397 _helpFileName = "gui_quad_revolution.html";
6399 _initWidget(editmode);
6400 // setFocusProxy( quads_lw );
6403 // ============================================================== getAssocsVTK
6405 * Returns elements currently associated to vtk
6407 QModelIndexList QuadRevolutionDialog::getAssocsVTK()
6409 QModelIndexList assocs;
6411 QListWidgetItem* item = NULL;
6412 if (getPatternDataSelectionModel() == NULL) return assocs;
6414 //ListWidget content
6415 const PatternDataModel* patternDataModel = getPatternDataModel();
6416 if ( !patternDataModel ) return assocs;
6417 for ( int r = 0; r < quads_lw->count(); ++r ){
6418 item = quads_lw->item(r);
6419 iQuad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
6420 if ( iQuad.isValid() )
6426 // ============================================================== Destructeur
6427 QuadRevolutionDialog::~QuadRevolutionDialog()
6431 // ============================================================== _initInputWidget
6432 void QuadRevolutionDialog::_initInputWidget( Mode editmode )
6435 QValidator *validator = new QRegExpValidator(rx, this);
6437 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
6438 installEventFilter(this);
6440 center_pt_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6441 axis_vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
6442 quads_lw->setProperty( "HexaWidgetType", QVariant::fromValue(QUAD_TREE) );
6444 center_pt_le->setValidator( validator );
6445 axis_vec_le->setValidator( validator );
6446 // quads_lw->setValidator( validator );
6448 // name_le->installEventFilter(this);
6449 center_pt_le->installEventFilter(this);
6450 axis_vec_le->installEventFilter(this);
6451 quads_lw->installEventFilter(this);
6453 if ( editmode == NEW_MODE ){
6454 angles_lw->setItemDelegate( new HexaAngleDoubleSpinBoxDelegate(angles_lw) );
6455 angles_lw->setEditTriggers( QAbstractItemView::DoubleClicked );
6457 QShortcut* delQuadShortcut = new QShortcut( QKeySequence(Qt::Key_X), quads_lw );
6458 delQuadShortcut->setContext( Qt::WidgetShortcut );
6459 connect( delQuadShortcut, SIGNAL(activated()), this, SLOT(delQuadItem()) );
6460 connect( add_angle_pb, SIGNAL(clicked()), this, SLOT(addAngleItem()));
6461 connect( del_angle_pb, SIGNAL(clicked()), this, SLOT(delAngleItem()));
6462 // connect(clear_pb, SIGNAL(clicked()), this, SLOT(clearQuads()));
6465 center_pt_le->setReadOnly(true);
6466 axis_vec_le->setReadOnly(true);
6468 connect(quads_lw, SIGNAL(itemSelectionChanged()), this, SLOT(selectElementOfModel()), Qt::UniqueConnection);
6471 // ============================================================== clear
6472 void QuadRevolutionDialog::clear()
6474 // name_le->clear();
6477 modelUnregister(quads_lw);
6479 center_pt_le->clear();
6480 modelUnregister(center_pt_le);
6482 axis_vec_le->clear();
6483 modelUnregister(axis_vec_le);
6486 modelUnregister(angles_lw);
6488 modelUnregister(this);
6492 // ============================================================== updateButtonBox
6493 void QuadRevolutionDialog::updateButtonBox() //CS_TODO? : check center, axis
6495 int nbQuads = quads_lw->count();
6496 int nbAngles = angles_lw->count();
6498 if ( nbQuads>0 && nbAngles> 0 ){
6499 //_applyCloseButton->setEnabled(true);
6500 _applyButton->setEnabled(true);
6502 //_applyCloseButton->setEnabled(false);
6503 _applyButton->setEnabled(false);
6508 // ============================================================== addAngleItem
6509 void QuadRevolutionDialog::addAngleItem() //CS_TODO
6511 QListWidgetItem* previousItem = angles_lw->currentItem();
6512 QListWidgetItem* newItem = new QListWidgetItem();
6514 double defaultValue = 180.;
6516 defaultValue = previousItem->data(Qt::EditRole).toDouble();
6518 newItem->setData( Qt::EditRole, QVariant(defaultValue) );
6519 newItem->setFlags( newItem->flags () | Qt::ItemIsEditable);
6520 angles_lw->addItem(newItem);
6525 // ============================================================== delAngleItem
6526 void QuadRevolutionDialog::delAngleItem()
6528 delete angles_lw->currentItem();
6532 // ============================================================== delQuadItem
6533 void QuadRevolutionDialog::delQuadItem()
6535 delete quads_lw->currentItem();
6539 // ============================================================== apply
6540 bool QuadRevolutionDialog::apply(QModelIndex& result)
6542 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
6545 SUIT_OverrideCursor wc;
6546 if ( !getDocumentModel() ) return false;
6547 const PatternDataModel* patternDataModel = getPatternDataModel();
6548 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
6549 if ( !patternDataModel || !patternBuilderModel) return false;
6551 QModelIndex ielts; //result
6552 QListWidgetItem* item = NULL;
6554 QModelIndexList istartquads;
6556 for ( int r = 0; r < quads_lw->count(); ++r){
6557 item = quads_lw->item(r);
6558 iquad = patternDataModel->mapToSource( item->data(LW_QMODELINDEX_ROLE).value<QModelIndex>() );
6559 if ( iquad.isValid() )
6560 istartquads << iquad;
6563 QModelIndex icenter_pt = patternDataModel->mapToSource( _index[center_pt_le] );
6564 QModelIndex iaxis_vec = patternBuilderModel->mapToSource( _index[axis_vec_le] );
6566 QList<double> angles;
6567 for ( int r = 0; r < angles_lw->count(); ++r){
6568 item = angles_lw->item(r);
6569 angles << item->data(Qt::EditRole).toDouble();
6572 if ( icenter_pt.isValid() && iaxis_vec.isValid() ){
6573 ielts = getDocumentModel()->revolutionQuads( istartquads, icenter_pt, iaxis_vec, angles );
6576 if ( !ielts.isValid() ){
6577 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE QUAD REVOLUTION" ) );
6580 _value = ielts.model()->data(ielts, HEXA_DATA_ROLE).value<HEXA_NS::Elements*>();
6582 // QString newName = name_le->text();
6583 // if ( !newName.isEmpty() )/*{*/
6584 // getDocumentModel()->setName( ielts, newName );
6586 // updateDefaultName(name_le, ielts);
6588 result = patternBuilderModel->mapFromSource(ielts);
6595 // ------------------------- MakeHemiSphereDialog ----------------------------------
6597 // ============================================================== Constructeur
6599 MakeHemiSphereDialog::MakeHemiSphereDialog( QWidget* parent, Mode editmode, Qt::WindowFlags f ):
6600 HexaBaseDialog(parent, editmode, f)
6602 _helpFileName = "gui_hemisphere.html";
6604 _initWidget(editmode);
6607 // ============================================================== Destructeur
6608 MakeHemiSphereDialog::~MakeHemiSphereDialog()
6612 // ============================================================== _initInputWidget
6613 void MakeHemiSphereDialog::_initInputWidget( Mode editmode )
6616 QValidator *validator = new QRegExpValidator(rx, this);
6618 // setProperty( "HexaWidgetType", QVariant::fromValue(ELEMENTS_TREE) );
6619 installEventFilter(this);
6621 sphere_center_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6622 cross_pt_le->setProperty( "HexaWidgetType", QVariant::fromValue(VERTEX_TREE) );
6623 hole_axis_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
6624 cross_vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
6625 radial_vec_le->setProperty( "HexaWidgetType", QVariant::fromValue(VECTOR_TREE) );
6627 sphere_center_le->setValidator( validator );
6628 cross_pt_le->setValidator( validator );
6629 hole_axis_le->setValidator( validator );
6630 cross_vec_le->setValidator( validator );
6631 radial_vec_le->setValidator( validator );
6634 // name_le->installEventFilter(this);
6635 sphere_center_le->installEventFilter(this);
6636 cross_pt_le->installEventFilter(this);
6637 hole_axis_le->installEventFilter(this);
6638 cross_vec_le->installEventFilter(this);
6639 radial_vec_le->installEventFilter(this);
6641 sphere_center_le->setReadOnly(true);
6642 cross_pt_le->setReadOnly(true);
6643 hole_axis_le->setReadOnly(true);
6644 cross_vec_le->setReadOnly(true);
6645 radial_vec_le->setReadOnly(true);
6648 // ============================================================== clear
6649 void MakeHemiSphereDialog::clear()
6651 sphere_center_le->clear();
6652 modelUnregister(sphere_center_le);
6654 hole_axis_le->clear();
6655 modelUnregister(hole_axis_le);
6657 cross_pt_le->clear();
6658 modelUnregister(cross_pt_le);
6660 cross_vec_le->clear();
6661 modelUnregister(cross_vec_le);
6663 radial_vec_le->clear();
6664 modelUnregister(radial_vec_le);
6666 modelUnregister(this);
6669 // ============================================================== apply
6670 bool MakeHemiSphereDialog::apply(QModelIndex& result)
6672 if (_currentObj != NULL) _highlightWidget(_currentObj, Qt::white);
6675 SUIT_OverrideCursor wc;
6676 if ( !getDocumentModel() ) return false;
6677 const PatternDataModel* patternDataModel = getPatternDataModel();
6678 const PatternBuilderModel* patternBuilderModel = getPatternBuilderModel();
6679 if ( !patternDataModel || !patternBuilderModel) return false;
6682 QModelIndex icenter = patternDataModel->mapToSource( _index[sphere_center_le] );
6683 QModelIndex iplorig = patternDataModel->mapToSource( _index[cross_pt_le] );
6684 QModelIndex ivecx = patternBuilderModel->mapToSource( _index[radial_vec_le] );
6685 QModelIndex ivecz = patternBuilderModel->mapToSource( _index[hole_axis_le] );
6687 double radext = sphere_radext_spb->value();
6688 double radhole = hole_rad_spb->value();
6690 int nrad = ngrid_rad_spb->value();
6691 int nang = ngrid_ang_spb->value();
6692 int nhaut = ngrid_height_spb->value();
6695 if ( icenter.isValid() && ivecx.isValid() && ivecz.isValid() && iplorig.isValid() ){
6696 if ( sphere_rind_cb->isChecked() ){ // rind
6697 double radint = sphere_radint_spb->value();
6698 if ( radial_partial_cb->isChecked() ){
6699 double angle = radial_angle_spb->value();
6700 iElts = getDocumentModel()->makePartRind( icenter, ivecx, ivecz,
6701 radext, radint, radhole,
6703 nrad, nang, nhaut );
6705 iElts = getDocumentModel()->makeRind( icenter,
6707 radext, radint, radhole,
6709 nrad, nang, nhaut );
6712 if ( radial_partial_cb->isChecked() ){
6713 double angle = radial_angle_spb->value();
6714 iElts = getDocumentModel()->makePartSphere( icenter, ivecx, ivecz,
6717 nrad, nang, nhaut );
6719 iElts = getDocumentModel()->makeSphere( icenter,
6723 nrad, nang, nhaut );
6729 if ( !iElts.isValid() ){
6730 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "CANNOT MAKE RIND" ) );
6733 _value = iElts.model()->data(iElts, HEXA_DATA_ROLE).value<HEXA_NS::Elements*>();
6735 // QString newName = name_le->text();
6736 // if ( !newName.isEmpty() )/*{*/
6737 // getDocumentModel()->setName( iElts, newName );
6739 // updateDefaultName(name_le, iElts);
6741 result = patternBuilderModel->mapFromSource(iElts);
6746 // ------------------------- ModelInfoDialog ----------------------------------
6748 ModelInfoDialog::ModelInfoDialog(QWidget* parent, Qt::WindowFlags wf):
6749 HexaBaseDialog(parent, INFO_MODE, wf)
6752 setWindowTitle(HEXABLOCKGUI::tr("MODEL_INFO"));
6755 void ModelInfoDialog::updateInfo()
6757 DocumentModel* docModel = getDocumentModel();
6758 if (docModel == NULL) return;
6761 model_name_le->setText(docModel->getName());
6763 //Nb of elements in the model
6764 total_vertices_le->setText(QString::number(docModel->getNbrElt(HEXA_NS::EL_VERTEX)));
6765 total_edges_le->setText(QString::number(docModel->getNbrElt(HEXA_NS::EL_EDGE)));
6766 total_quads_le->setText(QString::number(docModel->getNbrElt(HEXA_NS::EL_QUAD)));
6767 total_hexas_le->setText(QString::number(docModel->getNbrElt(HEXA_NS::EL_HEXA)));
6769 ///Nb of used elements in the model
6770 used_vertices_le->setText(QString::number(docModel->getNbrUsedElt(HEXA_NS::EL_VERTEX)));
6771 used_edges_le->setText(QString::number(docModel->getNbrUsedElt(HEXA_NS::EL_EDGE)));
6772 used_quads_le->setText(QString::number(docModel->getNbrUsedElt(HEXA_NS::EL_QUAD)));
6773 used_hexas_le->setText(QString::number(docModel->getNbrUsedElt(HEXA_NS::EL_HEXA)));
6775 //Nb of unused elements in the model
6776 unused_vertices_le->setText(QString::number(docModel->getNbrUnusedElt(HEXA_NS::EL_VERTEX)));
6777 unused_edges_le->setText(QString::number(docModel->getNbrUnusedElt(HEXA_NS::EL_EDGE)));
6778 unused_quads_le->setText(QString::number(docModel->getNbrUnusedElt(HEXA_NS::EL_QUAD)));
6779 unused_hexas_le->setText(QString::number(docModel->getNbrUnusedElt(HEXA_NS::EL_HEXA)));
6782 void ModelInfoDialog::showEvent( QShowEvent * event )
6785 QDialog::showEvent ( event );
6789 // ============================================================== hideEvent
6790 void ModelInfoDialog::hideEvent ( QHideEvent * event )
6792 QDialog::hideEvent( event );
6796 // ------------------------- AddShapeDialog ----------------------------------
6798 AddShapeDialog::AddShapeDialog(QWidget* parent, Mode editmode, Qt::WindowFlags wf):
6799 HexaBaseDialog(parent, editmode, wf)
6803 _initWidget(editmode);
6804 setWindowTitle(HEXABLOCKGUI::tr("ADD_SHAPE"));
6806 currentGeomObj.nullify();
6809 // ============================================================== Destructeur
6810 AddShapeDialog::~AddShapeDialog()
6812 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL(currentSelectionChanged()),
6813 this, SLOT(onCurrentSelectionChanged()) );
6816 // ============================================================== close
6817 void AddShapeDialog::close()
6819 HEXABLOCKGUI::assocInProgress = false;
6820 HexaBaseDialog::close();
6823 // ============================================================== _initInputWidget
6824 void AddShapeDialog::_initInputWidget( Mode editmode )
6826 shape_le->setProperty( "HexaWidgetType", QVariant::fromValue(GEOMSHAPE_TREE) );
6827 shape_le->setProperty( "GeomWidgetType", QVariant::fromValue(TopAbs_SHAPE) );
6828 shape_le->installEventFilter(this);
6829 shape_le->setReadOnly(true);
6832 void AddShapeDialog::clear()
6835 shape_le->setProperty("GeomObj", QVariant());
6836 currentGeomObj.nullify();
6838 modelUnregister(this);
6841 // ============================================================== onCurrentSelectionChanged
6842 void AddShapeDialog::onCurrentSelectionChanged()
6844 if ( !isVisible() ) return;
6846 SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
6848 bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
6849 if (!isOCC || getDocumentModel() == NULL) return;
6851 currentGeomObj = getSelected(TopAbs_SHAPE);
6852 shape_le->setText(GEOMBase::GetName( currentGeomObj.get() ));
6854 DocumentModel::GeomObj* geomObj = getDocumentModel()->convertToGeomObj(currentGeomObj);
6855 if (geomObj != NULL)
6856 shape_le->setProperty("GeomObj", QVariant::fromValue<DocumentModel::GeomObj>(*geomObj));
6859 // ============================================================== onWindowActivated
6860 void AddShapeDialog::onWindowActivated(SUIT_ViewManager* vm)
6862 QString vmType = vm->getType();
6863 if ( vmType == OCCViewer_Viewer::Type() ){
6864 globalSelection(HEXABLOCKGUI::currentOccGView->getViewWindow()); // close local contexts, if any
6865 localSelection(HEXABLOCKGUI::currentOccGView->getViewWindow(), TopAbs_SHAPE);
6866 shape_le->setFocus();
6871 // ============================================================== apply
6872 bool AddShapeDialog::apply(QModelIndex& result)
6874 TopoDS_Shape aShape;
6875 bool assocOK = false;
6877 if ( currentGeomObj && GEOMBase::GetShape(currentGeomObj.get(), aShape) && !aShape.IsNull() )
6879 QString shapeName = GEOMBase::GetName( currentGeomObj.get() );
6880 assocOK = getDocumentModel()->addShape(aShape, shapeName);
6884 SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), HEXABLOCKGUI::tr("ADD_SHAPE_FAILED") );
6888 getDocumentModel()->clearGeometry();
6889 getDocumentModel()->fillGeometry();