1 // Copyright (C) 2007-2016 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"
30 #include "GeometryGUI.h"
32 #include <SMESHGUI_Utils.h>
33 #include <SMESHGUI_HypothesesUtils.h>
34 #include <SMESHGUI_Dialog.h>
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESH_NumberFilter.hxx"
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Tools.h>
43 #include <QApplication>
47 #include <QHBoxLayout>
48 #include <QHeaderView>
49 #include <QGridLayout>
55 #include <QPushButton>
56 #include <QRadioButton>
58 #include <QTableWidget>
60 #include <QVBoxLayout>
63 #include <QStandardItemModel>
64 #include <QStandardItem>
65 #include <QTreeWidget>
66 #include <QTreeWidgetItem>
67 #include <QModelIndexList>
69 #include <LightApp_SelectionMgr.h>
70 #include <SalomeApp_Application.h>
71 #include <SALOME_ListIO.hxx>
72 #include "SALOME_LifeCycleCORBA.hxx"
74 #include <TopoDS_Shape.hxx>
75 #include <TopoDS_Iterator.hxx>
76 #include <SMESH_Gen_i.hxx>
77 #include <boost/shared_ptr.hpp>
78 #include <boost/algorithm/string.hpp>
79 #include <structmember.h>
98 TBL_MESHING = 0, TBL_PRECAD, TBL_CUSTOM,
100 // Enforced vertices array columns
101 ENF_VER_NAME_COLUMN = 0,
102 ENF_VER_FACE_ENTRY_COLUMN,
106 ENF_VER_ENTRY_COLUMN,
107 ENF_VER_GROUP_COLUMN,
110 PERIODICITY_OBJ_SOURCE_COLUMN = 0,
111 PERIODICITY_OBJ_TARGET_COLUMN,
112 PERIODICITY_P1_SOURCE_COLUMN,
113 PERIODICITY_P2_SOURCE_COLUMN,
114 PERIODICITY_P3_SOURCE_COLUMN,
115 PERIODICITY_P1_TARGET_COLUMN,
116 PERIODICITY_P2_TARGET_COLUMN,
117 PERIODICITY_P3_TARGET_COLUMN,
118 PERIODICITY_SHAPE_TYPE,
120 // PERIODICITY_OBJ_SOURCE_COLUMN = 0,
121 // PERIODICITY_ENTRY_SOURCE_COLUMN,
122 // PERIODICITY_OBJ_TARGET_COLUMN,
123 // PERIODICITY_ENTRY_TARGET_COLUMN,
124 // PERIODICITY_P1_SOURCE_COLUMN,
125 // PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
126 // PERIODICITY_P2_SOURCE_COLUMN,
127 // PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
128 // PERIODICITY_P3_SOURCE_COLUMN,
129 // PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
130 // PERIODICITY_P1_TARGET_COLUMN,
131 // PERIODICITY_P1_ENTRY_TARGET_COLUMN,
132 // PERIODICITY_P2_TARGET_COLUMN,
133 // PERIODICITY_P2_ENTRY_TARGET_COLUMN,
134 // PERIODICITY_P3_TARGET_COLUMN,
135 // PERIODICITY_P3_ENTRY_TARGET_COLUMN,
137 PERIODICITY_NB_COLUMN
163 // Enforced vertices inputs
171 // ENF_VER_GROUP_CHECK,
175 ENF_VER_INTERNAL_ALL_FACES,
176 ENF_VER_INTERNAL_ALL_FACES_GROUP,
177 // ENF_VER_VERTEX_BTN,
178 // ENF_VER_REMOVE_BTN,
179 // ENF_VER_SEPARATOR,
184 /**************************************************
185 Begin initialization Python structures and objects
186 ***************************************************/
196 PyStdOut_dealloc(PyStdOut *self)
202 PyStdOut_write(PyStdOut *self, PyObject *args)
206 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
209 *(self->out)=*(self->out)+c;
215 static PyMethodDef PyStdOut_methods[] = {
216 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
217 PyDoc_STR("write(string) -> None")},
218 {NULL, NULL} /* sentinel */
221 static PyMemberDef PyStdOut_memberlist[] = {
222 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
223 (char*)"flag indicating that a space needs to be printed; used by print"},
224 {NULL} /* Sentinel */
227 static PyTypeObject PyStdOut_Type = {
228 /* The ob_type field must be initialized in the module init function
229 * to be portable to Windows without using C++. */
230 PyObject_HEAD_INIT(NULL)
233 sizeof(PyStdOut), /*tp_basicsize*/
236 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
243 0, /*tp_as_sequence*/
248 PyObject_GenericGetAttr, /*tp_getattro*/
249 /* softspace is writable: we must supply tp_setattro */
250 PyObject_GenericSetAttr, /* tp_setattro */
252 Py_TPFLAGS_DEFAULT, /*tp_flags*/
256 0, /*tp_richcompare*/
257 0, /*tp_weaklistoffset*/
260 PyStdOut_methods, /*tp_methods*/
261 PyStdOut_memberlist, /*tp_members*/
275 PyObject * newPyStdOut( std::string& out )
277 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
282 return (PyObject*)self;
286 /*************************************************
287 End initialization Python structures and objects
288 **************************************************/
292 // BEGIN EnforcedTreeWidgetDelegate
295 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
296 : QItemDelegate(parent)
300 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
301 const QStyleOptionViewItem & option ,
302 const QModelIndex & index ) const
304 QModelIndex father = index.parent();
305 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
307 if (index.column() == ENF_VER_X_COLUMN || \
308 index.column() == ENF_VER_Y_COLUMN || \
309 index.column() == ENF_VER_Z_COLUMN)
311 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
312 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
313 editor->setReadOnly(!entry.isEmpty());
314 editor->setDisabled(!entry.isEmpty());
319 QLineEdit *editor = new QLineEdit(parent);
320 if (index.column() != ENF_VER_GROUP_COLUMN) {
321 editor->setReadOnly(!entry.isEmpty());
322 editor->setDisabled(!entry.isEmpty());
328 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
329 const QModelIndex &index) const
331 QString value = index.model()->data(index, Qt::EditRole).toString();
333 if (index.column() == ENF_VER_X_COLUMN ||
334 index.column() == ENF_VER_Y_COLUMN ||
335 index.column() == ENF_VER_Z_COLUMN)
337 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
338 lineEdit->setText(value);
341 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
342 lineEdit->setText(value);
346 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
347 const QModelIndex &index) const
349 QModelIndex parent = index.parent();
350 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
351 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
352 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
353 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
354 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
355 } else if (index.column() == ENF_VER_NAME_COLUMN) {
356 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
357 QString value = lineEdit->text();
358 if (entry.isEmpty() && !vertexExists(model, index, value))
359 model->setData(index, value, Qt::EditRole);
360 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
361 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
362 QString value = lineEdit->text();
363 if (!vertexExists(model, index, value))
364 model->setData(index, value, Qt::EditRole);
365 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
366 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
367 model->setData(index, lineEdit->text(), Qt::EditRole);
371 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
372 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
374 editor->setGeometry(option.rect);
377 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
378 const QModelIndex &index, QString value) const
381 QModelIndex parent = index.parent();
382 int row = index.row();
383 int col = index.column();
385 if (parent.isValid() && !value.isEmpty()) {
386 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
388 if (col == ENF_VER_X_COLUMN) {
389 x = value.toDouble();
390 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
391 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
393 if (col == ENF_VER_Y_COLUMN) {
394 y = value.toDouble();
395 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
396 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
398 if (col == ENF_VER_Z_COLUMN) {
399 z = value.toDouble();
400 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
401 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
403 int nbChildren = model->rowCount(parent);
404 for (int i = 0 ; i < nbChildren ; i++) {
406 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
407 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
408 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
409 if ((childX == x) && (childY == y) && (childZ == z)) {
416 else if (col == ENF_VER_NAME_COLUMN) {
417 int nbChildren = model->rowCount(parent);
418 for (int i = 0 ; i < nbChildren ; i++) {
420 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
421 if (childName == value) {
434 // END EnforcedTreeWidgetDelegate
439 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
440 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
443 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
444 : SMESHGUI_GenericHypothesisCreator( theHypType )
446 this->mySMPMap.clear();
448 GeomToolSelected = NULL;
449 GeomToolSelected = getGeomSelectionTool();
451 aSel = GeomToolSelected->selectionMgr();
453 /* Initialize the Python interpreter */
454 if (! Py_IsInitialized())
455 throw ("Error: Python interpreter is not initialized");
456 PyGILState_STATE gstate;
457 gstate = PyGILState_Ensure();
460 main_mod = PyImport_AddModule("__main__");
463 main_dict = PyModule_GetDict(main_mod);
465 PyRun_SimpleString("from math import *");
466 PyGILState_Release(gstate);
470 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
475 * \brief {Get or create the geom selection tool for active study}
477 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() const
479 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
480 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
481 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
482 that->GeomToolSelected = new GeomSelectionTools(aStudy);
484 return that->GeomToolSelected;
487 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
489 return GeometryGUI::GetGeomGen();
492 void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
494 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
495 ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
496 for ( ; anIt != selectionWidgets.end(); anIt++)
498 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
500 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
501 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
502 ListOfWidgets::const_iterator anIt2 = anIt;
503 for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
504 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
506 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
507 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
508 w1->AvoidSimultaneousSelection( w2 );
510 if ( !widgetToActivate )
511 widgetToActivate = w1;
514 if ( widgetToActivate )
515 widgetToActivate->activateSelection();
518 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
522 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
523 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
527 myAdvWidget->myOptionTable->setFocus();
528 QApplication::instance()->processEvents();
532 int iTbl = 0, nbTbl = myAdvWidget->myOptionTable->topLevelItemCount();
533 for ( ; iTbl < nbTbl; ++iTbl )
535 QTreeWidgetItem* table = myAdvWidget->myOptionTable->topLevelItem( iTbl );
536 int nbRows = table->childCount();
537 for ( int iRow = 0; iRow < nbRows; ++iRow )
539 QTreeWidgetItem* row = table->child( iRow );
540 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
542 if ( name.simplified().isEmpty() )
543 continue; // invalid custom option
545 if ( isDefault ) // not selected option
552 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
555 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
558 h->AddOption( name.toLatin1().constData(), value.toLatin1().constData() );
562 catch ( const SALOME::SALOME_Exception& ex )
564 msg = ex.details.text.in();
573 h->SetOptionValues( myOptions ); // restore values
574 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
578 // SizeMap and attractors
581 mySizeMapTable->setFocus();
582 QApplication::instance()->processEvents();
584 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
585 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
587 for ( ; row < nbRows; ++row )
589 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
590 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
591 if ( !sizeMap.isEmpty() ) {
592 if (that->sizeMapValidationFromRow(row))
595 e = entry.toStdString();
596 s = that->mySMPMap[entry].toStdString();
597 h->SetSizeMapEntry( e.c_str(), s.c_str() );
599 catch ( const SALOME::SALOME_Exception& ex )
601 msg = ex.details.text.in();
612 // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
615 // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
616 // So STD_TAB must be current tab to get correct value of it's spinbox.
617 myTabWidget->setCurrentIndex( STD_TAB );
621 if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
622 myStdWidget->myPhySize->text().toDouble() > 0.0 )))
623 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
627 if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
628 myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
629 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
633 if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
634 myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
635 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
639 if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
640 myStdWidget->myChordalError->text().toDouble() > 0.0 )))
641 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
650 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
652 QFrame* fr = new QFrame( 0 );
653 // fr-> setMinimumSize(600,400);
654 QVBoxLayout* lay = new QVBoxLayout( fr );
655 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
657 lay->setSpacing( 0 );
659 // main TabWidget of the dialog
660 myTabWidget = new QTabWidget( fr );
661 myTabWidget->setTabShape( QTabWidget::Rounded );
662 myTabWidget->setTabPosition( QTabWidget::North );
663 lay->addWidget( myTabWidget );
668 myStdGroup = new QWidget();
669 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
670 aStdLayout->setSpacing( 6 );
671 aStdLayout->setMargin( 11 );
674 myName = new QLineEdit( myStdGroup );
675 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
679 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
680 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
682 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
688 // row = max(row,maxrow)+1;
689 aStdLayout->setRowStretch(row,1);
690 aStdLayout->setColumnStretch(1,1);
694 // advanced parameters
695 myAdvGroup = new QWidget();
696 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
697 anAdvLayout->setSpacing( 6 );
698 anAdvLayout->setMargin( 11 );
699 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
700 //myAdvWidget->addBtn->setMenu( new QMenu() );
701 anAdvLayout->addWidget( myAdvWidget );
704 // Size Maps parameters
706 mySmpGroup = new QWidget();
707 // mySmpGroup->setMinimumWidth(500);
710 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
713 mySizeMapTable = new QTreeWidget( mySmpGroup );
714 mySizeMapTable ->setMinimumWidth(200);
715 QStringList sizeMapHeaders;
716 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
717 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
718 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
719 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
720 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
721 mySizeMapTable->setAlternatingRowColors(true);
724 smpTab = new QTabWidget( mySmpGroup );
725 smpTab->setTabShape( QTabWidget::Rounded );
726 smpTab->setTabPosition( QTabWidget::South );
727 lay->addWidget( smpTab );
729 // Filters of selection
730 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
732 SM_ShapeTypes.Add( TopAbs_VERTEX );
733 SM_ShapeTypes.Add( TopAbs_EDGE );
734 SM_ShapeTypes.Add( TopAbs_FACE );
735 SM_ShapeTypes.Add( TopAbs_COMPOUND );
737 ATT_ShapeTypes.Add( TopAbs_VERTEX );
738 ATT_ShapeTypes.Add( TopAbs_EDGE );
739 ATT_ShapeTypes.Add( TopAbs_WIRE );
740 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
742 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
743 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
744 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
746 // Standard size map tab
747 mySmpStdGroup = new QWidget();
748 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
749 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false);
750 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
751 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
752 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
753 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
756 myAttractorGroup = new QWidget();
757 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
758 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false);
759 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
760 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
761 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
762 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
763 QFrame* attLine = new QFrame(myAttractorGroup);
764 attLine->setFrameShape(QFrame::HLine);
765 attLine->setFrameShadow(QFrame::Sunken);
766 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false);
767 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
768 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
769 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
770 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
771 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
772 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
773 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
774 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
775 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
776 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
778 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
779 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
783 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
784 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
785 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
786 modifyMapButton->setEnabled(false);
789 myAttSelWdg->setEnabled(false);
790 myAttSizeSpin->setEnabled(false);
791 myAttSizeLabel->setEnabled(false);
792 myAttDistSpin->setEnabled(false);
793 myAttDistLabel->setEnabled(false);
794 myAttDistSpin2->setEnabled(false);
795 myAttDistLabel2->setEnabled(false);
796 myAttDistSpin->setValue(0.);
797 myAttDistSpin2->setValue(0.);
798 myAttSizeSpin->setValue(0.);
799 mySmpSizeSpin->setValue(0.);
802 // ADD WIDGETS (SIZEMAP TAB)
803 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
804 anSmpLayout->setColumnStretch(0, 1);
805 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
806 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
807 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
808 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
809 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
810 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
813 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
814 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
815 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
816 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
819 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
820 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
821 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
822 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
823 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
824 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
825 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
826 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
827 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
828 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
829 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
830 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
832 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
833 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
835 smpTab->setCurrentIndex( SMP_STD_TAB );
837 // Enforced vertices parameters
838 myEnfGroup = new QWidget();
839 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
841 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
842 // anEnfLayout->addWidget(myEnforcedVertexWidget);
843 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
845 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
846 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
847 myEnforcedTreeWidget->setSortingEnabled(true);
848 QStringList enforcedHeaders;
849 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
850 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
851 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
853 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
854 myEnforcedTreeWidget->header()->setStretchLastSection(true);
855 myEnforcedTreeWidget->setAlternatingRowColors(true);
856 myEnforcedTreeWidget->setUniformRowHeights(true);
857 myEnforcedTreeWidget->setAnimated(true);
858 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
859 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
860 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
861 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
862 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
864 myEnforcedTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
866 myEnforcedTreeWidget->resizeColumnToContents(column);
868 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
869 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
870 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
872 // FACE AND VERTEX SELECTION
873 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
874 shapeTypes1.Add( TopAbs_FACE );
875 shapeTypes1.Add( TopAbs_COMPOUND );
876 shapeTypes2.Add( TopAbs_VERTEX );
877 shapeTypes2.Add( TopAbs_COMPOUND );
879 // SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
880 // myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true);
881 // myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
883 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
884 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
885 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
887 //myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
889 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
890 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
891 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
893 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
894 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
895 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
897 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
898 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
899 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
901 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
902 myGroupName = new QLineEdit(myEnfGroup);
904 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
905 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
907 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
909 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
910 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
912 // myGlobalGroupName = new QCheckBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
913 // myGlobalGroupName->setChecked(false);
915 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
916 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
917 // FACE AND VERTEX SELECTION
918 //anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
919 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
920 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
921 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
922 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
923 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
924 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
925 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
926 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
927 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
928 // anEnfLayout2->addWidget(myGlobalGroupName, ENF_VER_GROUP_CHECK, 0, 1, 2);
929 // anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
930 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
931 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
932 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
933 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
934 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
935 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
936 // anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
937 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
938 // anEnfLayout->setRowStretch(1, 1);
941 // Periodicity parameters
942 myPeriodicityGroup = new QWidget();
943 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
945 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
946 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
947 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
949 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
951 QStringList myPeriodicityTreeHeaders;
952 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
953 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
954 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
955 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
956 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
957 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
958 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
959 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
960 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
961 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
963 // Hide the vertex name to make the widget more readable
964 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
965 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
966 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
967 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
968 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
969 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
970 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
973 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
974 myPeriodicityTreeWidget->setSortingEnabled(true);
976 myPeriodicityTreeWidget->setAlternatingRowColors(true);
977 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
978 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
980 size_t periodicityVisibleColumns = 2;
981 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
982 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
983 myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
985 myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
987 myPeriodicityTreeWidget->resizeColumnToContents(column);
989 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
991 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
993 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
995 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
996 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
997 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
999 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
1001 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
1002 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
1004 myPeriodicityOnFaceRadioButton->setChecked(true);
1006 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
1007 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
1010 // FACE, EDGE AND VERTEX SELECTION
1011 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
1012 shapeTypesFace.Add( TopAbs_FACE );
1013 shapeTypesFace.Add( TopAbs_EDGE );
1014 shapeTypesFace.Add( TopAbs_COMPOUND );
1015 shapeTypesEdge.Add( TopAbs_EDGE );
1016 shapeTypesEdge.Add( TopAbs_COMPOUND );
1018 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
1020 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1021 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1023 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1024 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false);
1025 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1026 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1028 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1029 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1030 // myPeriodicitySourceEdgeWdg->hide();
1031 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1033 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1034 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1036 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1037 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false);
1038 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1039 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1041 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1042 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1043 // myPeriodicityTargetEdgeWdg->hide();
1044 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1046 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1047 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1048 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1050 myPeriodicityGroupBox2->setCheckable(true);
1051 myPeriodicityGroupBox2->setChecked(false);
1053 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1054 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1056 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1057 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1060 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1061 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1064 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1065 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false);
1066 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1069 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1070 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1072 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1073 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false);
1074 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1077 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1078 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1080 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1081 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false);
1082 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1085 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1086 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1088 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1089 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false);
1090 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1093 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1094 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1096 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1097 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false);
1098 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1101 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1102 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1104 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1105 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false);
1106 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1108 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1109 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1112 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1113 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1115 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1116 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1118 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1120 myPeriodicitySelectionWidgets.clear();
1121 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1122 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1123 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1124 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1125 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1126 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1127 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1128 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1129 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1132 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1133 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1134 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1135 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1136 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1138 myTabWidget->setCurrentIndex( STD_TAB );
1140 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
1141 connect( myStdWidget->myAllowQuadrangles, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChange() ));
1144 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1145 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1146 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1147 // connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1148 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1149 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1150 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1151 connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1152 // connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1153 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1154 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1155 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1156 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1157 connect( myTabWidget, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1159 // Enforced vertices
1160 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1161 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1162 // connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1163 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1164 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1165 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1166 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1167 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1168 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1169 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1172 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1173 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1174 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1175 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1177 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1178 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1180 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1181 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1184 // connect( myPeriodicitySourceFaceWdg, SIGNAL(contentModified()), this, SLOT(onPeriodicityContentModified()));
1188 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1189 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1191 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1193 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1194 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1195 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1196 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1197 // myEnfFaceWdg->deactivateSelection();
1198 // myEnfVertexWdg->deactivateSelection();
1202 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1204 myStdWidget->onPhysicalMeshChanged();
1208 * This method resets the content of the X, Y, Z widgets;
1210 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1212 myXCoord->setCleared(true);
1213 myYCoord->setCleared(true);
1214 myZCoord->setCleared(true);
1215 myXCoord->setText("");
1216 myYCoord->setText("");
1217 myZCoord->setText("");
1218 // myGroupName->setText("");
1221 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1222 This method updates the tooltip of a modified item. The QLineEdit widgets content
1223 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1225 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1226 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1227 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1228 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1229 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1230 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1231 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1232 QTreeWidgetItem* parent = item->parent();
1234 clearEnforcedVertexWidgets();
1236 if (parent && (!x.isNull() || !entry.isNull())) {
1237 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1238 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1239 if (entry.isNull()) {
1240 toolTip += QString("(") + x.toString();
1241 toolTip += QString(", ") + y.toString();
1242 toolTip += QString(", ") + z.toString();
1243 toolTip += QString(")");
1246 if (!groupName.isEmpty())
1247 toolTip += QString(" [") + groupName + QString("]");
1249 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1252 myXCoord->SetValue(x.toDouble());
1253 myYCoord->SetValue(y.toDouble());
1254 myZCoord->SetValue(z.toDouble());
1257 if (!groupName.isEmpty())
1258 myGroupName->setText(groupName);
1262 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1263 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1264 clearEnforcedVertexWidgets();
1265 if (nbSelEnfVertex == 1)
1267 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1270 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1271 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1272 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1273 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1274 if (CORBA::is_nil(measureOp))
1277 CORBA::Double x,y,z;
1278 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1279 if ( measureOp->IsDone() )
1281 myXCoord->SetValue(x);
1282 myYCoord->SetValue(y);
1283 myZCoord->SetValue(z);
1289 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1290 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1291 of the enforced vertex clicked in the tree widget.
1293 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1294 clearEnforcedVertexWidgets();
1295 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1296 if (! items.isEmpty() && items.size() == 1) {
1297 QTreeWidgetItem *item = items[0];
1298 // for (int i=0 ; i < items.size() ; i++) {
1300 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1301 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1302 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1303 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1304 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1305 if (!x.isNull()/* && entry.isNull()*/) {
1306 myXCoord->SetValue(x.toDouble());
1307 myYCoord->SetValue(y.toDouble());
1308 myZCoord->SetValue(z.toDouble());
1311 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1312 myGroupName->setText(group.toString());
1317 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1318 This method adds a face containing enforced vertices in the tree widget.
1320 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1321 // Find theFaceEntry item
1322 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1323 QTreeWidgetItem* theItem;
1324 if (theItemList.empty()) {
1325 theItem = new QTreeWidgetItem();
1326 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1327 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1328 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1329 myEnforcedTreeWidget->addTopLevelItem(theItem);
1332 theItem = theItemList[0];
1337 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1338 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1340 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z,
1341 std::string vertexName,
1342 std::string geomEntry,
1343 std::string groupName)
1345 bool okToCreate = true;
1347 const int nbVert = myEnforcedTreeWidget->topLevelItemCount();
1348 for (int row = 0; row < nbVert; row++ )
1350 QTreeWidgetItem* child = myEnforcedTreeWidget->topLevelItem( row );
1351 QString childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1352 QString childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1353 double childX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1354 double childY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1355 double childZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1356 if (((childEntry.isEmpty()) && (childX == x) && (childY == y) && (childZ == z)) ||
1357 ( !childEntry.isEmpty() && childEntry == geomEntry.c_str() ))
1359 // update group name
1360 if ( childGroupName != groupName.c_str() ) {
1361 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1371 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( myEnforcedTreeWidget );
1372 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1373 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1374 QSize iconSize = iconSelect.size()*0.7;
1376 int vertexIndex=nbVert;
1377 QString myVertexName;
1379 while(indexRef != vertexIndex) {
1380 indexRef = vertexIndex;
1381 if (vertexName.empty())
1382 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1384 myVertexName = QString(vertexName.c_str());
1386 for (int row = 0;row<nbVert;row++) {
1387 QString name = myEnforcedTreeWidget->topLevelItem(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1388 if (myVertexName == name) {
1394 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1395 if (geomEntry.empty()) {
1396 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1397 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1398 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1401 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1402 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1404 if (groupName != "")
1405 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1407 QString toolTip = myVertexName;
1408 if (geomEntry.empty()) {
1409 toolTip += QString(" (%1, %2, %3").arg(x).arg(y).arg(z);
1411 if (groupName != "")
1412 toolTip += QString(" [%1]").arg(groupName.c_str());
1414 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1415 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1418 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1419 This method is called when a item is added into the enforced vertices tree widget
1421 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1423 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1425 getGeomSelectionTool()->selectionMgr()->clearFilters();
1426 //myEnfFaceWdg->deactivateSelection();
1427 myEnfVertexWdg->deactivateSelection();
1429 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1430 myEnforcedTreeWidget->resizeColumnToContents(column);
1433 //int selEnfFace = myEnfFaceWdg->NbObjects();
1434 int selEnfVertex = myEnfVertexWdg->NbObjects();
1435 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1437 // if (selEnfFace == 0)
1440 if ((selEnfVertex == 0) && coordsEmpty)
1443 string entry, shapeName;
1445 //for (int i = 0 ; i < selEnfVertex + !coordsEmpty; i++)
1447 //myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1448 //entry = myEnfFace->GetStudyEntry();
1449 //shapeName = myEnfFace->GetName();
1451 //QTreeWidgetItem * faceItem = addEnforcedFace(entry, shapeName);
1453 std::string groupName = myGroupName->text().toStdString();
1455 if (boost::trim_copy(groupName).empty())
1458 if (selEnfVertex <= 1)
1461 x = myXCoord->GetValue();
1462 y = myYCoord->GetValue();
1463 z = myZCoord->GetValue();
1464 if (selEnfVertex == 1) {
1465 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1466 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1469 addEnforcedVertex(x, y, z, "", "", groupName);
1473 if ( CORBA::is_nil(getGeomEngine()))
1476 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1477 if (CORBA::is_nil(measureOp))
1480 CORBA::Double x,y,z;
1482 for (int j = 0 ; j < selEnfVertex ; j++)
1484 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1485 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1486 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1487 if ( measureOp->IsDone() )
1488 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1489 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1490 addEnforcedVertex(0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1496 //myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1497 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1499 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1500 myEnforcedTreeWidget->resizeColumnToContents(column);
1502 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1503 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1504 myStdWidget->onPhysicalMeshChanged();
1508 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1509 This method is called when a item is removed from the enforced vertices tree widget
1511 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1512 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1513 QList<QTreeWidgetItem *> selectedVertices;
1514 QSet<QTreeWidgetItem *> selectedEntries;
1515 QTreeWidgetItem* item;
1517 foreach( item, selectedItems ) {
1518 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1519 if (! value.isNull())
1520 selectedVertices.append(item);
1522 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1523 if (! value.isNull())
1524 selectedVertices.append(item);
1526 selectedEntries.insert(item);
1530 foreach(item,selectedVertices) {
1531 QTreeWidgetItem* parent = item->parent();
1533 parent->removeChild(item);
1535 if ( parent && parent->childCount() == 0) {
1536 if (selectedEntries.contains(parent))
1537 selectedEntries.remove(parent);
1542 foreach(item,selectedEntries) {
1546 myEnforcedTreeWidget->selectionModel()->clearSelection();
1550 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1552 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1555 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1556 This method is called when a item is added into the periodicity table widget
1558 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1560 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1562 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1563 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1564 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1566 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1567 w1->deactivateSelection();
1571 // Source-Target selection
1572 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1573 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1575 if (selSource == 0 || selTarget == 0)
1578 // Vertices selection
1579 if (myPeriodicityGroupBox2->isChecked())
1581 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1582 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1583 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1584 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1585 //int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1586 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1588 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1590 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1591 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1596 // Add Source-Target in table
1597 string shapeEntry, sourceEntry, targetEntry;
1598 string shapeName, sourceName, targetName;
1599 GEOM::GEOM_Object_var shape;
1601 QTreeWidgetItem* item = new QTreeWidgetItem();
1602 myPeriodicityTreeWidget->addTopLevelItem(item);
1604 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1608 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1610 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1611 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1612 shapeName = shape->GetName();
1613 shapeEntry = shape->GetStudyEntry();
1614 item->setData(k, Qt::EditRole, shapeName.c_str() );
1615 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1616 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1620 // Add shape type in tree
1621 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1622 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1624 // Blank input fields
1625 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1627 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1628 w1->SetObject(GEOM::GEOM_Object::_nil());
1631 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1632 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1636 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1637 This method is called when a item is removed from the periodicity tree widget
1639 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1640 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1641 QTreeWidgetItem* item;
1643 foreach(item,selectedItems) {
1647 myEnforcedTreeWidget->selectionModel()->clearSelection();
1650 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1651 This method enable clears the field for periodicity by vertices
1653 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1657 for (int k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1659 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1660 w1->deactivateSelection();
1661 w1->SetObject(CORBA::Object::_nil());
1666 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1667 This method enable the proper shape selection widget to Face or Edge shapes
1669 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1671 // if (myPeriodicityOnFaceRadioButton->isChecked())
1673 // myPeriodicitySourceEdgeWdg->hide();
1674 // myPeriodicityTargetEdgeWdg->hide();
1675 // myPeriodicitySourceFaceWdg->show();
1676 // myPeriodicityTargetFaceWdg->show();
1680 // myPeriodicitySourceFaceWdg->hide();
1681 // myPeriodicityTargetFaceWdg->hide();
1682 // myPeriodicitySourceEdgeWdg->show();
1683 // myPeriodicityTargetEdgeWdg->show();
1687 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1689 QString shapeName, shapeEntry;
1690 CORBA::Object_var shape;
1692 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1693 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1695 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1697 shapeName = item->data(k, Qt::EditRole).toString();
1698 shapeEntry = item->data(k, Qt::UserRole).toString();
1699 if (! shapeEntry.isEmpty())
1701 shape = entryToObject(shapeEntry);
1702 w1->SetObject(shape);
1703 w1->deactivateSelection();
1705 myPeriodicityGroupBox2->setChecked(1);
1708 myPeriodicityGroupBox2->setChecked(0);
1711 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1712 myPeriodicityOnFaceRadioButton->setChecked(true);
1714 myPeriodicityOnEdgeRadioButton->setChecked(true);
1719 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1720 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1722 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1724 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1726 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1728 // find wich selection widget is activated
1729 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1731 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1732 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1734 // don't activate vertex selection if the group box is not checked
1735 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1737 // clear the selection, to avoid to put the same object in the other widget
1738 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1739 // activate the next widget
1740 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1741 w2->activateSelection();
1748 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1749 This method updates the GUI widgets with the hypothesis data
1751 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1753 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1755 BlsurfHypothesisData data;
1756 that->readParamsFromHypo( data );
1759 myName->setText( data.myName );
1760 QFontMetrics metrics( myName->font() );
1761 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1763 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1764 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1765 if (data.myPhySize <= 0)
1766 myStdWidget->myPhySize->setText("");
1768 myStdWidget->myPhySize->SetValue( data.myPhySize );
1769 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1770 if (data.myMinSize < 0)
1771 myStdWidget->myMinSize->setText("");
1773 myStdWidget->myMinSize->SetValue( data.myMinSize );
1774 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1775 if (data.myMaxSize < 0)
1776 myStdWidget->myMaxSize->setText("");
1778 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1779 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1780 myStdWidget->myUseGradation->setChecked( data.myUseGradation );
1781 if (data.myGradation <= 0 || !data.myUseGradation )
1782 myStdWidget->myGradation->setText("");
1784 myStdWidget->myGradation->SetValue( data.myGradation );
1785 myStdWidget->myUseVolumeGradation->setChecked( data.myUseVolumeGradation );
1786 if (data.myVolumeGradation <= 0 || !data.myUseVolumeGradation )
1787 myStdWidget->myVolumeGradation->setText("");
1789 myStdWidget->myVolumeGradation->SetValue( data.myVolumeGradation );
1790 myStdWidget->myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1792 if (data.myAngleMesh < 0)
1793 myStdWidget->myAngleMesh->setText("");
1795 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1796 if (data.myChordalError <= 0)
1797 myStdWidget->myChordalError->setText("");
1799 myStdWidget->myChordalError->SetValue( data.myChordalError );
1800 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1801 if (data.myAnisotropicRatio <= 0)
1802 myStdWidget->myAnisotropicRatio->setText("");
1804 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1805 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1806 if (data.myTinyEdgeLength <= 0)
1807 myStdWidget->myTinyEdgeLength->setText("");
1809 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1810 myStdWidget->myOptimiseTinyEdges->setChecked( data.myOptimiseTinyEdges );
1811 if (data.myTinyEdgeOptimisLength <= 0)
1812 myStdWidget->myTinyEdgeOptimisLength->setText("");
1814 myStdWidget->myTinyEdgeOptimisLength->SetValue( data.myTinyEdgeOptimisLength );
1815 myStdWidget->myCorrectSurfaceIntersection->setChecked( data.myCorrectSurfaceIntersection );
1816 if (data.myCorrectSurfaceIntersectionMaxCost <= 0)
1817 myStdWidget->myCorrectSurfaceIntersectionMaxCost->setText("");
1819 myStdWidget->myCorrectSurfaceIntersectionMaxCost->SetValue( data.myCorrectSurfaceIntersectionMaxCost );
1820 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1821 if (data.myBadElementAspectRatio <= 0)
1822 myStdWidget->myBadElementAspectRatio->setText("");
1824 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1825 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1826 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1828 myStdWidget->resizeWidgets();
1830 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1832 if ( myOptions.operator->() ) {
1833 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1834 myAdvWidget->AddOption( TBL_MESHING, that->myOptions[i].in() );
1836 if ( myPreCADOptions.operator->() ) {
1837 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i )
1838 myAdvWidget->AddOption( TBL_PRECAD, that->myPreCADOptions[i].in() );
1840 if ( myCustomOptions.operator->() ) {
1841 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1842 myAdvWidget->AddOption( TBL_CUSTOM, that->myCustomOptions[i].in() );
1844 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1845 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1846 // myGMFFileMode->setChecked(data.myGMFFileMode);
1849 QMapIterator<QString, QString> i(that->mySMPMap);
1850 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1851 while (i.hasNext()) {
1853 const QString entry = i.key();
1854 const QString sizeMap = i.value();
1855 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1856 //int row = mySizeMapTable->topLevelItemCount();
1857 QTreeWidgetItem* item = new QTreeWidgetItem();
1858 mySizeMapTable->addTopLevelItem( item );
1859 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1860 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1861 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1862 if (that->myATTMap.contains(entry)) {
1863 TAttractorVec & attVec = that->myATTMap[entry];
1864 for ( size_t i = 0; i < attVec.size(); ++i )
1866 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
1867 QTreeWidgetItem* child = new QTreeWidgetItem();
1868 item->addChild( child );
1869 item->setExpanded(true);
1870 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
1871 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
1872 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
1874 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
1875 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
1878 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
1884 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1887 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1888 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1889 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1891 // Enforced vertices
1892 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1894 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1895 TEntry entry = (*evmIt).first;
1896 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1898 //QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1900 TEnfVertexList evs = (*evmIt).second;
1902 TEnfVertexList::const_iterator evsIt = evs.begin();
1903 TEnfVertex *enfVertex;
1904 for ( ; evsIt != evs.end() ; ++evsIt) {
1905 enfVertex = (*evsIt);
1906 double x = 0, y = 0, z = 0;
1907 if (enfVertex->coords.size()) {
1908 x = enfVertex->coords[0];
1909 y = enfVertex->coords[1];
1910 z = enfVertex->coords[2];
1912 that->addEnforcedVertex(x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1916 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1917 myEnforcedTreeWidget->resizeColumnToContents(column);
1919 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1920 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1921 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1926 // Add an item in the tree widget for each association
1927 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
1929 QTreeWidgetItem* item = new QTreeWidgetItem();
1930 myPeriodicityTreeWidget->addTopLevelItem(item);
1931 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1932 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
1933 for (size_t k=0; k<periodicity_i.size(); k++)
1935 string shapeEntry = periodicity_i[k];
1936 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
1937 item->setData(k, Qt::EditRole, shapeName.c_str() );
1938 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1943 that->myStdWidget->onPhysicalMeshChanged();
1944 that->myStdWidget->onGeometricMeshChanged();
1945 that->onStateChange();
1948 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1949 This method updates the hypothesis data with the GUI widgets content.
1951 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1953 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1955 BlsurfHypothesisData data;
1956 QString guiHyp = that->readParamsFromWidgets( data );
1957 that->storeParamsToHypo( data );
1962 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1963 Updates the hypothesis data from hypothesis values.
1965 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
1967 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1968 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1970 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1971 h_data.myName = isCreation() && data ? hypName() : "";
1973 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
1974 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
1975 h_data.myPhySize = h->GetPhySize();
1976 h_data.myPhySizeRel = h->IsPhySizeRel();
1977 double minSize = h->GetMinSize();
1978 double maxSize = h->GetMaxSize();
1979 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
1980 h_data.myMinSizeRel = h->IsMinSizeRel();
1981 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
1982 h_data.myMaxSizeRel = h->IsMaxSizeRel();
1983 h_data.myUseGradation = h->GetUseGradation();
1984 h_data.myGradation = h->GetGradation();
1985 h_data.myUseVolumeGradation = h->GetUseVolumeGradation();
1986 h_data.myVolumeGradation = h->GetVolumeGradation();
1987 h_data.myAllowQuadrangles = h->GetQuadAllowed();
1988 double angle = h->GetAngleMesh();
1989 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
1990 double chordalError = h->GetChordalError();
1991 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
1992 h_data.myAnisotropic = h->GetAnisotropic();
1993 double myAnisotropicRatio = h->GetAnisotropicRatio();
1994 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
1995 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
1996 double myTinyEdgeLength = h->GetTinyEdgeLength();
1997 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
1998 h_data.myOptimiseTinyEdges = h->GetOptimiseTinyEdges();
1999 double myTinyEdgeOptimisLength = h->GetTinyEdgeOptimisationLength();
2000 h_data.myTinyEdgeOptimisLength = myTinyEdgeOptimisLength > 0 ? myTinyEdgeOptimisLength : -1.0;
2001 h_data.myCorrectSurfaceIntersection = h->GetCorrectSurfaceIntersection();
2002 double corrSurfaceIntersMaxCost = h->GetCorrectSurfaceIntersectionMaxCost();
2003 h_data.myCorrectSurfaceIntersectionMaxCost = corrSurfaceIntersMaxCost > 0 ? corrSurfaceIntersMaxCost : -1.0;
2004 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2005 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2006 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2007 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2008 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2009 h_data.myVerbosity = h->GetVerbosity();
2010 //h_data.myTopology = (int) h->GetTopology();
2011 //h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2012 // h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2013 // h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2016 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2017 that->myOptions = h->GetOptionValues();
2018 that->myPreCADOptions = h->GetPreCADOptionValues();
2019 that->myCustomOptions = h->GetAdvancedOptionValues();
2021 h_data.myGMFFileName = h->GetGMFFile();
2022 // h_data.myGMFFileMode = h->GetGMFFileMode();
2024 that->mySMPMap.clear();
2025 that->myATTMap.clear();
2026 // that->myAttDistMap.clear();
2027 // that->myDistMap.clear();
2029 // classic size maps
2030 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2031 QString fullSizeMaps;
2032 QStringList fullSizeMapList;
2033 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2034 for ( CORBA::ULong i = 0;i<mySizeMaps->length(); ++i ) {
2035 fullSizeMaps = mySizeMaps[i].in();
2036 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2037 if ( fullSizeMapList.count() > 1 ) {
2038 string fullSizeMap = fullSizeMapList[1].toStdString();
2039 int pos = fullSizeMap.find("return")+7;
2042 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2047 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2048 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2054 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2056 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2057 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2058 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2059 if ( fullCustomSizeMapList.count() > 1 ) {
2060 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2061 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2066 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2068 for ( CORBA::ULong i = 0;i<allMyAttractors->length(); ++i ) {
2069 QString myAttractors = allMyAttractors[i].in();
2070 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2071 if ( myAttractorList.count() > 1 ) {
2072 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2073 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2077 // attractor new version
2078 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2079 for ( CORBA::ULong i = 0;i<allMyAttractorParams->length(); ++i ) {
2080 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2081 QString faceEntry = myAttractorParams.faceEntry.in();
2082 QString attEntry = myAttractorParams.attEntry.in();
2083 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2084 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2085 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2086 myAttractorParams.startSize,
2087 myAttractorParams.infDist,
2088 myAttractorParams.constDist ));
2091 // Enforced vertices
2092 h_data.enfVertexList.clear();
2093 h_data.faceEntryEnfVertexListMap.clear();
2095 h_data.groupNameEnfVertexListMap.clear();
2098 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2100 for ( CORBA::ULong i = 0;i<faceEntryEnfVertexListMap->length(); ++i )
2102 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2103 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2105 for (CORBA::ULong j=0 ; j<vertexList.length(); ++j)
2107 TEnfVertex *enfVertex = new TEnfVertex();
2108 enfVertex->name = vertexList[j].name.in();
2109 enfVertex->geomEntry = vertexList[j].geomEntry.in();
2110 enfVertex->grpName = vertexList[j].grpName.in();
2111 for (CORBA::ULong k=0 ; k< vertexList[j].coords.length();k++)
2112 enfVertex->coords.push_back(vertexList[j].coords[k]);
2114 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2117 if (groupName != "") {
2118 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2122 // h_data.enfVertMap[entry] = evs;
2123 // h_data.entryCoordsListMap[entry] = coordsList;
2125 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2126 h_data.faceEntryEnfVertexListMap.erase(entry);
2129 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2130 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2134 h_data.preCadPeriodicityVector.clear();
2136 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2137 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2139 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2140 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2144 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2145 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2148 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2150 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2151 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2152 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2154 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2155 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2157 if (sourceVertices.length()!=0)
2159 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2160 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2161 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2164 if (targetVertices.length()!=0)
2166 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2167 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2168 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2172 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2174 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2176 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2180 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2181 Saves the hypothesis data to hypothesis values.
2183 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2185 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2186 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2192 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2194 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2195 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2196 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2197 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2199 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2200 if ( h->GetPhySize() != h_data.myPhySize ||
2201 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2202 if ( h_data.myPhySizeRel )
2203 h->SetPhySizeRel( h_data.myPhySize );
2205 h->SetPhySize( h_data.myPhySize );
2208 if (h->GetMinSize() != h_data.myMinSize ||
2209 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2210 if ( h_data.myMinSizeRel )
2211 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2213 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2215 if (h->GetMaxSize() != h_data.myMaxSize ||
2216 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2217 if ( h_data.myMaxSizeRel )
2218 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2220 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2222 if ( h->GetUseGradation() != h_data.myUseGradation )
2223 h->SetUseGradation( h_data.myUseGradation );
2224 if ( h->GetGradation() != h_data.myGradation )
2225 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2226 if ( h->GetUseVolumeGradation() != h_data.myUseVolumeGradation )
2227 h->SetUseVolumeGradation( h_data.myUseVolumeGradation );
2228 if ( h->GetVolumeGradation() != h_data.myVolumeGradation )
2229 h->SetVolumeGradation( h_data.myVolumeGradation <= 0 ? -1 : h_data.myVolumeGradation );
2231 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
2232 h->SetQuadAllowed( h_data.myAllowQuadrangles );
2234 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2235 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2236 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2237 if ( h->GetChordalError() != h_data.myChordalError )
2238 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2241 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2242 h->SetAnisotropic( h_data.myAnisotropic );
2243 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2244 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2246 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2247 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2248 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2249 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2251 if ( h->GetOptimiseTinyEdges() != h_data.myOptimiseTinyEdges )
2252 h->SetOptimiseTinyEdges( h_data.myOptimiseTinyEdges );
2253 if ( h_data.myOptimiseTinyEdges && ( h->GetTinyEdgeOptimisationLength() != h_data.myTinyEdgeOptimisLength ) )
2254 h->SetTinyEdgeOptimisationLength( h_data.myTinyEdgeOptimisLength <= 0 ? -1 :h_data.myTinyEdgeOptimisLength );
2255 if ( h->GetCorrectSurfaceIntersection() != h_data.myCorrectSurfaceIntersection )
2256 h->SetCorrectSurfaceIntersection( h_data.myCorrectSurfaceIntersection );
2257 if ( h_data.myCorrectSurfaceIntersection && ( h->GetCorrectSurfaceIntersectionMaxCost() != h_data.myCorrectSurfaceIntersectionMaxCost ) )
2258 h->SetCorrectSurfaceIntersectionMaxCost( h_data.myCorrectSurfaceIntersectionMaxCost <= 0 ? -1 :h_data.myCorrectSurfaceIntersectionMaxCost );
2260 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2261 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2262 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2263 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2265 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2266 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2268 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2269 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2271 if ( h->GetVerbosity() != h_data.myVerbosity )
2272 h->SetVerbosity( h_data.myVerbosity );
2273 // if ( h->GetTopology() != h_data.myTopology )
2274 // h->SetTopology( (int) h_data.myTopology );
2275 // if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2276 // h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2277 // if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2278 // h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2279 // if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2280 // h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2282 // options are set in checkParams()
2283 //h->SetOptionValues( myOptions ); // is set in readParamsFromWidgets()
2284 //h->SetPreCADOptionValues( myPreCADOptions ); // is set in readParamsFromWidgets()
2286 if ( h->GetGMFFile() != h_data.myGMFFileName )
2287 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2288 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2289 h->SetGMFFile( h_data.myGMFFileName.c_str());
2291 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2292 QMapIterator<QString,QString> i(that->mySMPMap);
2293 while (i.hasNext()) {
2295 const QString entry = i.key();
2296 const QString sizeMap = i.value();
2298 if (sizeMap == "__TO_DELETE__") {
2299 h->UnsetEntry(entry.toLatin1().constData());
2301 else if (sizeMap.startsWith("ATTRACTOR")) {
2302 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2304 else if (sizeMap.startsWith("def")) {
2305 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2308 if (!myATTMap[entry].empty()){
2309 const TAttractorVec& attVec = myATTMap[entry];
2310 for ( size_t i = 0; i < attVec.size(); ++i )
2312 if ( attVec[i].IsToDelete() )
2313 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2314 attVec[i].attEntry.c_str() );
2316 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2317 attVec[i].attEntry.c_str(),
2318 attVec[i].startSize,
2321 attVec[i].constDist );
2325 QString fullSizeMap;
2326 fullSizeMap = QString("");
2327 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2328 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2329 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2330 fullSizeMap = QString("def f(t): return ") + sizeMap;
2331 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2332 fullSizeMap = QString("def f(): return ") + sizeMap;
2333 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2338 // Enforced vertices
2341 std::string enfName;
2343 std::string groupName = "";
2346 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2347 // 1. Clear all enforced vertices in hypothesis
2348 // 2. Add new enforced vertex according to h_data
2350 if ( h->GetAllEnforcedVertices()->length() > 0 )
2351 h->ClearAllEnforcedVertices();
2354 TEnfVertexList::const_iterator evsIt;
2355 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2357 faceEntry = evmIt->first;
2358 evs = evmIt->second;
2359 evsIt = evs.begin();
2360 for ( ; evsIt != evs.end() ; ++evsIt)
2363 if ((*evsIt)->coords.size()) {
2364 x = (*evsIt)->coords[0];
2365 y = (*evsIt)->coords[1];
2366 z = (*evsIt)->coords[2];
2369 h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2373 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2374 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2375 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2376 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2379 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2380 h->ClearPreCadPeriodicityVectors();
2382 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2383 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2385 TPreCadPeriodicity periodicity_i = *pIt;
2386 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2387 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2388 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2389 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2390 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2391 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2392 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2393 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2394 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2396 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2397 if (! p1Source.empty())
2399 sourceVertices->length(3);
2400 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2401 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2402 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2406 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2407 if (! p1Target.empty())
2409 targetVertices->length(3);
2410 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2411 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2412 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2416 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2418 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2424 catch(const std::exception& ex) {
2425 std::cout << "Exception: " << ex.what() << std::endl;
2428 // catch(const SALOME::SALOME_Exception& ex)
2431 // // SalomeApp_Tools::QtCatchCorbaException(ex);
2437 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2438 Stores the widgets content to the hypothesis data.
2440 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2442 h_data.myName = myName ? myName->text() : "";
2443 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2444 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2445 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2446 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2447 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2448 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2449 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2450 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2451 h_data.myUseGradation = myStdWidget->myUseGradation->isChecked() && !myStdWidget->myGradation->text().isEmpty();
2452 h_data.myGradation = h_data.myUseGradation ? myStdWidget->myGradation->GetValue() : -1.0;
2453 h_data.myUseVolumeGradation = myStdWidget->myUseVolumeGradation->isChecked() && !myStdWidget->myVolumeGradation->text().isEmpty();
2454 h_data.myVolumeGradation = h_data.myUseVolumeGradation ? myStdWidget->myVolumeGradation->GetValue() : -1. ;
2455 h_data.myAllowQuadrangles = myStdWidget->myAllowQuadrangles->isChecked();
2456 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2457 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2458 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2459 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2460 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2461 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2462 h_data.myOptimiseTinyEdges = myStdWidget->myOptimiseTinyEdges->isChecked();
2463 h_data.myTinyEdgeOptimisLength = myStdWidget->myTinyEdgeOptimisLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeOptimisLength->GetValue();
2464 h_data.myCorrectSurfaceIntersection = myStdWidget->myCorrectSurfaceIntersection->isChecked();
2465 h_data.myCorrectSurfaceIntersectionMaxCost = myStdWidget->myCorrectSurfaceIntersectionMaxCost->text().isEmpty() ? -1.0 : myStdWidget->myCorrectSurfaceIntersectionMaxCost->GetValue();
2466 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2467 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2468 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2469 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2470 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2471 //h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2472 //h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2473 //h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2474 //h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2477 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2478 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2479 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2480 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2481 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2482 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2483 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2484 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2485 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2486 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2487 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2488 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2489 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2490 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2493 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2494 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2495 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2496 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2497 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2498 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2501 // guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2502 // guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2503 // guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2504 // guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2506 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2507 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2510 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2511 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2512 for ( ; row < nbRows; ++row )
2514 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2515 if ( that->mySMPMap.contains(entry) )
2516 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2519 // Enforced vertices
2520 h_data.enfVertexList.clear();
2521 h_data.faceEntryEnfVertexListMap.clear();
2523 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2524 std::string groupName = "", faceEntry = "";
2525 for (int i=0 ; i<nbEnforcedShapes ; i++)
2527 double childValueX,childValueY,childValueZ;
2528 std::string childName, vertexEntry;
2529 QTreeWidgetItem* child;
2531 child = myEnforcedTreeWidget->topLevelItem(i);
2532 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2533 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2534 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2535 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2536 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2537 // if (myGlobalGroupName->isChecked())
2538 // groupName = myGlobalGroupName->text().toStdString();
2540 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2542 TEnfVertex *enfVertex = new TEnfVertex();
2543 enfVertex->name = childName;
2544 if (vertexEntry.empty()) {
2545 enfVertex->coords.push_back(childValueX);
2546 enfVertex->coords.push_back(childValueY);
2547 enfVertex->coords.push_back(childValueZ);
2550 enfVertex->geomEntry = vertexEntry;
2551 enfVertex->grpName = groupName;
2552 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2553 // if (it == h_data.enfVertexList.end())
2554 h_data.enfVertexList.insert(enfVertex);
2556 if (groupName != "")
2557 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2559 h_data.faceEntryEnfVertexListMap[faceEntry].insert( enfVertex );
2562 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2563 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2566 h_data.preCadPeriodicityVector.clear();
2567 // For each tree item, store each value. Shapes are stored as entries.
2568 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2569 for (int i=0 ; i<nbPeriodicityDescriptions ; i++) {
2570 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2571 TPreCadPeriodicity periodicity_i;
2573 for (int k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2575 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2576 periodicity_i.push_back(entry);
2578 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2580 guiHyp += "PERIODICITY = yes; ";
2586 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2588 myAdvWidget->AddOption( TBL_CUSTOM, NULL );
2591 void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int row, int column )
2593 // if ( column != OPTION_NAME_COLUMN )
2595 // myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2598 // **********************
2599 // *** BEGIN SIZE MAP ***
2600 // **********************
2602 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2604 if ( myGeomSelWdg2->IsObjectSelected() ){
2605 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2607 else if ( myGeomSelWdg1->IsObjectSelected() ){
2608 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2611 mySMapObject = GEOM::GEOM_Object::_nil();
2613 bool dataAvailable = !mySMapObject->_is_nil();
2615 if ( dataAvailable )
2616 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2618 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2619 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2620 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2621 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2622 ( myATTMap.contains( qEntry )))
2625 QString attEntry = myAttSelWdg->GetValue();
2626 const TAttractorVec& attVec = myATTMap[ qEntry ];
2627 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2628 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2631 addMapButton->setEnabled( !mapExists && dataAvailable );
2632 modifyMapButton->setEnabled( mapExists && dataAvailable );
2635 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2637 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2638 if (col == SMP_SIZEMAP_COLUMN) {
2639 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2641 if (!mySMPMap.contains(entry))
2643 if ( QTreeWidgetItem* parent = item->parent() )
2647 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2649 if (!mySMPMap.contains(entry))
2652 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2653 CORBA::Object_var obj = entryToObject(entry);
2654 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2655 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2656 // Retrieve values of the selected item in the current tab widgets
2657 const TAttractorVec& attVec = myATTMap[entry];
2658 if ( !attVec.empty() )
2661 if ( !childEntry.isEmpty() )
2662 for ( size_t i = 0; i < attVec.size(); ++i )
2663 if ( childEntry == attVec[i].attEntry.c_str() )
2668 double phySize = attVec[iAtt].startSize;
2669 double infDist = attVec[iAtt].infDist;
2670 double constDist = attVec[iAtt].constDist;
2671 QString attEntry = attVec[iAtt].attEntry.c_str();
2672 CORBA::Object_var attObj = entryToObject(attEntry);
2673 myAttSizeSpin->setValue(phySize);
2674 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2675 myAttDistSpin->setValue(infDist);
2676 myAttractorCheck->setChecked(true);
2679 myAttractorCheck->setChecked(false);
2681 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2682 myAttDistSpin2->setValue(constDist);
2683 myConstSizeCheck->setChecked(true);
2686 myConstSizeCheck->setChecked(false);
2688 myGeomSelWdg2->SetObject(obj);
2689 myAttSelWdg->SetObject(attObj);
2692 else { // CLASSIC MAPS
2693 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2694 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2695 if (!sizeMap.startsWith("def")){
2696 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2702 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2704 getGeomSelectionTool()->selectionMgr()->clearFilters();
2705 if ( sender() == myTabWidget )
2707 myGeomSelWdg1 ->deactivateSelection();
2708 myGeomSelWdg2 ->deactivateSelection();
2709 myAttSelWdg ->deactivateSelection();
2710 //myEnfFaceWdg ->deactivateSelection();
2711 myEnfVertexWdg ->deactivateSelection();
2712 myPeriodicitySourceFaceWdg->deactivateSelection();
2713 myPeriodicityTargetFaceWdg->deactivateSelection();
2714 myPeriodicityP1SourceWdg ->deactivateSelection();
2715 myPeriodicityP2SourceWdg ->deactivateSelection();
2716 myPeriodicityP3SourceWdg ->deactivateSelection();
2717 myPeriodicityP1TargetWdg ->deactivateSelection();
2718 myPeriodicityP2TargetWdg ->deactivateSelection();
2719 myPeriodicityP3TargetWdg ->deactivateSelection();
2722 else if ( sender() == smpTab )
2724 myAttDistSpin->setValue(0.); // Reinitialize widgets
2725 myAttSizeSpin->setValue(0.);
2726 myAttDistSpin2->setValue(0.);
2727 mySmpSizeSpin->setValue(0.);
2728 myGeomSelWdg1->deactivateSelection();
2729 myGeomSelWdg2->deactivateSelection();
2730 myAttSelWdg->deactivateSelection();
2731 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2732 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2733 myAttSelWdg->SetObject(CORBA::Object::_nil());
2734 myAttractorCheck->setChecked(false);
2735 myConstSizeCheck->setChecked(false);
2739 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2741 if (state == Qt::Checked){
2742 myAttSelWdg->setEnabled(true);
2743 myAttSizeSpin->setEnabled(true);
2744 myAttSizeLabel->setEnabled(true);
2745 myAttDistSpin->setEnabled(true);
2746 myAttDistLabel->setEnabled(true);
2747 if (!myAttSelWdg->IsObjectSelected()){
2748 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2751 if (state == Qt::Unchecked){
2752 myAttDistSpin->setEnabled(false);
2753 myAttDistLabel->setEnabled(false);
2754 myAttDistSpin->setValue(0.);
2755 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2756 myAttSelWdg->setEnabled(false);
2757 myAttSizeSpin->setEnabled(false);
2758 myAttSizeLabel->setEnabled(false);
2759 myAttDistSpin2->setEnabled(false);
2760 myAttDistLabel2->setEnabled(false);
2762 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2763 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2766 onMapGeomContentModified();
2769 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2771 if (state == Qt::Checked){
2772 myAttSelWdg->setEnabled(true);
2773 myAttSizeSpin->setEnabled(true);
2774 myAttSizeLabel->setEnabled(true);
2775 myAttDistSpin2->setEnabled(true);
2776 myAttDistLabel2->setEnabled(true);
2777 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2778 !myAttSelWdg->IsObjectSelected()){
2779 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2782 if (state == Qt::Unchecked){
2783 myAttDistSpin2->setEnabled(false);
2784 myAttDistLabel2->setEnabled(false);
2785 myAttDistSpin2->setValue(0.);
2786 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2787 myAttSelWdg->setEnabled(false);
2788 myAttSizeSpin->setEnabled(false);
2789 myAttSizeLabel->setEnabled(false);
2790 myAttDistSpin->setEnabled(false);
2791 myAttDistLabel->setEnabled(false);
2793 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2794 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2797 onMapGeomContentModified();
2800 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2802 QList<int> selectedRows;
2803 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2804 QTreeWidgetItem* item;
2805 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2807 qSort( selectedRows );
2808 QListIterator<QTreeWidgetItem*> it( selected );
2810 while ( it.hasPrevious() ) {
2811 item = it.previous();
2812 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2813 QString parentEntry;
2814 if ( QTreeWidgetItem* parent = item->parent() )
2815 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2816 if (that->mySMPMap.contains(entry))
2818 that->mySMPMap[entry] = "__TO_DELETE__";
2819 if ( myATTMap.contains( entry ))
2821 TAttractorVec& attVec = myATTMap[entry];
2822 for ( size_t i = 0; i < attVec.size(); ++i )
2823 attVec[i].SetToDelete();
2826 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
2828 TAttractorVec& attVec = myATTMap[parentEntry];
2829 for ( size_t i = 0; i < attVec.size(); ++i )
2831 if ( entry == attVec[i].attEntry.c_str() )
2832 attVec[i].SetToDelete();
2835 if (that->mySMPShapeTypeMap.contains(entry))
2836 that->mySMPShapeTypeMap.remove(entry);
2837 // if (that->myDistMap.contains(entry))
2838 // that->myDistMap.remove(entry);
2839 // if (that->myAttDistMap.contains(entry))
2840 // that->myAttDistMap.remove(entry);
2843 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2844 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2847 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2849 if (col == SMP_SIZEMAP_COLUMN) {
2850 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2851 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2852 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2853 if (! that->mySMPShapeTypeMap.contains(entry))
2855 if (that->mySMPMap.contains(entry))
2856 if (that->mySMPMap[entry] == sizeMap
2857 || sizeMap.startsWith("Attractor")
2858 || sizeMap.startsWith("Constant") ){
2861 if (! sizeMap.isEmpty()) {
2862 that->mySMPMap[entry] = sizeMap;
2863 sizeMapValidationFromEntry(entry);
2866 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2868 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2872 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2875 if ( smpTab->currentIndex() == ATT_TAB ){
2876 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2877 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2878 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2879 res = insertAttractor(mySMapObject, myAttObject);
2882 if (smpTab->currentIndex() == SMP_STD_TAB ){
2883 if ( myGeomSelWdg1->IsObjectSelected() ){
2884 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2885 res = insertElement(mySMapObject);
2889 // Local size should be more than 0
2890 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
2891 SUIT_MessageBox::critical( dlg(),"Error" , msg );
2894 getGeomSelectionTool()->selectionMgr()->clearFilters();
2895 myAttDistSpin->setValue(0.);
2896 myAttSizeSpin->setValue(0.);
2897 myAttDistSpin2->setValue(0.);
2898 mySmpSizeSpin->setValue(0.);
2899 myConstSizeCheck->setChecked(false);
2900 myAttractorCheck->setChecked(false);
2901 myGeomSelWdg1->deactivateSelection();
2902 myGeomSelWdg2->deactivateSelection();
2903 myAttSelWdg->deactivateSelection();
2904 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2905 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2906 myAttSelWdg->SetObject(CORBA::Object::_nil());
2909 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
2912 if ( smpTab->currentIndex() == ATT_TAB ){
2913 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2914 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2915 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2916 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
2919 if (smpTab->currentIndex() == SMP_STD_TAB ){
2920 if ( myGeomSelWdg1->IsObjectSelected() ){
2921 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2922 res = insertElement(mySMapObject, /*modify = */true);
2926 // Local size should be more than 0
2927 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
2928 SUIT_MessageBox::critical( dlg(),"Error" , msg );
2931 getGeomSelectionTool()->selectionMgr()->clearFilters();
2932 myAttDistSpin->setValue(0.);
2933 myAttSizeSpin->setValue(0.);
2934 myAttDistSpin2->setValue(0.);
2935 mySmpSizeSpin->setValue(0.);
2936 myConstSizeCheck->setChecked(false);
2937 myAttractorCheck->setChecked(false);
2938 myGeomSelWdg1->deactivateSelection();
2939 myGeomSelWdg2->deactivateSelection();
2940 myAttSelWdg->deactivateSelection();
2941 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2942 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2943 myAttSelWdg->SetObject(CORBA::Object::_nil());
2946 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
2948 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2949 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2951 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2953 TopAbs_ShapeEnum shapeType;
2954 string entry, shapeName;
2955 entry = (string) anObject->GetStudyEntry();
2956 shapeName = anObject->GetName();
2957 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
2958 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
2959 // in order to write the size map with the right syntax in StoreParamsToHypo
2960 // (f(t) for edges, f(u,v) for faces ...)
2961 if (shapeType == TopAbs_COMPOUND){
2962 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
2963 TopoDS_Shape childShape;
2964 TopoDS_Iterator anIt(theShape);
2965 for(;anIt.More();anIt.Next()){
2966 childShape = anIt.Value();
2967 shapeType = childShape.ShapeType();
2968 if(!childShape.IsNull()){
2973 mySizeMapTable->setFocus();
2975 shapeEntry = QString::fromStdString(entry);
2976 double phySize = mySmpSizeSpin->value();
2979 return false; // Local size should be more than 0
2981 std::ostringstream oss;
2984 sizeMap = QString::fromStdString(oss.str());
2985 QTreeWidgetItem* item = new QTreeWidgetItem();
2987 int rowToChange = findRowFromEntry(shapeEntry);
2988 item = mySizeMapTable->topLevelItem( rowToChange );
2991 if (that->mySMPMap.contains(shapeEntry)) {
2992 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2996 mySizeMapTable->addTopLevelItem(item);
2998 that->mySMPMap[shapeEntry] = sizeMap;
2999 //that->myDistMap[shapeEntry] = 0. ;
3000 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3001 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3002 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3003 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3004 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3005 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3006 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3007 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3008 mySizeMapTable->clearSelection();
3010 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3011 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3012 myStdWidget->onPhysicalMeshChanged();
3017 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3019 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3020 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3022 TopAbs_ShapeEnum shapeType;
3023 string entry, attEntry, faceName, attName;
3024 entry = (string) aFace->GetStudyEntry();
3025 attEntry = (string) anAttractor->GetStudyEntry();
3026 faceName = aFace->GetName();
3027 attName = anAttractor->GetName();
3028 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3029 mySizeMapTable->setFocus();
3030 QString shapeEntry = QString::fromStdString(entry);
3031 QString qAttEntry = QString::fromStdString(attEntry);
3033 double phySize = h->GetPhySize();
3034 double infDist = 0. ;
3035 double constDist = 0. ;
3036 phySize = myAttSizeSpin->value();
3039 return false; // Local size should be more than 0
3041 if (myAttractorCheck->isChecked()){
3042 infDist = myAttDistSpin->value();
3044 if (myConstSizeCheck->isChecked()){
3045 constDist = myAttDistSpin2->value();
3047 std::ostringstream oss;
3048 std::ostringstream oss2;
3049 std::ostringstream oss3;
3053 QString sizeMap = QString::fromStdString(oss.str());
3054 QString infDistString = QString::fromStdString(oss2.str());
3055 QString constDistString = QString::fromStdString(oss3.str());
3057 QTreeWidgetItem* item;
3058 QTreeWidgetItem* child = 0;
3059 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3061 int rowToChange = findRowFromEntry(shapeEntry);
3062 item = mySizeMapTable->topLevelItem( rowToChange );
3064 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3065 if (( child = item->child( i )))
3066 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3068 TAttractorVec & attVec = myATTMap[shapeEntry];
3069 for ( size_t i = 0; i < attVec.size(); ++i )
3070 if ( attVec[i].attEntry == attEntry )
3072 attVec[i] = attParams;
3077 // if (that->mySMPMap.contains(shapeEntry)) {
3078 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3082 int rowToChange = findRowFromEntry(shapeEntry);
3083 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3085 item = mySizeMapTable->topLevelItem( rowToChange );
3088 item = new QTreeWidgetItem();
3089 mySizeMapTable->addTopLevelItem(item);
3091 child = new QTreeWidgetItem();
3092 item->addChild(child);
3093 bool exists = false;
3094 TAttractorVec & attVec = myATTMap[shapeEntry];
3095 for ( size_t i = 0; i < attVec.size(); ++i )
3096 if ( attVec[i].attEntry == attEntry )
3098 attVec[i] = attParams;
3103 myATTMap[shapeEntry].push_back( attParams );
3105 mySMPMap.insert(shapeEntry,sizeMap);
3106 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3107 item->setExpanded(true);
3108 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3109 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3110 if (infDist > std::numeric_limits<double>::epsilon()){
3111 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3113 else if (constDist > std::numeric_limits<double>::epsilon()){
3114 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3116 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3118 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3119 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3120 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3122 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3123 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3124 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3126 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3127 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3128 myStdWidget->onPhysicalMeshChanged();
3133 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3135 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3136 for ( ; row < nbRows; ++row )
3137 if (! sizeMapValidationFromRow(row))
3142 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3144 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3145 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3146 mySizeMapTable->setFocus();
3150 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3153 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3155 if (! that->mySMPMap.contains(myEntry)) {
3158 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3164 if (that->mySMPMap[myEntry].startsWith("def")) {
3165 expr = that->mySMPMap[myEntry].toStdString();
3167 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3168 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)) {
3171 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])" );
3177 // case size map is empty
3178 if (that->mySMPMap[myEntry].isEmpty()) {
3180 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3184 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3185 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3186 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3187 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3188 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3189 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3192 //assert(Py_IsInitialized());
3193 if (! Py_IsInitialized())
3194 throw ("Erreur: Python interpreter is not initialized");
3195 PyGILState_STATE gstate;
3196 gstate = PyGILState_Ensure();
3198 string err_description="";
3199 PyObject* obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3203 PyObject* new_stderr = newPyStdOut(err_description);
3204 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3205 Py_INCREF(old_stderr);
3206 PySys_SetObject((char*)"stderr", new_stderr);
3208 PySys_SetObject((char*)"stderr", old_stderr);
3209 Py_DECREF(new_stderr);
3211 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3212 PyGILState_Release(gstate);
3217 PyObject* func = PyObject_GetAttrString(main_mod, "f");
3221 PyObject* new_stderr = newPyStdOut(err_description);
3222 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3223 Py_INCREF(old_stderr);
3224 PySys_SetObject((char*)"stderr", new_stderr);
3226 PySys_SetObject((char*)"stderr", old_stderr);
3227 Py_DECREF(new_stderr);
3229 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3230 PyGILState_Release(gstate);
3234 PyGILState_Release(gstate);
3240 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3242 return tr( "BLSURF_TITLE" );
3245 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3247 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3250 QString BLSURFPluginGUI_HypothesisCreator::type() const
3252 return tr( "BLSURF_HYPOTHESIS" );
3255 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3257 return "blsurf_hypo_page.html";
3260 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3263 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3265 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3270 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3272 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
3273 SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
3274 CORBA::Object_var obj;
3275 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
3276 if (!aSObj->_is_nil()) {
3277 obj = aSObj->GetObject();
3278 aSObj->UnRegister();
3283 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3284 int endRow = mySizeMapTable->topLevelItemCount()-1;
3286 for ( ; row <= endRow; ++row )
3288 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3289 if (entry == entryForChecking )