1 // Copyright (C) 2007-2023 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, or (at your option) any later version.
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
21 // File : BLSURFPluginGUI_HypothesisCreator.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPluginGUI_HypothesisCreator.h"
28 #include "BLSURFPluginGUI_Dlg.h"
29 #include "BLSURFPlugin_Hypothesis.hxx"
31 #include <GeometryGUI.h>
33 #include <SMESHGUI_Dialog.h>
34 #include <SMESHGUI_HypothesesUtils.h>
35 #include <SMESHGUI_IdValidator.h>
36 #include <SMESHGUI_SpinBox.h>
37 #include <SMESHGUI_Utils.h>
38 #include <SMESH_Gen_i.hxx>
39 #include <SMESH_NumberFilter.hxx>
40 #include <StdMeshersGUI_SubShapeSelectorWdg.h>
42 #include <LightApp_SelectionMgr.h>
43 #include <SALOME_ListIO.hxx>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
47 #include <SalomeApp_Application.h>
48 #include <SalomeApp_Tools.h>
50 #include <QApplication>
54 #include <QGridLayout>
56 #include <QHBoxLayout>
57 #include <QHeaderView>
61 #include <QModelIndexList>
63 #include <QPushButton>
64 #include <QRadioButton>
67 #include <QStandardItem>
68 #include <QStandardItemModel>
70 #include <QTableWidget>
71 #include <QTreeWidget>
72 #include <QTreeWidgetItem>
73 #include <QVBoxLayout>
75 #include <TopoDS_Shape.hxx>
76 #include <TopoDS_Iterator.hxx>
78 #include <structmember.h> // Python
97 TBL_MESHING = 0, TBL_PRECAD, TBL_CUSTOM,
99 // Enforced vertices array columns
100 ENF_VER_NAME_COLUMN = 0,
101 ENF_VER_FACE_ENTRY_COLUMN,
105 ENF_VER_ENTRY_COLUMN,
106 ENF_VER_GROUP_COLUMN,
109 // Enforced 1D meshes
110 ENF_MESH_NB_COLUMNS = 2,
113 PERIODICITY_OBJ_SOURCE_COLUMN = 0,
114 PERIODICITY_OBJ_TARGET_COLUMN,
115 PERIODICITY_P1_SOURCE_COLUMN,
116 PERIODICITY_P2_SOURCE_COLUMN,
117 PERIODICITY_P3_SOURCE_COLUMN,
118 PERIODICITY_P1_TARGET_COLUMN,
119 PERIODICITY_P2_TARGET_COLUMN,
120 PERIODICITY_P3_TARGET_COLUMN,
121 PERIODICITY_SHAPE_TYPE,
123 // PERIODICITY_OBJ_SOURCE_COLUMN = 0,
124 // PERIODICITY_ENTRY_SOURCE_COLUMN,
125 // PERIODICITY_OBJ_TARGET_COLUMN,
126 // PERIODICITY_ENTRY_TARGET_COLUMN,
127 // PERIODICITY_P1_SOURCE_COLUMN,
128 // PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
129 // PERIODICITY_P2_SOURCE_COLUMN,
130 // PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
131 // PERIODICITY_P3_SOURCE_COLUMN,
132 // PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
133 // PERIODICITY_P1_TARGET_COLUMN,
134 // PERIODICITY_P1_ENTRY_TARGET_COLUMN,
135 // PERIODICITY_P2_TARGET_COLUMN,
136 // PERIODICITY_P2_ENTRY_TARGET_COLUMN,
137 // PERIODICITY_P3_TARGET_COLUMN,
138 // PERIODICITY_P3_ENTRY_TARGET_COLUMN,
140 PERIODICITY_NB_COLUMN
166 // Enforced vertices inputs
174 // ENF_VER_GROUP_CHECK,
178 ENF_VER_INTERNAL_ALL_FACES,
179 ENF_VER_INTERNAL_ALL_FACES_GROUP,
180 // ENF_VER_VERTEX_BTN,
181 // ENF_VER_REMOVE_BTN,
182 // ENF_VER_SEPARATOR,
187 /**************************************************
188 Begin initialization Python structures and objects
189 ***************************************************/
199 PyStdOut_dealloc(PyStdOut *self)
205 PyStdOut_write(PyStdOut *self, PyObject *args)
209 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
212 *(self->out)=*(self->out)+c;
218 static PyMethodDef PyStdOut_methods[] = {
219 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
220 PyDoc_STR("write(string) -> None")},
221 {0, 0, 0, 0} /* sentinel */
224 static PyMemberDef PyStdOut_memberlist[] = {
225 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
226 (char*)"flag indicating that a space needs to be printed; used by print"},
227 {0, 0, 0, 0, 0} /* Sentinel */
230 static PyTypeObject PyStdOut_Type = {
231 /* The ob_type field must be initialized in the module init function
232 * to be portable to Windows without using C++. */
233 PyVarObject_HEAD_INIT(NULL, 0)
235 sizeof(PyStdOut), /*tp_basicsize*/
238 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
245 0, /*tp_as_sequence*/
250 PyObject_GenericGetAttr, /*tp_getattro*/
251 /* softspace is writable: we must supply tp_setattro */
252 PyObject_GenericSetAttr, /* tp_setattro */
254 Py_TPFLAGS_DEFAULT, /*tp_flags*/
258 0, /*tp_richcompare*/
259 0, /*tp_weaklistoffset*/
262 PyStdOut_methods, /*tp_methods*/
263 PyStdOut_memberlist, /*tp_members*/
281 0, /*tp_version_tag*/
285 PyObject * newPyStdOut( std::string& out )
287 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
292 return (PyObject*)self;
296 /*************************************************
297 End initialization Python structures and objects
298 **************************************************/
302 // BEGIN EnforcedTreeWidgetDelegate
305 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
306 : QItemDelegate(parent)
310 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
311 const QStyleOptionViewItem & /*option*/ ,
312 const QModelIndex & index ) const
314 QModelIndex father = index.parent();
315 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
317 if (index.column() == ENF_VER_X_COLUMN || \
318 index.column() == ENF_VER_Y_COLUMN || \
319 index.column() == ENF_VER_Z_COLUMN)
321 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
322 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
323 editor->setReadOnly(!entry.isEmpty());
324 editor->setDisabled(!entry.isEmpty());
329 QLineEdit *editor = new QLineEdit(parent);
330 if (index.column() != ENF_VER_GROUP_COLUMN) {
331 editor->setReadOnly(!entry.isEmpty());
332 editor->setDisabled(!entry.isEmpty());
338 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
339 const QModelIndex &index) const
341 QString value = index.model()->data(index, Qt::EditRole).toString();
343 if (index.column() == ENF_VER_X_COLUMN ||
344 index.column() == ENF_VER_Y_COLUMN ||
345 index.column() == ENF_VER_Z_COLUMN)
347 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
348 lineEdit->setText(value);
351 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
352 lineEdit->setText(value);
356 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
357 const QModelIndex &index) const
359 QModelIndex parent = index.parent();
360 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
361 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
362 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
363 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
364 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
365 } else if (index.column() == ENF_VER_NAME_COLUMN) {
366 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
367 QString value = lineEdit->text();
368 if (entry.isEmpty() && !vertexExists(model, index, value))
369 model->setData(index, value, Qt::EditRole);
370 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
371 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
372 QString value = lineEdit->text();
373 if (!vertexExists(model, index, value))
374 model->setData(index, value, Qt::EditRole);
375 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
376 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
377 model->setData(index, lineEdit->text(), Qt::EditRole);
381 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
382 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
384 editor->setGeometry(option.rect);
387 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
388 const QModelIndex &index, QString value) const
391 QModelIndex parent = index.parent();
392 int row = index.row();
393 int col = index.column();
395 if (parent.isValid() && !value.isEmpty()) {
396 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
398 if (col == ENF_VER_X_COLUMN) {
399 x = value.toDouble();
400 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
401 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
403 if (col == ENF_VER_Y_COLUMN) {
404 y = value.toDouble();
405 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
406 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
408 if (col == ENF_VER_Z_COLUMN) {
409 z = value.toDouble();
410 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
411 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
413 int nbChildren = model->rowCount(parent);
414 for (int i = 0 ; i < nbChildren ; i++) {
416 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
417 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
418 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
419 if ((childX == x) && (childY == y) && (childZ == z)) {
426 else if (col == ENF_VER_NAME_COLUMN) {
427 int nbChildren = model->rowCount(parent);
428 for (int i = 0 ; i < nbChildren ; i++) {
430 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
431 if (childName == value) {
444 // END EnforcedTreeWidgetDelegate
449 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
450 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
453 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
454 : SMESHGUI_GenericHypothesisCreator( theHypType )
456 this->mySMPMap.clear();
458 GeomToolSelected = NULL;
459 GeomToolSelected = getGeomSelectionTool();
461 aSel = GeomToolSelected->selectionMgr();
463 /* Initialize the Python interpreter */
464 if (! Py_IsInitialized())
465 throw ("Error: Python interpreter is not initialized");
466 PyGILState_STATE gstate;
467 gstate = PyGILState_Ensure();
470 main_mod = PyImport_AddModule("__main__");
473 main_dict = PyModule_GetDict(main_mod);
475 PyRun_SimpleString("from math import *");
476 PyGILState_Release(gstate);
480 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
485 * \brief {Get or create the geom selection tool for active study}
487 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() const
489 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
490 if (that->GeomToolSelected == NULL) {
491 that->GeomToolSelected = new GeomSelectionTools();
493 return that->GeomToolSelected;
496 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
498 return GeometryGUI::GetGeomGen();
501 void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
503 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
504 ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
505 for ( ; anIt != selectionWidgets.end(); anIt++)
507 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
509 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
510 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
511 ListOfWidgets::const_iterator anIt2 = anIt;
512 for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
513 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
515 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
516 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
517 w1->AvoidSimultaneousSelection( w2 );
519 if ( !widgetToActivate )
520 widgetToActivate = w1;
523 if ( widgetToActivate )
524 widgetToActivate->activateSelection();
527 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
531 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
532 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
536 myAdvWidget->myOptionTable->setFocus();
537 QApplication::instance()->processEvents();
541 int iTbl = 0, nbTbl = myAdvWidget->myOptionTable->topLevelItemCount();
542 for ( ; iTbl < nbTbl; ++iTbl )
544 QTreeWidgetItem* table = myAdvWidget->myOptionTable->topLevelItem( iTbl );
545 int nbRows = table->childCount();
546 for ( int iRow = 0; iRow < nbRows; ++iRow )
548 QTreeWidgetItem* row = table->child( iRow );
549 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
551 if ( name.simplified().isEmpty() )
552 continue; // invalid custom option
554 if ( isDefault ) // not selected option
561 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
564 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
567 h->AddOption( name.toLatin1().constData(), value.toLatin1().constData() );
571 catch ( const SALOME::SALOME_Exception& ex )
573 msg = ex.details.text.in();
581 // SizeMap and attractors
584 mySizeMapTable->setFocus();
585 QApplication::instance()->processEvents();
587 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
588 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
590 for ( ; row < nbRows; ++row )
592 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
593 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
594 if ( !sizeMap.isEmpty() ) {
595 if (that->sizeMapValidationFromRow(row))
598 e = entry.toStdString();
599 s = that->mySMPMap[entry].toStdString();
600 //h->SetSizeMapEntry( e.c_str(), s.c_str() );
602 catch ( const SALOME::SALOME_Exception& ex )
604 msg = ex.details.text.in();
615 // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
618 // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
619 // So STD_TAB must be current tab to get correct value of it's spinbox.
620 myTabWidget->setCurrentIndex( STD_TAB );
624 if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
625 myStdWidget->myPhySize->text().toDouble() > 0.0 )))
626 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
630 if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
631 myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
632 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
636 if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
637 myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
638 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
642 if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
643 myStdWidget->myChordalError->text().toDouble() > 0.0 )))
644 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
647 // #16954 EDF 19466 - localsize
648 // Warn the user if local size is less than Min Size
650 !myStdWidget->myMinSizeRel->isChecked() &&
651 !myStdWidget->myMinSize->text().isEmpty() )
653 const double minSize = myStdWidget->myMinSize->GetValue();
655 for ( QMapIterator<QString,QString> i( mySMPMap ); i.hasNext() && ok ; )
658 double size = i.value().toDouble( &isValue );
659 ok = ( !isValue || size >= minSize );
661 for ( QMapIterator<QString, TAttractorVec > i( myATTMap ); i.hasNext() && ok ; )
664 const TAttractorVec& attVec = i.value();
665 for ( size_t i = 0; i < attVec.size(); ++i )
666 ok = ( attVec[i].IsToDelete() || attVec[i].startSize >= minSize );
669 msg = tr( "TOO_SMALL_LOCAL_SIZE" );
671 // Warn the user if local size is more than User Size
673 !myStdWidget->myPhySizeRel->isChecked() &&
674 !myStdWidget->myPhySize->text().isEmpty() )
676 const double userSize = myStdWidget->myPhySize->GetValue();
678 for ( QMapIterator<QString,QString> i( mySMPMap ); i.hasNext() && ok ; )
681 double size = i.value().toDouble( &isValue );
682 ok = ( !isValue || size <= userSize );
684 for ( QMapIterator<QString, TAttractorVec > i( myATTMap ); i.hasNext() && ok ; )
687 const TAttractorVec& attVec = i.value();
688 for ( size_t i = 0; i < attVec.size(); ++i )
689 ok = ( attVec[i].IsToDelete() || attVec[i].startSize <= userSize );
692 msg = tr( "TOO_LARGE_LOCAL_SIZE" );
700 h->SetOptionValues( myOptions ); // restore values
701 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
707 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
709 QFrame* fr = new QFrame( 0 );
710 QVBoxLayout* lay = new QVBoxLayout( fr );
712 lay->setSpacing( 0 );
714 // main TabWidget of the dialog
715 myTabWidget = new QTabWidget( fr );
716 myTabWidget->setTabShape( QTabWidget::Rounded );
717 myTabWidget->setTabPosition( QTabWidget::North );
718 lay->addWidget( myTabWidget );
723 myStdGroup = new QWidget();
724 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
725 aStdLayout->setSpacing( 6 );
726 aStdLayout->setMargin( 11 );
729 myName = new QLineEdit( myStdGroup );
730 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
732 myStdWidget->myPhysicalMesh->removeItem( PhysicalLocalSize );
737 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
738 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
740 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
745 aStdLayout->setRowStretch(row,1);
746 aStdLayout->setColumnStretch(1,1);
749 // advanced parameters
750 myAdvGroup = new QWidget();
751 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
752 anAdvLayout->setSpacing( 6 );
753 anAdvLayout->setMargin( 11 );
754 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
755 anAdvLayout->addWidget( myAdvWidget );
758 // Size Maps parameters
760 mySmpGroup = new QWidget( dlg() );
763 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
766 mySizeMapTable = new QTreeWidget( mySmpGroup );
767 mySizeMapTable ->setMinimumWidth(200);
768 QStringList sizeMapHeaders;
769 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
770 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
771 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
772 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
773 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
774 mySizeMapTable->setAlternatingRowColors(true);
777 smpTab = new QTabWidget( mySmpGroup );
778 smpTab->setTabShape( QTabWidget::Rounded );
779 smpTab->setTabPosition( QTabWidget::South );
780 lay->addWidget( smpTab );
782 // Filters of selection
783 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
785 SM_ShapeTypes.Add( TopAbs_VERTEX );
786 SM_ShapeTypes.Add( TopAbs_EDGE );
787 SM_ShapeTypes.Add( TopAbs_FACE );
788 SM_ShapeTypes.Add( TopAbs_COMPOUND );
790 ATT_ShapeTypes.Add( TopAbs_VERTEX );
791 ATT_ShapeTypes.Add( TopAbs_EDGE );
792 ATT_ShapeTypes.Add( TopAbs_WIRE );
793 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
795 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
796 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
797 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
799 // Standard size map tab
800 mySmpStdGroup = new QWidget();
801 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
802 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false);
803 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
804 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
805 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
806 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
809 myAttractorGroup = new QWidget();
810 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
811 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false);
812 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
813 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
814 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
815 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
816 QFrame* attLine = new QFrame(myAttractorGroup);
817 attLine->setFrameShape(QFrame::HLine);
818 attLine->setFrameShadow(QFrame::Sunken);
819 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false);
820 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
821 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
822 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
823 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
824 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
825 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
826 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
827 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
828 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
829 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
831 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
832 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
836 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
837 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
838 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
839 modifyMapButton->setEnabled(false);
842 myAttSelWdg->setEnabled(false);
843 myAttSizeSpin->setEnabled(false);
844 myAttSizeLabel->setEnabled(false);
845 myAttDistSpin->setEnabled(false);
846 myAttDistLabel->setEnabled(false);
847 myAttDistSpin2->setEnabled(false);
848 myAttDistLabel2->setEnabled(false);
849 myAttDistSpin->setValue(0.);
850 myAttDistSpin2->setValue(0.);
851 myAttSizeSpin->setValue(0.);
852 mySmpSizeSpin->setValue(0.);
855 // ADD WIDGETS (SIZEMAP TAB)
856 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
857 anSmpLayout->setColumnStretch(0, 1);
858 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
859 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
860 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
861 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
862 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
863 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
866 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
867 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
868 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
869 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
872 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
873 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
874 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
875 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
876 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
877 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
878 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
879 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
880 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
881 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
882 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
883 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
885 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
886 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
888 smpTab->setCurrentIndex( SMP_STD_TAB );
890 // Enforced vertices parameters
891 myEnfGroup = new QWidget( dlg() );
892 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
894 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
895 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
896 myEnforcedTreeWidget->setSortingEnabled(true);
897 QStringList enforcedHeaders;
898 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
899 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
900 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
902 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
903 myEnforcedTreeWidget->header()->setStretchLastSection(true);
904 myEnforcedTreeWidget->setAlternatingRowColors(true);
905 myEnforcedTreeWidget->setUniformRowHeights(true);
906 myEnforcedTreeWidget->setAnimated(true);
907 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
908 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
909 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
910 myEnforcedTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
911 myEnforcedTreeWidget->resizeColumnToContents(column);
913 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
914 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
915 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
917 // FACE AND VERTEX SELECTION
918 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
919 shapeTypes1.Add( TopAbs_FACE );
920 shapeTypes1.Add( TopAbs_COMPOUND );
921 shapeTypes2.Add( TopAbs_VERTEX );
922 shapeTypes2.Add( TopAbs_COMPOUND );
924 // SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
925 // myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true);
926 // myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
928 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
929 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
930 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
932 //myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
934 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
935 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
936 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
938 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
939 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
940 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
942 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
943 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
944 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
946 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
947 myGroupName = new QLineEdit(myEnfGroup);
949 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
950 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
952 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
954 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
955 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
957 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
958 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
959 // FACE AND VERTEX SELECTION
960 //anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
961 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
962 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
963 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
964 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
965 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
966 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
967 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
968 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
969 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
970 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
971 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
972 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
973 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
974 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
975 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
976 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
978 // ---------------------------
979 // Enforced meshes parameters
980 // ---------------------------
982 myEnfMeshGroup = new QWidget();
983 QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
985 myEnfMeshTableWdg = new QTableWidget(myEnfGroup);
986 //myEnfMeshTableWdg->setRowCount( 0 );
987 myEnfMeshTableWdg->setColumnCount( ENF_MESH_NB_COLUMNS );
988 myEnfMeshTableWdg->setSortingEnabled(true);
989 myEnfMeshTableWdg->verticalHeader()->hide();
990 myEnfMeshTableWdg->setHorizontalHeaderLabels( QStringList()
991 << tr( "ENF_NAME_COLUMN" )
992 << tr( "ENF_GROUP_COLUMN" ));
993 myEnfMeshTableWdg->horizontalHeader()->setStretchLastSection(true);
994 myEnfMeshTableWdg->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
995 myEnfMeshTableWdg->setAlternatingRowColors(true);
996 myEnfMeshTableWdg->setSelectionMode(QAbstractItemView::ExtendedSelection);
997 myEnfMeshTableWdg->setSelectionBehavior(QAbstractItemView::SelectItems);
998 myEnfMeshTableWdg->resizeColumnsToContents();
999 //myEnfMeshTableWdg->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
1001 myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( SMESH::IDSOURCE_EDGE, myEnfMeshGroup, /*multiSel=*/false);
1002 myEnfMeshWdg->SetDefaultText(tr("ENF_SELECT_MESH"), "QLineEdit { color: grey }");
1004 myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
1005 myEnfMeshWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
1006 myEnfMeshWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
1007 myEnfMeshWdg->AvoidSimultaneousSelection(myAttSelWdg);
1009 QLabel* enforcedGroupNameLabel = new QLabel( tr( "ENF_GROUP_LABEL" ), myEnfMeshGroup );
1010 myEnforcedGroupName = new QLineEdit(myEnfMeshGroup);
1012 myAddEnfMeshButton = new QPushButton(tr("ENF_ADD"),myEnfMeshGroup);
1013 myRemoveEnfMeshButton = new QPushButton(tr("ENF_REMOVE"),myEnfMeshGroup);
1015 QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
1016 anEnfMeshLayout2->addWidget(myEnfMeshWdg, 0, 0, 1, 2);
1017 anEnfMeshLayout2->addWidget(enforcedGroupNameLabel, 1, 0, 1, 1);
1018 anEnfMeshLayout2->addWidget(myEnforcedGroupName, 1, 1, 1, 1);
1019 anEnfMeshLayout2->addWidget(myAddEnfMeshButton, 2, 0, 1, 2);
1020 anEnfMeshLayout2->addWidget(myRemoveEnfMeshButton, 3, 0, 1, 2);
1021 anEnfMeshLayout2->setRowStretch( 4, 1 );
1023 anEnfMeshLayout->addWidget(myEnfMeshTableWdg, 0, 0, 5, 1);
1024 anEnfMeshLayout->addLayout(anEnfMeshLayout2, 0, 1, 1, 1);
1025 anEnfMeshLayout->setRowStretch( 2, 1 );
1029 // Periodicity parameters
1030 myPeriodicityGroup = new QWidget( dlg() );
1031 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
1033 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
1034 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
1035 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
1037 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
1039 QStringList myPeriodicityTreeHeaders;
1040 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
1041 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
1042 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
1043 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
1044 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
1045 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
1046 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
1047 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
1048 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
1049 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
1051 // Hide the vertex name to make the widget more readable
1052 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
1053 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
1054 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
1055 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
1056 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
1057 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
1058 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
1061 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
1062 myPeriodicityTreeWidget->setSortingEnabled(true);
1064 myPeriodicityTreeWidget->setAlternatingRowColors(true);
1065 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
1066 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
1068 int periodicityVisibleColumns = 2;
1069 for (int column = 0; column < periodicityVisibleColumns; ++column) {
1070 myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
1071 myPeriodicityTreeWidget->resizeColumnToContents(column);
1073 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
1075 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
1077 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
1079 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
1080 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
1081 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
1083 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
1085 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
1086 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
1088 myPeriodicityOnFaceRadioButton->setChecked(true);
1090 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
1091 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
1094 // FACE, EDGE AND VERTEX SELECTION
1095 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
1096 shapeTypesFace.Add( TopAbs_FACE );
1097 shapeTypesFace.Add( TopAbs_EDGE );
1098 shapeTypesFace.Add( TopAbs_COMPOUND );
1099 shapeTypesEdge.Add( TopAbs_EDGE );
1100 shapeTypesEdge.Add( TopAbs_COMPOUND );
1102 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
1104 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1105 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1107 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1108 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false);
1109 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1110 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1112 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1113 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1114 // myPeriodicitySourceEdgeWdg->hide();
1115 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1117 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1118 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1120 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1121 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false);
1122 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1123 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1125 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1126 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1127 // myPeriodicityTargetEdgeWdg->hide();
1128 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1130 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1131 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1132 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1134 myPeriodicityGroupBox2->setCheckable(true);
1135 myPeriodicityGroupBox2->setChecked(false);
1137 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1138 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1140 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1141 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1144 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1145 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1148 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1149 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false);
1150 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1153 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1154 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1156 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1157 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false);
1158 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1161 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1162 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1164 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1165 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false);
1166 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1169 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1170 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1172 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1173 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false);
1174 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1177 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1178 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1180 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1181 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false);
1182 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1185 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1186 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1188 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1189 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false);
1190 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1192 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1193 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1196 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1197 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1199 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1200 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1202 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1204 myPeriodicitySelectionWidgets.clear();
1205 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1206 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1207 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1208 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1209 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1210 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1211 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1212 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1213 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1215 // HyperPatch parameters
1217 QWidget* hpGroup = new QWidget();
1218 QGridLayout* hpLayout = new QGridLayout(hpGroup);
1220 myHyPatchTable = new QTableWidget( hpGroup );
1221 myHyPatchTable->setColumnCount(1);
1222 myHyPatchTable->setHorizontalHeaderLabels( QStringList() << tr("BLSURF_HYPATCH_TBL_HEADER") );
1223 myHyPatchTable->setAlternatingRowColors(true);
1224 myHyPatchTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
1227 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1228 myHyPatchFaceSelBtn = new QPushButton( iconSelect, tr("BLSURF_HYPATCH_SEL_FACE"), hpGroup );
1229 myHyPatchGroupSelBtn = new QPushButton( iconSelect, tr("BLSURF_HYPATCH_SEL_GROUP"), hpGroup );
1230 myHyPatchFaceSelBtn->setCheckable( true );
1231 myHyPatchGroupSelBtn->setCheckable( true );
1233 myHyPatchFaceSelector = new StdMeshersGUI_SubShapeSelectorWdg( hpGroup, TopAbs_FACE, /*toShowList=*/false );
1235 QLabel* hpTagsLbl = new QLabel( tr("BLSURF_TAGS"), hpGroup );
1236 myHyPatchTagsLE = new QLineEdit( hpGroup );
1237 myHyPatchTagsLE->setValidator( new SMESHGUI_IdValidator( hpGroup ));
1239 QPushButton* hpAddBtn = new QPushButton( tr("BLSURF_SM_ADD"), hpGroup );
1240 QPushButton* hpRemBtn = new QPushButton( tr("BLSURF_SM_REMOVE"), hpGroup );
1242 hpLayout->addWidget( myHyPatchTable, 0, 0, 5, 1 );
1243 hpLayout->addWidget( myHyPatchFaceSelBtn, 0, 1, 1, 2 );
1244 hpLayout->addWidget( myHyPatchGroupSelBtn, 0, 3, 1, 2 );
1245 hpLayout->addWidget( hpTagsLbl, 1, 1, 1, 1 );
1246 hpLayout->addWidget( myHyPatchTagsLE, 1, 2, 1, 3 );
1247 hpLayout->addWidget( hpAddBtn, 2, 1, 1, 2 );
1248 hpLayout->addWidget( hpRemBtn, 2, 3, 1, 2 );
1249 hpLayout->addWidget( myHyPatchFaceSelector, 3, 1, 1, 4 );
1254 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1255 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1257 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1258 myTabWidget->insertTab( ENF_V_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1259 myTabWidget->insertTab( ENF_M_TAB, myEnfMeshGroup, tr( "ENF_MESH" ) );
1260 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1261 myTabWidget->insertTab( HYPERPATCH_TAB, hpGroup, tr( "BLSURF_HYPERPATCH_TAB" ));
1267 myEnfMeshGroup->hide();
1268 myPeriodicityGroup->hide();
1271 myTabWidget->setCurrentIndex( STD_TAB );
1273 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), SLOT( onAddOption() ) );
1276 connect( addMapButton, SIGNAL( clicked()), SLOT( onAddMap() ) );
1277 connect( removeMapButton, SIGNAL( clicked()), SLOT( onRemoveMap() ) );
1278 connect( modifyMapButton, SIGNAL( clicked()), SLOT( onModifyMap() ) );
1279 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)), SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1280 connect( myGeomSelWdg2, SIGNAL( contentModified() ), SLOT( onMapGeomContentModified() ) );
1281 connect( myGeomSelWdg1, SIGNAL( contentModified() ), SLOT( onMapGeomContentModified() ) );
1282 connect( myAttSelWdg, SIGNAL( contentModified() ), SLOT( onMapGeomContentModified() ) );
1283 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)), SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1284 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), SLOT( onAttractorClicked( int ) ) );
1285 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), SLOT( onConstSizeClicked( int ) ) );
1286 connect( smpTab, SIGNAL( currentChanged ( int )), SLOT( onTabChanged( int ) ) );
1287 connect( myTabWidget, SIGNAL( currentChanged ( int )), SLOT( onTabChanged( int ) ) );
1289 // Enforced vertices
1290 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), SLOT( synchronizeCoords() ) );
1291 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1292 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), SLOT( synchronizeCoords() ) );
1293 connect( addVertexButton, SIGNAL( clicked()), SLOT( onAddEnforcedVertices() ) );
1294 connect( removeVertexButton, SIGNAL( clicked()), SLOT( onRemoveEnforcedVertex() ) );
1295 connect( myEnfVertexWdg, SIGNAL( contentModified()), SLOT( onSelectEnforcedVertex() ) );
1296 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), SLOT( onInternalVerticesClicked( int ) ) );
1299 connect( myAddEnfMeshButton, SIGNAL( clicked()), SLOT( onAddEnforcedMesh()));
1300 connect( myRemoveEnfMeshButton, SIGNAL( clicked()), SLOT( onRemoveEnforcedMesh()));
1301 connect( myEnfMeshWdg, SIGNAL( contentModified()), SLOT( onEnforcedMeshSelected()));
1302 connect( myEnfMeshTableWdg, SIGNAL( itemSelectionChanged()), SLOT( onEnfMeshTableSelected()));
1306 connect( myPeriodicityAddButton, SIGNAL( clicked()), SLOT( onAddPeriodicity() ) );
1307 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), SLOT( onRemovePeriodicity() ) );
1308 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1309 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), SLOT(onPeriodicityByVerticesChecked(bool)));
1311 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1312 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1314 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1315 connect( w1, SIGNAL( contentModified ()), SLOT( onPeriodicityContentModified() ));
1320 connect( myHyPatchFaceSelBtn, SIGNAL( toggled(bool) ), SLOT( onHyPatchFaceSelection(bool) ));
1321 connect( myHyPatchGroupSelBtn, SIGNAL( toggled(bool) ), SLOT( onHyPatchGroupSelection(bool) ));
1322 connect( myHyPatchFaceSelector, SIGNAL( shapeSelected() ), SLOT( onHyPatchSelectionChanged()));
1323 connect( hpAddBtn, SIGNAL( clicked() ), SLOT( onHyPatchAdd()));
1324 connect( hpRemBtn, SIGNAL( clicked() ), SLOT( onHyPatchRemove()));
1329 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1330 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1332 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1334 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1335 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1336 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1337 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1338 // myEnfFaceWdg->deactivateSelection();
1339 // myEnfVertexWdg->deactivateSelection();
1343 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1345 myStdWidget->onPhysicalMeshChanged();
1349 * This method resets the content of the X, Y, Z widgets;
1351 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1353 myXCoord->setCleared(true);
1354 myYCoord->setCleared(true);
1355 myZCoord->setCleared(true);
1356 myXCoord->setText("");
1357 myYCoord->setText("");
1358 myZCoord->setText("");
1359 // myGroupName->setText("");
1362 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1363 This method updates the tooltip of a modified item. The QLineEdit widgets content
1364 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1366 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int /*column*/)
1368 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1369 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1370 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1371 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1372 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1373 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1374 QTreeWidgetItem* parent = item->parent();
1376 clearEnforcedVertexWidgets();
1378 if (parent && (!x.isNull() || !entry.isNull())) {
1379 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1380 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1381 if (entry.isNull()) {
1382 toolTip += QString("(") + x.toString();
1383 toolTip += QString(", ") + y.toString();
1384 toolTip += QString(", ") + z.toString();
1385 toolTip += QString(")");
1388 if (!groupName.isEmpty())
1389 toolTip += QString(" [") + groupName + QString("]");
1391 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1394 myXCoord->SetValue(x.toDouble());
1395 myYCoord->SetValue(y.toDouble());
1396 myZCoord->SetValue(z.toDouble());
1399 if (!groupName.isEmpty())
1400 myGroupName->setText(groupName);
1404 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex()
1406 size_t nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1407 clearEnforcedVertexWidgets();
1408 if (nbSelEnfVertex == 1)
1410 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1413 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1414 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1415 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1416 if (CORBA::is_nil(measureOp))
1419 CORBA::Double x,y,z;
1420 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1421 if ( measureOp->IsDone() )
1423 myXCoord->SetValue(x);
1424 myYCoord->SetValue(y);
1425 myZCoord->SetValue(z);
1431 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1432 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1433 of the enforced vertex clicked in the tree widget.
1435 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1437 clearEnforcedVertexWidgets();
1438 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1439 if (! items.isEmpty() && items.size() == 1) {
1440 QTreeWidgetItem *item = items[0];
1441 // for (int i=0 ; i < items.size() ; i++) {
1443 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1444 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1445 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1446 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1447 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1448 if (!x.isNull()/* && entry.isNull()*/) {
1449 myXCoord->SetValue(x.toDouble());
1450 myYCoord->SetValue(y.toDouble());
1451 myZCoord->SetValue(z.toDouble());
1454 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1455 myGroupName->setText(group.toString());
1460 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1461 This method adds a face containing enforced vertices in the tree widget.
1463 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName)
1465 // Find theFaceEntry item
1466 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1467 QTreeWidgetItem* theItem;
1468 if (theItemList.empty()) {
1469 theItem = new QTreeWidgetItem();
1470 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1471 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1472 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1473 myEnforcedTreeWidget->addTopLevelItem(theItem);
1476 theItem = theItemList[0];
1481 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1482 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1484 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z,
1485 std::string vertexName,
1486 std::string geomEntry,
1487 std::string groupName)
1489 bool okToCreate = true;
1491 const int nbVert = myEnforcedTreeWidget->topLevelItemCount();
1492 for (int row = 0; row < nbVert; row++ )
1494 QTreeWidgetItem* child = myEnforcedTreeWidget->topLevelItem( row );
1495 QString childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1496 QString childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1497 double childX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1498 double childY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1499 double childZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1500 if (((childEntry.isEmpty()) && (childX == x) && (childY == y) && (childZ == z)) ||
1501 ( !childEntry.isEmpty() && childEntry == geomEntry.c_str() ))
1503 // update group name
1504 if ( childGroupName != groupName.c_str() ) {
1505 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1515 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( myEnforcedTreeWidget );
1516 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1517 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1518 QSize iconSize = iconSelect.size()*0.7;
1520 int vertexIndex=nbVert;
1521 QString myVertexName;
1523 while(indexRef != vertexIndex) {
1524 indexRef = vertexIndex;
1525 if (vertexName.empty())
1526 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1528 myVertexName = QString(vertexName.c_str());
1530 for (int row = 0;row<nbVert;row++) {
1531 QString name = myEnforcedTreeWidget->topLevelItem(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1532 if (myVertexName == name) {
1538 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1539 if (geomEntry.empty()) {
1540 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1541 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1542 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1545 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1546 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1548 if (groupName != "")
1549 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1551 QString toolTip = myVertexName;
1552 if (geomEntry.empty()) {
1553 toolTip += QString(" (%1, %2, %3").arg(x).arg(y).arg(z);
1555 if (groupName != "")
1556 toolTip += QString(" [%1]").arg(groupName.c_str());
1558 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1559 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1562 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1563 This method is called when a item is added into the enforced vertices tree widget
1565 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1567 getGeomSelectionTool()->selectionMgr()->clearFilters();
1568 myEnfVertexWdg->deactivateSelection();
1570 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1571 myEnforcedTreeWidget->resizeColumnToContents(column);
1574 size_t selEnfVertex = myEnfVertexWdg->NbObjects();
1575 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1577 if ((selEnfVertex == 0) && coordsEmpty)
1580 string entry, shapeName;
1582 std::string groupName = myGroupName->text().simplified().toStdString();
1584 if (selEnfVertex <= 1)
1587 x = myXCoord->GetValue();
1588 y = myYCoord->GetValue();
1589 z = myZCoord->GetValue();
1590 if (selEnfVertex == 1) {
1591 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1592 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1595 addEnforcedVertex(x, y, z, "", "", groupName);
1599 if ( CORBA::is_nil(getGeomEngine()))
1602 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1603 if (CORBA::is_nil(measureOp))
1606 CORBA::Double x,y,z;
1608 for (size_t j = 0 ; j < selEnfVertex ; j++)
1610 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1611 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1612 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1613 if ( measureOp->IsDone() )
1614 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1615 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1616 addEnforcedVertex(0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1622 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1624 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1625 myEnforcedTreeWidget->resizeColumnToContents(column);
1627 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1628 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1629 myStdWidget->onPhysicalMeshChanged();
1633 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1634 This method is called when a item is removed from the enforced vertices tree widget
1636 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1638 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1639 QList<QTreeWidgetItem *> selectedVertices;
1640 QSet<QTreeWidgetItem *> selectedEntries;
1641 QTreeWidgetItem* item;
1643 foreach( item, selectedItems ) {
1644 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1645 if (! value.isNull())
1646 selectedVertices.append(item);
1648 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1649 if (! value.isNull())
1650 selectedVertices.append(item);
1652 selectedEntries.insert(item);
1656 foreach(item,selectedVertices) {
1657 QTreeWidgetItem* parent = item->parent();
1659 parent->removeChild(item);
1661 if ( parent && parent->childCount() == 0) {
1662 if (selectedEntries.contains(parent))
1663 selectedEntries.remove(parent);
1668 foreach(item,selectedEntries) {
1672 myEnforcedTreeWidget->selectionModel()->clearSelection();
1676 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1678 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1681 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1682 This method is called when a item is added into the periodicity table widget
1684 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1686 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1688 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1689 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1690 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1692 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1693 w1->deactivateSelection();
1697 // Source-Target selection
1698 size_t selSource = myPeriodicitySourceFaceWdg->NbObjects();
1699 size_t selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1701 if (selSource == 0 || selTarget == 0)
1704 // Vertices selection
1705 if (myPeriodicityGroupBox2->isChecked())
1707 size_t P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1708 size_t P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1709 size_t P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1710 size_t P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1711 //size_t P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1712 size_t P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1714 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1716 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1717 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1722 // Add Source-Target in table
1723 string shapeEntry, sourceEntry, targetEntry;
1724 string shapeName, sourceName, targetName;
1725 GEOM::GEOM_Object_var shape;
1727 QTreeWidgetItem* item = new QTreeWidgetItem();
1728 myPeriodicityTreeWidget->addTopLevelItem(item);
1730 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1734 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1736 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1737 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1738 shapeName = shape->GetName();
1739 shapeEntry = shape->GetStudyEntry();
1740 item->setData(k, Qt::EditRole, shapeName.c_str() );
1741 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1742 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1746 // Add shape type in tree
1747 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1748 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1750 // Blank input fields
1751 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1753 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1754 w1->SetObject(GEOM::GEOM_Object::_nil());
1757 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1758 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1762 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1763 This method is called when a item is removed from the periodicity tree widget
1765 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1767 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1768 QTreeWidgetItem* item;
1770 foreach(item,selectedItems) {
1774 myEnforcedTreeWidget->selectionModel()->clearSelection();
1777 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1778 This method enable clears the field for periodicity by vertices
1780 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1784 for (int k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1786 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1787 w1->deactivateSelection();
1788 w1->SetObject(CORBA::Object::_nil());
1793 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1794 This method enable the proper shape selection widget to Face or Edge shapes
1796 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1798 // if (myPeriodicityOnFaceRadioButton->isChecked())
1800 // myPeriodicitySourceEdgeWdg->hide();
1801 // myPeriodicityTargetEdgeWdg->hide();
1802 // myPeriodicitySourceFaceWdg->show();
1803 // myPeriodicityTargetFaceWdg->show();
1807 // myPeriodicitySourceFaceWdg->hide();
1808 // myPeriodicityTargetFaceWdg->hide();
1809 // myPeriodicitySourceEdgeWdg->show();
1810 // myPeriodicityTargetEdgeWdg->show();
1814 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int /*row*/)
1816 QString shapeName, shapeEntry;
1817 CORBA::Object_var shape;
1819 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1820 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1822 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1824 shapeName = item->data(k, Qt::EditRole).toString();
1825 shapeEntry = item->data(k, Qt::UserRole).toString();
1826 if (! shapeEntry.isEmpty())
1828 shape = entryToObject(shapeEntry);
1829 w1->SetObject(shape);
1830 w1->deactivateSelection();
1832 myPeriodicityGroupBox2->setChecked(1);
1835 myPeriodicityGroupBox2->setChecked(0);
1838 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1839 myPeriodicityOnFaceRadioButton->setChecked(true);
1841 myPeriodicityOnEdgeRadioButton->setChecked(true);
1846 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1847 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1849 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1851 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1853 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1855 // find wich selection widget is activated
1856 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1858 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1859 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1861 // don't activate vertex selection if the group box is not checked
1862 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1864 // clear the selection, to avoid to put the same object in the other widget
1865 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1866 // activate the next widget
1867 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1868 w2->activateSelection();
1875 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1876 This method updates the GUI widgets with the hypothesis data
1878 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1880 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1882 BlsurfHypothesisData data;
1883 that->readParamsFromHypo( data );
1886 myName->setText( data.myName );
1887 QFontMetrics metrics( myName->font() );
1888 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1890 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1891 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1892 if (data.myPhySize <= 0)
1893 myStdWidget->myPhySize->setText("");
1895 myStdWidget->myPhySize->SetValue( data.myPhySize );
1896 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1897 if (data.myMinSize < 0)
1898 myStdWidget->myMinSize->setText("");
1900 myStdWidget->myMinSize->SetValue( data.myMinSize );
1901 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1902 if (data.myMaxSize < 0)
1903 myStdWidget->myMaxSize->setText("");
1905 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1906 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1907 myStdWidget->myUseGradation->setChecked( data.myUseGradation );
1908 if (data.myGradation <= 0 || !data.myUseGradation )
1909 myStdWidget->myGradation->setText("");
1911 myStdWidget->myGradation->SetValue( data.myGradation );
1912 myStdWidget->myUseVolumeGradation->setChecked( data.myUseVolumeGradation );
1913 if (data.myVolumeGradation <= 0 || !data.myUseVolumeGradation )
1914 myStdWidget->myVolumeGradation->setText("");
1916 myStdWidget->myVolumeGradation->SetValue( data.myVolumeGradation );
1918 foreach (QAbstractButton* button, myStdWidget->myButtonGroupElementType->buttons()) {
1919 if (myStdWidget->myButtonGroupElementType->id(button) == data.myElementType) {
1920 button->setChecked(true);
1925 myStdWidget->myUseSurfaceProximity->setChecked( data.myUseSurfaceProximity );
1926 myStdWidget->myNbSurfaceProximityLayers->setValue( data.myNbSurfaceProximityLayers );
1927 myStdWidget->mySurfaceProximityRatio->SetValue( data.mySurfaceProximityRatio );
1928 myStdWidget->myUseVolumeProximity->setChecked( data.myUseVolumeProximity );
1929 myStdWidget->myNbVolumeProximityLayers->setValue( data.myNbVolumeProximityLayers );
1930 myStdWidget->myVolumeProximityRatio->SetValue( data.myVolumeProximityRatio );
1931 if ( !data.myUseSurfaceProximity )
1933 //myStdWidget->myNbSurfaceProximityLayers->setText("");
1934 myStdWidget->mySurfaceProximityRatio->setText("");
1936 if ( !data.myUseVolumeProximity )
1938 //myStdWidget->myNbVolumeProximityLayers->setText("");
1939 myStdWidget->myVolumeProximityRatio->setText("");
1942 if (data.myAngleMesh < 0)
1943 myStdWidget->myAngleMesh->setText("");
1945 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1946 if (data.myChordalError <= 0)
1947 myStdWidget->myChordalError->setText("");
1949 myStdWidget->myChordalError->SetValue( data.myChordalError );
1950 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1951 if (data.myAnisotropicRatio <= 0)
1952 myStdWidget->myAnisotropicRatio->setText("");
1954 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1955 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1956 if (data.myTinyEdgeLength <= 0)
1957 myStdWidget->myTinyEdgeLength->setText("");
1959 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1960 myStdWidget->myOptimiseTinyEdges->setChecked( data.myOptimiseTinyEdges );
1961 if (data.myTinyEdgeOptimisLength <= 0)
1962 myStdWidget->myTinyEdgeOptimisLength->setText("");
1964 myStdWidget->myTinyEdgeOptimisLength->SetValue( data.myTinyEdgeOptimisLength );
1965 myStdWidget->myCorrectSurfaceIntersection->setChecked( data.myCorrectSurfaceIntersection );
1966 if (data.myCorrectSurfaceIntersectionMaxCost <= 0)
1967 myStdWidget->myCorrectSurfaceIntersectionMaxCost->setText("");
1969 myStdWidget->myCorrectSurfaceIntersectionMaxCost->SetValue( data.myCorrectSurfaceIntersectionMaxCost );
1970 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1971 if (data.myBadElementAspectRatio <= 0)
1972 myStdWidget->myBadElementAspectRatio->setText("");
1974 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1975 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1976 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1978 myStdWidget->resizeWidgets();
1980 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1982 if ( myOptions.operator->() ) {
1983 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1984 myAdvWidget->AddOption( TBL_MESHING, that->myOptions[i].in() );
1986 if ( myPreCADOptions.operator->() ) {
1987 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i )
1988 myAdvWidget->AddOption( TBL_PRECAD, that->myPreCADOptions[i].in() );
1990 if ( myCustomOptions.operator->() ) {
1991 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1992 myAdvWidget->AddOption( TBL_CUSTOM, that->myCustomOptions[i].in() );
1994 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1995 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1996 // myGMFFileMode->setChecked(data.myGMFFileMode);
1999 QMapIterator<QString, QString> i(that->mySMPMap);
2000 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2001 while (i.hasNext()) {
2003 const QString entry = i.key();
2004 const QString sizeMap = i.value();
2005 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
2006 //int row = mySizeMapTable->topLevelItemCount();
2007 QTreeWidgetItem* item = new QTreeWidgetItem();
2008 mySizeMapTable->addTopLevelItem( item );
2009 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
2010 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
2011 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
2012 if (that->myATTMap.contains(entry)) {
2013 TAttractorVec & attVec = that->myATTMap[entry];
2014 for ( size_t i = 0; i < attVec.size(); ++i )
2016 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
2017 QTreeWidgetItem* child = new QTreeWidgetItem();
2018 item->addChild( child );
2019 item->setExpanded(true);
2020 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
2021 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
2022 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
2024 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
2025 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
2028 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
2034 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
2037 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2038 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2039 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2041 // Enforced vertices
2042 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
2044 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
2045 TEntry entry = (*evmIt).first;
2046 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
2048 //QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
2050 TEnfVertexList evs = (*evmIt).second;
2052 TEnfVertexList::const_iterator evsIt = evs.begin();
2053 TEnfVertex *enfVertex;
2054 for ( ; evsIt != evs.end() ; ++evsIt) {
2055 enfVertex = (*evsIt);
2056 double x = 0, y = 0, z = 0;
2057 if (enfVertex->coords.size()) {
2058 x = enfVertex->coords[0];
2059 y = enfVertex->coords[1];
2060 z = enfVertex->coords[2];
2062 that->addEnforcedVertex(x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
2066 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
2067 myEnforcedTreeWidget->resizeColumnToContents(column);
2069 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
2070 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
2071 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
2075 // Add an item in the tree widget for each association
2076 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
2078 QTreeWidgetItem* item = new QTreeWidgetItem();
2079 myPeriodicityTreeWidget->addTopLevelItem(item);
2080 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
2081 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
2082 for (size_t k=0; k<periodicity_i.size(); k++)
2084 string shapeEntry = periodicity_i[k];
2085 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
2086 item->setData((int) k, Qt::EditRole, shapeName.c_str() );
2087 item->setData((int) k, Qt::UserRole, shapeEntry.c_str() );
2093 QString patchEntries;
2094 for ( int i = 0; i < data.hyperpatches.size(); ++i )
2096 if ( i < data.hyperEntries.size() )
2097 patchEntries = data.hyperEntries[i];
2098 that->addHyPatchToTable( data.hyperpatches[i], patchEntries );
2101 that->myStdWidget->onPhysicalMeshChanged();
2102 that->myStdWidget->onGeometricMeshChanged();
2103 that->onStateChange();
2107 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2108 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2110 BLSURFPlugin::EnforcedMeshesList_var enfMeshes = h->GetEnforcedMeshes();
2111 for ( CORBA::ULong i = 0; i < enfMeshes->length(); ++i )
2113 BLSURFPlugin::MG_EnforcedMesh1D & enfMesh = enfMeshes[i];
2114 that->addEnforcedMesh( enfMesh.mesh.in(), enfMesh.groupName.in() );
2118 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
2119 This method updates the hypothesis data with the GUI widgets content.
2121 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
2123 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2125 BlsurfHypothesisData data;
2126 QString guiHyp = that->readParamsFromWidgets( data );
2127 that->storeParamsToHypo( data );
2132 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
2133 Updates the hypothesis data from hypothesis values.
2135 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
2137 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2138 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2140 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
2141 h_data.myName = isCreation() && data ? hypName() : "";
2143 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
2144 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
2145 h_data.myPhySize = h->GetPhySize();
2146 h_data.myPhySizeRel = h->IsPhySizeRel();
2147 double minSize = h->GetMinSize();
2148 double maxSize = h->GetMaxSize();
2149 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2150 h_data.myMinSizeRel = h->IsMinSizeRel();
2151 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2152 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2153 h_data.myUseGradation = h->GetUseGradation();
2154 h_data.myGradation = h->GetGradation();
2155 h_data.myUseVolumeGradation = h->GetUseVolumeGradation();
2156 h_data.myVolumeGradation = h->GetVolumeGradation();
2157 h_data.myElementType = h->GetElementType();
2158 double angle = h->GetAngleMesh();
2159 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2160 double chordalError = h->GetChordalError();
2161 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2162 h_data.myAnisotropic = h->GetAnisotropic();
2163 double myAnisotropicRatio = h->GetAnisotropicRatio();
2164 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2165 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2166 double myTinyEdgeLength = h->GetTinyEdgeLength();
2167 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2168 h_data.myOptimiseTinyEdges = h->GetOptimiseTinyEdges();
2169 double myTinyEdgeOptimisLength = h->GetTinyEdgeOptimisationLength();
2170 h_data.myTinyEdgeOptimisLength = myTinyEdgeOptimisLength > 0 ? myTinyEdgeOptimisLength : -1.0;
2171 h_data.myCorrectSurfaceIntersection = h->GetCorrectSurfaceIntersection();
2172 double corrSurfaceIntersMaxCost = h->GetCorrectSurfaceIntersectionMaxCost();
2173 h_data.myCorrectSurfaceIntersectionMaxCost = corrSurfaceIntersMaxCost > 0 ? corrSurfaceIntersMaxCost : -1.0;
2174 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2175 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2176 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2177 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2178 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2179 h_data.myVerbosity = h->GetVerbosity();
2180 //h_data.myTopology = (int) h->GetTopology();
2181 //h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2182 // h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2183 // h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2184 h_data.myUseSurfaceProximity = h->GetSurfaceProximity ();
2185 h_data.myNbSurfaceProximityLayers = h->GetNbSurfaceProximityLayers();
2186 h_data.mySurfaceProximityRatio = h->GetSurfaceProximityRatio ();
2187 h_data.myUseVolumeProximity = h->GetVolumeProximity ();
2188 h_data.myNbVolumeProximityLayers = h->GetNbVolumeProximityLayers ();
2189 h_data.myVolumeProximityRatio = h->GetVolumeProximityRatio ();
2191 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2192 that->myOptions = h->GetOptionValues();
2193 that->myPreCADOptions = h->GetPreCADOptionValues();
2194 that->myCustomOptions = h->GetAdvancedOptionValues();
2196 h_data.myGMFFileName = h->GetGMFFile();
2197 // h_data.myGMFFileMode = h->GetGMFFileMode();
2199 that->mySMPMap.clear();
2200 that->myATTMap.clear();
2201 // that->myAttDistMap.clear();
2202 // that->myDistMap.clear();
2204 // classic size maps
2205 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2206 QString fullSizeMaps;
2207 QStringList fullSizeMapList;
2208 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2209 for ( CORBA::ULong i = 0;i<mySizeMaps->length(); ++i ) {
2210 fullSizeMaps = mySizeMaps[i].in();
2211 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2212 if ( fullSizeMapList.count() > 1 ) {
2213 string fullSizeMap = fullSizeMapList[1].toStdString();
2214 size_t pos = fullSizeMap.find("return")+7;
2217 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2222 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2223 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2229 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2231 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2232 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2233 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2234 if ( fullCustomSizeMapList.count() > 1 ) {
2235 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2236 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2241 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2243 for ( CORBA::ULong i = 0;i<allMyAttractors->length(); ++i ) {
2244 QString myAttractors = allMyAttractors[i].in();
2245 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2246 if ( myAttractorList.count() > 1 ) {
2247 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2248 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2252 // attractor new version
2253 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2254 for ( CORBA::ULong i = 0;i<allMyAttractorParams->length(); ++i ) {
2255 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2256 QString faceEntry = myAttractorParams.faceEntry.in();
2257 QString attEntry = myAttractorParams.attEntry.in();
2258 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2259 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2260 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2261 myAttractorParams.startSize,
2262 myAttractorParams.infDist,
2263 myAttractorParams.constDist ));
2266 // Enforced vertices
2267 h_data.enfVertexList.clear();
2268 h_data.faceEntryEnfVertexListMap.clear();
2270 h_data.groupNameEnfVertexListMap.clear();
2273 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2275 for ( CORBA::ULong i = 0;i<faceEntryEnfVertexListMap->length(); ++i )
2277 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2278 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2280 for (CORBA::ULong j=0 ; j<vertexList.length(); ++j)
2282 TEnfVertex *enfVertex = new TEnfVertex();
2283 enfVertex->name = vertexList[j].name.in();
2284 enfVertex->geomEntry = vertexList[j].geomEntry.in();
2285 enfVertex->grpName = vertexList[j].grpName.in();
2286 for (CORBA::ULong k=0 ; k< vertexList[j].coords.length();k++)
2287 enfVertex->coords.push_back(vertexList[j].coords[k]);
2289 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2292 if (groupName != "") {
2293 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2297 // h_data.enfVertMap[entry] = evs;
2298 // h_data.entryCoordsListMap[entry] = coordsList;
2300 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2301 h_data.faceEntryEnfVertexListMap.erase(entry);
2304 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2305 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2309 h_data.preCadPeriodicityVector.clear();
2311 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2312 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2314 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2315 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2319 GEOM::GEOM_Object_var geom = myHyPatchFaceSelector->GetGeomObjectByEntry( getMainShapeEntry() );
2320 if ( geom->_is_nil() )
2321 geom = myHyPatchFaceSelector->GetGeomObjectByEntry( getShapeEntry() );
2323 h_data.hyperpatches.clear();
2324 h_data.hyperEntries.clear();
2325 BLSURFPlugin::THyperPatchList_var patchList = h->GetHyperPatches( geom );
2326 BLSURFPlugin::THyperPatchEntriesList_var patchEntriesList = h->GetHyperPatchShapes();
2327 for ( CORBA::ULong i = 0; i < patchList->length(); ++i )
2330 BLSURFPlugin::THyperPatch& patch = patchList[i];
2331 for ( CORBA::ULong j = 0; j < patch.length(); ++j )
2332 tags += QString::number( patch[j] ) + " ";
2333 if ( !tags.isEmpty() )
2334 h_data.hyperpatches.append( tags );
2336 if ( patchEntriesList->length() == patchList->length() )
2339 BLSURFPlugin::THyperPatchEntries& patchEntries = patchEntriesList[i];
2340 for ( CORBA::ULong j = 0; j < patchEntries.length(); ++j )
2341 entries += patchEntries[j].in() + QString(" ");
2342 if ( !entries.isEmpty() )
2343 h_data.hyperEntries.append( entries );
2346 if ( h_data.hyperpatches.size() != h_data.hyperEntries.size() )
2347 h_data.hyperEntries.clear();
2352 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2353 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2356 for (CORBA::ULong i=0; i<preCadFacePeriodicityVector->length(); i++ )
2358 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2359 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2360 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2362 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2363 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2365 if (sourceVertices.length()!=0)
2367 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2368 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2370 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2373 if (targetVertices.length()!=0)
2375 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2376 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2378 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2382 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2384 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2386 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2390 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2391 Saves the hypothesis data to hypothesis values.
2393 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2395 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2396 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2402 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2404 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2405 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2406 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2407 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2409 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2410 if ( h->GetPhySize() != h_data.myPhySize ||
2411 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2412 if ( h_data.myPhySizeRel )
2413 h->SetPhySizeRel( h_data.myPhySize );
2415 h->SetPhySize( h_data.myPhySize );
2418 if (h->GetMinSize() != h_data.myMinSize ||
2419 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2420 if ( h_data.myMinSizeRel )
2421 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2423 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2425 if (h->GetMaxSize() != h_data.myMaxSize ||
2426 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2427 if ( h_data.myMaxSizeRel )
2428 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2430 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2432 if ( h->GetUseGradation() != h_data.myUseGradation )
2433 h->SetUseGradation( h_data.myUseGradation );
2434 if ( h->GetGradation() != h_data.myGradation )
2435 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2436 if ( h->GetUseVolumeGradation() != h_data.myUseVolumeGradation )
2437 h->SetUseVolumeGradation( h_data.myUseVolumeGradation );
2438 if ( h->GetVolumeGradation() != h_data.myVolumeGradation )
2439 h->SetVolumeGradation( h_data.myVolumeGradation <= 0 ? -1 : h_data.myVolumeGradation );
2441 h->SetSurfaceProximity ((CORBA::Short) h_data.myUseSurfaceProximity );
2442 h->SetNbSurfaceProximityLayers((CORBA::Short) h_data.myNbSurfaceProximityLayers );
2443 h->SetSurfaceProximityRatio ( h_data.mySurfaceProximityRatio );
2444 h->SetVolumeProximity ((CORBA::Short) h_data.myUseVolumeProximity );
2445 h->SetNbVolumeProximityLayers ((CORBA::Short) h_data.myNbVolumeProximityLayers );
2446 h->SetVolumeProximityRatio ( h_data.myVolumeProximityRatio );
2448 if ( h->GetElementType() != h_data.myElementType )
2449 h->SetElementType( h_data.myElementType );
2451 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2452 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2453 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2454 if ( h->GetChordalError() != h_data.myChordalError )
2455 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2458 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2459 h->SetAnisotropic( h_data.myAnisotropic );
2460 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2461 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2463 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2464 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2465 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2466 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2468 if ( h->GetOptimiseTinyEdges() != h_data.myOptimiseTinyEdges )
2469 h->SetOptimiseTinyEdges( h_data.myOptimiseTinyEdges );
2470 if ( h_data.myOptimiseTinyEdges && ( h->GetTinyEdgeOptimisationLength() != h_data.myTinyEdgeOptimisLength ) )
2471 h->SetTinyEdgeOptimisationLength( h_data.myTinyEdgeOptimisLength <= 0 ? -1 :h_data.myTinyEdgeOptimisLength );
2472 if ( h->GetCorrectSurfaceIntersection() != h_data.myCorrectSurfaceIntersection )
2473 h->SetCorrectSurfaceIntersection( h_data.myCorrectSurfaceIntersection );
2474 if ( h_data.myCorrectSurfaceIntersection && ( h->GetCorrectSurfaceIntersectionMaxCost() != h_data.myCorrectSurfaceIntersectionMaxCost ) )
2475 h->SetCorrectSurfaceIntersectionMaxCost( h_data.myCorrectSurfaceIntersectionMaxCost <= 0 ? -1 :h_data.myCorrectSurfaceIntersectionMaxCost );
2477 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2478 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2479 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2480 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2482 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2483 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2485 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2486 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2488 if ( h->GetVerbosity() != h_data.myVerbosity )
2489 h->SetVerbosity((CORBA::Short) h_data.myVerbosity );
2490 // if ( h->GetTopology() != h_data.myTopology )
2491 // h->SetTopology( (int) h_data.myTopology );
2492 // if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2493 // h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2494 // if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2495 // h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2496 // if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2497 // h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2499 // options are set in checkParams()
2500 //h->SetOptionValues( myOptions ); // is set in readParamsFromWidgets()
2501 //h->SetPreCADOptionValues( myPreCADOptions ); // is set in readParamsFromWidgets()
2503 if ( h->GetGMFFile() != h_data.myGMFFileName )
2504 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2505 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2506 h->SetGMFFile( h_data.myGMFFileName.c_str());
2508 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2509 QMapIterator<QString,QString> i(that->mySMPMap);
2510 while (i.hasNext()) {
2512 const QString entry = i.key();
2513 const QString sizeMap = i.value();
2515 if (sizeMap == "__TO_DELETE__") {
2516 h->UnsetEntry(entry.toLatin1().constData());
2518 else if (sizeMap.startsWith("ATTRACTOR")) {
2519 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2521 else if (sizeMap.startsWith("def")) {
2522 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2525 if (!myATTMap[entry].empty()){
2526 const TAttractorVec& attVec = myATTMap[entry];
2527 for ( size_t i = 0; i < attVec.size(); ++i )
2529 if ( attVec[i].IsToDelete() )
2530 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2531 attVec[i].attEntry.c_str() );
2533 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2534 attVec[i].attEntry.c_str(),
2535 attVec[i].startSize,
2538 attVec[i].constDist );
2542 QString fullSizeMap;
2543 fullSizeMap = QString("");
2544 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2545 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2546 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2547 fullSizeMap = QString("def f(t): return ") + sizeMap;
2548 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2549 fullSizeMap = QString("def f(): return ") + sizeMap;
2550 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2555 // Enforced vertices
2558 std::string enfName;
2560 std::string groupName = "";
2563 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2564 // 1. Clear all enforced vertices in hypothesis
2565 // 2. Add new enforced vertex according to h_data
2567 if ( h->GetAllEnforcedVertices()->length() > 0 )
2568 h->ClearAllEnforcedVertices();
2571 TEnfVertexList::const_iterator evsIt;
2572 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2574 faceEntry = evmIt->first;
2575 evs = evmIt->second;
2576 evsIt = evs.begin();
2577 for ( ; evsIt != evs.end() ; ++evsIt)
2580 if ((*evsIt)->coords.size()) {
2581 x = (*evsIt)->coords[0];
2582 y = (*evsIt)->coords[1];
2583 z = (*evsIt)->coords[2];
2586 h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2590 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2591 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2592 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2593 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2596 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2597 h->ClearPreCadPeriodicityVectors();
2599 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2600 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2602 TPreCadPeriodicity periodicity_i = *pIt;
2603 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2604 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2605 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2606 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2607 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2608 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2609 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2610 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2611 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2613 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2614 if (! p1Source.empty())
2616 sourceVertices->length(3);
2617 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2618 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2619 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2623 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2624 if (! p1Target.empty())
2626 targetVertices->length(3);
2627 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2628 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2629 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2633 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2635 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2639 BLSURFPlugin::THyperPatchList_var hpl = new BLSURFPlugin::THyperPatchList();
2640 BLSURFPlugin::THyperPatchEntriesList_var hpel = new BLSURFPlugin::THyperPatchEntriesList();
2641 hpl ->length( h_data.hyperpatches.size() );
2642 hpel->length( h_data.hyperEntries.size() );
2644 for ( int i = 0; i < h_data.hyperpatches.size(); ++i )
2646 QStringList tags = h_data.hyperpatches[i].split(" ", QString::SkipEmptyParts);
2647 BLSURFPlugin::THyperPatch& patch = hpl[ i ];
2648 patch.length( tags.size() );
2650 for ( int j = 0; j < tags.size(); ++j )
2651 patch[ j ] = tags[ j ].toInt();
2653 if ( i < h_data.hyperEntries.size() )
2655 QStringList entries = h_data.hyperEntries[i].split(" ", QString::SkipEmptyParts);
2656 BLSURFPlugin::THyperPatchEntries& pe = hpel[ i ];
2657 pe.length( entries.size() );
2659 for ( int j = 0; j < entries.size(); ++j )
2660 pe[ j ] = CORBA::string_dup( entries[ j ].toStdString().c_str() );
2663 if ( h_data.hyperEntries.size() == h_data.hyperpatches.size() )
2664 h->SetHyperPatchEntries( hpel );
2666 h->SetHyperPatches( hpl );
2670 BLSURFPlugin::EnforcedMeshesList_var enfMeshesList = new BLSURFPlugin::EnforcedMeshesList();
2671 enfMeshesList->length( myEnfMeshTableWdg->rowCount() );
2674 for ( int row = 0, nbRow = myEnfMeshTableWdg->rowCount(); row < nbRow; ++row )
2676 QTableWidgetItem * meshCell = myEnfMeshTableWdg->item( row, 0 );
2677 QString entry = meshCell->data( Qt::UserRole ).toString();
2678 QTableWidgetItem * groupCell = myEnfMeshTableWdg->item( row, 1 );
2679 QString groupName = groupCell->text();
2681 SMESH::SMESH_IDSource_var mesh = SMESH::EntryToInterface< SMESH::SMESH_IDSource >( entry );
2682 if ( !mesh->_is_nil() )
2684 enfMeshesList[ nbMeshes ].mesh = SMESH::SMESH_IDSource::_duplicate( mesh );
2685 enfMeshesList[ nbMeshes ].groupName = CORBA::string_dup( groupName.toStdString().c_str() );
2689 enfMeshesList->length( nbMeshes );
2691 h->SetEnforcedMeshes( enfMeshesList );
2702 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2703 Stores the widgets content to the hypothesis data.
2705 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2707 h_data.myName = myName ? myName->text() : "";
2708 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2709 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2710 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2711 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2712 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2713 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2714 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2715 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2716 h_data.myUseGradation = myStdWidget->myUseGradation->isChecked() && !myStdWidget->myGradation->text().isEmpty();
2717 h_data.myGradation = h_data.myUseGradation ? myStdWidget->myGradation->GetValue() : -1.0;
2718 h_data.myUseVolumeGradation = myStdWidget->myUseVolumeGradation->isChecked() && !myStdWidget->myVolumeGradation->text().isEmpty();
2719 h_data.myVolumeGradation = h_data.myUseVolumeGradation ? myStdWidget->myVolumeGradation->GetValue() : -1. ;
2720 h_data.myElementType = myStdWidget->myButtonGroupElementType->checkedId();
2721 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2722 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2723 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2724 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2725 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2726 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2727 h_data.myOptimiseTinyEdges = myStdWidget->myOptimiseTinyEdges->isChecked();
2728 h_data.myTinyEdgeOptimisLength = myStdWidget->myTinyEdgeOptimisLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeOptimisLength->GetValue();
2729 h_data.myCorrectSurfaceIntersection = myStdWidget->myCorrectSurfaceIntersection->isChecked();
2730 h_data.myCorrectSurfaceIntersectionMaxCost = myStdWidget->myCorrectSurfaceIntersectionMaxCost->text().isEmpty() ? -1.0 : myStdWidget->myCorrectSurfaceIntersectionMaxCost->GetValue();
2731 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2732 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2733 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2734 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2735 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2736 //h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2737 //h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2738 //h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2739 //h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2740 h_data.myUseSurfaceProximity = myStdWidget->myUseSurfaceProximity ->isChecked();
2741 h_data.myNbSurfaceProximityLayers = myStdWidget->myNbSurfaceProximityLayers->value();
2742 h_data.mySurfaceProximityRatio = myStdWidget->mySurfaceProximityRatio ->value();
2743 h_data.myUseVolumeProximity = myStdWidget->myUseVolumeProximity ->isChecked();
2744 h_data.myNbVolumeProximityLayers = myStdWidget->myNbVolumeProximityLayers ->value();
2745 h_data.myVolumeProximityRatio = myStdWidget->myVolumeProximityRatio ->value();
2748 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2749 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2750 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2751 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2752 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2753 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2754 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2755 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2756 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2757 guiHyp += tr("BLSURF_ELEMENT_TYPE") + " = " + QString::number(h_data.myElementType) + "; ";
2758 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2759 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2760 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2761 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2764 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2765 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2766 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2767 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2768 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2769 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2772 // guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2773 // guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2774 // guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2775 // guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2777 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2778 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2781 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2782 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2783 for ( ; row < nbRows; ++row )
2785 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2786 if ( that->mySMPMap.contains(entry) )
2787 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2790 // Enforced vertices
2791 h_data.enfVertexList.clear();
2792 h_data.faceEntryEnfVertexListMap.clear();
2794 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2795 std::string groupName = "", faceEntry = "";
2796 for (int i=0 ; i<nbEnforcedShapes ; i++)
2798 double childValueX,childValueY,childValueZ;
2799 std::string childName, vertexEntry;
2800 QTreeWidgetItem* child;
2802 child = myEnforcedTreeWidget->topLevelItem(i);
2803 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2804 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2805 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2806 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2807 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2808 // if (myGlobalGroupName->isChecked())
2809 // groupName = myGlobalGroupName->text().toStdString();
2811 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2813 TEnfVertex *enfVertex = new TEnfVertex();
2814 enfVertex->name = childName;
2815 if (vertexEntry.empty()) {
2816 enfVertex->coords.push_back(childValueX);
2817 enfVertex->coords.push_back(childValueY);
2818 enfVertex->coords.push_back(childValueZ);
2821 enfVertex->geomEntry = vertexEntry;
2822 enfVertex->grpName = groupName;
2823 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2824 // if (it == h_data.enfVertexList.end())
2825 h_data.enfVertexList.insert(enfVertex);
2827 if (groupName != "")
2828 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2830 h_data.faceEntryEnfVertexListMap[faceEntry].insert( enfVertex );
2833 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2834 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2837 h_data.preCadPeriodicityVector.clear();
2838 // For each tree item, store each value. Shapes are stored as entries.
2839 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2840 for (int i=0 ; i<nbPeriodicityDescriptions ; i++) {
2841 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2842 TPreCadPeriodicity periodicity_i;
2844 for (int k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2846 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2847 periodicity_i.push_back(entry);
2849 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2851 guiHyp += "PERIODICITY = yes; ";
2855 h_data.hyperpatches.clear();
2856 h_data.hyperEntries.clear();
2857 for ( int row = 0; row < myHyPatchTable->rowCount(); ++row )
2859 QTableWidgetItem* cell = myHyPatchTable->item( row, 0 );
2860 h_data.hyperpatches.append( cell->text() );
2861 if ( cell->data( Qt::UserRole ).isValid() )
2862 h_data.hyperEntries.append( cell->data( Qt::UserRole ).toString() );
2864 if ( h_data.hyperpatches.size() != h_data.hyperEntries.size() )
2865 h_data.hyperEntries.clear();
2870 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2872 myAdvWidget->AddOption( TBL_CUSTOM, NULL );
2875 void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int /*row*/, int /*column*/ )
2877 // if ( column != OPTION_NAME_COLUMN )
2879 // myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2882 // **********************
2883 // *** BEGIN SIZE MAP ***
2884 // **********************
2886 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2888 if ( myGeomSelWdg2->IsObjectSelected() ){
2889 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2891 else if ( myGeomSelWdg1->IsObjectSelected() ){
2892 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2895 mySMapObject = GEOM::GEOM_Object::_nil();
2897 bool dataAvailable = !mySMapObject->_is_nil();
2899 if ( dataAvailable )
2900 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2902 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2903 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2904 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2905 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2906 ( myATTMap.contains( qEntry )))
2909 QString attEntry = myAttSelWdg->GetValue();
2910 const TAttractorVec& attVec = myATTMap[ qEntry ];
2911 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2912 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2915 addMapButton->setEnabled( !mapExists && dataAvailable );
2916 modifyMapButton->setEnabled( mapExists && dataAvailable );
2919 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2921 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2922 if (col == SMP_SIZEMAP_COLUMN) {
2923 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2925 if (!mySMPMap.contains(entry))
2927 if ( QTreeWidgetItem* parent = item->parent() )
2931 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2933 if (!mySMPMap.contains(entry))
2936 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2937 CORBA::Object_var obj = entryToObject(entry);
2938 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2939 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2940 // Retrieve values of the selected item in the current tab widgets
2941 const TAttractorVec& attVec = myATTMap[entry];
2942 if ( !attVec.empty() )
2945 if ( !childEntry.isEmpty() )
2946 for ( size_t i = 0; i < attVec.size(); ++i )
2947 if ( childEntry == attVec[i].attEntry.c_str() )
2952 double phySize = attVec[iAtt].startSize;
2953 double infDist = attVec[iAtt].infDist;
2954 double constDist = attVec[iAtt].constDist;
2955 QString attEntry = attVec[iAtt].attEntry.c_str();
2956 CORBA::Object_var attObj = entryToObject(attEntry);
2957 myAttSizeSpin->setValue(phySize);
2958 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2959 myAttDistSpin->setValue(infDist);
2960 myAttractorCheck->setChecked(true);
2963 myAttractorCheck->setChecked(false);
2965 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2966 myAttDistSpin2->setValue(constDist);
2967 myConstSizeCheck->setChecked(true);
2970 myConstSizeCheck->setChecked(false);
2972 myGeomSelWdg2->SetObject(obj);
2973 myAttSelWdg->SetObject(attObj);
2976 else { // CLASSIC MAPS
2977 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2978 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2979 if (!sizeMap.startsWith("def")){
2980 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2986 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2988 getGeomSelectionTool()->selectionMgr()->clearFilters();
2989 if ( sender() == myTabWidget )
2991 myGeomSelWdg1 ->deactivateSelection();
2992 myGeomSelWdg2 ->deactivateSelection();
2993 myAttSelWdg ->deactivateSelection();
2994 myEnfVertexWdg ->deactivateSelection();
2995 myPeriodicitySourceFaceWdg->deactivateSelection();
2996 myPeriodicityTargetFaceWdg->deactivateSelection();
2997 myPeriodicityP1SourceWdg ->deactivateSelection();
2998 myPeriodicityP2SourceWdg ->deactivateSelection();
2999 myPeriodicityP3SourceWdg ->deactivateSelection();
3000 myPeriodicityP1TargetWdg ->deactivateSelection();
3001 myPeriodicityP2TargetWdg ->deactivateSelection();
3002 myPeriodicityP3TargetWdg ->deactivateSelection();
3003 myEnfMeshWdg ->deactivateSelection();
3004 if ( myHyPatchFaceSelBtn->isChecked() )
3005 myHyPatchFaceSelBtn->toggle();
3006 if ( myHyPatchGroupSelBtn->isChecked() )
3007 myHyPatchGroupSelBtn->toggle();
3009 else if ( sender() == smpTab )
3011 myAttDistSpin->setValue(0.); // Reinitialize widgets
3012 myAttSizeSpin->setValue(0.);
3013 myAttDistSpin2->setValue(0.);
3014 mySmpSizeSpin->setValue(0.);
3015 myGeomSelWdg1->deactivateSelection();
3016 myGeomSelWdg2->deactivateSelection();
3017 myAttSelWdg->deactivateSelection();
3018 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3019 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3020 myAttSelWdg->SetObject(CORBA::Object::_nil());
3021 myAttractorCheck->setChecked(false);
3022 myConstSizeCheck->setChecked(false);
3025 if ( tab == SMP_TAB ) // [#16954] limit local size by Min and User Size
3027 double minSize = 0, maxSize = COORD_MAX;
3029 if ( !myStdWidget->myMinSizeRel->isChecked() &&
3030 !myStdWidget->myMinSize->text().isEmpty() )
3031 minSize = myStdWidget->myMinSize->GetValue();
3033 if ( !myStdWidget->myPhySizeRel->isChecked() &&
3034 !myStdWidget->myPhySize->text().isEmpty() )
3035 maxSize = myStdWidget->myPhySize->GetValue();
3037 mySmpSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
3038 myAttSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
3041 if ( tab == ENF_M_TAB )
3043 myEnfMeshWdg->activateSelection();
3044 onEnforcedMeshSelected(); // update buttons
3045 onEnfMeshTableSelected();
3046 if ( myEnforcedGroupName->text().isEmpty() )
3047 myEnforcedGroupName->setText("Group 1D");
3051 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
3053 if (state == Qt::Checked){
3054 myAttSelWdg->setEnabled(true);
3055 myAttSizeSpin->setEnabled(true);
3056 myAttSizeLabel->setEnabled(true);
3057 myAttDistSpin->setEnabled(true);
3058 myAttDistLabel->setEnabled(true);
3059 if (!myAttSelWdg->IsObjectSelected()){
3060 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
3063 if (state == Qt::Unchecked){
3064 myAttDistSpin->setEnabled(false);
3065 myAttDistLabel->setEnabled(false);
3066 myAttDistSpin->setValue(0.);
3067 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
3068 myAttSelWdg->setEnabled(false);
3069 myAttSizeSpin->setEnabled(false);
3070 myAttSizeLabel->setEnabled(false);
3071 myAttDistSpin2->setEnabled(false);
3072 myAttDistLabel2->setEnabled(false);
3074 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
3075 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
3078 onMapGeomContentModified();
3081 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
3083 if (state == Qt::Checked){
3084 myAttSelWdg->setEnabled(true);
3085 myAttSizeSpin->setEnabled(true);
3086 myAttSizeLabel->setEnabled(true);
3087 myAttDistSpin2->setEnabled(true);
3088 myAttDistLabel2->setEnabled(true);
3089 if (myAttractorCheck->checkState() == Qt::Unchecked &&
3090 !myAttSelWdg->IsObjectSelected()){
3091 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
3094 if (state == Qt::Unchecked){
3095 myAttDistSpin2->setEnabled(false);
3096 myAttDistLabel2->setEnabled(false);
3097 myAttDistSpin2->setValue(0.);
3098 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
3099 myAttSelWdg->setEnabled(false);
3100 myAttSizeSpin->setEnabled(false);
3101 myAttSizeLabel->setEnabled(false);
3102 myAttDistSpin->setEnabled(false);
3103 myAttDistLabel->setEnabled(false);
3105 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
3106 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
3109 onMapGeomContentModified();
3112 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
3114 QList<int> selectedRows;
3115 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
3116 QTreeWidgetItem* item;
3117 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3119 qSort( selectedRows );
3120 QListIterator<QTreeWidgetItem*> it( selected );
3122 while ( it.hasPrevious() ) {
3123 item = it.previous();
3124 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
3125 QString parentEntry;
3126 if ( QTreeWidgetItem* parent = item->parent() )
3127 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
3128 if (that->mySMPMap.contains(entry))
3130 that->mySMPMap[entry] = "__TO_DELETE__";
3131 if ( myATTMap.contains( entry ))
3133 TAttractorVec& attVec = myATTMap[entry];
3134 for ( size_t i = 0; i < attVec.size(); ++i )
3135 attVec[i].SetToDelete();
3138 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
3140 TAttractorVec& attVec = myATTMap[parentEntry];
3141 for ( size_t i = 0; i < attVec.size(); ++i )
3143 if ( entry == attVec[i].attEntry.c_str() )
3144 attVec[i].SetToDelete();
3147 if (that->mySMPShapeTypeMap.contains(entry))
3148 that->mySMPShapeTypeMap.remove(entry);
3149 // if (that->myDistMap.contains(entry))
3150 // that->myDistMap.remove(entry);
3151 // if (that->myAttDistMap.contains(entry))
3152 // that->myAttDistMap.remove(entry);
3155 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
3156 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
3159 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
3161 if (col == SMP_SIZEMAP_COLUMN) {
3162 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3163 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
3164 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
3165 if (! that->mySMPShapeTypeMap.contains(entry))
3167 if (that->mySMPMap.contains(entry))
3168 if (that->mySMPMap[entry] == sizeMap
3169 || sizeMap.startsWith("Attractor")
3170 || sizeMap.startsWith("Constant") ){
3173 if (! sizeMap.isEmpty()) {
3174 that->mySMPMap[entry] = sizeMap;
3175 sizeMapValidationFromEntry(entry);
3178 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
3180 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
3184 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
3187 if ( smpTab->currentIndex() == ATT_TAB ){
3188 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3189 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3190 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3191 res = insertAttractor(mySMapObject, myAttObject);
3194 if (smpTab->currentIndex() == SMP_STD_TAB ){
3195 if ( myGeomSelWdg1->IsObjectSelected() ){
3196 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3197 res = insertElement(mySMapObject);
3201 // Local size should be more than 0
3202 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3203 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3206 getGeomSelectionTool()->selectionMgr()->clearFilters();
3207 myAttDistSpin->setValue(0.);
3208 myAttSizeSpin->setValue(0.);
3209 myAttDistSpin2->setValue(0.);
3210 mySmpSizeSpin->setValue(0.);
3211 myConstSizeCheck->setChecked(false);
3212 myAttractorCheck->setChecked(false);
3213 myGeomSelWdg1->deactivateSelection();
3214 myGeomSelWdg2->deactivateSelection();
3215 myAttSelWdg->deactivateSelection();
3216 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3217 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3218 myAttSelWdg->SetObject(CORBA::Object::_nil());
3221 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
3224 if ( smpTab->currentIndex() == ATT_TAB ){
3225 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3226 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3227 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3228 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
3231 if (smpTab->currentIndex() == SMP_STD_TAB ){
3232 if ( myGeomSelWdg1->IsObjectSelected() ){
3233 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3234 res = insertElement(mySMapObject, /*modify = */true);
3238 // Local size should be more than 0
3239 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3240 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3243 getGeomSelectionTool()->selectionMgr()->clearFilters();
3244 myAttDistSpin->setValue(0.);
3245 myAttSizeSpin->setValue(0.);
3246 myAttDistSpin2->setValue(0.);
3247 mySmpSizeSpin->setValue(0.);
3248 myConstSizeCheck->setChecked(false);
3249 myAttractorCheck->setChecked(false);
3250 myGeomSelWdg1->deactivateSelection();
3251 myGeomSelWdg2->deactivateSelection();
3252 myAttSelWdg->deactivateSelection();
3253 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3254 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3255 myAttSelWdg->SetObject(CORBA::Object::_nil());
3258 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3260 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3261 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3263 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3265 TopAbs_ShapeEnum shapeType;
3266 string entry, shapeName;
3267 entry = (string) anObject->GetStudyEntry();
3268 shapeName = anObject->GetName();
3269 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3270 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3271 // in order to write the size map with the right syntax in StoreParamsToHypo
3272 // (f(t) for edges, f(u,v) for faces ...)
3273 if (shapeType == TopAbs_COMPOUND){
3274 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3275 TopoDS_Shape childShape;
3276 TopoDS_Iterator anIt(theShape);
3277 for(;anIt.More();anIt.Next()){
3278 childShape = anIt.Value();
3279 shapeType = childShape.ShapeType();
3280 if(!childShape.IsNull()){
3285 mySizeMapTable->setFocus();
3287 shapeEntry = QString::fromStdString(entry);
3288 double phySize = mySmpSizeSpin->value();
3291 return false; // Local size should be more than 0
3293 std::ostringstream oss;
3296 sizeMap = QString::fromStdString(oss.str());
3297 QTreeWidgetItem* item = new QTreeWidgetItem();
3299 int rowToChange = findRowFromEntry(shapeEntry);
3300 item = mySizeMapTable->topLevelItem( rowToChange );
3303 if (that->mySMPMap.contains(shapeEntry)) {
3304 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3308 mySizeMapTable->addTopLevelItem(item);
3310 that->mySMPMap[shapeEntry] = sizeMap;
3311 //that->myDistMap[shapeEntry] = 0. ;
3312 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3313 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3314 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3315 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3316 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3317 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3318 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3319 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3320 mySizeMapTable->clearSelection();
3322 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3323 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3324 myStdWidget->onPhysicalMeshChanged();
3329 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3331 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3332 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3334 TopAbs_ShapeEnum shapeType;
3335 string entry, attEntry, faceName, attName;
3336 entry = (string) aFace->GetStudyEntry();
3337 attEntry = (string) anAttractor->GetStudyEntry();
3338 faceName = aFace->GetName();
3339 attName = anAttractor->GetName();
3340 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3341 mySizeMapTable->setFocus();
3342 QString shapeEntry = QString::fromStdString(entry);
3343 QString qAttEntry = QString::fromStdString(attEntry);
3345 double phySize = h->GetPhySize();
3346 double infDist = 0. ;
3347 double constDist = 0. ;
3348 phySize = myAttSizeSpin->value();
3351 return false; // Local size should be more than 0
3353 if (myAttractorCheck->isChecked()){
3354 infDist = myAttDistSpin->value();
3356 if (myConstSizeCheck->isChecked()){
3357 constDist = myAttDistSpin2->value();
3359 std::ostringstream oss;
3360 std::ostringstream oss2;
3361 std::ostringstream oss3;
3365 QString sizeMap = QString::fromStdString(oss.str());
3366 QString infDistString = QString::fromStdString(oss2.str());
3367 QString constDistString = QString::fromStdString(oss3.str());
3369 QTreeWidgetItem* item;
3370 QTreeWidgetItem* child = 0;
3371 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3373 int rowToChange = findRowFromEntry(shapeEntry);
3374 item = mySizeMapTable->topLevelItem( rowToChange );
3376 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3377 if (( child = item->child( i )))
3378 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3380 TAttractorVec & attVec = myATTMap[shapeEntry];
3381 for ( size_t i = 0; i < attVec.size(); ++i )
3382 if ( attVec[i].attEntry == attEntry )
3384 attVec[i] = attParams;
3389 // if (that->mySMPMap.contains(shapeEntry)) {
3390 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3394 int rowToChange = findRowFromEntry(shapeEntry);
3395 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3397 item = mySizeMapTable->topLevelItem( rowToChange );
3400 item = new QTreeWidgetItem();
3401 mySizeMapTable->addTopLevelItem(item);
3403 child = new QTreeWidgetItem();
3404 item->addChild(child);
3405 bool exists = false;
3406 TAttractorVec & attVec = myATTMap[shapeEntry];
3407 for ( size_t i = 0; i < attVec.size(); ++i )
3408 if ( attVec[i].attEntry == attEntry )
3410 attVec[i] = attParams;
3415 myATTMap[shapeEntry].push_back( attParams );
3417 mySMPMap.insert(shapeEntry,sizeMap);
3418 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3419 item->setExpanded(true);
3420 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3421 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3422 if (infDist > std::numeric_limits<double>::epsilon()){
3423 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3425 else if (constDist > std::numeric_limits<double>::epsilon()){
3426 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3428 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3430 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3431 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3432 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3434 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3435 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3436 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3438 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3439 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3440 myStdWidget->onPhysicalMeshChanged();
3445 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3447 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3448 for ( ; row < nbRows; ++row )
3449 if (! sizeMapValidationFromRow(row))
3454 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3456 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3457 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3458 mySizeMapTable->setFocus();
3462 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3465 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3467 if (! that->mySMPMap.contains(myEntry)) {
3470 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3476 if (that->mySMPMap[myEntry].startsWith("def")) {
3477 expr = that->mySMPMap[myEntry].toStdString();
3479 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3480 if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$")) != 1)) {
3483 SUIT_MessageBox::warning( dlg(),"Definition of attractor : Error" ,"An attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False[;d])" );
3489 // case size map is empty
3490 if (that->mySMPMap[myEntry].isEmpty()) {
3492 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3496 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3497 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3498 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3499 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3500 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3501 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3504 //assert(Py_IsInitialized());
3505 if (! Py_IsInitialized())
3506 throw ("Erreur: Python interpreter is not initialized");
3507 PyGILState_STATE gstate;
3508 gstate = PyGILState_Ensure();
3510 string err_description="";
3511 PyObject* obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3515 PyObject* new_stderr = newPyStdOut(err_description);
3516 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3517 Py_INCREF(old_stderr);
3518 PySys_SetObject((char*)"stderr", new_stderr);
3520 PySys_SetObject((char*)"stderr", old_stderr);
3521 Py_DECREF(new_stderr);
3523 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3524 PyGILState_Release(gstate);
3529 PyObject* func = PyObject_GetAttrString(main_mod, "f");
3533 PyObject* new_stderr = newPyStdOut(err_description);
3534 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3535 Py_INCREF(old_stderr);
3536 PySys_SetObject((char*)"stderr", new_stderr);
3538 PySys_SetObject((char*)"stderr", old_stderr);
3539 Py_DECREF(new_stderr);
3541 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3542 PyGILState_Release(gstate);
3546 PyGILState_Release(gstate);
3552 //================================================================================
3554 * \brief SLOT: Activate selection of faces in the Viewer
3556 //================================================================================
3558 void BLSURFPluginGUI_HypothesisCreator::onHyPatchFaceSelection(bool on)
3560 if ( on && myHyPatchFaceSelector->GetMainShape().IsNull() )
3562 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
3563 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
3564 myHyPatchFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
3566 myHyPatchFaceSelector->setVisible( on ); // show its buttons
3567 myHyPatchFaceSelector->ShowPreview( on ); // show faces in the Viewer
3568 // treat selection or not
3569 myHyPatchFaceSelector->ActivateSelection( on || myHyPatchGroupSelBtn->isChecked() );
3572 myHyPatchGroupSelBtn->setChecked( false );
3575 //================================================================================
3577 * \brief SLOT: Deactivate selection of faces in the Viewer
3579 //================================================================================
3581 void BLSURFPluginGUI_HypothesisCreator::onHyPatchGroupSelection(bool on)
3583 if ( on && myHyPatchFaceSelector->GetMainShape().IsNull() )
3585 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
3586 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
3587 myHyPatchFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
3589 if ( !myHyPatchFaceSelBtn->isChecked() )
3591 myHyPatchFaceSelector->setVisible( false ); // show its buttons
3592 myHyPatchFaceSelector->ShowPreview( false ); // show faces in the Viewer
3594 // treat selection or not
3595 myHyPatchFaceSelector->ActivateSelection( on || myHyPatchFaceSelBtn->isChecked() );
3598 myHyPatchFaceSelBtn->setChecked( false );
3601 //================================================================================
3603 * \brief SLOT: show IDs of selected faces in Tags LineEdit
3605 //================================================================================
3607 void BLSURFPluginGUI_HypothesisCreator::onHyPatchSelectionChanged()
3610 const QList<int>& tags = myHyPatchFaceSelector->GetSelectedIDs();
3611 for ( int i = 0; i < tags.size(); ++i )
3612 tagString += QString::number( tags[i] ) + " ";
3614 myHyPatchTagsLE->setText( tagString );
3617 //================================================================================
3619 * \brief SLOT: Add the Tags to the HyperPatch table
3621 //================================================================================
3623 void BLSURFPluginGUI_HypothesisCreator::onHyPatchAdd()
3625 QStringList tagList = myHyPatchTagsLE->text().split(" ", QString::SkipEmptyParts);
3626 if ( tagList.size() > 1 )
3628 LightApp_SelectionMgr* selMrg = SMESHGUI::GetSMESHGUI()->selectionMgr();
3629 SALOME_ListIO aList;
3630 selMrg->selectedObjects( aList );
3632 for ( SALOME_ListIteratorOfListIO anIt( aList ); anIt.More(); anIt.Next() )
3634 Handle(SALOME_InteractiveObject) io = anIt.Value();
3635 GEOM::GEOM_Object_var go = myHyPatchFaceSelector->GetGeomObjectByEntry( io->getEntry() );
3636 if ( !CORBA::is_nil( go ))
3637 entries += io->getEntry() + QString(" ");
3644 addHyPatchToTable( myHyPatchTagsLE->text(), entries );
3645 myHyPatchTagsLE->setText("");
3649 //================================================================================
3651 * \brief Add a row to myHyPatchTable
3653 //================================================================================
3655 void BLSURFPluginGUI_HypothesisCreator::addHyPatchToTable(const QString& tags,
3656 const QString& entries)
3658 if ( tags.isEmpty() ) return;
3660 QTableWidgetItem* cell = new QTableWidgetItem( tags );
3661 cell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
3662 if ( entries.isEmpty() )
3663 cell->setData( Qt::UserRole, QVariant() );
3665 cell->setData( Qt::UserRole, entries );
3667 int row = myHyPatchTable->rowCount();
3668 myHyPatchTable->insertRow( row );
3669 myHyPatchTable->setItem( row, 0, cell );
3672 //================================================================================
3674 * \brief SLOT: remove selected rows from the HyperPatch table
3676 //================================================================================
3678 void BLSURFPluginGUI_HypothesisCreator::onHyPatchRemove()
3680 QList<QTableWidgetItem *> items = myHyPatchTable->selectedItems();
3681 while ( !items.isEmpty() )
3683 myHyPatchTable->removeRow( items[0]->row() );
3684 items = myHyPatchTable->selectedItems();
3688 //================================================================================
3690 * \brief Add a new row in Enforced mesh table
3692 //================================================================================
3694 void BLSURFPluginGUI_HypothesisCreator::addEnforcedMesh( SMESH::SMESH_IDSource_ptr mesh,
3695 const QString& groupName )
3697 _PTR(SObject) sobj = SMESH::FindSObject( mesh );
3701 QString meshEntry = sobj->GetID().c_str();
3702 QString meshName = sobj->GetName().c_str();
3704 QTableWidgetItem* meshCell = new QTableWidgetItem( meshName );
3705 meshCell->setData( Qt::UserRole, meshEntry );
3706 meshCell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
3708 QTableWidgetItem* groupCell = new QTableWidgetItem( groupName );
3709 groupCell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable );
3711 int row = myEnfMeshTableWdg->rowCount();
3712 myEnfMeshTableWdg->insertRow( row );
3713 myEnfMeshTableWdg->setItem( row, 0, meshCell );
3714 myEnfMeshTableWdg->setItem( row, 1, groupCell );
3716 myEnfMeshTableWdg->resizeColumnToContents( 0 );
3717 myEnfMeshTableWdg->resizeColumnToContents( 1 );
3720 //================================================================================
3722 * \brief SLOT called when [Add] is clicked in Enforced mesh tab.
3723 * Add an item to the enforced meshes table
3725 //================================================================================
3727 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedMesh()
3729 if ( myEnfMeshWdg->NbObjects() != 1 )
3732 SMESH::SMESH_IDSource_var mesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
3733 QString groupName = myEnforcedGroupName->text().simplified();
3735 addEnforcedMesh( mesh, groupName );
3737 selectionMgr()->clearSelected();
3738 myEnfMeshWdg->SetObject( SMESH::SMESH_IDSource::_nil() );
3741 //================================================================================
3743 * \brief SLOT called when [Remove] is clicked in Enforced mesh tab.
3744 * Remove a selected mesh from the enforced meshes table
3746 //================================================================================
3748 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
3750 QList<int> selectedRows;
3751 QList<QTableWidgetItem *> selectedItems = myEnfMeshTableWdg->selectedItems();
3752 QTableWidgetItem* item;
3754 foreach( item, selectedItems )
3757 if (!selectedRows.contains( row ) )
3758 selectedRows.append(row);
3761 qSort( selectedRows );
3762 QListIterator<int> it( selectedRows );
3764 while ( it.hasPrevious() ) {
3765 row = it.previous();
3766 myEnfMeshTableWdg->removeRow(row );
3769 myEnfMeshTableWdg->selectionModel()->clearSelection();
3771 onEnforcedMeshSelected(); // to activate [Add] if possible
3774 //================================================================================
3776 * \brief SLOT called when mesh selection changes. Enable/disable [Add] button
3778 //================================================================================
3780 void BLSURFPluginGUI_HypothesisCreator::onEnforcedMeshSelected()
3782 bool enable = ( myEnfMeshWdg->NbObjects() == 1 );
3785 // check if a selected mesh contains segments
3786 SMESH::SMESH_IDSource_var mesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
3787 if (( enable = !mesh->_is_nil() ))
3789 SMESH::array_of_ElementType_var types = mesh->GetTypes();
3790 if (( enable = ( types->length() > 0 )))
3793 for ( CORBA::ULong i = 0; i < types->length() && !enable; ++i )
3794 enable = ( types[ i ] = SMESH::EDGE );
3798 // check if this mesh is already in the table
3801 _PTR(SObject) sobj = SMESH::FindSObject( mesh );
3802 if (( enable = bool( sobj )))
3804 QString meshEntry = sobj->GetID().c_str();
3805 for ( int row = 0, nbRow = myEnfMeshTableWdg->rowCount(); row < nbRow && enable; ++row )
3807 QTableWidgetItem * cell = myEnfMeshTableWdg->item( row, 0 );
3808 enable = ( meshEntry != cell->data( Qt::UserRole ).toString() );
3813 myAddEnfMeshButton->setEnabled( enable );
3816 //================================================================================
3818 * \brief SLOT called when selection changes in the table. Enable/disable [Remove] button
3820 //================================================================================
3822 void BLSURFPluginGUI_HypothesisCreator::onEnfMeshTableSelected()
3824 bool enable = !myEnfMeshTableWdg->selectedItems().empty();
3826 myRemoveEnfMeshButton->setEnabled( enable );
3829 //================================================================================
3831 * \brief Return false if algorithm is a re-mesher
3833 //================================================================================
3835 bool BLSURFPluginGUI_HypothesisCreator::hasGeom() const
3837 return hypType() == BLSURFPlugin_Hypothesis::GetHypType(true);
3840 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3842 return tr( "BLSURF_TITLE" );
3845 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3847 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3850 QString BLSURFPluginGUI_HypothesisCreator::type() const
3852 return tr( "BLSURF_HYPOTHESIS" );
3855 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3857 return "blsurf_hypo_page.html";
3860 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3863 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3865 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3870 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3872 CORBA::Object_var obj;
3873 SALOMEDS::SObject_var aSObj = SMESH_Gen_i::GetSMESHGen()->getStudyServant()->FindObjectID( entry.toStdString().c_str() );
3874 if (!aSObj->_is_nil()) {
3875 obj = aSObj->GetObject();
3876 aSObj->UnRegister();
3881 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3882 int endRow = mySizeMapTable->topLevelItemCount()-1;
3884 for ( ; row <= endRow; ++row )
3886 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3887 if (entry == entryForChecking )