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"
29 #include "BLSURFPlugin_Hypothesis.hxx"
31 #include <GeometryGUI.h>
33 #include <SMESHGUI_Dialog.h>
34 #include <SMESHGUI_HypothesesUtils.h>
35 #include <SMESHGUI_IdValidator.h>
36 #include <SMESHGUI_SpinBox.h>
37 #include <SMESHGUI_Utils.h>
38 #include <SMESH_Gen_i.hxx>
39 #include <SMESH_NumberFilter.hxx>
40 #include <StdMeshersGUI_SubShapeSelectorWdg.h>
42 #include <LightApp_SelectionMgr.h>
43 #include <SALOME_ListIO.hxx>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
47 #include <SalomeApp_Application.h>
48 #include <SalomeApp_Tools.h>
50 #include <QApplication>
54 #include <QGridLayout>
56 #include <QHBoxLayout>
57 #include <QHeaderView>
61 #include <QModelIndexList>
63 #include <QPushButton>
64 #include <QRadioButton>
67 #include <QStandardItem>
68 #include <QStandardItemModel>
70 #include <QTableWidget>
71 #include <QTreeWidget>
72 #include <QTreeWidgetItem>
73 #include <QVBoxLayout>
75 #include <TopoDS_Shape.hxx>
76 #include <TopoDS_Iterator.hxx>
78 #include <structmember.h> // Python
96 TBL_MESHING = 0, TBL_PRECAD, TBL_CUSTOM,
98 // Enforced vertices array columns
99 ENF_VER_NAME_COLUMN = 0,
100 ENF_VER_FACE_ENTRY_COLUMN,
104 ENF_VER_ENTRY_COLUMN,
105 ENF_VER_GROUP_COLUMN,
108 PERIODICITY_OBJ_SOURCE_COLUMN = 0,
109 PERIODICITY_OBJ_TARGET_COLUMN,
110 PERIODICITY_P1_SOURCE_COLUMN,
111 PERIODICITY_P2_SOURCE_COLUMN,
112 PERIODICITY_P3_SOURCE_COLUMN,
113 PERIODICITY_P1_TARGET_COLUMN,
114 PERIODICITY_P2_TARGET_COLUMN,
115 PERIODICITY_P3_TARGET_COLUMN,
116 PERIODICITY_SHAPE_TYPE,
118 // PERIODICITY_OBJ_SOURCE_COLUMN = 0,
119 // PERIODICITY_ENTRY_SOURCE_COLUMN,
120 // PERIODICITY_OBJ_TARGET_COLUMN,
121 // PERIODICITY_ENTRY_TARGET_COLUMN,
122 // PERIODICITY_P1_SOURCE_COLUMN,
123 // PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
124 // PERIODICITY_P2_SOURCE_COLUMN,
125 // PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
126 // PERIODICITY_P3_SOURCE_COLUMN,
127 // PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
128 // PERIODICITY_P1_TARGET_COLUMN,
129 // PERIODICITY_P1_ENTRY_TARGET_COLUMN,
130 // PERIODICITY_P2_TARGET_COLUMN,
131 // PERIODICITY_P2_ENTRY_TARGET_COLUMN,
132 // PERIODICITY_P3_TARGET_COLUMN,
133 // PERIODICITY_P3_ENTRY_TARGET_COLUMN,
135 PERIODICITY_NB_COLUMN
161 // Enforced vertices inputs
169 // ENF_VER_GROUP_CHECK,
173 ENF_VER_INTERNAL_ALL_FACES,
174 ENF_VER_INTERNAL_ALL_FACES_GROUP,
175 // ENF_VER_VERTEX_BTN,
176 // ENF_VER_REMOVE_BTN,
177 // ENF_VER_SEPARATOR,
182 /**************************************************
183 Begin initialization Python structures and objects
184 ***************************************************/
194 PyStdOut_dealloc(PyStdOut *self)
200 PyStdOut_write(PyStdOut *self, PyObject *args)
204 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
207 *(self->out)=*(self->out)+c;
213 static PyMethodDef PyStdOut_methods[] = {
214 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
215 PyDoc_STR("write(string) -> None")},
216 {NULL, NULL} /* sentinel */
219 static PyMemberDef PyStdOut_memberlist[] = {
220 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
221 (char*)"flag indicating that a space needs to be printed; used by print"},
222 {NULL} /* Sentinel */
225 static PyTypeObject PyStdOut_Type = {
226 /* The ob_type field must be initialized in the module init function
227 * to be portable to Windows without using C++. */
228 PyVarObject_HEAD_INIT(NULL, 0)
230 sizeof(PyStdOut), /*tp_basicsize*/
233 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
240 0, /*tp_as_sequence*/
245 PyObject_GenericGetAttr, /*tp_getattro*/
246 /* softspace is writable: we must supply tp_setattro */
247 PyObject_GenericSetAttr, /* tp_setattro */
249 Py_TPFLAGS_DEFAULT, /*tp_flags*/
253 0, /*tp_richcompare*/
254 0, /*tp_weaklistoffset*/
257 PyStdOut_methods, /*tp_methods*/
258 PyStdOut_memberlist, /*tp_members*/
272 PyObject * newPyStdOut( std::string& out )
274 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
279 return (PyObject*)self;
283 /*************************************************
284 End initialization Python structures and objects
285 **************************************************/
289 // BEGIN EnforcedTreeWidgetDelegate
292 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
293 : QItemDelegate(parent)
297 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
298 const QStyleOptionViewItem & option ,
299 const QModelIndex & index ) const
301 QModelIndex father = index.parent();
302 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
304 if (index.column() == ENF_VER_X_COLUMN || \
305 index.column() == ENF_VER_Y_COLUMN || \
306 index.column() == ENF_VER_Z_COLUMN)
308 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
309 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
310 editor->setReadOnly(!entry.isEmpty());
311 editor->setDisabled(!entry.isEmpty());
316 QLineEdit *editor = new QLineEdit(parent);
317 if (index.column() != ENF_VER_GROUP_COLUMN) {
318 editor->setReadOnly(!entry.isEmpty());
319 editor->setDisabled(!entry.isEmpty());
325 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
326 const QModelIndex &index) const
328 QString value = index.model()->data(index, Qt::EditRole).toString();
330 if (index.column() == ENF_VER_X_COLUMN ||
331 index.column() == ENF_VER_Y_COLUMN ||
332 index.column() == ENF_VER_Z_COLUMN)
334 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
335 lineEdit->setText(value);
338 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
339 lineEdit->setText(value);
343 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
344 const QModelIndex &index) const
346 QModelIndex parent = index.parent();
347 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
348 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
349 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
350 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
351 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
352 } else if (index.column() == ENF_VER_NAME_COLUMN) {
353 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
354 QString value = lineEdit->text();
355 if (entry.isEmpty() && !vertexExists(model, index, value))
356 model->setData(index, value, Qt::EditRole);
357 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
358 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
359 QString value = lineEdit->text();
360 if (!vertexExists(model, index, value))
361 model->setData(index, value, Qt::EditRole);
362 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
363 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
364 model->setData(index, lineEdit->text(), Qt::EditRole);
368 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
369 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
371 editor->setGeometry(option.rect);
374 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
375 const QModelIndex &index, QString value) const
378 QModelIndex parent = index.parent();
379 int row = index.row();
380 int col = index.column();
382 if (parent.isValid() && !value.isEmpty()) {
383 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
385 if (col == ENF_VER_X_COLUMN) {
386 x = value.toDouble();
387 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
388 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
390 if (col == ENF_VER_Y_COLUMN) {
391 y = value.toDouble();
392 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
393 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
395 if (col == ENF_VER_Z_COLUMN) {
396 z = value.toDouble();
397 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
398 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
400 int nbChildren = model->rowCount(parent);
401 for (int i = 0 ; i < nbChildren ; i++) {
403 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
404 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
405 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
406 if ((childX == x) && (childY == y) && (childZ == z)) {
413 else if (col == ENF_VER_NAME_COLUMN) {
414 int nbChildren = model->rowCount(parent);
415 for (int i = 0 ; i < nbChildren ; i++) {
417 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
418 if (childName == value) {
431 // END EnforcedTreeWidgetDelegate
436 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
437 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
440 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
441 : SMESHGUI_GenericHypothesisCreator( theHypType )
443 this->mySMPMap.clear();
445 GeomToolSelected = NULL;
446 GeomToolSelected = getGeomSelectionTool();
448 aSel = GeomToolSelected->selectionMgr();
450 /* Initialize the Python interpreter */
451 if (! Py_IsInitialized())
452 throw ("Error: Python interpreter is not initialized");
453 PyGILState_STATE gstate;
454 gstate = PyGILState_Ensure();
457 main_mod = PyImport_AddModule("__main__");
460 main_dict = PyModule_GetDict(main_mod);
462 PyRun_SimpleString("from math import *");
463 PyGILState_Release(gstate);
467 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
472 * \brief {Get or create the geom selection tool for active study}
474 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() const
476 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
477 if (that->GeomToolSelected == NULL) {
478 that->GeomToolSelected = new GeomSelectionTools();
480 return that->GeomToolSelected;
483 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
485 return GeometryGUI::GetGeomGen();
488 void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
490 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
491 ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
492 for ( ; anIt != selectionWidgets.end(); anIt++)
494 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
496 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
497 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
498 ListOfWidgets::const_iterator anIt2 = anIt;
499 for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
500 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
502 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
503 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
504 w1->AvoidSimultaneousSelection( w2 );
506 if ( !widgetToActivate )
507 widgetToActivate = w1;
510 if ( widgetToActivate )
511 widgetToActivate->activateSelection();
514 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
518 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
519 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
523 myAdvWidget->myOptionTable->setFocus();
524 QApplication::instance()->processEvents();
528 int iTbl = 0, nbTbl = myAdvWidget->myOptionTable->topLevelItemCount();
529 for ( ; iTbl < nbTbl; ++iTbl )
531 QTreeWidgetItem* table = myAdvWidget->myOptionTable->topLevelItem( iTbl );
532 int nbRows = table->childCount();
533 for ( int iRow = 0; iRow < nbRows; ++iRow )
535 QTreeWidgetItem* row = table->child( iRow );
536 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
538 if ( name.simplified().isEmpty() )
539 continue; // invalid custom option
541 if ( isDefault ) // not selected option
548 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
551 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
554 h->AddOption( name.toLatin1().constData(), value.toLatin1().constData() );
558 catch ( const SALOME::SALOME_Exception& ex )
560 msg = ex.details.text.in();
569 h->SetOptionValues( myOptions ); // restore values
570 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
574 // SizeMap and attractors
577 mySizeMapTable->setFocus();
578 QApplication::instance()->processEvents();
580 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
581 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
583 for ( ; row < nbRows; ++row )
585 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
586 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
587 if ( !sizeMap.isEmpty() ) {
588 if (that->sizeMapValidationFromRow(row))
591 e = entry.toStdString();
592 s = that->mySMPMap[entry].toStdString();
593 h->SetSizeMapEntry( e.c_str(), s.c_str() );
595 catch ( const SALOME::SALOME_Exception& ex )
597 msg = ex.details.text.in();
608 // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
611 // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
612 // So STD_TAB must be current tab to get correct value of it's spinbox.
613 myTabWidget->setCurrentIndex( STD_TAB );
617 if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
618 myStdWidget->myPhySize->text().toDouble() > 0.0 )))
619 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
623 if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
624 myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
625 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
629 if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
630 myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
631 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
635 if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
636 myStdWidget->myChordalError->text().toDouble() > 0.0 )))
637 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
646 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
648 QFrame* fr = new QFrame( 0 );
649 QVBoxLayout* lay = new QVBoxLayout( fr );
651 lay->setSpacing( 0 );
653 // main TabWidget of the dialog
654 myTabWidget = new QTabWidget( fr );
655 myTabWidget->setTabShape( QTabWidget::Rounded );
656 myTabWidget->setTabPosition( QTabWidget::North );
657 lay->addWidget( myTabWidget );
662 myStdGroup = new QWidget();
663 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
664 aStdLayout->setSpacing( 6 );
665 aStdLayout->setMargin( 11 );
668 myName = new QLineEdit( myStdGroup );
669 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
671 myStdWidget->myPhysicalMesh->removeItem( PhysicalLocalSize );
676 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
677 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
679 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
684 aStdLayout->setRowStretch(row,1);
685 aStdLayout->setColumnStretch(1,1);
688 // advanced parameters
689 myAdvGroup = new QWidget();
690 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
691 anAdvLayout->setSpacing( 6 );
692 anAdvLayout->setMargin( 11 );
693 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
694 anAdvLayout->addWidget( myAdvWidget );
697 // Size Maps parameters
699 mySmpGroup = new QWidget( dlg() );
702 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
705 mySizeMapTable = new QTreeWidget( mySmpGroup );
706 mySizeMapTable ->setMinimumWidth(200);
707 QStringList sizeMapHeaders;
708 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
709 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
710 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
711 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
712 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
713 mySizeMapTable->setAlternatingRowColors(true);
716 smpTab = new QTabWidget( mySmpGroup );
717 smpTab->setTabShape( QTabWidget::Rounded );
718 smpTab->setTabPosition( QTabWidget::South );
719 lay->addWidget( smpTab );
721 // Filters of selection
722 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
724 SM_ShapeTypes.Add( TopAbs_VERTEX );
725 SM_ShapeTypes.Add( TopAbs_EDGE );
726 SM_ShapeTypes.Add( TopAbs_FACE );
727 SM_ShapeTypes.Add( TopAbs_COMPOUND );
729 ATT_ShapeTypes.Add( TopAbs_VERTEX );
730 ATT_ShapeTypes.Add( TopAbs_EDGE );
731 ATT_ShapeTypes.Add( TopAbs_WIRE );
732 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
734 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
735 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
736 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
738 // Standard size map tab
739 mySmpStdGroup = new QWidget();
740 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
741 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false);
742 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
743 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
744 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
745 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
748 myAttractorGroup = new QWidget();
749 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
750 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false);
751 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
752 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
753 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
754 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
755 QFrame* attLine = new QFrame(myAttractorGroup);
756 attLine->setFrameShape(QFrame::HLine);
757 attLine->setFrameShadow(QFrame::Sunken);
758 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false);
759 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
760 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
761 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
762 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
763 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
764 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
765 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
766 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
767 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
768 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
770 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
771 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
775 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
776 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
777 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
778 modifyMapButton->setEnabled(false);
781 myAttSelWdg->setEnabled(false);
782 myAttSizeSpin->setEnabled(false);
783 myAttSizeLabel->setEnabled(false);
784 myAttDistSpin->setEnabled(false);
785 myAttDistLabel->setEnabled(false);
786 myAttDistSpin2->setEnabled(false);
787 myAttDistLabel2->setEnabled(false);
788 myAttDistSpin->setValue(0.);
789 myAttDistSpin2->setValue(0.);
790 myAttSizeSpin->setValue(0.);
791 mySmpSizeSpin->setValue(0.);
794 // ADD WIDGETS (SIZEMAP TAB)
795 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
796 anSmpLayout->setColumnStretch(0, 1);
797 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
798 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
799 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
800 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
801 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
802 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
805 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
806 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
807 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
808 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
811 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
812 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
813 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
814 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
815 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
816 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
817 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
818 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
819 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
820 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
821 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
822 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
824 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
825 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
827 smpTab->setCurrentIndex( SMP_STD_TAB );
829 // Enforced vertices parameters
830 myEnfGroup = new QWidget( dlg() );
831 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
833 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
834 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
835 myEnforcedTreeWidget->setSortingEnabled(true);
836 QStringList enforcedHeaders;
837 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
838 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
839 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
841 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
842 myEnforcedTreeWidget->header()->setStretchLastSection(true);
843 myEnforcedTreeWidget->setAlternatingRowColors(true);
844 myEnforcedTreeWidget->setUniformRowHeights(true);
845 myEnforcedTreeWidget->setAnimated(true);
846 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
847 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
848 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
849 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
850 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
852 myEnforcedTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
854 myEnforcedTreeWidget->resizeColumnToContents(column);
856 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
857 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
858 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
860 // FACE AND VERTEX SELECTION
861 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
862 shapeTypes1.Add( TopAbs_FACE );
863 shapeTypes1.Add( TopAbs_COMPOUND );
864 shapeTypes2.Add( TopAbs_VERTEX );
865 shapeTypes2.Add( TopAbs_COMPOUND );
867 // SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
868 // myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true);
869 // myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
871 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
872 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
873 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
875 //myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
877 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
878 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
879 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
881 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
882 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
883 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
885 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
886 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
887 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
889 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
890 myGroupName = new QLineEdit(myEnfGroup);
892 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
893 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
895 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
897 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
898 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
900 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
901 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
902 // FACE AND VERTEX SELECTION
903 //anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
904 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
905 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
906 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
907 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
908 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
909 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
910 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
911 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
912 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
913 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
914 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
915 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
916 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
917 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
918 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
919 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
922 // Periodicity parameters
923 myPeriodicityGroup = new QWidget( dlg() );
924 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
926 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
927 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
928 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
930 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
932 QStringList myPeriodicityTreeHeaders;
933 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
934 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
935 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
936 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
937 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
938 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
939 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
940 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
941 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
942 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
944 // Hide the vertex name to make the widget more readable
945 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
946 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
947 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
948 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
949 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
950 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
951 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
954 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
955 myPeriodicityTreeWidget->setSortingEnabled(true);
957 myPeriodicityTreeWidget->setAlternatingRowColors(true);
958 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
959 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
961 size_t periodicityVisibleColumns = 2;
962 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
963 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
964 myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
966 myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
968 myPeriodicityTreeWidget->resizeColumnToContents(column);
970 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
972 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
974 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
976 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
977 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
978 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
980 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
982 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
983 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
985 myPeriodicityOnFaceRadioButton->setChecked(true);
987 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
988 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
991 // FACE, EDGE AND VERTEX SELECTION
992 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
993 shapeTypesFace.Add( TopAbs_FACE );
994 shapeTypesFace.Add( TopAbs_EDGE );
995 shapeTypesFace.Add( TopAbs_COMPOUND );
996 shapeTypesEdge.Add( TopAbs_EDGE );
997 shapeTypesEdge.Add( TopAbs_COMPOUND );
999 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
1001 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1002 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1004 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1005 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false);
1006 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1007 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1009 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1010 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1011 // myPeriodicitySourceEdgeWdg->hide();
1012 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1014 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1015 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1017 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1018 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false);
1019 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1020 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1022 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1023 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1024 // myPeriodicityTargetEdgeWdg->hide();
1025 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1027 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1028 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1029 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1031 myPeriodicityGroupBox2->setCheckable(true);
1032 myPeriodicityGroupBox2->setChecked(false);
1034 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1035 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1037 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1038 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1041 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1042 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1045 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1046 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false);
1047 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1050 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1051 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1053 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1054 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false);
1055 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1058 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1059 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1061 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1062 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false);
1063 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1066 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1067 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1069 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1070 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false);
1071 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1074 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1075 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1077 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1078 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false);
1079 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1082 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1083 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1085 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1086 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false);
1087 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1089 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1090 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1093 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1094 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1096 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1097 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1099 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1101 myPeriodicitySelectionWidgets.clear();
1102 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1103 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1104 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1105 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1106 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1107 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1108 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1109 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1110 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1112 // HyperPatch parameters
1114 QWidget* hpGroup = new QWidget();
1115 QGridLayout* hpLayout = new QGridLayout(hpGroup);
1117 myHyPatchTable = new QTableWidget( hpGroup );
1118 myHyPatchTable->setColumnCount(1);
1119 myHyPatchTable->setHorizontalHeaderLabels( QStringList() << tr("BLSURF_HYPATCH_TBL_HEADER") );
1120 myHyPatchTable->setAlternatingRowColors(true);
1121 myHyPatchTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
1124 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1125 myHyPatchFaceSelBtn = new QPushButton( iconSelect, tr("BLSURF_HYPATCH_SEL_FACE"), hpGroup );
1126 myHyPatchGroupSelBtn = new QPushButton( iconSelect, tr("BLSURF_HYPATCH_SEL_GROUP"), hpGroup );
1127 myHyPatchFaceSelBtn->setCheckable( true );
1128 myHyPatchGroupSelBtn->setCheckable( true );
1130 myHyPatchFaceSelector = new StdMeshersGUI_SubShapeSelectorWdg( hpGroup, TopAbs_FACE, /*toShowList=*/false );
1132 QLabel* hpTagsLbl = new QLabel( tr("BLSURF_TAGS"), hpGroup );
1133 myHyPatchTagsLE = new QLineEdit( hpGroup );
1134 myHyPatchTagsLE->setValidator( new SMESHGUI_IdValidator( hpGroup ));
1136 QPushButton* hpAddBtn = new QPushButton( tr("BLSURF_SM_ADD"), hpGroup );
1137 QPushButton* hpRemBtn = new QPushButton( tr("BLSURF_SM_REMOVE"), hpGroup );
1139 hpLayout->addWidget( myHyPatchTable, 0, 0, 5, 1 );
1140 hpLayout->addWidget( myHyPatchFaceSelBtn, 0, 1, 1, 2 );
1141 hpLayout->addWidget( myHyPatchGroupSelBtn, 0, 3, 1, 2 );
1142 hpLayout->addWidget( hpTagsLbl, 1, 1, 1, 1 );
1143 hpLayout->addWidget( myHyPatchTagsLE, 1, 2, 1, 3 );
1144 hpLayout->addWidget( hpAddBtn, 2, 1, 1, 2 );
1145 hpLayout->addWidget( hpRemBtn, 2, 3, 1, 2 );
1146 hpLayout->addWidget( myHyPatchFaceSelector, 3, 1, 1, 4 );
1151 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1152 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1154 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1155 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1156 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1157 myTabWidget->insertTab( HYPERPATCH_TAB, hpGroup, tr( "BLSURF_HYPERPATCH_TAB" ));
1163 myPeriodicityGroup->hide();
1166 myTabWidget->setCurrentIndex( STD_TAB );
1168 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
1171 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1172 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1173 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1174 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1175 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1176 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1177 connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1178 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1179 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1180 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1181 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1182 connect( myTabWidget, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1184 // Enforced vertices
1185 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1186 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1187 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1188 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1189 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1190 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1191 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1194 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1195 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1196 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1197 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1199 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1200 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1202 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1203 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1208 connect( myHyPatchFaceSelBtn, SIGNAL( toggled(bool) ), SLOT( onHyPatchFaceSelection(bool) ));
1209 connect( myHyPatchGroupSelBtn, SIGNAL( toggled(bool) ), SLOT( onHyPatchGroupSelection(bool) ));
1210 connect( myHyPatchFaceSelector, SIGNAL( shapeSelected() ), SLOT( onHyPatchSelectionChanged()));
1211 connect( hpAddBtn, SIGNAL( clicked() ), SLOT( onHyPatchAdd()));
1212 connect( hpRemBtn, SIGNAL( clicked() ), SLOT( onHyPatchRemove()));
1217 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1218 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1220 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1222 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1223 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1224 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1225 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1226 // myEnfFaceWdg->deactivateSelection();
1227 // myEnfVertexWdg->deactivateSelection();
1231 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1233 myStdWidget->onPhysicalMeshChanged();
1237 * This method resets the content of the X, Y, Z widgets;
1239 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1241 myXCoord->setCleared(true);
1242 myYCoord->setCleared(true);
1243 myZCoord->setCleared(true);
1244 myXCoord->setText("");
1245 myYCoord->setText("");
1246 myZCoord->setText("");
1247 // myGroupName->setText("");
1250 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1251 This method updates the tooltip of a modified item. The QLineEdit widgets content
1252 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1254 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1255 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1256 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1257 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1258 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1259 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1260 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1261 QTreeWidgetItem* parent = item->parent();
1263 clearEnforcedVertexWidgets();
1265 if (parent && (!x.isNull() || !entry.isNull())) {
1266 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1267 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1268 if (entry.isNull()) {
1269 toolTip += QString("(") + x.toString();
1270 toolTip += QString(", ") + y.toString();
1271 toolTip += QString(", ") + z.toString();
1272 toolTip += QString(")");
1275 if (!groupName.isEmpty())
1276 toolTip += QString(" [") + groupName + QString("]");
1278 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1281 myXCoord->SetValue(x.toDouble());
1282 myYCoord->SetValue(y.toDouble());
1283 myZCoord->SetValue(z.toDouble());
1286 if (!groupName.isEmpty())
1287 myGroupName->setText(groupName);
1291 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1292 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1293 clearEnforcedVertexWidgets();
1294 if (nbSelEnfVertex == 1)
1296 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1299 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1300 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1301 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1302 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1303 if (CORBA::is_nil(measureOp))
1306 CORBA::Double x,y,z;
1307 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1308 if ( measureOp->IsDone() )
1310 myXCoord->SetValue(x);
1311 myYCoord->SetValue(y);
1312 myZCoord->SetValue(z);
1318 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1319 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1320 of the enforced vertex clicked in the tree widget.
1322 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1323 clearEnforcedVertexWidgets();
1324 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1325 if (! items.isEmpty() && items.size() == 1) {
1326 QTreeWidgetItem *item = items[0];
1327 // for (int i=0 ; i < items.size() ; i++) {
1329 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1330 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1331 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1332 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1333 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1334 if (!x.isNull()/* && entry.isNull()*/) {
1335 myXCoord->SetValue(x.toDouble());
1336 myYCoord->SetValue(y.toDouble());
1337 myZCoord->SetValue(z.toDouble());
1340 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1341 myGroupName->setText(group.toString());
1346 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1347 This method adds a face containing enforced vertices in the tree widget.
1349 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1350 // Find theFaceEntry item
1351 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1352 QTreeWidgetItem* theItem;
1353 if (theItemList.empty()) {
1354 theItem = new QTreeWidgetItem();
1355 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1356 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1357 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1358 myEnforcedTreeWidget->addTopLevelItem(theItem);
1361 theItem = theItemList[0];
1366 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1367 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1369 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z,
1370 std::string vertexName,
1371 std::string geomEntry,
1372 std::string groupName)
1374 bool okToCreate = true;
1376 const int nbVert = myEnforcedTreeWidget->topLevelItemCount();
1377 for (int row = 0; row < nbVert; row++ )
1379 QTreeWidgetItem* child = myEnforcedTreeWidget->topLevelItem( row );
1380 QString childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1381 QString childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1382 double childX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1383 double childY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1384 double childZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1385 if (((childEntry.isEmpty()) && (childX == x) && (childY == y) && (childZ == z)) ||
1386 ( !childEntry.isEmpty() && childEntry == geomEntry.c_str() ))
1388 // update group name
1389 if ( childGroupName != groupName.c_str() ) {
1390 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1400 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( myEnforcedTreeWidget );
1401 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1402 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1403 QSize iconSize = iconSelect.size()*0.7;
1405 int vertexIndex=nbVert;
1406 QString myVertexName;
1408 while(indexRef != vertexIndex) {
1409 indexRef = vertexIndex;
1410 if (vertexName.empty())
1411 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1413 myVertexName = QString(vertexName.c_str());
1415 for (int row = 0;row<nbVert;row++) {
1416 QString name = myEnforcedTreeWidget->topLevelItem(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1417 if (myVertexName == name) {
1423 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1424 if (geomEntry.empty()) {
1425 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1426 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1427 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1430 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1431 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1433 if (groupName != "")
1434 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1436 QString toolTip = myVertexName;
1437 if (geomEntry.empty()) {
1438 toolTip += QString(" (%1, %2, %3").arg(x).arg(y).arg(z);
1440 if (groupName != "")
1441 toolTip += QString(" [%1]").arg(groupName.c_str());
1443 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1444 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1447 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1448 This method is called when a item is added into the enforced vertices tree widget
1450 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1452 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1454 getGeomSelectionTool()->selectionMgr()->clearFilters();
1455 myEnfVertexWdg->deactivateSelection();
1457 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1458 myEnforcedTreeWidget->resizeColumnToContents(column);
1461 int selEnfVertex = myEnfVertexWdg->NbObjects();
1462 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1464 if ((selEnfVertex == 0) && coordsEmpty)
1467 string entry, shapeName;
1469 std::string groupName = myGroupName->text().simplified().toStdString();
1471 if (selEnfVertex <= 1)
1474 x = myXCoord->GetValue();
1475 y = myYCoord->GetValue();
1476 z = myZCoord->GetValue();
1477 if (selEnfVertex == 1) {
1478 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1479 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1482 addEnforcedVertex(x, y, z, "", "", groupName);
1486 if ( CORBA::is_nil(getGeomEngine()))
1489 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1490 if (CORBA::is_nil(measureOp))
1493 CORBA::Double x,y,z;
1495 for (int j = 0 ; j < selEnfVertex ; j++)
1497 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1498 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1499 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1500 if ( measureOp->IsDone() )
1501 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1502 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1503 addEnforcedVertex(0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1509 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1511 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1512 myEnforcedTreeWidget->resizeColumnToContents(column);
1514 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1515 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1516 myStdWidget->onPhysicalMeshChanged();
1520 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1521 This method is called when a item is removed from the enforced vertices tree widget
1523 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1524 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1525 QList<QTreeWidgetItem *> selectedVertices;
1526 QSet<QTreeWidgetItem *> selectedEntries;
1527 QTreeWidgetItem* item;
1529 foreach( item, selectedItems ) {
1530 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1531 if (! value.isNull())
1532 selectedVertices.append(item);
1534 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1535 if (! value.isNull())
1536 selectedVertices.append(item);
1538 selectedEntries.insert(item);
1542 foreach(item,selectedVertices) {
1543 QTreeWidgetItem* parent = item->parent();
1545 parent->removeChild(item);
1547 if ( parent && parent->childCount() == 0) {
1548 if (selectedEntries.contains(parent))
1549 selectedEntries.remove(parent);
1554 foreach(item,selectedEntries) {
1558 myEnforcedTreeWidget->selectionModel()->clearSelection();
1562 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1564 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1567 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1568 This method is called when a item is added into the periodicity table widget
1570 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1572 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1574 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1575 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1576 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1578 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1579 w1->deactivateSelection();
1583 // Source-Target selection
1584 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1585 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1587 if (selSource == 0 || selTarget == 0)
1590 // Vertices selection
1591 if (myPeriodicityGroupBox2->isChecked())
1593 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1594 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1595 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1596 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1597 //int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1598 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1600 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1602 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1603 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1608 // Add Source-Target in table
1609 string shapeEntry, sourceEntry, targetEntry;
1610 string shapeName, sourceName, targetName;
1611 GEOM::GEOM_Object_var shape;
1613 QTreeWidgetItem* item = new QTreeWidgetItem();
1614 myPeriodicityTreeWidget->addTopLevelItem(item);
1616 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1620 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1622 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1623 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1624 shapeName = shape->GetName();
1625 shapeEntry = shape->GetStudyEntry();
1626 item->setData(k, Qt::EditRole, shapeName.c_str() );
1627 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1628 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1632 // Add shape type in tree
1633 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1634 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1636 // Blank input fields
1637 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1639 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1640 w1->SetObject(GEOM::GEOM_Object::_nil());
1643 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1644 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1648 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1649 This method is called when a item is removed from the periodicity tree widget
1651 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1652 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1653 QTreeWidgetItem* item;
1655 foreach(item,selectedItems) {
1659 myEnforcedTreeWidget->selectionModel()->clearSelection();
1662 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1663 This method enable clears the field for periodicity by vertices
1665 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1669 for (int k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1671 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1672 w1->deactivateSelection();
1673 w1->SetObject(CORBA::Object::_nil());
1678 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1679 This method enable the proper shape selection widget to Face or Edge shapes
1681 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1683 // if (myPeriodicityOnFaceRadioButton->isChecked())
1685 // myPeriodicitySourceEdgeWdg->hide();
1686 // myPeriodicityTargetEdgeWdg->hide();
1687 // myPeriodicitySourceFaceWdg->show();
1688 // myPeriodicityTargetFaceWdg->show();
1692 // myPeriodicitySourceFaceWdg->hide();
1693 // myPeriodicityTargetFaceWdg->hide();
1694 // myPeriodicitySourceEdgeWdg->show();
1695 // myPeriodicityTargetEdgeWdg->show();
1699 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1701 QString shapeName, shapeEntry;
1702 CORBA::Object_var shape;
1704 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1705 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1707 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1709 shapeName = item->data(k, Qt::EditRole).toString();
1710 shapeEntry = item->data(k, Qt::UserRole).toString();
1711 if (! shapeEntry.isEmpty())
1713 shape = entryToObject(shapeEntry);
1714 w1->SetObject(shape);
1715 w1->deactivateSelection();
1717 myPeriodicityGroupBox2->setChecked(1);
1720 myPeriodicityGroupBox2->setChecked(0);
1723 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1724 myPeriodicityOnFaceRadioButton->setChecked(true);
1726 myPeriodicityOnEdgeRadioButton->setChecked(true);
1731 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1732 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1734 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1736 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1738 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1740 // find wich selection widget is activated
1741 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1743 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1744 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1746 // don't activate vertex selection if the group box is not checked
1747 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1749 // clear the selection, to avoid to put the same object in the other widget
1750 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1751 // activate the next widget
1752 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1753 w2->activateSelection();
1760 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1761 This method updates the GUI widgets with the hypothesis data
1763 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1765 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1767 BlsurfHypothesisData data;
1768 that->readParamsFromHypo( data );
1771 myName->setText( data.myName );
1772 QFontMetrics metrics( myName->font() );
1773 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1775 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1776 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1777 if (data.myPhySize <= 0)
1778 myStdWidget->myPhySize->setText("");
1780 myStdWidget->myPhySize->SetValue( data.myPhySize );
1781 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1782 if (data.myMinSize < 0)
1783 myStdWidget->myMinSize->setText("");
1785 myStdWidget->myMinSize->SetValue( data.myMinSize );
1786 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1787 if (data.myMaxSize < 0)
1788 myStdWidget->myMaxSize->setText("");
1790 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1791 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1792 myStdWidget->myUseGradation->setChecked( data.myUseGradation );
1793 if (data.myGradation <= 0 || !data.myUseGradation )
1794 myStdWidget->myGradation->setText("");
1796 myStdWidget->myGradation->SetValue( data.myGradation );
1797 myStdWidget->myUseVolumeGradation->setChecked( data.myUseVolumeGradation );
1798 if (data.myVolumeGradation <= 0 || !data.myUseVolumeGradation )
1799 myStdWidget->myVolumeGradation->setText("");
1801 myStdWidget->myVolumeGradation->SetValue( data.myVolumeGradation );
1803 foreach (QAbstractButton* button, myStdWidget->myButtonGroupElementType->buttons()) {
1804 if (myStdWidget->myButtonGroupElementType->id(button) == data.myElementType) {
1805 button->setChecked(true);
1810 if (data.myAngleMesh < 0)
1811 myStdWidget->myAngleMesh->setText("");
1813 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1814 if (data.myChordalError <= 0)
1815 myStdWidget->myChordalError->setText("");
1817 myStdWidget->myChordalError->SetValue( data.myChordalError );
1818 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1819 if (data.myAnisotropicRatio <= 0)
1820 myStdWidget->myAnisotropicRatio->setText("");
1822 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1823 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1824 if (data.myTinyEdgeLength <= 0)
1825 myStdWidget->myTinyEdgeLength->setText("");
1827 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1828 myStdWidget->myOptimiseTinyEdges->setChecked( data.myOptimiseTinyEdges );
1829 if (data.myTinyEdgeOptimisLength <= 0)
1830 myStdWidget->myTinyEdgeOptimisLength->setText("");
1832 myStdWidget->myTinyEdgeOptimisLength->SetValue( data.myTinyEdgeOptimisLength );
1833 myStdWidget->myCorrectSurfaceIntersection->setChecked( data.myCorrectSurfaceIntersection );
1834 if (data.myCorrectSurfaceIntersectionMaxCost <= 0)
1835 myStdWidget->myCorrectSurfaceIntersectionMaxCost->setText("");
1837 myStdWidget->myCorrectSurfaceIntersectionMaxCost->SetValue( data.myCorrectSurfaceIntersectionMaxCost );
1838 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1839 if (data.myBadElementAspectRatio <= 0)
1840 myStdWidget->myBadElementAspectRatio->setText("");
1842 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1843 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1844 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1846 myStdWidget->resizeWidgets();
1848 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1850 if ( myOptions.operator->() ) {
1851 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1852 myAdvWidget->AddOption( TBL_MESHING, that->myOptions[i].in() );
1854 if ( myPreCADOptions.operator->() ) {
1855 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i )
1856 myAdvWidget->AddOption( TBL_PRECAD, that->myPreCADOptions[i].in() );
1858 if ( myCustomOptions.operator->() ) {
1859 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1860 myAdvWidget->AddOption( TBL_CUSTOM, that->myCustomOptions[i].in() );
1862 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1863 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1864 // myGMFFileMode->setChecked(data.myGMFFileMode);
1867 QMapIterator<QString, QString> i(that->mySMPMap);
1868 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1869 while (i.hasNext()) {
1871 const QString entry = i.key();
1872 const QString sizeMap = i.value();
1873 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1874 //int row = mySizeMapTable->topLevelItemCount();
1875 QTreeWidgetItem* item = new QTreeWidgetItem();
1876 mySizeMapTable->addTopLevelItem( item );
1877 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1878 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1879 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1880 if (that->myATTMap.contains(entry)) {
1881 TAttractorVec & attVec = that->myATTMap[entry];
1882 for ( size_t i = 0; i < attVec.size(); ++i )
1884 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
1885 QTreeWidgetItem* child = new QTreeWidgetItem();
1886 item->addChild( child );
1887 item->setExpanded(true);
1888 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
1889 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
1890 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
1892 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
1893 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
1896 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
1902 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1905 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1906 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1907 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1909 // Enforced vertices
1910 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1912 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1913 TEntry entry = (*evmIt).first;
1914 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1916 //QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1918 TEnfVertexList evs = (*evmIt).second;
1920 TEnfVertexList::const_iterator evsIt = evs.begin();
1921 TEnfVertex *enfVertex;
1922 for ( ; evsIt != evs.end() ; ++evsIt) {
1923 enfVertex = (*evsIt);
1924 double x = 0, y = 0, z = 0;
1925 if (enfVertex->coords.size()) {
1926 x = enfVertex->coords[0];
1927 y = enfVertex->coords[1];
1928 z = enfVertex->coords[2];
1930 that->addEnforcedVertex(x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1934 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1935 myEnforcedTreeWidget->resizeColumnToContents(column);
1937 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1938 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1939 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1943 // Add an item in the tree widget for each association
1944 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
1946 QTreeWidgetItem* item = new QTreeWidgetItem();
1947 myPeriodicityTreeWidget->addTopLevelItem(item);
1948 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1949 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
1950 for (size_t k=0; k<periodicity_i.size(); k++)
1952 string shapeEntry = periodicity_i[k];
1953 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
1954 item->setData(k, Qt::EditRole, shapeName.c_str() );
1955 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1960 for ( int i = 0; i < data.hyperpatches.size(); ++i )
1961 that->addHyPatchToTable( data.hyperpatches[i] );
1964 that->myStdWidget->onPhysicalMeshChanged();
1965 that->myStdWidget->onGeometricMeshChanged();
1966 that->onStateChange();
1969 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1970 This method updates the hypothesis data with the GUI widgets content.
1972 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1974 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1976 BlsurfHypothesisData data;
1977 QString guiHyp = that->readParamsFromWidgets( data );
1978 that->storeParamsToHypo( data );
1983 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1984 Updates the hypothesis data from hypothesis values.
1986 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
1988 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1989 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1991 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1992 h_data.myName = isCreation() && data ? hypName() : "";
1994 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
1995 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
1996 h_data.myPhySize = h->GetPhySize();
1997 h_data.myPhySizeRel = h->IsPhySizeRel();
1998 double minSize = h->GetMinSize();
1999 double maxSize = h->GetMaxSize();
2000 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2001 h_data.myMinSizeRel = h->IsMinSizeRel();
2002 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2003 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2004 h_data.myUseGradation = h->GetUseGradation();
2005 h_data.myGradation = h->GetGradation();
2006 h_data.myUseVolumeGradation = h->GetUseVolumeGradation();
2007 h_data.myVolumeGradation = h->GetVolumeGradation();
2008 h_data.myElementType = h->GetElementType();
2009 double angle = h->GetAngleMesh();
2010 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2011 double chordalError = h->GetChordalError();
2012 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2013 h_data.myAnisotropic = h->GetAnisotropic();
2014 double myAnisotropicRatio = h->GetAnisotropicRatio();
2015 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2016 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2017 double myTinyEdgeLength = h->GetTinyEdgeLength();
2018 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2019 h_data.myOptimiseTinyEdges = h->GetOptimiseTinyEdges();
2020 double myTinyEdgeOptimisLength = h->GetTinyEdgeOptimisationLength();
2021 h_data.myTinyEdgeOptimisLength = myTinyEdgeOptimisLength > 0 ? myTinyEdgeOptimisLength : -1.0;
2022 h_data.myCorrectSurfaceIntersection = h->GetCorrectSurfaceIntersection();
2023 double corrSurfaceIntersMaxCost = h->GetCorrectSurfaceIntersectionMaxCost();
2024 h_data.myCorrectSurfaceIntersectionMaxCost = corrSurfaceIntersMaxCost > 0 ? corrSurfaceIntersMaxCost : -1.0;
2025 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2026 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2027 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2028 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2029 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2030 h_data.myVerbosity = h->GetVerbosity();
2031 //h_data.myTopology = (int) h->GetTopology();
2032 //h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2033 // h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2034 // h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2037 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2038 that->myOptions = h->GetOptionValues();
2039 that->myPreCADOptions = h->GetPreCADOptionValues();
2040 that->myCustomOptions = h->GetAdvancedOptionValues();
2042 h_data.myGMFFileName = h->GetGMFFile();
2043 // h_data.myGMFFileMode = h->GetGMFFileMode();
2045 that->mySMPMap.clear();
2046 that->myATTMap.clear();
2047 // that->myAttDistMap.clear();
2048 // that->myDistMap.clear();
2050 // classic size maps
2051 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2052 QString fullSizeMaps;
2053 QStringList fullSizeMapList;
2054 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2055 for ( CORBA::ULong i = 0;i<mySizeMaps->length(); ++i ) {
2056 fullSizeMaps = mySizeMaps[i].in();
2057 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2058 if ( fullSizeMapList.count() > 1 ) {
2059 string fullSizeMap = fullSizeMapList[1].toStdString();
2060 int pos = fullSizeMap.find("return")+7;
2063 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2068 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2069 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2075 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2077 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2078 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2079 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2080 if ( fullCustomSizeMapList.count() > 1 ) {
2081 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2082 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2087 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2089 for ( CORBA::ULong i = 0;i<allMyAttractors->length(); ++i ) {
2090 QString myAttractors = allMyAttractors[i].in();
2091 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2092 if ( myAttractorList.count() > 1 ) {
2093 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2094 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2098 // attractor new version
2099 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2100 for ( CORBA::ULong i = 0;i<allMyAttractorParams->length(); ++i ) {
2101 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2102 QString faceEntry = myAttractorParams.faceEntry.in();
2103 QString attEntry = myAttractorParams.attEntry.in();
2104 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2105 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2106 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2107 myAttractorParams.startSize,
2108 myAttractorParams.infDist,
2109 myAttractorParams.constDist ));
2112 // Enforced vertices
2113 h_data.enfVertexList.clear();
2114 h_data.faceEntryEnfVertexListMap.clear();
2116 h_data.groupNameEnfVertexListMap.clear();
2119 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2121 for ( CORBA::ULong i = 0;i<faceEntryEnfVertexListMap->length(); ++i )
2123 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2124 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2126 for (CORBA::ULong j=0 ; j<vertexList.length(); ++j)
2128 TEnfVertex *enfVertex = new TEnfVertex();
2129 enfVertex->name = vertexList[j].name.in();
2130 enfVertex->geomEntry = vertexList[j].geomEntry.in();
2131 enfVertex->grpName = vertexList[j].grpName.in();
2132 for (CORBA::ULong k=0 ; k< vertexList[j].coords.length();k++)
2133 enfVertex->coords.push_back(vertexList[j].coords[k]);
2135 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2138 if (groupName != "") {
2139 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2143 // h_data.enfVertMap[entry] = evs;
2144 // h_data.entryCoordsListMap[entry] = coordsList;
2146 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2147 h_data.faceEntryEnfVertexListMap.erase(entry);
2150 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2151 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2155 h_data.preCadPeriodicityVector.clear();
2157 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2158 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2160 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2161 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2165 h_data.hyperpatches.clear();
2166 BLSURFPlugin::THyperPatchList_var patchList = h->GetHyperPatches();
2167 for ( CORBA::ULong i = 0; i < patchList->length(); ++i )
2170 BLSURFPlugin::THyperPatch& patch = patchList[i];
2171 for ( CORBA::ULong j = 0; j < patch.length(); ++j )
2172 tags += QString::number( patch[j] ) + " ";
2173 if ( !tags.isEmpty() )
2174 h_data.hyperpatches.append( tags );
2180 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2181 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2184 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2186 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2187 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2188 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2190 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2191 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2193 if (sourceVertices.length()!=0)
2195 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2196 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2197 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2200 if (targetVertices.length()!=0)
2202 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2203 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2204 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2208 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2210 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2212 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2216 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2217 Saves the hypothesis data to hypothesis values.
2219 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2221 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2222 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2228 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2230 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2231 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2232 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2233 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2235 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2236 if ( h->GetPhySize() != h_data.myPhySize ||
2237 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2238 if ( h_data.myPhySizeRel )
2239 h->SetPhySizeRel( h_data.myPhySize );
2241 h->SetPhySize( h_data.myPhySize );
2244 if (h->GetMinSize() != h_data.myMinSize ||
2245 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2246 if ( h_data.myMinSizeRel )
2247 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2249 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2251 if (h->GetMaxSize() != h_data.myMaxSize ||
2252 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2253 if ( h_data.myMaxSizeRel )
2254 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2256 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2258 if ( h->GetUseGradation() != h_data.myUseGradation )
2259 h->SetUseGradation( h_data.myUseGradation );
2260 if ( h->GetGradation() != h_data.myGradation )
2261 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2262 if ( h->GetUseVolumeGradation() != h_data.myUseVolumeGradation )
2263 h->SetUseVolumeGradation( h_data.myUseVolumeGradation );
2264 if ( h->GetVolumeGradation() != h_data.myVolumeGradation )
2265 h->SetVolumeGradation( h_data.myVolumeGradation <= 0 ? -1 : h_data.myVolumeGradation );
2267 if ( h->GetElementType() != h_data.myElementType )
2268 h->SetElementType( h_data.myElementType );
2270 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2271 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2272 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2273 if ( h->GetChordalError() != h_data.myChordalError )
2274 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2277 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2278 h->SetAnisotropic( h_data.myAnisotropic );
2279 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2280 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2282 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2283 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2284 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2285 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2287 if ( h->GetOptimiseTinyEdges() != h_data.myOptimiseTinyEdges )
2288 h->SetOptimiseTinyEdges( h_data.myOptimiseTinyEdges );
2289 if ( h_data.myOptimiseTinyEdges && ( h->GetTinyEdgeOptimisationLength() != h_data.myTinyEdgeOptimisLength ) )
2290 h->SetTinyEdgeOptimisationLength( h_data.myTinyEdgeOptimisLength <= 0 ? -1 :h_data.myTinyEdgeOptimisLength );
2291 if ( h->GetCorrectSurfaceIntersection() != h_data.myCorrectSurfaceIntersection )
2292 h->SetCorrectSurfaceIntersection( h_data.myCorrectSurfaceIntersection );
2293 if ( h_data.myCorrectSurfaceIntersection && ( h->GetCorrectSurfaceIntersectionMaxCost() != h_data.myCorrectSurfaceIntersectionMaxCost ) )
2294 h->SetCorrectSurfaceIntersectionMaxCost( h_data.myCorrectSurfaceIntersectionMaxCost <= 0 ? -1 :h_data.myCorrectSurfaceIntersectionMaxCost );
2296 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2297 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2298 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2299 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2301 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2302 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2304 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2305 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2307 if ( h->GetVerbosity() != h_data.myVerbosity )
2308 h->SetVerbosity( h_data.myVerbosity );
2309 // if ( h->GetTopology() != h_data.myTopology )
2310 // h->SetTopology( (int) h_data.myTopology );
2311 // if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2312 // h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2313 // if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2314 // h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2315 // if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2316 // h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2318 // options are set in checkParams()
2319 //h->SetOptionValues( myOptions ); // is set in readParamsFromWidgets()
2320 //h->SetPreCADOptionValues( myPreCADOptions ); // is set in readParamsFromWidgets()
2322 if ( h->GetGMFFile() != h_data.myGMFFileName )
2323 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2324 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2325 h->SetGMFFile( h_data.myGMFFileName.c_str());
2327 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2328 QMapIterator<QString,QString> i(that->mySMPMap);
2329 while (i.hasNext()) {
2331 const QString entry = i.key();
2332 const QString sizeMap = i.value();
2334 if (sizeMap == "__TO_DELETE__") {
2335 h->UnsetEntry(entry.toLatin1().constData());
2337 else if (sizeMap.startsWith("ATTRACTOR")) {
2338 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2340 else if (sizeMap.startsWith("def")) {
2341 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2344 if (!myATTMap[entry].empty()){
2345 const TAttractorVec& attVec = myATTMap[entry];
2346 for ( size_t i = 0; i < attVec.size(); ++i )
2348 if ( attVec[i].IsToDelete() )
2349 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2350 attVec[i].attEntry.c_str() );
2352 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2353 attVec[i].attEntry.c_str(),
2354 attVec[i].startSize,
2357 attVec[i].constDist );
2361 QString fullSizeMap;
2362 fullSizeMap = QString("");
2363 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2364 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2365 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2366 fullSizeMap = QString("def f(t): return ") + sizeMap;
2367 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2368 fullSizeMap = QString("def f(): return ") + sizeMap;
2369 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2374 // Enforced vertices
2377 std::string enfName;
2379 std::string groupName = "";
2382 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2383 // 1. Clear all enforced vertices in hypothesis
2384 // 2. Add new enforced vertex according to h_data
2386 if ( h->GetAllEnforcedVertices()->length() > 0 )
2387 h->ClearAllEnforcedVertices();
2390 TEnfVertexList::const_iterator evsIt;
2391 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2393 faceEntry = evmIt->first;
2394 evs = evmIt->second;
2395 evsIt = evs.begin();
2396 for ( ; evsIt != evs.end() ; ++evsIt)
2399 if ((*evsIt)->coords.size()) {
2400 x = (*evsIt)->coords[0];
2401 y = (*evsIt)->coords[1];
2402 z = (*evsIt)->coords[2];
2405 h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2409 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2410 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2411 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2412 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2415 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2416 h->ClearPreCadPeriodicityVectors();
2418 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2419 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2421 TPreCadPeriodicity periodicity_i = *pIt;
2422 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2423 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2424 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2425 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2426 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2427 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2428 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2429 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2430 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2432 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2433 if (! p1Source.empty())
2435 sourceVertices->length(3);
2436 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2437 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2438 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2442 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2443 if (! p1Target.empty())
2445 targetVertices->length(3);
2446 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2447 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2448 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2452 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2454 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2458 BLSURFPlugin::THyperPatchList_var hpl = new BLSURFPlugin::THyperPatchList();
2459 hpl->length( h_data.hyperpatches.size() );
2461 for ( int i = 0; i < h_data.hyperpatches.size(); ++i )
2463 QStringList tags = h_data.hyperpatches[i].split(" ", QString::SkipEmptyParts);
2464 BLSURFPlugin::THyperPatch& patch = hpl[ i ];
2465 patch.length( tags.size() );
2467 for ( int j = 0; j < tags.size(); ++j )
2468 patch[ j ] = tags[ j ].toDouble();
2470 h->SetHyperPatches( hpl );
2481 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2482 Stores the widgets content to the hypothesis data.
2484 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2486 h_data.myName = myName ? myName->text() : "";
2487 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2488 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2489 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2490 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2491 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2492 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2493 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2494 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2495 h_data.myUseGradation = myStdWidget->myUseGradation->isChecked() && !myStdWidget->myGradation->text().isEmpty();
2496 h_data.myGradation = h_data.myUseGradation ? myStdWidget->myGradation->GetValue() : -1.0;
2497 h_data.myUseVolumeGradation = myStdWidget->myUseVolumeGradation->isChecked() && !myStdWidget->myVolumeGradation->text().isEmpty();
2498 h_data.myVolumeGradation = h_data.myUseVolumeGradation ? myStdWidget->myVolumeGradation->GetValue() : -1. ;
2499 h_data.myElementType = myStdWidget->myButtonGroupElementType->checkedId();
2500 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2501 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2502 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2503 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2504 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2505 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2506 h_data.myOptimiseTinyEdges = myStdWidget->myOptimiseTinyEdges->isChecked();
2507 h_data.myTinyEdgeOptimisLength = myStdWidget->myTinyEdgeOptimisLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeOptimisLength->GetValue();
2508 h_data.myCorrectSurfaceIntersection = myStdWidget->myCorrectSurfaceIntersection->isChecked();
2509 h_data.myCorrectSurfaceIntersectionMaxCost = myStdWidget->myCorrectSurfaceIntersectionMaxCost->text().isEmpty() ? -1.0 : myStdWidget->myCorrectSurfaceIntersectionMaxCost->GetValue();
2510 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2511 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2512 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2513 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2514 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2515 //h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2516 //h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2517 //h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2518 //h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2521 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2522 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2523 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2524 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2525 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2526 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2527 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2528 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2529 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2530 guiHyp += tr("BLSURF_ELEMENT_TYPE") + " = " + QString::number(h_data.myElementType) + "; ";
2531 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2532 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2533 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2534 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2537 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2538 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2539 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2540 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2541 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2542 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2545 // guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2546 // guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2547 // guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2548 // guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2550 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2551 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2554 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2555 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2556 for ( ; row < nbRows; ++row )
2558 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2559 if ( that->mySMPMap.contains(entry) )
2560 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2563 // Enforced vertices
2564 h_data.enfVertexList.clear();
2565 h_data.faceEntryEnfVertexListMap.clear();
2567 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2568 std::string groupName = "", faceEntry = "";
2569 for (int i=0 ; i<nbEnforcedShapes ; i++)
2571 double childValueX,childValueY,childValueZ;
2572 std::string childName, vertexEntry;
2573 QTreeWidgetItem* child;
2575 child = myEnforcedTreeWidget->topLevelItem(i);
2576 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2577 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2578 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2579 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2580 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2581 // if (myGlobalGroupName->isChecked())
2582 // groupName = myGlobalGroupName->text().toStdString();
2584 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2586 TEnfVertex *enfVertex = new TEnfVertex();
2587 enfVertex->name = childName;
2588 if (vertexEntry.empty()) {
2589 enfVertex->coords.push_back(childValueX);
2590 enfVertex->coords.push_back(childValueY);
2591 enfVertex->coords.push_back(childValueZ);
2594 enfVertex->geomEntry = vertexEntry;
2595 enfVertex->grpName = groupName;
2596 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2597 // if (it == h_data.enfVertexList.end())
2598 h_data.enfVertexList.insert(enfVertex);
2600 if (groupName != "")
2601 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2603 h_data.faceEntryEnfVertexListMap[faceEntry].insert( enfVertex );
2606 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2607 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2610 h_data.preCadPeriodicityVector.clear();
2611 // For each tree item, store each value. Shapes are stored as entries.
2612 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2613 for (int i=0 ; i<nbPeriodicityDescriptions ; i++) {
2614 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2615 TPreCadPeriodicity periodicity_i;
2617 for (int k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2619 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2620 periodicity_i.push_back(entry);
2622 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2624 guiHyp += "PERIODICITY = yes; ";
2628 h_data.hyperpatches.clear();
2629 for ( int row = 0; row < myHyPatchTable->rowCount(); ++row )
2630 h_data.hyperpatches.append( myHyPatchTable->item( row, 0 )->text() );
2635 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2637 myAdvWidget->AddOption( TBL_CUSTOM, NULL );
2640 void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int row, int column )
2642 // if ( column != OPTION_NAME_COLUMN )
2644 // myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2647 // **********************
2648 // *** BEGIN SIZE MAP ***
2649 // **********************
2651 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2653 if ( myGeomSelWdg2->IsObjectSelected() ){
2654 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2656 else if ( myGeomSelWdg1->IsObjectSelected() ){
2657 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2660 mySMapObject = GEOM::GEOM_Object::_nil();
2662 bool dataAvailable = !mySMapObject->_is_nil();
2664 if ( dataAvailable )
2665 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2667 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2668 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2669 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2670 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2671 ( myATTMap.contains( qEntry )))
2674 QString attEntry = myAttSelWdg->GetValue();
2675 const TAttractorVec& attVec = myATTMap[ qEntry ];
2676 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2677 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2680 addMapButton->setEnabled( !mapExists && dataAvailable );
2681 modifyMapButton->setEnabled( mapExists && dataAvailable );
2684 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2686 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2687 if (col == SMP_SIZEMAP_COLUMN) {
2688 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2690 if (!mySMPMap.contains(entry))
2692 if ( QTreeWidgetItem* parent = item->parent() )
2696 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2698 if (!mySMPMap.contains(entry))
2701 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2702 CORBA::Object_var obj = entryToObject(entry);
2703 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2704 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2705 // Retrieve values of the selected item in the current tab widgets
2706 const TAttractorVec& attVec = myATTMap[entry];
2707 if ( !attVec.empty() )
2710 if ( !childEntry.isEmpty() )
2711 for ( size_t i = 0; i < attVec.size(); ++i )
2712 if ( childEntry == attVec[i].attEntry.c_str() )
2717 double phySize = attVec[iAtt].startSize;
2718 double infDist = attVec[iAtt].infDist;
2719 double constDist = attVec[iAtt].constDist;
2720 QString attEntry = attVec[iAtt].attEntry.c_str();
2721 CORBA::Object_var attObj = entryToObject(attEntry);
2722 myAttSizeSpin->setValue(phySize);
2723 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2724 myAttDistSpin->setValue(infDist);
2725 myAttractorCheck->setChecked(true);
2728 myAttractorCheck->setChecked(false);
2730 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2731 myAttDistSpin2->setValue(constDist);
2732 myConstSizeCheck->setChecked(true);
2735 myConstSizeCheck->setChecked(false);
2737 myGeomSelWdg2->SetObject(obj);
2738 myAttSelWdg->SetObject(attObj);
2741 else { // CLASSIC MAPS
2742 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2743 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2744 if (!sizeMap.startsWith("def")){
2745 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2751 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2753 getGeomSelectionTool()->selectionMgr()->clearFilters();
2754 if ( sender() == myTabWidget )
2756 myGeomSelWdg1 ->deactivateSelection();
2757 myGeomSelWdg2 ->deactivateSelection();
2758 myAttSelWdg ->deactivateSelection();
2759 myEnfVertexWdg ->deactivateSelection();
2760 myPeriodicitySourceFaceWdg->deactivateSelection();
2761 myPeriodicityTargetFaceWdg->deactivateSelection();
2762 myPeriodicityP1SourceWdg ->deactivateSelection();
2763 myPeriodicityP2SourceWdg ->deactivateSelection();
2764 myPeriodicityP3SourceWdg ->deactivateSelection();
2765 myPeriodicityP1TargetWdg ->deactivateSelection();
2766 myPeriodicityP2TargetWdg ->deactivateSelection();
2767 myPeriodicityP3TargetWdg ->deactivateSelection();
2768 if ( myHyPatchFaceSelBtn->isChecked() )
2769 myHyPatchFaceSelBtn->toggle();
2770 if ( myHyPatchGroupSelBtn->isChecked() )
2771 myHyPatchGroupSelBtn->toggle();
2774 else if ( sender() == smpTab )
2776 myAttDistSpin->setValue(0.); // Reinitialize widgets
2777 myAttSizeSpin->setValue(0.);
2778 myAttDistSpin2->setValue(0.);
2779 mySmpSizeSpin->setValue(0.);
2780 myGeomSelWdg1->deactivateSelection();
2781 myGeomSelWdg2->deactivateSelection();
2782 myAttSelWdg->deactivateSelection();
2783 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2784 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2785 myAttSelWdg->SetObject(CORBA::Object::_nil());
2786 myAttractorCheck->setChecked(false);
2787 myConstSizeCheck->setChecked(false);
2791 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2793 if (state == Qt::Checked){
2794 myAttSelWdg->setEnabled(true);
2795 myAttSizeSpin->setEnabled(true);
2796 myAttSizeLabel->setEnabled(true);
2797 myAttDistSpin->setEnabled(true);
2798 myAttDistLabel->setEnabled(true);
2799 if (!myAttSelWdg->IsObjectSelected()){
2800 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2803 if (state == Qt::Unchecked){
2804 myAttDistSpin->setEnabled(false);
2805 myAttDistLabel->setEnabled(false);
2806 myAttDistSpin->setValue(0.);
2807 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2808 myAttSelWdg->setEnabled(false);
2809 myAttSizeSpin->setEnabled(false);
2810 myAttSizeLabel->setEnabled(false);
2811 myAttDistSpin2->setEnabled(false);
2812 myAttDistLabel2->setEnabled(false);
2814 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2815 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2818 onMapGeomContentModified();
2821 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2823 if (state == Qt::Checked){
2824 myAttSelWdg->setEnabled(true);
2825 myAttSizeSpin->setEnabled(true);
2826 myAttSizeLabel->setEnabled(true);
2827 myAttDistSpin2->setEnabled(true);
2828 myAttDistLabel2->setEnabled(true);
2829 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2830 !myAttSelWdg->IsObjectSelected()){
2831 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2834 if (state == Qt::Unchecked){
2835 myAttDistSpin2->setEnabled(false);
2836 myAttDistLabel2->setEnabled(false);
2837 myAttDistSpin2->setValue(0.);
2838 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2839 myAttSelWdg->setEnabled(false);
2840 myAttSizeSpin->setEnabled(false);
2841 myAttSizeLabel->setEnabled(false);
2842 myAttDistSpin->setEnabled(false);
2843 myAttDistLabel->setEnabled(false);
2845 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2846 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2849 onMapGeomContentModified();
2852 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2854 QList<int> selectedRows;
2855 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2856 QTreeWidgetItem* item;
2857 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2859 qSort( selectedRows );
2860 QListIterator<QTreeWidgetItem*> it( selected );
2862 while ( it.hasPrevious() ) {
2863 item = it.previous();
2864 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2865 QString parentEntry;
2866 if ( QTreeWidgetItem* parent = item->parent() )
2867 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2868 if (that->mySMPMap.contains(entry))
2870 that->mySMPMap[entry] = "__TO_DELETE__";
2871 if ( myATTMap.contains( entry ))
2873 TAttractorVec& attVec = myATTMap[entry];
2874 for ( size_t i = 0; i < attVec.size(); ++i )
2875 attVec[i].SetToDelete();
2878 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
2880 TAttractorVec& attVec = myATTMap[parentEntry];
2881 for ( size_t i = 0; i < attVec.size(); ++i )
2883 if ( entry == attVec[i].attEntry.c_str() )
2884 attVec[i].SetToDelete();
2887 if (that->mySMPShapeTypeMap.contains(entry))
2888 that->mySMPShapeTypeMap.remove(entry);
2889 // if (that->myDistMap.contains(entry))
2890 // that->myDistMap.remove(entry);
2891 // if (that->myAttDistMap.contains(entry))
2892 // that->myAttDistMap.remove(entry);
2895 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2896 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2899 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2901 if (col == SMP_SIZEMAP_COLUMN) {
2902 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2903 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2904 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2905 if (! that->mySMPShapeTypeMap.contains(entry))
2907 if (that->mySMPMap.contains(entry))
2908 if (that->mySMPMap[entry] == sizeMap
2909 || sizeMap.startsWith("Attractor")
2910 || sizeMap.startsWith("Constant") ){
2913 if (! sizeMap.isEmpty()) {
2914 that->mySMPMap[entry] = sizeMap;
2915 sizeMapValidationFromEntry(entry);
2918 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2920 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2924 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2927 if ( smpTab->currentIndex() == ATT_TAB ){
2928 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2929 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2930 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2931 res = insertAttractor(mySMapObject, myAttObject);
2934 if (smpTab->currentIndex() == SMP_STD_TAB ){
2935 if ( myGeomSelWdg1->IsObjectSelected() ){
2936 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2937 res = insertElement(mySMapObject);
2941 // Local size should be more than 0
2942 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
2943 SUIT_MessageBox::critical( dlg(),"Error" , msg );
2946 getGeomSelectionTool()->selectionMgr()->clearFilters();
2947 myAttDistSpin->setValue(0.);
2948 myAttSizeSpin->setValue(0.);
2949 myAttDistSpin2->setValue(0.);
2950 mySmpSizeSpin->setValue(0.);
2951 myConstSizeCheck->setChecked(false);
2952 myAttractorCheck->setChecked(false);
2953 myGeomSelWdg1->deactivateSelection();
2954 myGeomSelWdg2->deactivateSelection();
2955 myAttSelWdg->deactivateSelection();
2956 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2957 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2958 myAttSelWdg->SetObject(CORBA::Object::_nil());
2961 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
2964 if ( smpTab->currentIndex() == ATT_TAB ){
2965 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2966 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2967 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2968 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
2971 if (smpTab->currentIndex() == SMP_STD_TAB ){
2972 if ( myGeomSelWdg1->IsObjectSelected() ){
2973 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2974 res = insertElement(mySMapObject, /*modify = */true);
2978 // Local size should be more than 0
2979 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
2980 SUIT_MessageBox::critical( dlg(),"Error" , msg );
2983 getGeomSelectionTool()->selectionMgr()->clearFilters();
2984 myAttDistSpin->setValue(0.);
2985 myAttSizeSpin->setValue(0.);
2986 myAttDistSpin2->setValue(0.);
2987 mySmpSizeSpin->setValue(0.);
2988 myConstSizeCheck->setChecked(false);
2989 myAttractorCheck->setChecked(false);
2990 myGeomSelWdg1->deactivateSelection();
2991 myGeomSelWdg2->deactivateSelection();
2992 myAttSelWdg->deactivateSelection();
2993 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2994 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2995 myAttSelWdg->SetObject(CORBA::Object::_nil());
2998 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3000 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3001 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3003 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3005 TopAbs_ShapeEnum shapeType;
3006 string entry, shapeName;
3007 entry = (string) anObject->GetStudyEntry();
3008 shapeName = anObject->GetName();
3009 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3010 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3011 // in order to write the size map with the right syntax in StoreParamsToHypo
3012 // (f(t) for edges, f(u,v) for faces ...)
3013 if (shapeType == TopAbs_COMPOUND){
3014 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3015 TopoDS_Shape childShape;
3016 TopoDS_Iterator anIt(theShape);
3017 for(;anIt.More();anIt.Next()){
3018 childShape = anIt.Value();
3019 shapeType = childShape.ShapeType();
3020 if(!childShape.IsNull()){
3025 mySizeMapTable->setFocus();
3027 shapeEntry = QString::fromStdString(entry);
3028 double phySize = mySmpSizeSpin->value();
3031 return false; // Local size should be more than 0
3033 std::ostringstream oss;
3036 sizeMap = QString::fromStdString(oss.str());
3037 QTreeWidgetItem* item = new QTreeWidgetItem();
3039 int rowToChange = findRowFromEntry(shapeEntry);
3040 item = mySizeMapTable->topLevelItem( rowToChange );
3043 if (that->mySMPMap.contains(shapeEntry)) {
3044 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3048 mySizeMapTable->addTopLevelItem(item);
3050 that->mySMPMap[shapeEntry] = sizeMap;
3051 //that->myDistMap[shapeEntry] = 0. ;
3052 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3053 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3054 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3055 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3056 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3057 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3058 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3059 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3060 mySizeMapTable->clearSelection();
3062 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3063 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3064 myStdWidget->onPhysicalMeshChanged();
3069 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3071 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3072 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3074 TopAbs_ShapeEnum shapeType;
3075 string entry, attEntry, faceName, attName;
3076 entry = (string) aFace->GetStudyEntry();
3077 attEntry = (string) anAttractor->GetStudyEntry();
3078 faceName = aFace->GetName();
3079 attName = anAttractor->GetName();
3080 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3081 mySizeMapTable->setFocus();
3082 QString shapeEntry = QString::fromStdString(entry);
3083 QString qAttEntry = QString::fromStdString(attEntry);
3085 double phySize = h->GetPhySize();
3086 double infDist = 0. ;
3087 double constDist = 0. ;
3088 phySize = myAttSizeSpin->value();
3091 return false; // Local size should be more than 0
3093 if (myAttractorCheck->isChecked()){
3094 infDist = myAttDistSpin->value();
3096 if (myConstSizeCheck->isChecked()){
3097 constDist = myAttDistSpin2->value();
3099 std::ostringstream oss;
3100 std::ostringstream oss2;
3101 std::ostringstream oss3;
3105 QString sizeMap = QString::fromStdString(oss.str());
3106 QString infDistString = QString::fromStdString(oss2.str());
3107 QString constDistString = QString::fromStdString(oss3.str());
3109 QTreeWidgetItem* item;
3110 QTreeWidgetItem* child = 0;
3111 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3113 int rowToChange = findRowFromEntry(shapeEntry);
3114 item = mySizeMapTable->topLevelItem( rowToChange );
3116 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3117 if (( child = item->child( i )))
3118 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3120 TAttractorVec & attVec = myATTMap[shapeEntry];
3121 for ( size_t i = 0; i < attVec.size(); ++i )
3122 if ( attVec[i].attEntry == attEntry )
3124 attVec[i] = attParams;
3129 // if (that->mySMPMap.contains(shapeEntry)) {
3130 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3134 int rowToChange = findRowFromEntry(shapeEntry);
3135 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3137 item = mySizeMapTable->topLevelItem( rowToChange );
3140 item = new QTreeWidgetItem();
3141 mySizeMapTable->addTopLevelItem(item);
3143 child = new QTreeWidgetItem();
3144 item->addChild(child);
3145 bool exists = false;
3146 TAttractorVec & attVec = myATTMap[shapeEntry];
3147 for ( size_t i = 0; i < attVec.size(); ++i )
3148 if ( attVec[i].attEntry == attEntry )
3150 attVec[i] = attParams;
3155 myATTMap[shapeEntry].push_back( attParams );
3157 mySMPMap.insert(shapeEntry,sizeMap);
3158 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3159 item->setExpanded(true);
3160 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3161 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3162 if (infDist > std::numeric_limits<double>::epsilon()){
3163 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3165 else if (constDist > std::numeric_limits<double>::epsilon()){
3166 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3168 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3170 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3171 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3172 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3174 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3175 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3176 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3178 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3179 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3180 myStdWidget->onPhysicalMeshChanged();
3185 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3187 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3188 for ( ; row < nbRows; ++row )
3189 if (! sizeMapValidationFromRow(row))
3194 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3196 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3197 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3198 mySizeMapTable->setFocus();
3202 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3205 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3207 if (! that->mySMPMap.contains(myEntry)) {
3210 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3216 if (that->mySMPMap[myEntry].startsWith("def")) {
3217 expr = that->mySMPMap[myEntry].toStdString();
3219 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3220 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)) {
3223 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])" );
3229 // case size map is empty
3230 if (that->mySMPMap[myEntry].isEmpty()) {
3232 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3236 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3237 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3238 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3239 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3240 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3241 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3244 //assert(Py_IsInitialized());
3245 if (! Py_IsInitialized())
3246 throw ("Erreur: Python interpreter is not initialized");
3247 PyGILState_STATE gstate;
3248 gstate = PyGILState_Ensure();
3250 string err_description="";
3251 PyObject* obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3255 PyObject* new_stderr = newPyStdOut(err_description);
3256 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3257 Py_INCREF(old_stderr);
3258 PySys_SetObject((char*)"stderr", new_stderr);
3260 PySys_SetObject((char*)"stderr", old_stderr);
3261 Py_DECREF(new_stderr);
3263 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3264 PyGILState_Release(gstate);
3269 PyObject* func = PyObject_GetAttrString(main_mod, "f");
3273 PyObject* new_stderr = newPyStdOut(err_description);
3274 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3275 Py_INCREF(old_stderr);
3276 PySys_SetObject((char*)"stderr", new_stderr);
3278 PySys_SetObject((char*)"stderr", old_stderr);
3279 Py_DECREF(new_stderr);
3281 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3282 PyGILState_Release(gstate);
3286 PyGILState_Release(gstate);
3292 //================================================================================
3294 * \brief SLOT: Activate selection of faces in the Viewer
3296 //================================================================================
3298 void BLSURFPluginGUI_HypothesisCreator::onHyPatchFaceSelection(bool on)
3300 if ( on && myHyPatchFaceSelector->GetMainShape().IsNull() )
3302 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
3303 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
3304 myHyPatchFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
3306 myHyPatchFaceSelector->setVisible( on ); // show its buttons
3307 myHyPatchFaceSelector->ShowPreview( on ); // show faces in the Viewer
3308 // treat selection or not
3309 myHyPatchFaceSelector->ActivateSelection( on || myHyPatchGroupSelBtn->isChecked() );
3312 myHyPatchGroupSelBtn->setChecked( false );
3315 //================================================================================
3317 * \brief SLOT: Deactivate selection of faces in the Viewer
3319 //================================================================================
3321 void BLSURFPluginGUI_HypothesisCreator::onHyPatchGroupSelection(bool on)
3323 if ( on && myHyPatchFaceSelector->GetMainShape().IsNull() )
3325 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
3326 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
3327 myHyPatchFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
3329 if ( !myHyPatchFaceSelBtn->isChecked() )
3331 myHyPatchFaceSelector->setVisible( false ); // show its buttons
3332 myHyPatchFaceSelector->ShowPreview( false ); // show faces in the Viewer
3334 // treat selection or not
3335 myHyPatchFaceSelector->ActivateSelection( on || myHyPatchFaceSelBtn->isChecked() );
3338 myHyPatchFaceSelBtn->setChecked( false );
3341 //================================================================================
3343 * \brief SLOT: show IDs of selected faces in Tags LineEdit
3345 //================================================================================
3347 void BLSURFPluginGUI_HypothesisCreator::onHyPatchSelectionChanged()
3350 const QList<int>& tags = myHyPatchFaceSelector->GetSelectedIDs();
3351 for ( int i = 0; i < tags.size(); ++i )
3352 tagString += QString::number( tags[i] ) + " ";
3354 myHyPatchTagsLE->setText( tagString );
3357 //================================================================================
3359 * \brief SLOT: Add the Tags to the HyperPatch table
3361 //================================================================================
3363 void BLSURFPluginGUI_HypothesisCreator::onHyPatchAdd()
3365 QStringList tagList = myHyPatchTagsLE->text().split(" ", QString::SkipEmptyParts);
3366 if ( tagList.size() > 1 )
3368 addHyPatchToTable( myHyPatchTagsLE->text() );
3369 myHyPatchTagsLE->setText("");
3373 //================================================================================
3375 * \brief Add a row to myHyPatchTable
3377 //================================================================================
3379 void BLSURFPluginGUI_HypothesisCreator::addHyPatchToTable(const QString& tags)
3381 if ( tags.isEmpty() ) return;
3383 QTableWidgetItem* cell = new QTableWidgetItem( tags );
3384 cell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
3386 int row = myHyPatchTable->rowCount();
3387 myHyPatchTable->insertRow( row );
3388 myHyPatchTable->setItem( row, 0, cell );
3391 //================================================================================
3393 * \brief SLOT: remove selected rows from the HyperPatch table
3395 //================================================================================
3397 void BLSURFPluginGUI_HypothesisCreator::onHyPatchRemove()
3399 QList<QTableWidgetItem *> items = myHyPatchTable->selectedItems();
3400 while ( !items.isEmpty() )
3402 myHyPatchTable->removeRow( items[0]->row() );
3403 items = myHyPatchTable->selectedItems();
3407 bool BLSURFPluginGUI_HypothesisCreator::hasGeom() const
3409 return hypType() == BLSURFPlugin_Hypothesis::GetHypType(true);
3412 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3414 return tr( "BLSURF_TITLE" );
3417 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3419 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3422 QString BLSURFPluginGUI_HypothesisCreator::type() const
3424 return tr( "BLSURF_HYPOTHESIS" );
3427 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3429 return "blsurf_hypo_page.html";
3432 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3435 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3437 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3442 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3444 CORBA::Object_var obj;
3445 SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.toStdString().c_str() );
3446 if (!aSObj->_is_nil()) {
3447 obj = aSObj->GetObject();
3448 aSObj->UnRegister();
3453 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3454 int endRow = mySizeMapTable->topLevelItemCount()-1;
3456 for ( ; row <= endRow; ++row )
3458 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3459 if (entry == entryForChecking )