1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPluginGUI_HypothesisCreator.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPluginGUI_HypothesisCreator.h"
28 #include "BLSURFPluginGUI_Dlg.h"
30 #include "GeometryGUI.h"
32 #include <SMESHGUI_Utils.h>
33 #include <SMESHGUI_HypothesesUtils.h>
34 #include <SMESHGUI_Dialog.h>
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESH_NumberFilter.hxx"
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Tools.h>
43 #include <QApplication>
47 #include <QHBoxLayout>
48 #include <QHeaderView>
49 #include <QGridLayout>
55 #include <QPushButton>
56 #include <QRadioButton>
58 #include <QTableWidget>
60 #include <QVBoxLayout>
63 #include <QStandardItemModel>
64 #include <QStandardItem>
65 #include <QTreeWidget>
66 #include <QTreeWidgetItem>
67 #include <QModelIndexList>
69 #include <LightApp_SelectionMgr.h>
70 #include <SalomeApp_Application.h>
71 #include <SALOME_ListIO.hxx>
72 #include "SALOME_LifeCycleCORBA.hxx"
74 #include <TopoDS_Shape.hxx>
75 #include <TopoDS_Iterator.hxx>
76 #include <SMESH_Gen_i.hxx>
77 #include <boost/shared_ptr.hpp>
78 #include <boost/algorithm/string.hpp>
79 #include <structmember.h>
95 // Enforced vertices array columns
96 ENF_VER_NAME_COLUMN = 0,
97 ENF_VER_FACE_ENTRY_COLUMN,
101 ENF_VER_ENTRY_COLUMN,
102 ENF_VER_GROUP_COLUMN,
105 PERIODICITY_OBJ_SOURCE_COLUMN = 0,
106 PERIODICITY_OBJ_TARGET_COLUMN,
107 PERIODICITY_P1_SOURCE_COLUMN,
108 PERIODICITY_P2_SOURCE_COLUMN,
109 PERIODICITY_P3_SOURCE_COLUMN,
110 PERIODICITY_P1_TARGET_COLUMN,
111 PERIODICITY_P2_TARGET_COLUMN,
112 PERIODICITY_P3_TARGET_COLUMN,
113 PERIODICITY_SHAPE_TYPE,
115 // PERIODICITY_OBJ_SOURCE_COLUMN = 0,
116 // PERIODICITY_ENTRY_SOURCE_COLUMN,
117 // PERIODICITY_OBJ_TARGET_COLUMN,
118 // PERIODICITY_ENTRY_TARGET_COLUMN,
119 // PERIODICITY_P1_SOURCE_COLUMN,
120 // PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
121 // PERIODICITY_P2_SOURCE_COLUMN,
122 // PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
123 // PERIODICITY_P3_SOURCE_COLUMN,
124 // PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
125 // PERIODICITY_P1_TARGET_COLUMN,
126 // PERIODICITY_P1_ENTRY_TARGET_COLUMN,
127 // PERIODICITY_P2_TARGET_COLUMN,
128 // PERIODICITY_P2_ENTRY_TARGET_COLUMN,
129 // PERIODICITY_P3_TARGET_COLUMN,
130 // PERIODICITY_P3_ENTRY_TARGET_COLUMN,
132 PERIODICITY_NB_COLUMN
158 // Enforced vertices inputs
166 // ENF_VER_GROUP_CHECK,
170 ENF_VER_INTERNAL_ALL_FACES,
171 ENF_VER_INTERNAL_ALL_FACES_GROUP,
172 // ENF_VER_VERTEX_BTN,
173 // ENF_VER_REMOVE_BTN,
174 // ENF_VER_SEPARATOR,
179 /**************************************************
180 Begin initialization Python structures and objects
181 ***************************************************/
190 PyStdOut_dealloc(PyStdOut *self)
196 PyStdOut_write(PyStdOut *self, PyObject *args)
200 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
204 *(self->out)=*(self->out)+c;
210 static PyMethodDef PyStdOut_methods[] = {
211 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
212 PyDoc_STR("write(string) -> None")},
213 {NULL, NULL} /* sentinel */
216 static PyMemberDef PyStdOut_memberlist[] = {
217 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
218 (char*)"flag indicating that a space needs to be printed; used by print"},
219 {NULL} /* Sentinel */
222 static PyTypeObject PyStdOut_Type = {
223 /* The ob_type field must be initialized in the module init function
224 * to be portable to Windows without using C++. */
225 PyObject_HEAD_INIT(NULL)
228 sizeof(PyStdOut), /*tp_basicsize*/
231 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
238 0, /*tp_as_sequence*/
243 PyObject_GenericGetAttr, /*tp_getattro*/
244 /* softspace is writable: we must supply tp_setattro */
245 PyObject_GenericSetAttr, /* tp_setattro */
247 Py_TPFLAGS_DEFAULT, /*tp_flags*/
251 0, /*tp_richcompare*/
252 0, /*tp_weaklistoffset*/
255 PyStdOut_methods, /*tp_methods*/
256 PyStdOut_memberlist, /*tp_members*/
270 PyObject * newPyStdOut( std::string& out )
273 self = PyObject_New(PyStdOut, &PyStdOut_Type);
278 return (PyObject*)self;
281 /*************************************************
282 End initialization Python structures and objects
283 **************************************************/
287 // BEGIN EnforcedTreeWidgetDelegate
290 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
291 : QItemDelegate(parent)
295 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
296 const QStyleOptionViewItem & option ,
297 const QModelIndex & index ) const
299 QModelIndex father = index.parent();
300 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
302 if (index.column() == ENF_VER_X_COLUMN || \
303 index.column() == ENF_VER_Y_COLUMN || \
304 index.column() == ENF_VER_Z_COLUMN)
306 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
307 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
308 editor->setReadOnly(!entry.isEmpty());
309 editor->setDisabled(!entry.isEmpty());
314 QLineEdit *editor = new QLineEdit(parent);
315 if (index.column() != ENF_VER_GROUP_COLUMN) {
316 editor->setReadOnly(!entry.isEmpty());
317 editor->setDisabled(!entry.isEmpty());
323 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
324 const QModelIndex &index) const
326 QString value = index.model()->data(index, Qt::EditRole).toString();
328 if (index.column() == ENF_VER_X_COLUMN ||
329 index.column() == ENF_VER_Y_COLUMN ||
330 index.column() == ENF_VER_Z_COLUMN)
332 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
333 lineEdit->setText(value);
336 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
337 lineEdit->setText(value);
341 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
342 const QModelIndex &index) const
344 QModelIndex parent = index.parent();
345 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
346 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
347 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
348 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
349 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
350 } else if (index.column() == ENF_VER_NAME_COLUMN) {
351 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
352 QString value = lineEdit->text();
353 if (entry.isEmpty() && !vertexExists(model, index, value))
354 model->setData(index, value, Qt::EditRole);
355 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
356 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
357 QString value = lineEdit->text();
358 if (!vertexExists(model, index, value))
359 model->setData(index, value, Qt::EditRole);
360 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
361 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
362 model->setData(index, lineEdit->text(), Qt::EditRole);
366 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
367 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
369 editor->setGeometry(option.rect);
372 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
373 const QModelIndex &index, QString value) const
376 QModelIndex parent = index.parent();
377 int row = index.row();
378 int col = index.column();
380 if (parent.isValid() && !value.isEmpty()) {
381 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
383 if (col == ENF_VER_X_COLUMN) {
384 x = value.toDouble();
385 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
386 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
388 if (col == ENF_VER_Y_COLUMN) {
389 y = value.toDouble();
390 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
391 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
393 if (col == ENF_VER_Z_COLUMN) {
394 z = value.toDouble();
395 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
396 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
398 int nbChildren = model->rowCount(parent);
399 for (int i = 0 ; i < nbChildren ; i++) {
401 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
402 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
403 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
404 if ((childX == x) && (childY == y) && (childZ == z)) {
411 else if (col == ENF_VER_NAME_COLUMN) {
412 int nbChildren = model->rowCount(parent);
413 for (int i = 0 ; i < nbChildren ; i++) {
415 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
416 if (childName == value) {
429 // END EnforcedTreeWidgetDelegate
434 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
435 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
438 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
439 : SMESHGUI_GenericHypothesisCreator( theHypType )
441 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
442 this->mySMPMap.clear();
444 GeomToolSelected = NULL;
445 GeomToolSelected = getGeomSelectionTool();
447 aSel = GeomToolSelected->selectionMgr();
449 /* Initialize the Python interpreter */
450 if (! Py_IsInitialized())
451 throw ("Error: Python interpreter is not initialized");
452 PyGILState_STATE gstate;
453 gstate = PyGILState_Ensure();
456 main_mod = PyImport_AddModule("__main__");
459 main_dict = PyModule_GetDict(main_mod);
461 PyRun_SimpleString("from math import *");
462 PyGILState_Release(gstate);
466 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
471 * \brief {Get or create the geom selection tool for active study}
473 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() const
475 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
476 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
477 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
478 that->GeomToolSelected = new GeomSelectionTools(aStudy);
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
516 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
519 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
520 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
524 myAdvWidget->myOptionTable->setFocus();
525 QApplication::instance()->processEvents();
527 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
528 for ( ; row < nbRows; ++row )
530 QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
531 QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
532 if ( !value.isEmpty() ) {
534 QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed();
535 if (optionType == "PRECAD")
536 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
537 else if (optionType == "BLSURF")
538 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
540 catch ( const SALOME::SALOME_Exception& ex )
542 msg = ex.details.text.in();
550 h->SetOptionValues( myOptions ); // restore values
551 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
554 // SizeMap and attractors
557 mySizeMapTable->setFocus();
558 QApplication::instance()->processEvents();
560 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
561 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
563 for ( ; row < nbRows; ++row )
565 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
566 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
567 MESSAGE("entry ="<<entry.toStdString())
568 if ( !sizeMap.isEmpty() ) {
569 if (that->sizeMapValidationFromRow(row))
572 MESSAGE("entry ="<<entry.toStdString())
573 MESSAGE("sizeMap ="<<sizeMap.toStdString())
575 e = entry.toStdString();
576 s = that->mySMPMap[entry].toStdString();
577 MESSAGE("row = "<<row)
580 h->SetSizeMapEntry( e.c_str(), s.c_str() );
582 catch ( const SALOME::SALOME_Exception& ex )
584 msg = ex.details.text.in();
595 // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
598 // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
599 // So STD_TAB must be current tab to get correct value of it's spinbox.
600 myTabWidget->setCurrentIndex( STD_TAB );
604 if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
605 myStdWidget->myPhySize->text().toDouble() > 0.0 )))
606 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
610 if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
611 myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
612 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
616 if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
617 myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
618 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
622 if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
623 myStdWidget->myChordalError->text().toDouble() > 0.0 )))
624 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
633 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
635 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
637 QFrame* fr = new QFrame( 0 );
638 // fr-> setMinimumSize(600,400);
639 QVBoxLayout* lay = new QVBoxLayout( fr );
640 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
642 lay->setSpacing( 0 );
644 // main TabWidget of the dialog
645 myTabWidget = new QTabWidget( fr );
646 myTabWidget->setTabShape( QTabWidget::Rounded );
647 myTabWidget->setTabPosition( QTabWidget::North );
648 lay->addWidget( myTabWidget );
653 myStdGroup = new QWidget();
654 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
655 aStdLayout->setSpacing( 6 );
656 aStdLayout->setMargin( 11 );
659 myName = new QLineEdit( myStdGroup );
660 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
664 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
665 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
667 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
673 // row = max(row,maxrow)+1;
674 aStdLayout->setRowStretch(row,1);
675 aStdLayout->setColumnStretch(1,1);
679 // advanced parameters
680 myAdvGroup = new QWidget();
681 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
682 anAdvLayout->setSpacing( 6 );
683 anAdvLayout->setMargin( 11 );
684 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
685 myAdvWidget->addBtn->setMenu( new QMenu() );
686 anAdvLayout->addWidget( myAdvWidget);
689 // Size Maps parameters
691 mySmpGroup = new QWidget();
692 // mySmpGroup->setMinimumWidth(500);
695 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
698 mySizeMapTable = new QTreeWidget( mySmpGroup );
699 mySizeMapTable ->setMinimumWidth(200);
700 QStringList sizeMapHeaders;
701 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
702 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
703 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
704 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
705 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
706 mySizeMapTable->setAlternatingRowColors(true);
709 smpTab = new QTabWidget( mySmpGroup );
710 smpTab->setTabShape( QTabWidget::Rounded );
711 smpTab->setTabPosition( QTabWidget::South );
712 lay->addWidget( smpTab );
714 // Filters of selection
715 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
717 SM_ShapeTypes.Add( TopAbs_VERTEX );
718 SM_ShapeTypes.Add( TopAbs_EDGE );
719 SM_ShapeTypes.Add( TopAbs_FACE );
720 SM_ShapeTypes.Add( TopAbs_COMPOUND );
722 ATT_ShapeTypes.Add( TopAbs_VERTEX );
723 ATT_ShapeTypes.Add( TopAbs_EDGE );
724 ATT_ShapeTypes.Add( TopAbs_WIRE );
725 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
727 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
728 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
729 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
731 // Standard size map tab
732 mySmpStdGroup = new QWidget();
733 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
734 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false);
735 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
736 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
737 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
738 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
741 myAttractorGroup = new QWidget();
742 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
743 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false,/*stretch=*/false);
744 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
745 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
746 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
747 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
748 QFrame* attLine = new QFrame(myAttractorGroup);
749 attLine->setFrameShape(QFrame::HLine);
750 attLine->setFrameShadow(QFrame::Sunken);
751 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false);
752 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
753 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
754 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
755 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
756 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
757 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
758 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
759 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
760 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
761 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
763 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
764 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
768 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
769 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
770 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
771 modifyMapButton->setEnabled(false);
774 myAttSelWdg->setEnabled(false);
775 myAttSizeSpin->setEnabled(false);
776 myAttSizeLabel->setEnabled(false);
777 myAttDistSpin->setEnabled(false);
778 myAttDistLabel->setEnabled(false);
779 myAttDistSpin2->setEnabled(false);
780 myAttDistLabel2->setEnabled(false);
781 myAttDistSpin->setValue(0.);
782 myAttDistSpin2->setValue(0.);
783 myAttSizeSpin->setValue(0.);
784 mySmpSizeSpin->setValue(0.);
787 // ADD WIDGETS (SIZEMAP TAB)
788 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
789 anSmpLayout->setColumnStretch(0, 1);
790 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
791 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
792 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
793 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
794 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
795 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
798 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
799 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
800 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
801 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
804 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
805 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
806 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
807 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
808 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
809 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
810 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
811 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
812 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
813 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
814 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
815 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
817 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
818 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
820 smpTab->setCurrentIndex( SMP_STD_TAB );
822 // Enforced vertices parameters
823 myEnfGroup = new QWidget();
824 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
826 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
827 // anEnfLayout->addWidget(myEnforcedVertexWidget);
828 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
829 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
831 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
832 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
833 myEnforcedTreeWidget->setSortingEnabled(true);
834 QStringList enforcedHeaders;
835 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
836 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
837 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
839 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
840 myEnforcedTreeWidget->header()->setStretchLastSection(true);
841 myEnforcedTreeWidget->setAlternatingRowColors(true);
842 myEnforcedTreeWidget->setUniformRowHeights(true);
843 myEnforcedTreeWidget->setAnimated(true);
844 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
845 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
846 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
847 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
848 myEnforcedTreeWidget->resizeColumnToContents(column);
850 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
851 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
852 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
854 // FACE AND VERTEX SELECTION
855 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
856 shapeTypes1.Add( TopAbs_FACE );
857 shapeTypes1.Add( TopAbs_COMPOUND );
858 shapeTypes2.Add( TopAbs_VERTEX );
859 shapeTypes2.Add( TopAbs_COMPOUND );
861 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
862 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true, /*stretch=*/false);
863 myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
865 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
866 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
867 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
869 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
871 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
872 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
873 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
875 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
876 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
877 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
879 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
880 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
881 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
883 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
884 myGroupName = new QLineEdit(myEnfGroup);
886 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
887 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
889 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
891 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
892 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
894 // myGlobalGroupName = new QCheckBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
895 // myGlobalGroupName->setChecked(false);
897 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
898 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
899 // FACE AND VERTEX SELECTION
900 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
901 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
902 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
903 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
904 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
905 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
906 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
907 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
908 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
909 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
910 // anEnfLayout2->addWidget(myGlobalGroupName, ENF_VER_GROUP_CHECK, 0, 1, 2);
911 // anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
912 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
913 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
914 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
915 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
916 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
917 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
918 // anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
919 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
920 // anEnfLayout->setRowStretch(1, 1);
923 // Periodicity parameters
924 myPeriodicityGroup = new QWidget();
925 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
927 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
928 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
929 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
931 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
933 QStringList myPeriodicityTreeHeaders;
934 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
935 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
936 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
937 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
938 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
939 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
940 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
941 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
942 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
943 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
945 // Hide the vertex name to make the widget more readable
946 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
947 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
948 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
949 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
950 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
951 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
952 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
955 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
956 myPeriodicityTreeWidget->setSortingEnabled(true);
958 myPeriodicityTreeWidget->setAlternatingRowColors(true);
959 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
960 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
962 int periodicityVisibleColumns = 2;
963 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
964 myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
965 myPeriodicityTreeWidget->resizeColumnToContents(column);
967 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
969 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
971 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
973 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
974 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
975 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
977 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
979 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
980 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
982 myPeriodicityOnFaceRadioButton->setChecked(true);
984 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
985 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
988 // FACE, EDGE AND VERTEX SELECTION
989 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
990 shapeTypesFace.Add( TopAbs_FACE );
991 shapeTypesFace.Add( TopAbs_EDGE );
992 shapeTypesFace.Add( TopAbs_COMPOUND );
993 shapeTypesEdge.Add( TopAbs_EDGE );
994 shapeTypesEdge.Add( TopAbs_COMPOUND );
996 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
998 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
999 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1001 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1002 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1003 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1004 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1006 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1007 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1008 // myPeriodicitySourceEdgeWdg->hide();
1009 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1011 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1012 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1014 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1015 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1016 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1017 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1019 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1020 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1021 // myPeriodicityTargetEdgeWdg->hide();
1022 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1024 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1025 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1026 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1028 myPeriodicityGroupBox2->setCheckable(true);
1029 myPeriodicityGroupBox2->setChecked(false);
1031 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1032 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1034 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1035 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1038 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1039 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1042 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1043 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1044 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1047 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1048 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1050 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1051 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1052 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1055 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1056 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1058 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1059 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1060 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1063 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1064 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1066 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1067 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1068 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1071 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1072 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1074 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1075 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1076 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1079 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1080 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1082 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1083 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1084 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1086 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1087 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1090 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1091 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1093 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1094 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1096 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1098 myPeriodicitySelectionWidgets.clear();
1099 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1100 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1101 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1102 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1103 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1104 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1105 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1106 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1107 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1110 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1111 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1112 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1113 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1114 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1116 myTabWidget->setCurrentIndex( STD_TAB );
1118 connect( myAdvWidget->addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1119 connect( myAdvWidget->addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1120 connect( myAdvWidget->rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1121 connect( myStdWidget->myAllowQuadrangles, SIGNAL( stateChanged( int )),this, SLOT( onStateChange() ));
1124 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1125 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1126 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1127 // connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1128 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1129 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1130 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1131 connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1132 // connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1133 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1134 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1135 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1136 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1137 connect( myTabWidget, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1139 // Enforced vertices
1140 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1141 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1142 // connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1143 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1144 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1145 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1146 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1147 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1148 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1149 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1152 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1153 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1154 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1155 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1157 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1158 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1160 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1161 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1164 // connect( myPeriodicitySourceFaceWdg, SIGNAL(contentModified()), this, SLOT(onPeriodicityContentModified()));
1168 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1169 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1171 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1173 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1174 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1175 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1176 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1177 // myEnfFaceWdg->deactivateSelection();
1178 // myEnfVertexWdg->deactivateSelection();
1182 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1184 myStdWidget->myGradation->setEnabled( !myStdWidget->myAllowQuadrangles->isChecked() );
1188 * This method resets the content of the X, Y, Z widgets;
1190 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1192 myXCoord->setCleared(true);
1193 myYCoord->setCleared(true);
1194 myZCoord->setCleared(true);
1195 myXCoord->setText("");
1196 myYCoord->setText("");
1197 myZCoord->setText("");
1198 // myGroupName->setText("");
1201 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1202 This method updates the tooltip of a modified item. The QLineEdit widgets content
1203 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1205 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1206 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1207 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1208 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1209 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1210 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1211 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1212 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1213 QTreeWidgetItem* parent = item->parent();
1215 clearEnforcedVertexWidgets();
1217 if (parent && (!x.isNull() || !entry.isNull())) {
1218 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1219 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1220 if (entry.isNull()) {
1221 toolTip += QString("(") + x.toString();
1222 toolTip += QString(", ") + y.toString();
1223 toolTip += QString(", ") + z.toString();
1224 toolTip += QString(")");
1227 if (!groupName.isEmpty())
1228 toolTip += QString(" [") + groupName + QString("]");
1230 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1233 myXCoord->SetValue(x.toDouble());
1234 myYCoord->SetValue(y.toDouble());
1235 myZCoord->SetValue(z.toDouble());
1238 if (!groupName.isEmpty())
1239 myGroupName->setText(groupName);
1243 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1244 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1245 clearEnforcedVertexWidgets();
1246 if (nbSelEnfVertex == 1)
1248 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1251 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1252 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1253 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1254 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1255 if (CORBA::is_nil(measureOp))
1258 CORBA::Double x,y,z;
1259 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1260 if ( measureOp->IsDone() )
1262 myXCoord->SetValue(x);
1263 myYCoord->SetValue(y);
1264 myZCoord->SetValue(z);
1270 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1271 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1272 of the enforced vertex clicked in the tree widget.
1274 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1275 clearEnforcedVertexWidgets();
1276 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1277 if (! items.isEmpty() && items.size() == 1) {
1278 QTreeWidgetItem *item = items[0];
1279 // for (int i=0 ; i < items.size() ; i++) {
1281 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1282 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1283 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1284 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1285 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1286 if (!x.isNull()/* && entry.isNull()*/) {
1287 myXCoord->SetValue(x.toDouble());
1288 myYCoord->SetValue(y.toDouble());
1289 myZCoord->SetValue(z.toDouble());
1292 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1293 myGroupName->setText(group.toString());
1298 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1299 This method adds a face containing enforced vertices in the tree widget.
1301 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1302 // Find theFaceEntry item
1303 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1304 QTreeWidgetItem* theItem;
1305 if (theItemList.empty()) {
1306 theItem = new QTreeWidgetItem();
1307 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1308 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1309 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1310 myEnforcedTreeWidget->addTopLevelItem(theItem);
1313 theItem = theItemList[0];
1318 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1319 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1321 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(QTreeWidgetItem* theItem, double x, double y, double z,
1322 std::string vertexName, std::string geomEntry, std::string groupName) {
1324 std::string theFaceName = theItem->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
1325 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1326 bool okToCreate = true;
1328 const int nbVert = theItem->childCount();
1329 // MESSAGE("Number of child rows: " << nbVert);
1331 double childValueX,childValueY,childValueZ;
1332 QString childEntry, childGroupName;
1333 QTreeWidgetItem* child;
1334 for (int row = 0;row<nbVert;row++) {
1335 child = theItem->child(row);
1336 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1337 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1338 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1339 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1340 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1341 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1342 // update group name
1343 if (childGroupName.toStdString() != groupName) {
1344 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1345 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1353 if (geomEntry.empty()) {
1354 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1357 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1362 if (geomEntry.empty()) {
1363 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1366 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1369 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1370 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1371 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1372 QSize iconSize = iconSelect.size()*0.7;
1374 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1375 QString myVertexName;
1377 while(indexRef != vertexIndex) {
1378 indexRef = vertexIndex;
1379 if (vertexName.empty())
1380 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1382 myVertexName = QString(vertexName.c_str());
1384 for (int row = 0;row<nbVert;row++) {
1385 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1386 if (myVertexName == name) {
1392 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1393 if (geomEntry.empty()) {
1394 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1395 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1396 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1399 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1400 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1402 if (groupName != "")
1403 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1405 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1406 if (geomEntry.empty()) {
1407 toolTip += QString(" (%1, ").arg(x);
1408 toolTip += QString("%1, ").arg(y);
1409 toolTip += QString("%1)").arg(z);
1411 if (groupName != "")
1412 toolTip += QString(" [%1]").arg(groupName.c_str());
1414 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1415 theItem->setExpanded(true);
1416 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1419 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1420 This method is called when a item is added into the enforced vertices tree widget
1422 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1423 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1425 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1427 getGeomSelectionTool()->selectionMgr()->clearFilters();
1428 myEnfFaceWdg->deactivateSelection();
1429 myEnfVertexWdg->deactivateSelection();
1431 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1432 myEnforcedTreeWidget->resizeColumnToContents(column);
1435 int selEnfFace = myEnfFaceWdg->NbObjects();
1436 int selEnfVertex = myEnfVertexWdg->NbObjects();
1437 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1439 if (selEnfFace == 0)
1442 if ((selEnfVertex == 0) && coordsEmpty)
1445 string entry, shapeName;
1447 for (int i = 0 ; i < selEnfFace ; i++) {
1448 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1449 entry = myEnfFace->GetStudyEntry();
1450 shapeName = myEnfFace->GetName();
1452 QTreeWidgetItem * faceItem = addEnforcedFace(entry, shapeName);
1454 std::string groupName = myGroupName->text().toStdString();
1456 if (boost::trim_copy(groupName).empty())
1459 if (selEnfVertex <= 1)
1462 x = myXCoord->GetValue();
1463 y = myYCoord->GetValue();
1464 z = myZCoord->GetValue();
1465 if (selEnfVertex == 1) {
1466 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1467 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1470 addEnforcedVertex(faceItem, x, y, z, "", "", groupName);
1474 if ( CORBA::is_nil(getGeomEngine()))
1477 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1478 if (CORBA::is_nil(measureOp))
1481 CORBA::Double x,y,z;
1483 for (int j = 0 ; j < selEnfVertex ; j++)
1485 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1486 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1487 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1488 if ( measureOp->IsDone() )
1489 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1490 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1491 addEnforcedVertex(faceItem, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1497 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1498 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1500 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1501 myEnforcedTreeWidget->resizeColumnToContents(column);
1503 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1504 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1505 myStdWidget->onPhysicalMeshChanged();
1509 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1510 This method is called when a item is removed from the enforced vertices tree widget
1512 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1513 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1514 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1515 QList<QTreeWidgetItem *> selectedVertices;
1516 QSet<QTreeWidgetItem *> selectedEntries;
1517 QTreeWidgetItem* item;
1519 foreach( item, selectedItems ) {
1520 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1521 if (! value.isNull())
1522 selectedVertices.append(item);
1524 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1525 if (! value.isNull())
1526 selectedVertices.append(item);
1528 selectedEntries.insert(item);
1532 foreach(item,selectedVertices) {
1533 QTreeWidgetItem* parent = item->parent();
1534 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1535 parent->removeChild(item);
1537 if (parent->childCount() == 0) {
1538 if (selectedEntries.contains(parent))
1539 selectedEntries.remove(parent);
1544 foreach(item,selectedEntries) {
1545 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1549 myEnforcedTreeWidget->selectionModel()->clearSelection();
1553 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1555 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1558 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1559 This method is called when a item is added into the periodicity table widget
1561 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1562 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1564 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1566 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1567 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1568 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1570 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1571 w1->deactivateSelection();
1575 // Source-Target selection
1576 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1577 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1579 if (selSource == 0 || selTarget == 0)
1582 // Vertices selection
1583 if (myPeriodicityGroupBox2->isChecked())
1585 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1586 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1587 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1588 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1589 int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1590 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1592 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1594 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1595 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1600 // Add Source-Target in table
1601 string shapeEntry, sourceEntry, targetEntry;
1602 string shapeName, sourceName, targetName;
1603 GEOM::GEOM_Object_var shape;
1605 QTreeWidgetItem* item = new QTreeWidgetItem();
1606 myPeriodicityTreeWidget->addTopLevelItem(item);
1608 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1612 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1614 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1615 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1616 shapeName = shape->GetName();
1617 shapeEntry = shape->GetStudyEntry();
1618 item->setData(k, Qt::EditRole, shapeName.c_str() );
1619 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1620 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1624 // Add shape type in tree
1625 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1626 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1628 // Blank input fields
1629 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1631 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1632 w1->SetObject(GEOM::GEOM_Object::_nil());
1635 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1636 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1640 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1641 This method is called when a item is removed from the periodicity tree widget
1643 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1644 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1645 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1646 QTreeWidgetItem* item;
1648 foreach(item,selectedItems) {
1649 MESSAGE("Remove " << item->text(0).toStdString());
1653 myEnforcedTreeWidget->selectionModel()->clearSelection();
1656 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1657 This method enable clears the field for periodicity by vertices
1659 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1663 for (size_t k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1665 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1666 w1->deactivateSelection();
1667 w1->SetObject(CORBA::Object::_nil());
1672 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1673 This method enable the proper shape selection widget to Face or Edge shapes
1675 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1677 // if (myPeriodicityOnFaceRadioButton->isChecked())
1679 // MESSAGE("Show Face");
1680 // myPeriodicitySourceEdgeWdg->hide();
1681 // myPeriodicityTargetEdgeWdg->hide();
1682 // myPeriodicitySourceFaceWdg->show();
1683 // myPeriodicityTargetFaceWdg->show();
1687 // MESSAGE("Show Edge");
1688 // myPeriodicitySourceFaceWdg->hide();
1689 // myPeriodicityTargetFaceWdg->hide();
1690 // myPeriodicitySourceEdgeWdg->show();
1691 // myPeriodicityTargetEdgeWdg->show();
1695 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1697 QString shapeName, shapeEntry;
1698 CORBA::Object_var shape;
1700 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1701 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1703 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1705 shapeName = item->data(k, Qt::EditRole).toString();
1706 shapeEntry = item->data(k, Qt::UserRole).toString();
1707 if (! shapeEntry.isEmpty())
1709 shape = entryToObject(shapeEntry);
1710 w1->SetObject(shape);
1711 w1->deactivateSelection();
1713 myPeriodicityGroupBox2->setChecked(1);
1716 myPeriodicityGroupBox2->setChecked(0);
1719 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1720 myPeriodicityOnFaceRadioButton->setChecked(true);
1722 myPeriodicityOnEdgeRadioButton->setChecked(true);
1727 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1728 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1730 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1732 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1734 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1736 // find wich selection widget is activated
1737 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1739 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1740 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1742 // don't activate vertex selection if the group box is not checked
1743 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1745 // clear the selection, to avoid to put the same object in the other widget
1746 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1747 // activate the next widget
1748 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1749 w2->activateSelection();
1756 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1757 This method updates the GUI widgets with the hypothesis data
1759 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1761 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1762 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1764 BlsurfHypothesisData data;
1765 that->readParamsFromHypo( data );
1768 myName->setText( data.myName );
1769 QFontMetrics metrics( myName->font() );
1770 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1772 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1773 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1774 if (data.myPhySize <= 0)
1775 myStdWidget->myPhySize->setText("");
1777 myStdWidget->myPhySize->SetValue( data.myPhySize );
1778 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1779 if (data.myMinSize < 0)
1780 myStdWidget->myMinSize->setText("");
1782 myStdWidget->myMinSize->SetValue( data.myMinSize );
1783 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1784 if (data.myMaxSize < 0)
1785 myStdWidget->myMaxSize->setText("");
1787 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1788 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1789 if (data.myGradation <= 0)
1790 myStdWidget->myGradation->setText("");
1792 myStdWidget->myGradation->SetValue( data.myGradation );
1793 myStdWidget->myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1795 if (data.myAngleMesh < 0)
1796 myStdWidget->myAngleMesh->setText("");
1798 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1799 if (data.myChordalError <= 0)
1800 myStdWidget->myChordalError->setText("");
1802 myStdWidget->myChordalError->SetValue( data.myChordalError );
1803 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1804 if (data.myAnisotropicRatio <= 0)
1805 myStdWidget->myAnisotropicRatio->setText("");
1807 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1808 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1809 if (data.myTinyEdgeLength <= 0)
1810 myStdWidget->myTinyEdgeLength->setText("");
1812 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1813 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1814 if (data.myBadElementAspectRatio <= 0)
1815 myStdWidget->myBadElementAspectRatio->setText("");
1817 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1818 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1819 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1821 myStdWidget->resizeWidgets();
1823 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1824 myAdvWidget->myPreCADGroupBox->setChecked(data.myTopology == PreCAD);
1825 myAdvWidget->myPreCADMergeEdges->setChecked( data.myPreCADMergeEdges );
1826 myAdvWidget->myPreCADProcess3DTopology->setChecked( data.myPreCADProcess3DTopology );
1827 myAdvWidget->myPreCADDiscardInput->setChecked( data.myPreCADDiscardInput );
1829 if ( myOptions.operator->() ) {
1830 // MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
1831 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1832 QString option = that->myOptions[i].in();
1833 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1834 if ( name_value.count() > 1 ) {
1835 QString idStr = QString("%1").arg( i );
1836 int row = myAdvWidget->myOptionTable->rowCount();
1837 myAdvWidget->myOptionTable->setRowCount( row+1 );
1838 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1839 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1840 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "BLSURF" ) );
1841 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
1842 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1843 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1844 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1845 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1846 Qt::ItemIsEditable |
1847 Qt::ItemIsEnabled );
1851 if ( myPreCADOptions.operator->() ) {
1852 // MESSAGE("retrieveParams():myPreCADOptions->length() = " << myPreCADOptions->length());
1853 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
1854 QString option = that->myPreCADOptions[i].in();
1855 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1856 if ( name_value.count() > 1 ) {
1857 QString idStr = QString("%1").arg( i );
1858 int row = myAdvWidget->myOptionTable->rowCount();
1859 myAdvWidget->myOptionTable->setRowCount( row+1 );
1860 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1861 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1862 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "PRECAD" ) );
1863 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
1864 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1865 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1866 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1867 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1868 Qt::ItemIsEditable |
1869 Qt::ItemIsEnabled );
1873 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1874 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1875 // myGMFFileMode->setChecked(data.myGMFFileMode);
1878 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1879 QMapIterator<QString, QString> i(that->mySMPMap);
1880 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1881 while (i.hasNext()) {
1883 const QString entry = i.key();
1884 const QString sizeMap = i.value();
1885 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1886 int row = mySizeMapTable->topLevelItemCount();
1887 QTreeWidgetItem* item = new QTreeWidgetItem();
1888 mySizeMapTable->addTopLevelItem( item );
1889 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1890 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1891 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1892 if (that->myATTMap.contains(entry)) {
1893 TAttractorVec & attVec = that->myATTMap[entry];
1894 for ( size_t i = 0; i < attVec.size(); ++i )
1896 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
1897 QTreeWidgetItem* child = new QTreeWidgetItem();
1898 item->addChild( child );
1899 item->setExpanded(true);
1900 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
1901 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
1902 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
1904 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
1905 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
1908 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
1914 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1917 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1918 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1919 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1921 // Enforced vertices
1922 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1923 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1925 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1926 TEntry entry = (*evmIt).first;
1927 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1928 MESSAGE("Face entry: " << entry);
1929 MESSAGE("Face name: " << shapeName);
1931 QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1933 TEnfVertexList evs = (*evmIt).second;
1935 TEnfVertexList::const_iterator evsIt = evs.begin();
1936 TEnfVertex *enfVertex;
1937 for ( ; evsIt != evs.end() ; ++evsIt) {
1938 enfVertex = (*evsIt);
1939 MESSAGE("Name: " << enfVertex->name);
1941 if (enfVertex->coords.size()) {
1942 x = enfVertex->coords[0];
1943 y = enfVertex->coords[1];
1944 z = enfVertex->coords[2];
1946 that->addEnforcedVertex(faceItem, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1950 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1951 myEnforcedTreeWidget->resizeColumnToContents(column);
1953 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1954 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1955 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1958 MESSAGE("retrieveParams(): periodicity ");
1961 // Add an item in the tree widget for each association
1962 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
1964 QTreeWidgetItem* item = new QTreeWidgetItem();
1965 myPeriodicityTreeWidget->addTopLevelItem(item);
1966 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1967 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
1968 for (size_t k=0; k<periodicity_i.size(); k++)
1970 string shapeEntry = periodicity_i[k];
1971 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
1972 item->setData(k, Qt::EditRole, shapeName.c_str() );
1973 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1978 that->myStdWidget->onPhysicalMeshChanged();
1979 that->myStdWidget->onGeometricMeshChanged();
1980 that->onStateChange();
1983 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1984 This method updates the hypothesis data with the GUI widgets content.
1986 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1988 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParams");
1989 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1991 BlsurfHypothesisData data;
1992 QString guiHyp = that->readParamsFromWidgets( data );
1993 that->storeParamsToHypo( data );
1998 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1999 Updates the hypothesis data from hypothesis values.
2001 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
2003 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
2004 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2005 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2007 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
2008 h_data.myName = isCreation() && data ? hypName() : "";
2010 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
2011 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
2012 h_data.myPhySize = h->GetPhySize();
2013 h_data.myPhySizeRel = h->IsPhySizeRel();
2014 double minSize = h->GetMinSize();
2015 double maxSize = h->GetMaxSize();
2016 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2017 h_data.myMinSizeRel = h->IsMinSizeRel();
2018 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2019 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2020 h_data.myGradation = h->GetGradation();
2021 h_data.myAllowQuadrangles = h->GetQuadAllowed();
2022 double angle = h->GetAngleMesh();
2023 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2024 double chordalError = h->GetChordalError();
2025 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2026 h_data.myAnisotropic = h->GetAnisotropic();
2027 double myAnisotropicRatio = h->GetAnisotropicRatio();
2028 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2029 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2030 double myTinyEdgeLength = h->GetTinyEdgeLength();
2031 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2032 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2033 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2034 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2035 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2036 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2037 h_data.myVerbosity = h->GetVerbosity();
2038 h_data.myTopology = (int) h->GetTopology();
2039 h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2040 h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2041 h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2044 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2045 that->myOptions = h->GetOptionValues();
2046 that->myPreCADOptions = h->GetPreCADOptionValues();
2048 h_data.myGMFFileName = h->GetGMFFile();
2049 // h_data.myGMFFileMode = h->GetGMFFileMode();
2051 that->mySMPMap.clear();
2052 that->myATTMap.clear();
2053 // that->myAttDistMap.clear();
2054 // that->myDistMap.clear();
2056 // classic size maps
2057 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2058 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
2059 QString fullSizeMaps;
2060 QStringList fullSizeMapList;
2061 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2062 for ( int i = 0;i<mySizeMaps->length(); ++i ) {
2063 fullSizeMaps = mySizeMaps[i].in();
2064 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
2065 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2066 if ( fullSizeMapList.count() > 1 ) {
2067 string fullSizeMap = fullSizeMapList[1].toStdString();
2068 int pos = fullSizeMap.find("return")+7;
2069 // MESSAGE("pos:" << pos);
2072 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2077 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2078 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
2079 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2080 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
2086 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2087 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
2089 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2090 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2091 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2092 if ( fullCustomSizeMapList.count() > 1 ) {
2093 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2094 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2095 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
2096 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
2101 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2102 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
2104 for ( int i = 0;i<allMyAttractors->length(); ++i ) {
2105 QString myAttractors = allMyAttractors[i].in();
2106 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2107 if ( myAttractorList.count() > 1 ) {
2108 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2109 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2110 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
2111 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
2115 // attractor new version
2116 MESSAGE("readParamsFromHypo, Attractors")
2117 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2118 for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
2119 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2120 QString faceEntry = myAttractorParams.faceEntry.in();
2121 QString attEntry = myAttractorParams.attEntry.in();
2122 MESSAGE("attEntry = "<<attEntry.toStdString())
2123 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2124 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2125 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2126 myAttractorParams.startSize,
2127 myAttractorParams.infDist,
2128 myAttractorParams.constDist ));
2131 // Enforced vertices
2132 h_data.enfVertexList.clear();
2133 h_data.faceEntryEnfVertexListMap.clear();
2135 h_data.groupNameEnfVertexListMap.clear();
2138 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2139 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
2141 for ( int i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
2142 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2143 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
2144 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2145 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
2147 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
2149 for (int j=0 ; j<vertexList.length(); ++j) {
2150 TEnfVertex *enfVertex = new TEnfVertex();
2152 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
2153 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
2154 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
2155 for (int k=0 ; k< vertexList[j].coords.length();k++)
2156 enfVertex->coords.push_back(vertexList[j].coords[k]);
2158 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2161 if (groupName != "") {
2162 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2166 // h_data.enfVertMap[entry] = evs;
2167 // h_data.entryCoordsListMap[entry] = coordsList;
2169 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2170 h_data.faceEntryEnfVertexListMap.erase(entry);
2173 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2174 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2177 MESSAGE("readParamsFromHypo, Periodicity")
2179 h_data.preCadPeriodicityVector.clear();
2181 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2182 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2184 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2185 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2189 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2190 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2193 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2195 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2196 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2197 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2199 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2200 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2202 if (sourceVertices.length()!=0)
2204 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2205 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2206 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2209 if (targetVertices.length()!=0)
2211 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2212 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2213 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2217 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2219 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2221 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2225 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2226 Saves the hypothesis data to hypothesis values.
2228 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2230 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
2231 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2232 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2238 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2240 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2241 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2242 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2243 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2245 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2246 if ( h->GetPhySize() != h_data.myPhySize ||
2247 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2248 if ( h_data.myPhySizeRel )
2249 h->SetPhySizeRel( h_data.myPhySize );
2251 h->SetPhySize( h_data.myPhySize );
2254 if (h->GetMinSize() != h_data.myMinSize ||
2255 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2256 if ( h_data.myMinSizeRel )
2257 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2259 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2261 if (h->GetMaxSize() != h_data.myMaxSize ||
2262 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2263 if ( h_data.myMaxSizeRel )
2264 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2266 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2268 if ( h->GetGradation() != h_data.myGradation )
2269 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2270 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
2271 h->SetQuadAllowed( h_data.myAllowQuadrangles );
2273 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2274 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2275 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2276 if ( h->GetChordalError() != h_data.myChordalError )
2277 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2280 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2281 h->SetAnisotropic( h_data.myAnisotropic );
2282 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2283 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2285 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2286 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2287 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2288 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2290 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2291 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2292 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2293 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2295 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2296 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2298 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2299 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2301 if ( h->GetVerbosity() != h_data.myVerbosity )
2302 h->SetVerbosity( h_data.myVerbosity );
2303 if ( h->GetTopology() != h_data.myTopology )
2304 h->SetTopology( (int) h_data.myTopology );
2305 if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2306 h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2307 if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2308 h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2309 if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2310 h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2312 h->SetOptionValues( myOptions ); // is set in checkParams()
2313 h->SetPreCADOptionValues( myPreCADOptions ); // is set in checkParams()
2315 if ( h->GetGMFFile() != h_data.myGMFFileName )
2316 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2317 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2318 h->SetGMFFile( h_data.myGMFFileName.c_str());
2320 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2321 QMapIterator<QString,QString> i(that->mySMPMap);
2322 while (i.hasNext()) {
2324 const QString entry = i.key();
2325 const QString sizeMap = i.value();
2327 if (sizeMap == "__TO_DELETE__") {
2328 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
2329 h->UnsetEntry(entry.toLatin1().constData());
2331 else if (sizeMap.startsWith("ATTRACTOR")) {
2332 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2333 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2335 else if (sizeMap.startsWith("def")) {
2336 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2337 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2340 if (!myATTMap[entry].empty()){
2341 const TAttractorVec& attVec = myATTMap[entry];
2342 for ( size_t i = 0; i < attVec.size(); ++i )
2344 if ( attVec[i].IsToDelete() )
2345 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2346 attVec[i].attEntry.c_str() );
2348 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2349 attVec[i].attEntry.c_str(),
2350 attVec[i].startSize,
2353 attVec[i].constDist );
2357 QString fullSizeMap;
2358 fullSizeMap = QString("");
2359 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2360 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2361 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2362 fullSizeMap = QString("def f(t): return ") + sizeMap;
2363 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2364 fullSizeMap = QString("def f(): return ") + sizeMap;
2365 MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
2366 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2371 // Enforced vertices
2374 std::string enfName;
2376 std::string groupName = "";
2379 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2380 // 1. Clear all enforced vertices in hypothesis
2381 // 2. Add new enforced vertex according to h_data
2383 if ( h->GetAllEnforcedVertices()->length() > 0 )
2384 h->ClearAllEnforcedVertices();
2387 TEnfVertexList::const_iterator evsIt;
2388 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2390 faceEntry = evmIt->first;
2391 evs = evmIt->second;
2392 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
2393 evsIt = evs.begin();
2394 for ( ; evsIt != evs.end() ; ++evsIt)
2397 if ((*evsIt)->coords.size()) {
2398 x = (*evsIt)->coords[0];
2399 y = (*evsIt)->coords[1];
2400 z = (*evsIt)->coords[2];
2402 ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2406 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2407 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2408 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2409 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2412 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2413 h->ClearPreCadPeriodicityVectors();
2415 MESSAGE("h_data.preCadPeriodicityVector.size(): " << h_data.preCadPeriodicityVector.size());
2416 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2417 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2419 TPreCadPeriodicity periodicity_i = *pIt;
2420 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2421 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2422 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2423 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2424 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2425 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2426 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2427 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2428 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2430 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2431 if (! p1Source.empty())
2433 sourceVertices->length(3);
2434 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2435 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2436 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2440 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2441 if (! p1Target.empty())
2443 targetVertices->length(3);
2444 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2445 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2446 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2450 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2452 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2455 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end periodicity");
2459 catch(const std::exception& ex) {
2460 std::cout << "Exception: " << ex.what() << std::endl;
2463 // catch(const SALOME::SALOME_Exception& ex)
2466 // // SalomeApp_Tools::QtCatchCorbaException(ex);
2469 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end");
2473 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2474 Stores the widgets content to the hypothesis data.
2476 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2478 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
2479 h_data.myName = myName ? myName->text() : "";
2480 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2481 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2482 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2483 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2484 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2485 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2486 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2487 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2488 h_data.myGradation = myStdWidget->myGradation->text().isEmpty() ? -1.0 : myStdWidget->myGradation->GetValue();
2489 h_data.myAllowQuadrangles = myStdWidget->myAllowQuadrangles->isChecked();
2490 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2491 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2492 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2493 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2494 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2495 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2496 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2497 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2498 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2499 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2500 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2501 h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2502 h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2503 h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2504 h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2507 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2508 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2509 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2510 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2511 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2512 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2513 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2514 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2515 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2516 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2517 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2518 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2519 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2520 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2523 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2524 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2525 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2526 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2527 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2528 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2531 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2532 guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2533 guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2534 guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2536 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2537 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
2538 for ( ; row < nbRows; ++row )
2540 int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2541 std::string optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
2542 if ( id >= 0 && ( ( optionType == "BLSURF" && id < myOptions->length() ) || ( optionType == "PRECAD" && id < myPreCADOptions->length() ) ) )
2544 QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
2545 QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
2546 if ( value.isNull() )
2548 if (optionType == "PRECAD")
2549 that->myPreCADOptions[ id ] = ( name + ":" + value).toLatin1().constData();
2551 that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
2553 if ( value != "" ) {
2554 if (optionType == "PRECAD")
2555 guiHyp += "PRECAD_";
2556 guiHyp += name + " = " + value + "; ";
2561 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2562 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2565 row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2566 for ( ; row < nbRows; ++row )
2568 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2569 if ( that->mySMPMap.contains(entry) )
2570 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2573 // Enforced vertices
2574 h_data.enfVertexList.clear();
2575 h_data.faceEntryEnfVertexListMap.clear();
2577 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2578 int nbEnforcedVertices = 0;
2579 std::string groupName = "";
2580 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
2581 for (int i=0 ; i<nbEnforcedShapes ; i++) {
2582 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
2584 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2585 nbEnforcedVertices = shapeItem->childCount();
2586 if (nbEnforcedVertices >0) {
2587 double childValueX,childValueY,childValueZ;
2588 std::string childName, vertexEntry;
2589 QTreeWidgetItem* child;
2592 for (row = 0;row<nbEnforcedVertices;row++) {
2593 child = shapeItem->child(row);
2594 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2595 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2596 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2597 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2598 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2599 // if (myGlobalGroupName->isChecked())
2600 // groupName = myGlobalGroupName->text().toStdString();
2602 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2604 TEnfVertex *enfVertex = new TEnfVertex();
2605 enfVertex->name = childName;
2606 if (vertexEntry.empty()) {
2607 enfVertex->coords.push_back(childValueX);
2608 enfVertex->coords.push_back(childValueY);
2609 enfVertex->coords.push_back(childValueZ);
2612 enfVertex->geomEntry = vertexEntry;
2613 enfVertex->grpName = groupName;
2614 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2615 // if (it == h_data.enfVertexList.end())
2616 h_data.enfVertexList.insert(enfVertex);
2617 evs.insert(enfVertex);
2619 if (groupName != "")
2620 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2623 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2628 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2629 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2632 h_data.preCadPeriodicityVector.clear();
2633 // For each tree item, store each value. Shapes are stored as entries.
2634 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2635 for (size_t i=0 ; i<nbPeriodicityDescriptions ; i++) {
2636 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2637 TPreCadPeriodicity periodicity_i;
2639 for (size_t k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2642 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2644 periodicity_i.push_back(entry);
2646 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2648 guiHyp += "PERIODICITY = yes; ";
2651 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2655 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2657 QMenu* menu = (QMenu*)sender();
2658 // fill popup with option names
2660 QString name_value, name;
2661 if ( myOptions.operator->() ) {
2662 QMenu* blsurfMenu = menu->addMenu(tr("OPTION_MENU_BLSURF"));
2663 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
2664 name_value = myOptions[i].in();
2665 name = name_value.split( ":", QString::KeepEmptyParts )[0];
2666 blsurfMenu->addAction( name );
2669 if ( myPreCADOptions.operator->() ) {
2670 QMenu* preCADmenu = menu->addMenu(tr("OPTION_MENU_PRECAD"));
2671 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
2672 name_value = myPreCADOptions[i].in();
2673 name = name_value.split( ":", QString::KeepEmptyParts )[0];
2674 preCADmenu->addAction( name );
2679 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
2681 myAdvWidget->myOptionTable->setFocus();
2682 QMenu* menu = (QMenu*)( a->parent() );
2684 int idx = menu->actions().indexOf( a );
2685 QString idStr = QString("%1").arg( idx );
2686 QString option, optionType;
2687 if (menu->title() == tr("OPTION_MENU_BLSURF")) {
2688 option = myOptions[idx].in();
2689 optionType = "BLSURF";
2691 else if (menu->title() == tr("OPTION_MENU_PRECAD")) {
2692 option = myPreCADOptions[idx].in();
2693 optionType = "PRECAD";
2695 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
2697 // look for a row with optionName
2698 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
2699 for ( ; row < nbRows; ++row )
2700 if ( myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
2701 if ( myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text() == optionType )
2703 // add a row if not found
2704 if ( row == nbRows ) {
2705 myAdvWidget->myOptionTable->setRowCount( row+1 );
2706 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
2707 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
2708 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( optionType ) );
2709 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
2710 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
2711 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
2712 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
2713 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
2714 Qt::ItemIsEditable |
2715 Qt::ItemIsEnabled );
2716 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2718 myAdvWidget->myOptionTable->clearSelection();
2719 myAdvWidget->myOptionTable->scrollToItem( myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2720 //myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
2721 myAdvWidget->myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
2722 //myAdvWidget->myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2725 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
2727 // clear option values and remember selected row
2728 QList<int> selectedRows;
2729 QList<QTableWidgetItem*> selected = myAdvWidget->myOptionTable->selectedItems();
2730 QTableWidgetItem* item;
2731 foreach( item, selected ) {
2732 int row = item->row();
2733 if ( !selectedRows.contains( row ) ) {
2734 selectedRows.append( row );
2735 int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2736 QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text();
2738 if (optionType == "BLSURF" && id < myOptions->length() )
2739 myOptions[ id ] = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2740 else if (optionType == "PRECAD" && id < myPreCADOptions->length() )
2741 myPreCADOptions[ id ] = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2744 qSort( selectedRows );
2745 QListIterator<int> it( selectedRows );
2747 while ( it.hasPrevious() )
2748 myAdvWidget->myOptionTable->removeRow( it.previous() );
2751 // **********************
2752 // *** BEGIN SIZE MAP ***
2753 // **********************
2755 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2757 if ( myGeomSelWdg2->IsObjectSelected() ){
2758 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2760 else if ( myGeomSelWdg1->IsObjectSelected() ){
2761 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2764 mySMapObject = GEOM::GEOM_Object::_nil();
2766 bool dataAvailable = !mySMapObject->_is_nil();
2768 if ( dataAvailable )
2769 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2771 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2772 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2773 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2774 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2775 ( myATTMap.contains( qEntry )))
2778 QString attEntry = myAttSelWdg->GetValue();
2779 const TAttractorVec& attVec = myATTMap[ qEntry ];
2780 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2781 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2784 addMapButton->setEnabled( !mapExists && dataAvailable );
2785 modifyMapButton->setEnabled( mapExists && dataAvailable );
2788 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2790 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2791 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2792 if (col == SMP_SIZEMAP_COLUMN) {
2793 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2795 if (!mySMPMap.contains(entry))
2797 if ( QTreeWidgetItem* parent = item->parent() )
2801 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2803 if (!mySMPMap.contains(entry))
2806 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2807 CORBA::Object_var obj = entryToObject(entry);
2808 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2809 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2810 // Retrieve values of the selected item in the current tab widgets
2811 const TAttractorVec& attVec = myATTMap[entry];
2812 if ( !attVec.empty() )
2815 if ( !childEntry.isEmpty() )
2816 for ( size_t i = 0; i < attVec.size(); ++i )
2817 if ( childEntry == attVec[i].attEntry.c_str() )
2822 double phySize = attVec[iAtt].startSize;
2823 double infDist = attVec[iAtt].infDist;
2824 double constDist = attVec[iAtt].constDist;
2825 QString attEntry = attVec[iAtt].attEntry.c_str();
2826 CORBA::Object_var attObj = entryToObject(attEntry);
2827 myAttSizeSpin->setValue(phySize);
2828 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2829 myAttDistSpin->setValue(infDist);
2830 myAttractorCheck->setChecked(true);
2833 myAttractorCheck->setChecked(false);
2835 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2836 myAttDistSpin2->setValue(constDist);
2837 myConstSizeCheck->setChecked(true);
2840 myConstSizeCheck->setChecked(false);
2842 myGeomSelWdg2->SetObject(obj);
2843 myAttSelWdg->SetObject(attObj);
2846 else { // CLASSIC MAPS
2847 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2848 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2849 if (!sizeMap.startsWith("def")){
2850 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2856 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2858 getGeomSelectionTool()->selectionMgr()->clearFilters();
2859 if ( sender() == myTabWidget )
2861 myGeomSelWdg1 ->deactivateSelection();
2862 myGeomSelWdg2 ->deactivateSelection();
2863 myAttSelWdg ->deactivateSelection();
2864 myEnfFaceWdg ->deactivateSelection();
2865 myEnfVertexWdg ->deactivateSelection();
2866 myPeriodicitySourceFaceWdg->deactivateSelection();
2867 myPeriodicityTargetFaceWdg->deactivateSelection();
2868 myPeriodicityP1SourceWdg ->deactivateSelection();
2869 myPeriodicityP2SourceWdg ->deactivateSelection();
2870 myPeriodicityP3SourceWdg ->deactivateSelection();
2871 myPeriodicityP1TargetWdg ->deactivateSelection();
2872 myPeriodicityP2TargetWdg ->deactivateSelection();
2873 myPeriodicityP3TargetWdg ->deactivateSelection();
2876 else if ( sender() == smpTab )
2878 myAttDistSpin->setValue(0.); // Reinitialize widgets
2879 myAttSizeSpin->setValue(0.);
2880 myAttDistSpin2->setValue(0.);
2881 mySmpSizeSpin->setValue(0.);
2882 myGeomSelWdg1->deactivateSelection();
2883 myGeomSelWdg2->deactivateSelection();
2884 myAttSelWdg->deactivateSelection();
2885 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2886 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2887 myAttSelWdg->SetObject(CORBA::Object::_nil());
2888 myAttractorCheck->setChecked(false);
2889 myConstSizeCheck->setChecked(false);
2893 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2895 if (state == Qt::Checked){
2896 myAttSelWdg->setEnabled(true);
2897 myAttSizeSpin->setEnabled(true);
2898 myAttSizeLabel->setEnabled(true);
2899 myAttDistSpin->setEnabled(true);
2900 myAttDistLabel->setEnabled(true);
2901 if (!myAttSelWdg->IsObjectSelected()){
2902 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2905 if (state == Qt::Unchecked){
2906 myAttDistSpin->setEnabled(false);
2907 myAttDistLabel->setEnabled(false);
2908 myAttDistSpin->setValue(0.);
2909 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2910 myAttSelWdg->setEnabled(false);
2911 myAttSizeSpin->setEnabled(false);
2912 myAttSizeLabel->setEnabled(false);
2913 myAttDistSpin2->setEnabled(false);
2914 myAttDistLabel2->setEnabled(false);
2916 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2917 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2920 onMapGeomContentModified();
2923 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2925 if (state == Qt::Checked){
2926 myAttSelWdg->setEnabled(true);
2927 myAttSizeSpin->setEnabled(true);
2928 myAttSizeLabel->setEnabled(true);
2929 myAttDistSpin2->setEnabled(true);
2930 myAttDistLabel2->setEnabled(true);
2931 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2932 !myAttSelWdg->IsObjectSelected()){
2933 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2936 if (state == Qt::Unchecked){
2937 myAttDistSpin2->setEnabled(false);
2938 myAttDistLabel2->setEnabled(false);
2939 myAttDistSpin2->setValue(0.);
2940 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2941 myAttSelWdg->setEnabled(false);
2942 myAttSizeSpin->setEnabled(false);
2943 myAttSizeLabel->setEnabled(false);
2944 myAttDistSpin->setEnabled(false);
2945 myAttDistLabel->setEnabled(false);
2947 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2948 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2951 onMapGeomContentModified();
2954 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2956 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
2957 QList<int> selectedRows;
2958 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2959 QTreeWidgetItem* item;
2960 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2962 qSort( selectedRows );
2963 QListIterator<QTreeWidgetItem*> it( selected );
2965 while ( it.hasPrevious() ) {
2966 item = it.previous();
2967 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2968 QString parentEntry;
2969 if ( QTreeWidgetItem* parent = item->parent() )
2970 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2971 if (that->mySMPMap.contains(entry))
2973 that->mySMPMap[entry] = "__TO_DELETE__";
2974 if ( myATTMap.contains( entry ))
2976 TAttractorVec& attVec = myATTMap[entry];
2977 for ( size_t i = 0; i < attVec.size(); ++i )
2978 attVec[i].SetToDelete();
2981 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
2983 TAttractorVec& attVec = myATTMap[parentEntry];
2984 for ( size_t i = 0; i < attVec.size(); ++i )
2986 if ( entry == attVec[i].attEntry.c_str() )
2987 attVec[i].SetToDelete();
2990 if (that->mySMPShapeTypeMap.contains(entry))
2991 that->mySMPShapeTypeMap.remove(entry);
2992 // if (that->myDistMap.contains(entry))
2993 // that->myDistMap.remove(entry);
2994 // if (that->myAttDistMap.contains(entry))
2995 // that->myAttDistMap.remove(entry);
2998 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2999 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
3002 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
3004 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
3005 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
3006 if (col == SMP_SIZEMAP_COLUMN) {
3007 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3008 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
3009 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
3010 MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
3011 if (! that->mySMPShapeTypeMap.contains(entry))
3012 MESSAGE("no such entry in mySMPShapeTypeMap")
3014 if (that->mySMPMap.contains(entry))
3015 if (that->mySMPMap[entry] == sizeMap
3016 || sizeMap.startsWith("Attractor")
3017 || sizeMap.startsWith("Constant") ){
3020 if (! sizeMap.isEmpty()) {
3021 that->mySMPMap[entry] = sizeMap;
3022 sizeMapValidationFromEntry(entry);
3025 MESSAGE("Size map empty: reverse to precedent value" );
3026 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
3028 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
3032 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
3035 if ( smpTab->currentIndex() == ATT_TAB ){
3036 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3037 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3038 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3039 res = insertAttractor(mySMapObject, myAttObject);
3042 if (smpTab->currentIndex() == SMP_STD_TAB ){
3043 if ( myGeomSelWdg1->IsObjectSelected() ){
3044 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3045 res = insertElement(mySMapObject);
3049 // Local size should be more than 0
3050 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3051 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3054 getGeomSelectionTool()->selectionMgr()->clearFilters();
3055 myAttDistSpin->setValue(0.);
3056 myAttSizeSpin->setValue(0.);
3057 myAttDistSpin2->setValue(0.);
3058 mySmpSizeSpin->setValue(0.);
3059 myConstSizeCheck->setChecked(false);
3060 myAttractorCheck->setChecked(false);
3061 myGeomSelWdg1->deactivateSelection();
3062 myGeomSelWdg2->deactivateSelection();
3063 myAttSelWdg->deactivateSelection();
3064 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3065 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3066 myAttSelWdg->SetObject(CORBA::Object::_nil());
3069 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
3071 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
3073 if ( smpTab->currentIndex() == ATT_TAB ){
3074 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3075 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3076 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3077 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
3080 if (smpTab->currentIndex() == SMP_STD_TAB ){
3081 if ( myGeomSelWdg1->IsObjectSelected() ){
3082 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3083 res = insertElement(mySMapObject, /*modify = */true);
3087 // Local size should be more than 0
3088 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3089 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3092 getGeomSelectionTool()->selectionMgr()->clearFilters();
3093 myAttDistSpin->setValue(0.);
3094 myAttSizeSpin->setValue(0.);
3095 myAttDistSpin2->setValue(0.);
3096 mySmpSizeSpin->setValue(0.);
3097 myConstSizeCheck->setChecked(false);
3098 myAttractorCheck->setChecked(false);
3099 myGeomSelWdg1->deactivateSelection();
3100 myGeomSelWdg2->deactivateSelection();
3101 myAttSelWdg->deactivateSelection();
3102 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3103 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3104 myAttSelWdg->SetObject(CORBA::Object::_nil());
3107 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3109 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
3110 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3111 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3113 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3115 TopAbs_ShapeEnum shapeType;
3116 string entry, shapeName;
3117 entry = (string) anObject->GetStudyEntry();
3118 MESSAGE("entry = "<<entry);
3119 shapeName = anObject->GetName();
3120 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3121 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3122 // in order to write the size map with the right syntax in StoreParamsToHypo
3123 // (f(t) for edges, f(u,v) for faces ...)
3124 if (shapeType == TopAbs_COMPOUND){
3125 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3126 TopoDS_Shape childShape;
3127 TopoDS_Iterator anIt(theShape);
3128 for(;anIt.More();anIt.Next()){
3129 childShape = anIt.Value();
3130 shapeType = childShape.ShapeType();
3131 if(!childShape.IsNull()){
3136 mySizeMapTable->setFocus();
3138 shapeEntry = QString::fromStdString(entry);
3139 double phySize = mySmpSizeSpin->value();
3142 return false; // Local size should be more than 0
3144 std::ostringstream oss;
3147 sizeMap = QString::fromStdString(oss.str());
3148 QTreeWidgetItem* item = new QTreeWidgetItem();
3150 int rowToChange = findRowFromEntry(shapeEntry);
3151 item = mySizeMapTable->topLevelItem( rowToChange );
3154 if (that->mySMPMap.contains(shapeEntry)) {
3155 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3156 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3160 mySizeMapTable->addTopLevelItem(item);
3162 that->mySMPMap[shapeEntry] = sizeMap;
3163 //that->myDistMap[shapeEntry] = 0. ;
3164 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3165 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3166 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3167 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3168 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3169 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3170 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3171 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3172 mySizeMapTable->clearSelection();
3174 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3175 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3176 myStdWidget->onPhysicalMeshChanged();
3181 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3183 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
3184 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3185 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3187 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3189 TopAbs_ShapeEnum shapeType;
3190 string entry, attEntry, faceName, attName;
3191 entry = (string) aFace->GetStudyEntry();
3192 attEntry = (string) anAttractor->GetStudyEntry();
3193 faceName = aFace->GetName();
3194 attName = anAttractor->GetName();
3195 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3196 mySizeMapTable->setFocus();
3197 QString shapeEntry = QString::fromStdString(entry);
3198 QString qAttEntry = QString::fromStdString(attEntry);
3200 double phySize = h->GetPhySize();
3201 double infDist = 0. ;
3202 double constDist = 0. ;
3203 phySize = myAttSizeSpin->value();
3206 return false; // Local size should be more than 0
3208 if (myAttractorCheck->isChecked()){
3209 infDist = myAttDistSpin->value();
3211 if (myConstSizeCheck->isChecked()){
3212 constDist = myAttDistSpin2->value();
3214 std::ostringstream oss;
3215 std::ostringstream oss2;
3216 std::ostringstream oss3;
3220 QString sizeMap = QString::fromStdString(oss.str());
3221 QString infDistString = QString::fromStdString(oss2.str());
3222 QString constDistString = QString::fromStdString(oss3.str());
3224 QTreeWidgetItem* item;
3225 QTreeWidgetItem* child;
3226 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3228 int rowToChange = findRowFromEntry(shapeEntry);
3229 item = mySizeMapTable->topLevelItem( rowToChange );
3231 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3232 if (( child = item->child( i )))
3233 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3235 TAttractorVec & attVec = myATTMap[shapeEntry];
3236 for ( size_t i = 0; i < attVec.size(); ++i )
3237 if ( attVec[i].attEntry == attEntry )
3239 attVec[i] = attParams;
3244 // if (that->mySMPMap.contains(shapeEntry)) {
3245 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3246 // // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3250 int rowToChange = findRowFromEntry(shapeEntry);
3251 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3253 item = mySizeMapTable->topLevelItem( rowToChange );
3256 item = new QTreeWidgetItem();
3257 mySizeMapTable->addTopLevelItem(item);
3259 child = new QTreeWidgetItem();
3260 item->addChild(child);
3261 bool exists = false;
3262 TAttractorVec & attVec = myATTMap[shapeEntry];
3263 for ( size_t i = 0; i < attVec.size(); ++i )
3264 if ( attVec[i].attEntry == attEntry )
3266 attVec[i] = attParams;
3271 myATTMap[shapeEntry].push_back( attParams );
3273 mySMPMap.insert(shapeEntry,sizeMap);
3274 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3275 item->setExpanded(true);
3276 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3277 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3278 if (infDist > std::numeric_limits<double>::epsilon()){
3279 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3281 else if (constDist > std::numeric_limits<double>::epsilon()){
3282 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3284 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3286 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3287 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3288 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3290 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3291 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3292 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3294 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3295 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3296 myStdWidget->onPhysicalMeshChanged();
3298 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
3302 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3304 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
3305 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3306 for ( ; row < nbRows; ++row )
3307 if (! sizeMapValidationFromRow(row))
3312 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3314 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
3315 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3316 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3317 mySizeMapTable->setFocus();
3321 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3323 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
3324 MESSAGE("myEntry = "<<myEntry.toStdString())
3326 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3328 if (! that->mySMPMap.contains(myEntry)) {
3329 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
3332 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3333 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
3339 if (that->mySMPMap[myEntry].startsWith("def")) {
3340 // MESSAGE("custom function" );
3341 expr = that->mySMPMap[myEntry].toStdString();
3343 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3344 // MESSAGE("Attractor" );
3345 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)) {
3348 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])" );
3354 // case size map is empty
3355 if (that->mySMPMap[myEntry].isEmpty()) {
3357 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3361 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3362 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3363 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3364 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3365 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3366 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3369 //assert(Py_IsInitialized());
3370 if (! Py_IsInitialized())
3371 throw ("Erreur: Python interpreter is not initialized");
3372 PyGILState_STATE gstate;
3373 gstate = PyGILState_Ensure();
3375 PyObject * obj = NULL;
3376 PyObject* new_stderr = NULL;
3377 string err_description="";
3378 obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3382 new_stderr=newPyStdOut(err_description);
3383 PySys_SetObject((char*)"stderr", new_stderr);
3385 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
3386 Py_DECREF(new_stderr);
3388 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3389 PyGILState_Release(gstate);
3394 PyObject * func = NULL;
3395 func = PyObject_GetAttrString(main_mod, "f");
3399 new_stderr=newPyStdOut(err_description);
3400 PySys_SetObject((char*)"stderr", new_stderr);
3402 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
3403 Py_DECREF(new_stderr);
3405 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3406 PyGILState_Release(gstate);
3410 PyGILState_Release(gstate);
3412 // MESSAGE("SizeMap expression "<<expr<<" is valid");
3417 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3419 return tr( "BLSURF_TITLE" );
3422 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3424 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3427 QString BLSURFPluginGUI_HypothesisCreator::type() const
3429 return tr( "BLSURF_HYPOTHESIS" );
3432 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3434 return "blsurf_hypo_page.html";
3437 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3440 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3442 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3447 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3449 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
3450 SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
3451 CORBA::Object_var obj;
3452 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
3453 if (!aSObj->_is_nil()) {
3454 obj = aSObj->GetObject();
3455 aSObj->UnRegister();
3460 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3461 int endRow = mySizeMapTable->topLevelItemCount()-1;
3463 for ( ; row <= endRow; ++row )
3465 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3466 if (entry == entryForChecking )
3469 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)