1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPluginGUI_HypothesisCreator.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPluginGUI_HypothesisCreator.h"
28 #include "BLSURFPluginGUI_Dlg.h"
30 #include "GeometryGUI.h"
32 #include <SMESHGUI_Utils.h>
33 #include <SMESHGUI_HypothesesUtils.h>
34 #include <SMESHGUI_Dialog.h>
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESH_NumberFilter.hxx"
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Tools.h>
43 #include <QApplication>
47 #include <QHBoxLayout>
48 #include <QHeaderView>
49 #include <QGridLayout>
55 #include <QPushButton>
56 #include <QRadioButton>
58 #include <QTableWidget>
60 #include <QVBoxLayout>
63 #include <QStandardItemModel>
64 #include <QStandardItem>
65 #include <QTreeWidget>
66 #include <QTreeWidgetItem>
67 #include <QModelIndexList>
69 #include <LightApp_SelectionMgr.h>
70 #include <SalomeApp_Application.h>
71 #include <SALOME_ListIO.hxx>
72 #include "SALOME_LifeCycleCORBA.hxx"
74 #include <TopoDS_Shape.hxx>
75 #include <TopoDS_Iterator.hxx>
76 #include <SMESH_Gen_i.hxx>
77 #include <boost/shared_ptr.hpp>
78 #include <boost/algorithm/string.hpp>
79 #include <structmember.h>
98 TBL_MESHING = 0, TBL_PRECAD, TBL_CUSTOM,
100 // Enforced vertices array columns
101 ENF_VER_NAME_COLUMN = 0,
102 ENF_VER_FACE_ENTRY_COLUMN,
106 ENF_VER_ENTRY_COLUMN,
107 ENF_VER_GROUP_COLUMN,
110 PERIODICITY_OBJ_SOURCE_COLUMN = 0,
111 PERIODICITY_OBJ_TARGET_COLUMN,
112 PERIODICITY_P1_SOURCE_COLUMN,
113 PERIODICITY_P2_SOURCE_COLUMN,
114 PERIODICITY_P3_SOURCE_COLUMN,
115 PERIODICITY_P1_TARGET_COLUMN,
116 PERIODICITY_P2_TARGET_COLUMN,
117 PERIODICITY_P3_TARGET_COLUMN,
118 PERIODICITY_SHAPE_TYPE,
120 // PERIODICITY_OBJ_SOURCE_COLUMN = 0,
121 // PERIODICITY_ENTRY_SOURCE_COLUMN,
122 // PERIODICITY_OBJ_TARGET_COLUMN,
123 // PERIODICITY_ENTRY_TARGET_COLUMN,
124 // PERIODICITY_P1_SOURCE_COLUMN,
125 // PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
126 // PERIODICITY_P2_SOURCE_COLUMN,
127 // PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
128 // PERIODICITY_P3_SOURCE_COLUMN,
129 // PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
130 // PERIODICITY_P1_TARGET_COLUMN,
131 // PERIODICITY_P1_ENTRY_TARGET_COLUMN,
132 // PERIODICITY_P2_TARGET_COLUMN,
133 // PERIODICITY_P2_ENTRY_TARGET_COLUMN,
134 // PERIODICITY_P3_TARGET_COLUMN,
135 // PERIODICITY_P3_ENTRY_TARGET_COLUMN,
137 PERIODICITY_NB_COLUMN
163 // Enforced vertices inputs
171 // ENF_VER_GROUP_CHECK,
175 ENF_VER_INTERNAL_ALL_FACES,
176 ENF_VER_INTERNAL_ALL_FACES_GROUP,
177 // ENF_VER_VERTEX_BTN,
178 // ENF_VER_REMOVE_BTN,
179 // ENF_VER_SEPARATOR,
184 /**************************************************
185 Begin initialization Python structures and objects
186 ***************************************************/
196 PyStdOut_dealloc(PyStdOut *self)
202 PyStdOut_write(PyStdOut *self, PyObject *args)
206 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
209 *(self->out)=*(self->out)+c;
215 static PyMethodDef PyStdOut_methods[] = {
216 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
217 PyDoc_STR("write(string) -> None")},
218 {NULL, NULL} /* sentinel */
221 static PyMemberDef PyStdOut_memberlist[] = {
222 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
223 (char*)"flag indicating that a space needs to be printed; used by print"},
224 {NULL} /* Sentinel */
227 static PyTypeObject PyStdOut_Type = {
228 /* The ob_type field must be initialized in the module init function
229 * to be portable to Windows without using C++. */
230 PyObject_HEAD_INIT(NULL)
233 sizeof(PyStdOut), /*tp_basicsize*/
236 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
243 0, /*tp_as_sequence*/
248 PyObject_GenericGetAttr, /*tp_getattro*/
249 /* softspace is writable: we must supply tp_setattro */
250 PyObject_GenericSetAttr, /* tp_setattro */
252 Py_TPFLAGS_DEFAULT, /*tp_flags*/
256 0, /*tp_richcompare*/
257 0, /*tp_weaklistoffset*/
260 PyStdOut_methods, /*tp_methods*/
261 PyStdOut_memberlist, /*tp_members*/
275 PyObject * newPyStdOut( std::string& out )
277 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
282 return (PyObject*)self;
286 /*************************************************
287 End initialization Python structures and objects
288 **************************************************/
292 // BEGIN EnforcedTreeWidgetDelegate
295 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
296 : QItemDelegate(parent)
300 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
301 const QStyleOptionViewItem & option ,
302 const QModelIndex & index ) const
304 QModelIndex father = index.parent();
305 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
307 if (index.column() == ENF_VER_X_COLUMN || \
308 index.column() == ENF_VER_Y_COLUMN || \
309 index.column() == ENF_VER_Z_COLUMN)
311 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
312 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
313 editor->setReadOnly(!entry.isEmpty());
314 editor->setDisabled(!entry.isEmpty());
319 QLineEdit *editor = new QLineEdit(parent);
320 if (index.column() != ENF_VER_GROUP_COLUMN) {
321 editor->setReadOnly(!entry.isEmpty());
322 editor->setDisabled(!entry.isEmpty());
328 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
329 const QModelIndex &index) const
331 QString value = index.model()->data(index, Qt::EditRole).toString();
333 if (index.column() == ENF_VER_X_COLUMN ||
334 index.column() == ENF_VER_Y_COLUMN ||
335 index.column() == ENF_VER_Z_COLUMN)
337 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
338 lineEdit->setText(value);
341 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
342 lineEdit->setText(value);
346 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
347 const QModelIndex &index) const
349 QModelIndex parent = index.parent();
350 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
351 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
352 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
353 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
354 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
355 } else if (index.column() == ENF_VER_NAME_COLUMN) {
356 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
357 QString value = lineEdit->text();
358 if (entry.isEmpty() && !vertexExists(model, index, value))
359 model->setData(index, value, Qt::EditRole);
360 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
361 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
362 QString value = lineEdit->text();
363 if (!vertexExists(model, index, value))
364 model->setData(index, value, Qt::EditRole);
365 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
366 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
367 model->setData(index, lineEdit->text(), Qt::EditRole);
371 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
372 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
374 editor->setGeometry(option.rect);
377 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
378 const QModelIndex &index, QString value) const
381 QModelIndex parent = index.parent();
382 int row = index.row();
383 int col = index.column();
385 if (parent.isValid() && !value.isEmpty()) {
386 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
388 if (col == ENF_VER_X_COLUMN) {
389 x = value.toDouble();
390 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
391 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
393 if (col == ENF_VER_Y_COLUMN) {
394 y = value.toDouble();
395 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
396 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
398 if (col == ENF_VER_Z_COLUMN) {
399 z = value.toDouble();
400 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
401 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
403 int nbChildren = model->rowCount(parent);
404 for (int i = 0 ; i < nbChildren ; i++) {
406 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
407 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
408 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
409 if ((childX == x) && (childY == y) && (childZ == z)) {
416 else if (col == ENF_VER_NAME_COLUMN) {
417 int nbChildren = model->rowCount(parent);
418 for (int i = 0 ; i < nbChildren ; i++) {
420 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
421 if (childName == value) {
434 // END EnforcedTreeWidgetDelegate
439 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
440 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
443 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
444 : SMESHGUI_GenericHypothesisCreator( theHypType )
446 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
447 this->mySMPMap.clear();
449 GeomToolSelected = NULL;
450 GeomToolSelected = getGeomSelectionTool();
452 aSel = GeomToolSelected->selectionMgr();
454 /* Initialize the Python interpreter */
455 if (! Py_IsInitialized())
456 throw ("Error: Python interpreter is not initialized");
457 PyGILState_STATE gstate;
458 gstate = PyGILState_Ensure();
461 main_mod = PyImport_AddModule("__main__");
464 main_dict = PyModule_GetDict(main_mod);
466 PyRun_SimpleString("from math import *");
467 PyGILState_Release(gstate);
471 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
476 * \brief {Get or create the geom selection tool for active study}
478 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() const
480 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
481 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
482 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
483 that->GeomToolSelected = new GeomSelectionTools(aStudy);
485 return that->GeomToolSelected;
488 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
490 return GeometryGUI::GetGeomGen();
493 void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
495 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
496 ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
497 for ( ; anIt != selectionWidgets.end(); anIt++)
499 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
501 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
502 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
503 ListOfWidgets::const_iterator anIt2 = anIt;
504 for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
505 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
507 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
508 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
509 w1->AvoidSimultaneousSelection( w2 );
511 if ( !widgetToActivate )
512 widgetToActivate = w1;
515 if ( widgetToActivate )
516 widgetToActivate->activateSelection();
519 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
521 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
524 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
525 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
529 myAdvWidget->myOptionTable->setFocus();
530 QApplication::instance()->processEvents();
534 int iTbl = 0, nbTbl = myAdvWidget->myOptionTable->topLevelItemCount();
535 for ( ; iTbl < nbTbl; ++iTbl )
537 QTreeWidgetItem* table = myAdvWidget->myOptionTable->topLevelItem( iTbl );
538 int nbRows = table->childCount();
539 for ( int iRow = 0; iRow < nbRows; ++iRow )
541 QTreeWidgetItem* row = table->child( iRow );
542 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
544 if ( name.simplified().isEmpty() )
545 continue; // invalid custom option
547 if ( isDefault ) // not selected option
554 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
557 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
560 h->AddOption( name.toLatin1().constData(), value.toLatin1().constData() );
564 catch ( const SALOME::SALOME_Exception& ex )
566 msg = ex.details.text.in();
575 h->SetOptionValues( myOptions ); // restore values
576 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
580 // SizeMap and attractors
583 mySizeMapTable->setFocus();
584 QApplication::instance()->processEvents();
586 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
587 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
589 for ( ; row < nbRows; ++row )
591 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
592 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
593 MESSAGE("entry ="<<entry.toStdString())
594 if ( !sizeMap.isEmpty() ) {
595 if (that->sizeMapValidationFromRow(row))
598 MESSAGE("entry ="<<entry.toStdString())
599 MESSAGE("sizeMap ="<<sizeMap.toStdString())
601 e = entry.toStdString();
602 s = that->mySMPMap[entry].toStdString();
603 MESSAGE("row = "<<row)
606 h->SetSizeMapEntry( e.c_str(), s.c_str() );
608 catch ( const SALOME::SALOME_Exception& ex )
610 msg = ex.details.text.in();
621 // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
624 // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
625 // So STD_TAB must be current tab to get correct value of it's spinbox.
626 myTabWidget->setCurrentIndex( STD_TAB );
630 if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
631 myStdWidget->myPhySize->text().toDouble() > 0.0 )))
632 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
636 if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
637 myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
638 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
642 if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
643 myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
644 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
648 if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
649 myStdWidget->myChordalError->text().toDouble() > 0.0 )))
650 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
659 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
661 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
663 QFrame* fr = new QFrame( 0 );
664 // fr-> setMinimumSize(600,400);
665 QVBoxLayout* lay = new QVBoxLayout( fr );
666 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
668 lay->setSpacing( 0 );
670 // main TabWidget of the dialog
671 myTabWidget = new QTabWidget( fr );
672 myTabWidget->setTabShape( QTabWidget::Rounded );
673 myTabWidget->setTabPosition( QTabWidget::North );
674 lay->addWidget( myTabWidget );
679 myStdGroup = new QWidget();
680 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
681 aStdLayout->setSpacing( 6 );
682 aStdLayout->setMargin( 11 );
685 myName = new QLineEdit( myStdGroup );
686 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
690 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
691 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
693 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
699 // row = max(row,maxrow)+1;
700 aStdLayout->setRowStretch(row,1);
701 aStdLayout->setColumnStretch(1,1);
705 // advanced parameters
706 myAdvGroup = new QWidget();
707 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
708 anAdvLayout->setSpacing( 6 );
709 anAdvLayout->setMargin( 11 );
710 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
711 //myAdvWidget->addBtn->setMenu( new QMenu() );
712 anAdvLayout->addWidget( myAdvWidget );
715 // Size Maps parameters
717 mySmpGroup = new QWidget();
718 // mySmpGroup->setMinimumWidth(500);
721 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
724 mySizeMapTable = new QTreeWidget( mySmpGroup );
725 mySizeMapTable ->setMinimumWidth(200);
726 QStringList sizeMapHeaders;
727 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
728 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
729 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
730 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
731 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
732 mySizeMapTable->setAlternatingRowColors(true);
735 smpTab = new QTabWidget( mySmpGroup );
736 smpTab->setTabShape( QTabWidget::Rounded );
737 smpTab->setTabPosition( QTabWidget::South );
738 lay->addWidget( smpTab );
740 // Filters of selection
741 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
743 SM_ShapeTypes.Add( TopAbs_VERTEX );
744 SM_ShapeTypes.Add( TopAbs_EDGE );
745 SM_ShapeTypes.Add( TopAbs_FACE );
746 SM_ShapeTypes.Add( TopAbs_COMPOUND );
748 ATT_ShapeTypes.Add( TopAbs_VERTEX );
749 ATT_ShapeTypes.Add( TopAbs_EDGE );
750 ATT_ShapeTypes.Add( TopAbs_WIRE );
751 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
753 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
754 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
755 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
757 // Standard size map tab
758 mySmpStdGroup = new QWidget();
759 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
760 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false);
761 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
762 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
763 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
764 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
767 myAttractorGroup = new QWidget();
768 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
769 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false);
770 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
771 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
772 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
773 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
774 QFrame* attLine = new QFrame(myAttractorGroup);
775 attLine->setFrameShape(QFrame::HLine);
776 attLine->setFrameShadow(QFrame::Sunken);
777 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false);
778 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
779 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
780 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
781 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
782 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
783 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
784 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
785 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
786 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
787 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
789 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
790 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
794 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
795 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
796 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
797 modifyMapButton->setEnabled(false);
800 myAttSelWdg->setEnabled(false);
801 myAttSizeSpin->setEnabled(false);
802 myAttSizeLabel->setEnabled(false);
803 myAttDistSpin->setEnabled(false);
804 myAttDistLabel->setEnabled(false);
805 myAttDistSpin2->setEnabled(false);
806 myAttDistLabel2->setEnabled(false);
807 myAttDistSpin->setValue(0.);
808 myAttDistSpin2->setValue(0.);
809 myAttSizeSpin->setValue(0.);
810 mySmpSizeSpin->setValue(0.);
813 // ADD WIDGETS (SIZEMAP TAB)
814 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
815 anSmpLayout->setColumnStretch(0, 1);
816 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
817 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
818 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
819 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
820 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
821 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
824 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
825 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
826 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
827 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
830 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
831 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
832 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
833 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
834 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
835 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
836 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
837 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
838 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
839 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
840 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
841 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
843 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
844 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
846 smpTab->setCurrentIndex( SMP_STD_TAB );
848 // Enforced vertices parameters
849 myEnfGroup = new QWidget();
850 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
852 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
853 // anEnfLayout->addWidget(myEnforcedVertexWidget);
854 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
855 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
857 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
858 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
859 myEnforcedTreeWidget->setSortingEnabled(true);
860 QStringList enforcedHeaders;
861 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
862 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
863 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
865 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
866 myEnforcedTreeWidget->header()->setStretchLastSection(true);
867 myEnforcedTreeWidget->setAlternatingRowColors(true);
868 myEnforcedTreeWidget->setUniformRowHeights(true);
869 myEnforcedTreeWidget->setAnimated(true);
870 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
871 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
872 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
873 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
874 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
876 myEnforcedTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
878 myEnforcedTreeWidget->resizeColumnToContents(column);
880 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
881 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
882 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
884 // FACE AND VERTEX SELECTION
885 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
886 shapeTypes1.Add( TopAbs_FACE );
887 shapeTypes1.Add( TopAbs_COMPOUND );
888 shapeTypes2.Add( TopAbs_VERTEX );
889 shapeTypes2.Add( TopAbs_COMPOUND );
891 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
892 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true);
893 myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
895 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
896 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
897 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
899 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
901 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
902 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
903 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
905 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
906 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
907 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
909 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
910 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
911 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
913 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
914 myGroupName = new QLineEdit(myEnfGroup);
916 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
917 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
919 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
921 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
922 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
924 // myGlobalGroupName = new QCheckBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
925 // myGlobalGroupName->setChecked(false);
927 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
928 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
929 // FACE AND VERTEX SELECTION
930 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
931 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
932 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
933 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
934 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
935 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
936 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
937 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
938 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
939 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
940 // anEnfLayout2->addWidget(myGlobalGroupName, ENF_VER_GROUP_CHECK, 0, 1, 2);
941 // anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
942 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
943 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
944 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
945 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
946 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
947 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
948 // anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
949 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
950 // anEnfLayout->setRowStretch(1, 1);
953 // Periodicity parameters
954 myPeriodicityGroup = new QWidget();
955 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
957 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
958 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
959 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
961 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
963 QStringList myPeriodicityTreeHeaders;
964 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
965 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
966 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
967 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
968 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
969 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
970 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
971 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
972 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
973 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
975 // Hide the vertex name to make the widget more readable
976 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
977 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
978 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
979 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
980 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
981 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
982 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
985 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
986 myPeriodicityTreeWidget->setSortingEnabled(true);
988 myPeriodicityTreeWidget->setAlternatingRowColors(true);
989 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
990 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
992 size_t periodicityVisibleColumns = 2;
993 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
994 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
995 myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
997 myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
999 myPeriodicityTreeWidget->resizeColumnToContents(column);
1001 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
1003 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
1005 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
1007 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
1008 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
1009 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
1011 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
1013 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
1014 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
1016 myPeriodicityOnFaceRadioButton->setChecked(true);
1018 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
1019 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
1022 // FACE, EDGE AND VERTEX SELECTION
1023 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
1024 shapeTypesFace.Add( TopAbs_FACE );
1025 shapeTypesFace.Add( TopAbs_EDGE );
1026 shapeTypesFace.Add( TopAbs_COMPOUND );
1027 shapeTypesEdge.Add( TopAbs_EDGE );
1028 shapeTypesEdge.Add( TopAbs_COMPOUND );
1030 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
1032 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1033 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1035 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1036 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false);
1037 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1038 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1040 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1041 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1042 // myPeriodicitySourceEdgeWdg->hide();
1043 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1045 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1046 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1048 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1049 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false);
1050 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1051 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1053 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1054 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1055 // myPeriodicityTargetEdgeWdg->hide();
1056 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1058 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1059 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1060 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1062 myPeriodicityGroupBox2->setCheckable(true);
1063 myPeriodicityGroupBox2->setChecked(false);
1065 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1066 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1068 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1069 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1072 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1073 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1076 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1077 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false);
1078 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1081 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1082 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1084 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1085 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false);
1086 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1089 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1090 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1092 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1093 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false);
1094 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1097 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1098 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1100 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1101 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false);
1102 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1105 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1106 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1108 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1109 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false);
1110 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1113 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1114 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1116 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1117 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false);
1118 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1120 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1121 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1124 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1125 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1127 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1128 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1130 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1132 myPeriodicitySelectionWidgets.clear();
1133 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1134 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1135 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1136 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1137 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1138 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1139 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1140 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1141 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1144 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1145 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1146 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1147 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1148 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1150 myTabWidget->setCurrentIndex( STD_TAB );
1152 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
1153 connect( myStdWidget->myAllowQuadrangles, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChange() ));
1156 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1157 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1158 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1159 // connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1160 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1161 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1162 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1163 connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1164 // connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1165 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1166 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1167 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1168 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1169 connect( myTabWidget, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1171 // Enforced vertices
1172 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1173 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1174 // connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1175 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1176 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1177 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1178 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1179 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1180 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1181 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1184 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1185 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1186 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1187 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1189 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1190 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1192 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1193 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1196 // connect( myPeriodicitySourceFaceWdg, SIGNAL(contentModified()), this, SLOT(onPeriodicityContentModified()));
1200 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1201 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1203 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1205 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1206 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1207 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1208 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1209 // myEnfFaceWdg->deactivateSelection();
1210 // myEnfVertexWdg->deactivateSelection();
1214 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1216 myStdWidget->onPhysicalMeshChanged();
1220 * This method resets the content of the X, Y, Z widgets;
1222 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1224 myXCoord->setCleared(true);
1225 myYCoord->setCleared(true);
1226 myZCoord->setCleared(true);
1227 myXCoord->setText("");
1228 myYCoord->setText("");
1229 myZCoord->setText("");
1230 // myGroupName->setText("");
1233 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1234 This method updates the tooltip of a modified item. The QLineEdit widgets content
1235 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1237 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1238 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1239 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1240 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1241 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1242 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1243 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1244 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1245 QTreeWidgetItem* parent = item->parent();
1247 clearEnforcedVertexWidgets();
1249 if (parent && (!x.isNull() || !entry.isNull())) {
1250 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1251 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1252 if (entry.isNull()) {
1253 toolTip += QString("(") + x.toString();
1254 toolTip += QString(", ") + y.toString();
1255 toolTip += QString(", ") + z.toString();
1256 toolTip += QString(")");
1259 if (!groupName.isEmpty())
1260 toolTip += QString(" [") + groupName + QString("]");
1262 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1265 myXCoord->SetValue(x.toDouble());
1266 myYCoord->SetValue(y.toDouble());
1267 myZCoord->SetValue(z.toDouble());
1270 if (!groupName.isEmpty())
1271 myGroupName->setText(groupName);
1275 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1276 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1277 clearEnforcedVertexWidgets();
1278 if (nbSelEnfVertex == 1)
1280 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1283 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1284 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1285 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1286 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1287 if (CORBA::is_nil(measureOp))
1290 CORBA::Double x,y,z;
1291 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1292 if ( measureOp->IsDone() )
1294 myXCoord->SetValue(x);
1295 myYCoord->SetValue(y);
1296 myZCoord->SetValue(z);
1302 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1303 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1304 of the enforced vertex clicked in the tree widget.
1306 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1307 clearEnforcedVertexWidgets();
1308 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1309 if (! items.isEmpty() && items.size() == 1) {
1310 QTreeWidgetItem *item = items[0];
1311 // for (int i=0 ; i < items.size() ; i++) {
1313 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1314 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1315 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1316 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1317 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1318 if (!x.isNull()/* && entry.isNull()*/) {
1319 myXCoord->SetValue(x.toDouble());
1320 myYCoord->SetValue(y.toDouble());
1321 myZCoord->SetValue(z.toDouble());
1324 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1325 myGroupName->setText(group.toString());
1330 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1331 This method adds a face containing enforced vertices in the tree widget.
1333 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1334 // Find theFaceEntry item
1335 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1336 QTreeWidgetItem* theItem;
1337 if (theItemList.empty()) {
1338 theItem = new QTreeWidgetItem();
1339 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1340 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1341 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1342 myEnforcedTreeWidget->addTopLevelItem(theItem);
1345 theItem = theItemList[0];
1350 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1351 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1353 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(QTreeWidgetItem* theItem, double x, double y, double z,
1354 std::string vertexName, std::string geomEntry, std::string groupName) {
1356 std::string theFaceName = theItem->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
1357 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1358 bool okToCreate = true;
1360 const int nbVert = theItem->childCount();
1361 // MESSAGE("Number of child rows: " << nbVert);
1363 double childValueX,childValueY,childValueZ;
1364 QString childEntry, childGroupName;
1365 QTreeWidgetItem* child;
1366 for (int row = 0;row<nbVert;row++) {
1367 child = theItem->child(row);
1368 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1369 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1370 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1371 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1372 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1373 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1374 // update group name
1375 if (childGroupName.toStdString() != groupName) {
1376 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1377 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1385 if (geomEntry.empty()) {
1386 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1389 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1394 if (geomEntry.empty()) {
1395 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1398 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1401 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1402 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1403 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1404 QSize iconSize = iconSelect.size()*0.7;
1406 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1407 QString myVertexName;
1409 while(indexRef != vertexIndex) {
1410 indexRef = vertexIndex;
1411 if (vertexName.empty())
1412 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1414 myVertexName = QString(vertexName.c_str());
1416 for (int row = 0;row<nbVert;row++) {
1417 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1418 if (myVertexName == name) {
1424 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1425 if (geomEntry.empty()) {
1426 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1427 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1428 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1431 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1432 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1434 if (groupName != "")
1435 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1437 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1438 if (geomEntry.empty()) {
1439 toolTip += QString(" (%1, ").arg(x);
1440 toolTip += QString("%1, ").arg(y);
1441 toolTip += QString("%1)").arg(z);
1443 if (groupName != "")
1444 toolTip += QString(" [%1]").arg(groupName.c_str());
1446 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1447 theItem->setExpanded(true);
1448 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1451 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1452 This method is called when a item is added into the enforced vertices tree widget
1454 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1455 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1457 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1459 getGeomSelectionTool()->selectionMgr()->clearFilters();
1460 myEnfFaceWdg->deactivateSelection();
1461 myEnfVertexWdg->deactivateSelection();
1463 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1464 myEnforcedTreeWidget->resizeColumnToContents(column);
1467 int selEnfFace = myEnfFaceWdg->NbObjects();
1468 int selEnfVertex = myEnfVertexWdg->NbObjects();
1469 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1471 if (selEnfFace == 0)
1474 if ((selEnfVertex == 0) && coordsEmpty)
1477 string entry, shapeName;
1479 for (int i = 0 ; i < selEnfFace ; i++) {
1480 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1481 entry = myEnfFace->GetStudyEntry();
1482 shapeName = myEnfFace->GetName();
1484 QTreeWidgetItem * faceItem = addEnforcedFace(entry, shapeName);
1486 std::string groupName = myGroupName->text().toStdString();
1488 if (boost::trim_copy(groupName).empty())
1491 if (selEnfVertex <= 1)
1494 x = myXCoord->GetValue();
1495 y = myYCoord->GetValue();
1496 z = myZCoord->GetValue();
1497 if (selEnfVertex == 1) {
1498 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1499 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1502 addEnforcedVertex(faceItem, x, y, z, "", "", groupName);
1506 if ( CORBA::is_nil(getGeomEngine()))
1509 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1510 if (CORBA::is_nil(measureOp))
1513 CORBA::Double x,y,z;
1515 for (int j = 0 ; j < selEnfVertex ; j++)
1517 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1518 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1519 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1520 if ( measureOp->IsDone() )
1521 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1522 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1523 addEnforcedVertex(faceItem, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1529 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1530 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1532 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1533 myEnforcedTreeWidget->resizeColumnToContents(column);
1535 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1536 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1537 myStdWidget->onPhysicalMeshChanged();
1541 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1542 This method is called when a item is removed from the enforced vertices tree widget
1544 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1545 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1546 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1547 QList<QTreeWidgetItem *> selectedVertices;
1548 QSet<QTreeWidgetItem *> selectedEntries;
1549 QTreeWidgetItem* item;
1551 foreach( item, selectedItems ) {
1552 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1553 if (! value.isNull())
1554 selectedVertices.append(item);
1556 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1557 if (! value.isNull())
1558 selectedVertices.append(item);
1560 selectedEntries.insert(item);
1564 foreach(item,selectedVertices) {
1565 QTreeWidgetItem* parent = item->parent();
1566 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1567 parent->removeChild(item);
1569 if (parent->childCount() == 0) {
1570 if (selectedEntries.contains(parent))
1571 selectedEntries.remove(parent);
1576 foreach(item,selectedEntries) {
1577 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1581 myEnforcedTreeWidget->selectionModel()->clearSelection();
1585 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1587 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1590 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1591 This method is called when a item is added into the periodicity table widget
1593 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1594 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1596 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1598 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1599 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1600 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1602 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1603 w1->deactivateSelection();
1607 // Source-Target selection
1608 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1609 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1611 if (selSource == 0 || selTarget == 0)
1614 // Vertices selection
1615 if (myPeriodicityGroupBox2->isChecked())
1617 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1618 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1619 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1620 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1621 //int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1622 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1624 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1626 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1627 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1632 // Add Source-Target in table
1633 string shapeEntry, sourceEntry, targetEntry;
1634 string shapeName, sourceName, targetName;
1635 GEOM::GEOM_Object_var shape;
1637 QTreeWidgetItem* item = new QTreeWidgetItem();
1638 myPeriodicityTreeWidget->addTopLevelItem(item);
1640 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1644 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1646 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1647 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1648 shapeName = shape->GetName();
1649 shapeEntry = shape->GetStudyEntry();
1650 item->setData(k, Qt::EditRole, shapeName.c_str() );
1651 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1652 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1656 // Add shape type in tree
1657 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1658 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1660 // Blank input fields
1661 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1663 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1664 w1->SetObject(GEOM::GEOM_Object::_nil());
1667 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1668 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1672 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1673 This method is called when a item is removed from the periodicity tree widget
1675 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1676 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1677 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1678 QTreeWidgetItem* item;
1680 foreach(item,selectedItems) {
1681 MESSAGE("Remove " << item->text(0).toStdString());
1685 myEnforcedTreeWidget->selectionModel()->clearSelection();
1688 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1689 This method enable clears the field for periodicity by vertices
1691 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1695 for (int k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1697 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1698 w1->deactivateSelection();
1699 w1->SetObject(CORBA::Object::_nil());
1704 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1705 This method enable the proper shape selection widget to Face or Edge shapes
1707 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1709 // if (myPeriodicityOnFaceRadioButton->isChecked())
1711 // MESSAGE("Show Face");
1712 // myPeriodicitySourceEdgeWdg->hide();
1713 // myPeriodicityTargetEdgeWdg->hide();
1714 // myPeriodicitySourceFaceWdg->show();
1715 // myPeriodicityTargetFaceWdg->show();
1719 // MESSAGE("Show Edge");
1720 // myPeriodicitySourceFaceWdg->hide();
1721 // myPeriodicityTargetFaceWdg->hide();
1722 // myPeriodicitySourceEdgeWdg->show();
1723 // myPeriodicityTargetEdgeWdg->show();
1727 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1729 QString shapeName, shapeEntry;
1730 CORBA::Object_var shape;
1732 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1733 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1735 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1737 shapeName = item->data(k, Qt::EditRole).toString();
1738 shapeEntry = item->data(k, Qt::UserRole).toString();
1739 if (! shapeEntry.isEmpty())
1741 shape = entryToObject(shapeEntry);
1742 w1->SetObject(shape);
1743 w1->deactivateSelection();
1745 myPeriodicityGroupBox2->setChecked(1);
1748 myPeriodicityGroupBox2->setChecked(0);
1751 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1752 myPeriodicityOnFaceRadioButton->setChecked(true);
1754 myPeriodicityOnEdgeRadioButton->setChecked(true);
1759 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1760 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1762 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1764 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1766 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1768 // find wich selection widget is activated
1769 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1771 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1772 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1774 // don't activate vertex selection if the group box is not checked
1775 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1777 // clear the selection, to avoid to put the same object in the other widget
1778 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1779 // activate the next widget
1780 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1781 w2->activateSelection();
1788 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1789 This method updates the GUI widgets with the hypothesis data
1791 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1793 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1794 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1796 BlsurfHypothesisData data;
1797 that->readParamsFromHypo( data );
1800 myName->setText( data.myName );
1801 QFontMetrics metrics( myName->font() );
1802 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1804 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1805 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1806 if (data.myPhySize <= 0)
1807 myStdWidget->myPhySize->setText("");
1809 myStdWidget->myPhySize->SetValue( data.myPhySize );
1810 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1811 if (data.myMinSize < 0)
1812 myStdWidget->myMinSize->setText("");
1814 myStdWidget->myMinSize->SetValue( data.myMinSize );
1815 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1816 if (data.myMaxSize < 0)
1817 myStdWidget->myMaxSize->setText("");
1819 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1820 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1821 myStdWidget->myUseGradation->setChecked( data.myUseGradation );
1822 if (data.myGradation <= 0 || !data.myUseGradation )
1823 myStdWidget->myGradation->setText("");
1825 myStdWidget->myGradation->SetValue( data.myGradation );
1826 myStdWidget->myUseVolumeGradation->setChecked( data.myUseVolumeGradation );
1827 if (data.myVolumeGradation <= 0 || !data.myUseVolumeGradation )
1828 myStdWidget->myVolumeGradation->setText("");
1830 myStdWidget->myVolumeGradation->SetValue( data.myVolumeGradation );
1831 myStdWidget->myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1833 if (data.myAngleMesh < 0)
1834 myStdWidget->myAngleMesh->setText("");
1836 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1837 if (data.myChordalError <= 0)
1838 myStdWidget->myChordalError->setText("");
1840 myStdWidget->myChordalError->SetValue( data.myChordalError );
1841 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1842 if (data.myAnisotropicRatio <= 0)
1843 myStdWidget->myAnisotropicRatio->setText("");
1845 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1846 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1847 if (data.myTinyEdgeLength <= 0)
1848 myStdWidget->myTinyEdgeLength->setText("");
1850 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1851 myStdWidget->myOptimiseTinyEdges->setChecked( data.myOptimiseTinyEdges );
1852 if (data.myTinyEdgeOptimisLength <= 0)
1853 myStdWidget->myTinyEdgeOptimisLength->setText("");
1855 myStdWidget->myTinyEdgeOptimisLength->SetValue( data.myTinyEdgeOptimisLength );
1856 myStdWidget->myCorrectSurfaceIntersection->setChecked( data.myCorrectSurfaceIntersection );
1857 if (data.myCorrectSurfaceIntersectionMaxCost <= 0)
1858 myStdWidget->myCorrectSurfaceIntersectionMaxCost->setText("");
1860 myStdWidget->myCorrectSurfaceIntersectionMaxCost->SetValue( data.myCorrectSurfaceIntersectionMaxCost );
1861 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1862 if (data.myBadElementAspectRatio <= 0)
1863 myStdWidget->myBadElementAspectRatio->setText("");
1865 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1866 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1867 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1869 myStdWidget->resizeWidgets();
1871 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1873 if ( myOptions.operator->() ) {
1874 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1875 myAdvWidget->AddOption( TBL_MESHING, that->myOptions[i].in() );
1877 if ( myPreCADOptions.operator->() ) {
1878 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i )
1879 myAdvWidget->AddOption( TBL_PRECAD, that->myPreCADOptions[i].in() );
1881 if ( myCustomOptions.operator->() ) {
1882 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1883 myAdvWidget->AddOption( TBL_CUSTOM, that->myCustomOptions[i].in() );
1885 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1886 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1887 // myGMFFileMode->setChecked(data.myGMFFileMode);
1890 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1891 QMapIterator<QString, QString> i(that->mySMPMap);
1892 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1893 while (i.hasNext()) {
1895 const QString entry = i.key();
1896 const QString sizeMap = i.value();
1897 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1898 //int row = mySizeMapTable->topLevelItemCount();
1899 QTreeWidgetItem* item = new QTreeWidgetItem();
1900 mySizeMapTable->addTopLevelItem( item );
1901 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1902 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1903 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1904 if (that->myATTMap.contains(entry)) {
1905 TAttractorVec & attVec = that->myATTMap[entry];
1906 for ( size_t i = 0; i < attVec.size(); ++i )
1908 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
1909 QTreeWidgetItem* child = new QTreeWidgetItem();
1910 item->addChild( child );
1911 item->setExpanded(true);
1912 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
1913 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
1914 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
1916 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
1917 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
1920 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
1926 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1929 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1930 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1931 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1933 // Enforced vertices
1934 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1935 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1937 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1938 TEntry entry = (*evmIt).first;
1939 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1940 MESSAGE("Face entry: " << entry);
1941 MESSAGE("Face name: " << shapeName);
1943 QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1945 TEnfVertexList evs = (*evmIt).second;
1947 TEnfVertexList::const_iterator evsIt = evs.begin();
1948 TEnfVertex *enfVertex;
1949 for ( ; evsIt != evs.end() ; ++evsIt) {
1950 enfVertex = (*evsIt);
1951 MESSAGE("Name: " << enfVertex->name);
1952 double x = 0, y = 0, z = 0;
1953 if (enfVertex->coords.size()) {
1954 x = enfVertex->coords[0];
1955 y = enfVertex->coords[1];
1956 z = enfVertex->coords[2];
1958 that->addEnforcedVertex(faceItem, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1962 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1963 myEnforcedTreeWidget->resizeColumnToContents(column);
1965 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1966 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1967 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1970 MESSAGE("retrieveParams(): periodicity ");
1973 // Add an item in the tree widget for each association
1974 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
1976 QTreeWidgetItem* item = new QTreeWidgetItem();
1977 myPeriodicityTreeWidget->addTopLevelItem(item);
1978 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1979 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
1980 for (size_t k=0; k<periodicity_i.size(); k++)
1982 string shapeEntry = periodicity_i[k];
1983 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
1984 item->setData(k, Qt::EditRole, shapeName.c_str() );
1985 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1990 that->myStdWidget->onPhysicalMeshChanged();
1991 that->myStdWidget->onGeometricMeshChanged();
1992 that->onStateChange();
1995 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1996 This method updates the hypothesis data with the GUI widgets content.
1998 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
2000 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParams");
2001 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2003 BlsurfHypothesisData data;
2004 QString guiHyp = that->readParamsFromWidgets( data );
2005 that->storeParamsToHypo( data );
2010 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
2011 Updates the hypothesis data from hypothesis values.
2013 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
2015 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
2016 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2017 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2019 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
2020 h_data.myName = isCreation() && data ? hypName() : "";
2022 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
2023 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
2024 h_data.myPhySize = h->GetPhySize();
2025 h_data.myPhySizeRel = h->IsPhySizeRel();
2026 double minSize = h->GetMinSize();
2027 double maxSize = h->GetMaxSize();
2028 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2029 h_data.myMinSizeRel = h->IsMinSizeRel();
2030 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2031 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2032 h_data.myUseGradation = h->GetUseGradation();
2033 h_data.myGradation = h->GetGradation();
2034 h_data.myUseVolumeGradation = h->GetUseVolumeGradation();
2035 h_data.myVolumeGradation = h->GetVolumeGradation();
2036 h_data.myAllowQuadrangles = h->GetQuadAllowed();
2037 double angle = h->GetAngleMesh();
2038 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2039 double chordalError = h->GetChordalError();
2040 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2041 h_data.myAnisotropic = h->GetAnisotropic();
2042 double myAnisotropicRatio = h->GetAnisotropicRatio();
2043 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2044 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2045 double myTinyEdgeLength = h->GetTinyEdgeLength();
2046 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2047 h_data.myOptimiseTinyEdges = h->GetOptimiseTinyEdges();
2048 double myTinyEdgeOptimisLength = h->GetTinyEdgeOptimisationLength();
2049 h_data.myTinyEdgeOptimisLength = myTinyEdgeOptimisLength > 0 ? myTinyEdgeOptimisLength : -1.0;
2050 h_data.myCorrectSurfaceIntersection = h->GetCorrectSurfaceIntersection();
2051 double corrSurfaceIntersMaxCost = h->GetCorrectSurfaceIntersectionMaxCost();
2052 h_data.myCorrectSurfaceIntersectionMaxCost = corrSurfaceIntersMaxCost > 0 ? corrSurfaceIntersMaxCost : -1.0;
2053 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2054 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2055 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2056 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2057 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2058 h_data.myVerbosity = h->GetVerbosity();
2059 //h_data.myTopology = (int) h->GetTopology();
2060 //h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2061 // h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2062 // h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2065 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2066 that->myOptions = h->GetOptionValues();
2067 that->myPreCADOptions = h->GetPreCADOptionValues();
2068 that->myCustomOptions = h->GetAdvancedOptionValues();
2070 h_data.myGMFFileName = h->GetGMFFile();
2071 // h_data.myGMFFileMode = h->GetGMFFileMode();
2073 that->mySMPMap.clear();
2074 that->myATTMap.clear();
2075 // that->myAttDistMap.clear();
2076 // that->myDistMap.clear();
2078 // classic size maps
2079 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2080 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
2081 QString fullSizeMaps;
2082 QStringList fullSizeMapList;
2083 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2084 for ( CORBA::ULong i = 0;i<mySizeMaps->length(); ++i ) {
2085 fullSizeMaps = mySizeMaps[i].in();
2086 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
2087 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2088 if ( fullSizeMapList.count() > 1 ) {
2089 string fullSizeMap = fullSizeMapList[1].toStdString();
2090 int pos = fullSizeMap.find("return")+7;
2091 // MESSAGE("pos:" << pos);
2094 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2099 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2100 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
2101 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2102 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
2108 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2109 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
2111 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2112 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2113 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2114 if ( fullCustomSizeMapList.count() > 1 ) {
2115 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2116 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2117 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
2118 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
2123 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2124 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
2126 for ( CORBA::ULong i = 0;i<allMyAttractors->length(); ++i ) {
2127 QString myAttractors = allMyAttractors[i].in();
2128 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2129 if ( myAttractorList.count() > 1 ) {
2130 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2131 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2132 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
2133 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
2137 // attractor new version
2138 MESSAGE("readParamsFromHypo, Attractors")
2139 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2140 for ( CORBA::ULong i = 0;i<allMyAttractorParams->length(); ++i ) {
2141 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2142 QString faceEntry = myAttractorParams.faceEntry.in();
2143 QString attEntry = myAttractorParams.attEntry.in();
2144 MESSAGE("attEntry = "<<attEntry.toStdString())
2145 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2146 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2147 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2148 myAttractorParams.startSize,
2149 myAttractorParams.infDist,
2150 myAttractorParams.constDist ));
2153 // Enforced vertices
2154 h_data.enfVertexList.clear();
2155 h_data.faceEntryEnfVertexListMap.clear();
2157 h_data.groupNameEnfVertexListMap.clear();
2160 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2161 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
2163 for ( CORBA::ULong i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
2164 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2165 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
2166 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2167 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
2169 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
2171 for (CORBA::ULong j=0 ; j<vertexList.length(); ++j) {
2172 TEnfVertex *enfVertex = new TEnfVertex();
2174 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
2175 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
2176 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
2177 for (CORBA::ULong k=0 ; k< vertexList[j].coords.length();k++)
2178 enfVertex->coords.push_back(vertexList[j].coords[k]);
2180 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2183 if (groupName != "") {
2184 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2188 // h_data.enfVertMap[entry] = evs;
2189 // h_data.entryCoordsListMap[entry] = coordsList;
2191 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2192 h_data.faceEntryEnfVertexListMap.erase(entry);
2195 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2196 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2199 MESSAGE("readParamsFromHypo, Periodicity")
2201 h_data.preCadPeriodicityVector.clear();
2203 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2204 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2206 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2207 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2211 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2212 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2215 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2217 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2218 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2219 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2221 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2222 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2224 if (sourceVertices.length()!=0)
2226 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2227 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2228 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2231 if (targetVertices.length()!=0)
2233 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2234 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2235 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2239 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2241 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2243 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2247 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2248 Saves the hypothesis data to hypothesis values.
2250 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2252 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
2253 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2254 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2260 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2262 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2263 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2264 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2265 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2267 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2268 if ( h->GetPhySize() != h_data.myPhySize ||
2269 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2270 if ( h_data.myPhySizeRel )
2271 h->SetPhySizeRel( h_data.myPhySize );
2273 h->SetPhySize( h_data.myPhySize );
2276 if (h->GetMinSize() != h_data.myMinSize ||
2277 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2278 if ( h_data.myMinSizeRel )
2279 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2281 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2283 if (h->GetMaxSize() != h_data.myMaxSize ||
2284 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2285 if ( h_data.myMaxSizeRel )
2286 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2288 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2290 if ( h->GetUseGradation() != h_data.myUseGradation )
2291 h->SetUseGradation( h_data.myUseGradation );
2292 if ( h->GetGradation() != h_data.myGradation )
2293 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2294 if ( h->GetUseVolumeGradation() != h_data.myUseVolumeGradation )
2295 h->SetUseVolumeGradation( h_data.myUseVolumeGradation );
2296 if ( h->GetVolumeGradation() != h_data.myVolumeGradation )
2297 h->SetVolumeGradation( h_data.myVolumeGradation <= 0 ? -1 : h_data.myVolumeGradation );
2299 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
2300 h->SetQuadAllowed( h_data.myAllowQuadrangles );
2302 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2303 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2304 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2305 if ( h->GetChordalError() != h_data.myChordalError )
2306 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2309 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2310 h->SetAnisotropic( h_data.myAnisotropic );
2311 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2312 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2314 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2315 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2316 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2317 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2319 if ( h->GetOptimiseTinyEdges() != h_data.myOptimiseTinyEdges )
2320 h->SetOptimiseTinyEdges( h_data.myOptimiseTinyEdges );
2321 if ( h_data.myOptimiseTinyEdges && ( h->GetTinyEdgeOptimisationLength() != h_data.myTinyEdgeOptimisLength ) )
2322 h->SetTinyEdgeOptimisationLength( h_data.myTinyEdgeOptimisLength <= 0 ? -1 :h_data.myTinyEdgeOptimisLength );
2323 if ( h->GetCorrectSurfaceIntersection() != h_data.myCorrectSurfaceIntersection )
2324 h->SetCorrectSurfaceIntersection( h_data.myCorrectSurfaceIntersection );
2325 if ( h_data.myCorrectSurfaceIntersection && ( h->GetCorrectSurfaceIntersectionMaxCost() != h_data.myCorrectSurfaceIntersectionMaxCost ) )
2326 h->SetCorrectSurfaceIntersectionMaxCost( h_data.myCorrectSurfaceIntersectionMaxCost <= 0 ? -1 :h_data.myCorrectSurfaceIntersectionMaxCost );
2328 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2329 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2330 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2331 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2333 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2334 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2336 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2337 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2339 if ( h->GetVerbosity() != h_data.myVerbosity )
2340 h->SetVerbosity( h_data.myVerbosity );
2341 // if ( h->GetTopology() != h_data.myTopology )
2342 // h->SetTopology( (int) h_data.myTopology );
2343 // if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2344 // h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2345 // if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2346 // h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2347 // if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2348 // h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2350 // options are set in checkParams()
2351 //h->SetOptionValues( myOptions ); // is set in readParamsFromWidgets()
2352 //h->SetPreCADOptionValues( myPreCADOptions ); // is set in readParamsFromWidgets()
2354 if ( h->GetGMFFile() != h_data.myGMFFileName )
2355 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2356 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2357 h->SetGMFFile( h_data.myGMFFileName.c_str());
2359 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2360 QMapIterator<QString,QString> i(that->mySMPMap);
2361 while (i.hasNext()) {
2363 const QString entry = i.key();
2364 const QString sizeMap = i.value();
2366 if (sizeMap == "__TO_DELETE__") {
2367 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
2368 h->UnsetEntry(entry.toLatin1().constData());
2370 else if (sizeMap.startsWith("ATTRACTOR")) {
2371 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2372 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2374 else if (sizeMap.startsWith("def")) {
2375 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2376 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2379 if (!myATTMap[entry].empty()){
2380 const TAttractorVec& attVec = myATTMap[entry];
2381 for ( size_t i = 0; i < attVec.size(); ++i )
2383 if ( attVec[i].IsToDelete() )
2384 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2385 attVec[i].attEntry.c_str() );
2387 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2388 attVec[i].attEntry.c_str(),
2389 attVec[i].startSize,
2392 attVec[i].constDist );
2396 QString fullSizeMap;
2397 fullSizeMap = QString("");
2398 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2399 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2400 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2401 fullSizeMap = QString("def f(t): return ") + sizeMap;
2402 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2403 fullSizeMap = QString("def f(): return ") + sizeMap;
2404 MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
2405 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2410 // Enforced vertices
2413 std::string enfName;
2415 std::string groupName = "";
2418 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2419 // 1. Clear all enforced vertices in hypothesis
2420 // 2. Add new enforced vertex according to h_data
2422 if ( h->GetAllEnforcedVertices()->length() > 0 )
2423 h->ClearAllEnforcedVertices();
2426 TEnfVertexList::const_iterator evsIt;
2427 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2429 faceEntry = evmIt->first;
2430 evs = evmIt->second;
2431 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
2432 evsIt = evs.begin();
2433 for ( ; evsIt != evs.end() ; ++evsIt)
2436 if ((*evsIt)->coords.size()) {
2437 x = (*evsIt)->coords[0];
2438 y = (*evsIt)->coords[1];
2439 z = (*evsIt)->coords[2];
2442 h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2446 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2447 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2448 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2449 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2452 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2453 h->ClearPreCadPeriodicityVectors();
2455 MESSAGE("h_data.preCadPeriodicityVector.size(): " << h_data.preCadPeriodicityVector.size());
2456 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2457 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2459 TPreCadPeriodicity periodicity_i = *pIt;
2460 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2461 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2462 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2463 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2464 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2465 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2466 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2467 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2468 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2470 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2471 if (! p1Source.empty())
2473 sourceVertices->length(3);
2474 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2475 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2476 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2480 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2481 if (! p1Target.empty())
2483 targetVertices->length(3);
2484 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2485 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2486 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2490 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2492 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2495 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end periodicity");
2499 catch(const std::exception& ex) {
2500 std::cout << "Exception: " << ex.what() << std::endl;
2503 // catch(const SALOME::SALOME_Exception& ex)
2506 // // SalomeApp_Tools::QtCatchCorbaException(ex);
2509 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end");
2513 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2514 Stores the widgets content to the hypothesis data.
2516 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2518 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
2519 h_data.myName = myName ? myName->text() : "";
2520 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2521 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2522 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2523 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2524 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2525 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2526 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2527 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2528 h_data.myUseGradation = myStdWidget->myUseGradation->isChecked() && !myStdWidget->myGradation->text().isEmpty();
2529 h_data.myGradation = h_data.myUseGradation ? myStdWidget->myGradation->GetValue() : -1.0;
2530 h_data.myUseVolumeGradation = myStdWidget->myUseVolumeGradation->isChecked() && !myStdWidget->myVolumeGradation->text().isEmpty();
2531 h_data.myVolumeGradation = h_data.myUseVolumeGradation ? myStdWidget->myVolumeGradation->GetValue() : -1. ;
2532 h_data.myAllowQuadrangles = myStdWidget->myAllowQuadrangles->isChecked();
2533 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2534 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2535 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2536 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2537 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2538 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2539 h_data.myOptimiseTinyEdges = myStdWidget->myOptimiseTinyEdges->isChecked();
2540 h_data.myTinyEdgeOptimisLength = myStdWidget->myTinyEdgeOptimisLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeOptimisLength->GetValue();
2541 h_data.myCorrectSurfaceIntersection = myStdWidget->myCorrectSurfaceIntersection->isChecked();
2542 h_data.myCorrectSurfaceIntersectionMaxCost = myStdWidget->myCorrectSurfaceIntersectionMaxCost->text().isEmpty() ? -1.0 : myStdWidget->myCorrectSurfaceIntersectionMaxCost->GetValue();
2543 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2544 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2545 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2546 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2547 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2548 //h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2549 //h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2550 //h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2551 //h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2554 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2555 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2556 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2557 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2558 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2559 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2560 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2561 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2562 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2563 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2564 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2565 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2566 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2567 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2570 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2571 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2572 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2573 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2574 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2575 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2578 // guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2579 // guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2580 // guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2581 // guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2583 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2584 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2587 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2588 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2589 for ( ; row < nbRows; ++row )
2591 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2592 if ( that->mySMPMap.contains(entry) )
2593 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2596 // Enforced vertices
2597 h_data.enfVertexList.clear();
2598 h_data.faceEntryEnfVertexListMap.clear();
2600 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2601 int nbEnforcedVertices = 0;
2602 std::string groupName = "";
2603 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
2604 for (int i=0 ; i<nbEnforcedShapes ; i++) {
2605 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
2607 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2608 nbEnforcedVertices = shapeItem->childCount();
2609 if (nbEnforcedVertices >0) {
2610 double childValueX,childValueY,childValueZ;
2611 std::string childName, vertexEntry;
2612 QTreeWidgetItem* child;
2615 for (row = 0;row<nbEnforcedVertices;row++) {
2616 child = shapeItem->child(row);
2617 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2618 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2619 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2620 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2621 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2622 // if (myGlobalGroupName->isChecked())
2623 // groupName = myGlobalGroupName->text().toStdString();
2625 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2627 TEnfVertex *enfVertex = new TEnfVertex();
2628 enfVertex->name = childName;
2629 if (vertexEntry.empty()) {
2630 enfVertex->coords.push_back(childValueX);
2631 enfVertex->coords.push_back(childValueY);
2632 enfVertex->coords.push_back(childValueZ);
2635 enfVertex->geomEntry = vertexEntry;
2636 enfVertex->grpName = groupName;
2637 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2638 // if (it == h_data.enfVertexList.end())
2639 h_data.enfVertexList.insert(enfVertex);
2640 evs.insert(enfVertex);
2642 if (groupName != "")
2643 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2646 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2651 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2652 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2655 h_data.preCadPeriodicityVector.clear();
2656 // For each tree item, store each value. Shapes are stored as entries.
2657 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2658 for (int i=0 ; i<nbPeriodicityDescriptions ; i++) {
2659 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2660 TPreCadPeriodicity periodicity_i;
2662 for (int k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2665 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2667 periodicity_i.push_back(entry);
2669 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2671 guiHyp += "PERIODICITY = yes; ";
2674 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2678 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2680 myAdvWidget->AddOption( TBL_CUSTOM, NULL );
2683 void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int row, int column )
2685 // if ( column != OPTION_NAME_COLUMN )
2687 // myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2690 // **********************
2691 // *** BEGIN SIZE MAP ***
2692 // **********************
2694 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2696 if ( myGeomSelWdg2->IsObjectSelected() ){
2697 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2699 else if ( myGeomSelWdg1->IsObjectSelected() ){
2700 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2703 mySMapObject = GEOM::GEOM_Object::_nil();
2705 bool dataAvailable = !mySMapObject->_is_nil();
2707 if ( dataAvailable )
2708 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2710 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2711 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2712 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2713 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2714 ( myATTMap.contains( qEntry )))
2717 QString attEntry = myAttSelWdg->GetValue();
2718 const TAttractorVec& attVec = myATTMap[ qEntry ];
2719 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2720 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2723 addMapButton->setEnabled( !mapExists && dataAvailable );
2724 modifyMapButton->setEnabled( mapExists && dataAvailable );
2727 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2729 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2730 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2731 if (col == SMP_SIZEMAP_COLUMN) {
2732 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2734 if (!mySMPMap.contains(entry))
2736 if ( QTreeWidgetItem* parent = item->parent() )
2740 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2742 if (!mySMPMap.contains(entry))
2745 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2746 CORBA::Object_var obj = entryToObject(entry);
2747 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2748 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2749 // Retrieve values of the selected item in the current tab widgets
2750 const TAttractorVec& attVec = myATTMap[entry];
2751 if ( !attVec.empty() )
2754 if ( !childEntry.isEmpty() )
2755 for ( size_t i = 0; i < attVec.size(); ++i )
2756 if ( childEntry == attVec[i].attEntry.c_str() )
2761 double phySize = attVec[iAtt].startSize;
2762 double infDist = attVec[iAtt].infDist;
2763 double constDist = attVec[iAtt].constDist;
2764 QString attEntry = attVec[iAtt].attEntry.c_str();
2765 CORBA::Object_var attObj = entryToObject(attEntry);
2766 myAttSizeSpin->setValue(phySize);
2767 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2768 myAttDistSpin->setValue(infDist);
2769 myAttractorCheck->setChecked(true);
2772 myAttractorCheck->setChecked(false);
2774 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2775 myAttDistSpin2->setValue(constDist);
2776 myConstSizeCheck->setChecked(true);
2779 myConstSizeCheck->setChecked(false);
2781 myGeomSelWdg2->SetObject(obj);
2782 myAttSelWdg->SetObject(attObj);
2785 else { // CLASSIC MAPS
2786 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2787 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2788 if (!sizeMap.startsWith("def")){
2789 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2795 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2797 getGeomSelectionTool()->selectionMgr()->clearFilters();
2798 if ( sender() == myTabWidget )
2800 myGeomSelWdg1 ->deactivateSelection();
2801 myGeomSelWdg2 ->deactivateSelection();
2802 myAttSelWdg ->deactivateSelection();
2803 myEnfFaceWdg ->deactivateSelection();
2804 myEnfVertexWdg ->deactivateSelection();
2805 myPeriodicitySourceFaceWdg->deactivateSelection();
2806 myPeriodicityTargetFaceWdg->deactivateSelection();
2807 myPeriodicityP1SourceWdg ->deactivateSelection();
2808 myPeriodicityP2SourceWdg ->deactivateSelection();
2809 myPeriodicityP3SourceWdg ->deactivateSelection();
2810 myPeriodicityP1TargetWdg ->deactivateSelection();
2811 myPeriodicityP2TargetWdg ->deactivateSelection();
2812 myPeriodicityP3TargetWdg ->deactivateSelection();
2815 else if ( sender() == smpTab )
2817 myAttDistSpin->setValue(0.); // Reinitialize widgets
2818 myAttSizeSpin->setValue(0.);
2819 myAttDistSpin2->setValue(0.);
2820 mySmpSizeSpin->setValue(0.);
2821 myGeomSelWdg1->deactivateSelection();
2822 myGeomSelWdg2->deactivateSelection();
2823 myAttSelWdg->deactivateSelection();
2824 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2825 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2826 myAttSelWdg->SetObject(CORBA::Object::_nil());
2827 myAttractorCheck->setChecked(false);
2828 myConstSizeCheck->setChecked(false);
2832 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2834 if (state == Qt::Checked){
2835 myAttSelWdg->setEnabled(true);
2836 myAttSizeSpin->setEnabled(true);
2837 myAttSizeLabel->setEnabled(true);
2838 myAttDistSpin->setEnabled(true);
2839 myAttDistLabel->setEnabled(true);
2840 if (!myAttSelWdg->IsObjectSelected()){
2841 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2844 if (state == Qt::Unchecked){
2845 myAttDistSpin->setEnabled(false);
2846 myAttDistLabel->setEnabled(false);
2847 myAttDistSpin->setValue(0.);
2848 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2849 myAttSelWdg->setEnabled(false);
2850 myAttSizeSpin->setEnabled(false);
2851 myAttSizeLabel->setEnabled(false);
2852 myAttDistSpin2->setEnabled(false);
2853 myAttDistLabel2->setEnabled(false);
2855 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2856 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2859 onMapGeomContentModified();
2862 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2864 if (state == Qt::Checked){
2865 myAttSelWdg->setEnabled(true);
2866 myAttSizeSpin->setEnabled(true);
2867 myAttSizeLabel->setEnabled(true);
2868 myAttDistSpin2->setEnabled(true);
2869 myAttDistLabel2->setEnabled(true);
2870 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2871 !myAttSelWdg->IsObjectSelected()){
2872 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2875 if (state == Qt::Unchecked){
2876 myAttDistSpin2->setEnabled(false);
2877 myAttDistLabel2->setEnabled(false);
2878 myAttDistSpin2->setValue(0.);
2879 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2880 myAttSelWdg->setEnabled(false);
2881 myAttSizeSpin->setEnabled(false);
2882 myAttSizeLabel->setEnabled(false);
2883 myAttDistSpin->setEnabled(false);
2884 myAttDistLabel->setEnabled(false);
2886 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2887 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2890 onMapGeomContentModified();
2893 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2895 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
2896 QList<int> selectedRows;
2897 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2898 QTreeWidgetItem* item;
2899 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2901 qSort( selectedRows );
2902 QListIterator<QTreeWidgetItem*> it( selected );
2904 while ( it.hasPrevious() ) {
2905 item = it.previous();
2906 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2907 QString parentEntry;
2908 if ( QTreeWidgetItem* parent = item->parent() )
2909 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2910 if (that->mySMPMap.contains(entry))
2912 that->mySMPMap[entry] = "__TO_DELETE__";
2913 if ( myATTMap.contains( entry ))
2915 TAttractorVec& attVec = myATTMap[entry];
2916 for ( size_t i = 0; i < attVec.size(); ++i )
2917 attVec[i].SetToDelete();
2920 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
2922 TAttractorVec& attVec = myATTMap[parentEntry];
2923 for ( size_t i = 0; i < attVec.size(); ++i )
2925 if ( entry == attVec[i].attEntry.c_str() )
2926 attVec[i].SetToDelete();
2929 if (that->mySMPShapeTypeMap.contains(entry))
2930 that->mySMPShapeTypeMap.remove(entry);
2931 // if (that->myDistMap.contains(entry))
2932 // that->myDistMap.remove(entry);
2933 // if (that->myAttDistMap.contains(entry))
2934 // that->myAttDistMap.remove(entry);
2937 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2938 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2941 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2943 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
2944 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2945 if (col == SMP_SIZEMAP_COLUMN) {
2946 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2947 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2948 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2949 MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
2950 if (! that->mySMPShapeTypeMap.contains(entry))
2951 MESSAGE("no such entry in mySMPShapeTypeMap")
2953 if (that->mySMPMap.contains(entry))
2954 if (that->mySMPMap[entry] == sizeMap
2955 || sizeMap.startsWith("Attractor")
2956 || sizeMap.startsWith("Constant") ){
2959 if (! sizeMap.isEmpty()) {
2960 that->mySMPMap[entry] = sizeMap;
2961 sizeMapValidationFromEntry(entry);
2964 MESSAGE("Size map empty: reverse to precedent value" );
2965 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2967 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2971 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2974 if ( smpTab->currentIndex() == ATT_TAB ){
2975 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2976 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2977 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2978 res = insertAttractor(mySMapObject, myAttObject);
2981 if (smpTab->currentIndex() == SMP_STD_TAB ){
2982 if ( myGeomSelWdg1->IsObjectSelected() ){
2983 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2984 res = insertElement(mySMapObject);
2988 // Local size should be more than 0
2989 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
2990 SUIT_MessageBox::critical( dlg(),"Error" , msg );
2993 getGeomSelectionTool()->selectionMgr()->clearFilters();
2994 myAttDistSpin->setValue(0.);
2995 myAttSizeSpin->setValue(0.);
2996 myAttDistSpin2->setValue(0.);
2997 mySmpSizeSpin->setValue(0.);
2998 myConstSizeCheck->setChecked(false);
2999 myAttractorCheck->setChecked(false);
3000 myGeomSelWdg1->deactivateSelection();
3001 myGeomSelWdg2->deactivateSelection();
3002 myAttSelWdg->deactivateSelection();
3003 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3004 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3005 myAttSelWdg->SetObject(CORBA::Object::_nil());
3008 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
3010 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
3012 if ( smpTab->currentIndex() == ATT_TAB ){
3013 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3014 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3015 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3016 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
3019 if (smpTab->currentIndex() == SMP_STD_TAB ){
3020 if ( myGeomSelWdg1->IsObjectSelected() ){
3021 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3022 res = insertElement(mySMapObject, /*modify = */true);
3026 // Local size should be more than 0
3027 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3028 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3031 getGeomSelectionTool()->selectionMgr()->clearFilters();
3032 myAttDistSpin->setValue(0.);
3033 myAttSizeSpin->setValue(0.);
3034 myAttDistSpin2->setValue(0.);
3035 mySmpSizeSpin->setValue(0.);
3036 myConstSizeCheck->setChecked(false);
3037 myAttractorCheck->setChecked(false);
3038 myGeomSelWdg1->deactivateSelection();
3039 myGeomSelWdg2->deactivateSelection();
3040 myAttSelWdg->deactivateSelection();
3041 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3042 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3043 myAttSelWdg->SetObject(CORBA::Object::_nil());
3046 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3048 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
3049 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3050 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3052 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3054 TopAbs_ShapeEnum shapeType;
3055 string entry, shapeName;
3056 entry = (string) anObject->GetStudyEntry();
3057 MESSAGE("entry = "<<entry);
3058 shapeName = anObject->GetName();
3059 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3060 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3061 // in order to write the size map with the right syntax in StoreParamsToHypo
3062 // (f(t) for edges, f(u,v) for faces ...)
3063 if (shapeType == TopAbs_COMPOUND){
3064 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3065 TopoDS_Shape childShape;
3066 TopoDS_Iterator anIt(theShape);
3067 for(;anIt.More();anIt.Next()){
3068 childShape = anIt.Value();
3069 shapeType = childShape.ShapeType();
3070 if(!childShape.IsNull()){
3075 mySizeMapTable->setFocus();
3077 shapeEntry = QString::fromStdString(entry);
3078 double phySize = mySmpSizeSpin->value();
3081 return false; // Local size should be more than 0
3083 std::ostringstream oss;
3086 sizeMap = QString::fromStdString(oss.str());
3087 QTreeWidgetItem* item = new QTreeWidgetItem();
3089 int rowToChange = findRowFromEntry(shapeEntry);
3090 item = mySizeMapTable->topLevelItem( rowToChange );
3093 if (that->mySMPMap.contains(shapeEntry)) {
3094 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3095 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3099 mySizeMapTable->addTopLevelItem(item);
3101 that->mySMPMap[shapeEntry] = sizeMap;
3102 //that->myDistMap[shapeEntry] = 0. ;
3103 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3104 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3105 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3106 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3107 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3108 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3109 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3110 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3111 mySizeMapTable->clearSelection();
3113 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3114 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3115 myStdWidget->onPhysicalMeshChanged();
3120 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3122 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
3123 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3124 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3126 TopAbs_ShapeEnum shapeType;
3127 string entry, attEntry, faceName, attName;
3128 entry = (string) aFace->GetStudyEntry();
3129 attEntry = (string) anAttractor->GetStudyEntry();
3130 faceName = aFace->GetName();
3131 attName = anAttractor->GetName();
3132 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3133 mySizeMapTable->setFocus();
3134 QString shapeEntry = QString::fromStdString(entry);
3135 QString qAttEntry = QString::fromStdString(attEntry);
3137 double phySize = h->GetPhySize();
3138 double infDist = 0. ;
3139 double constDist = 0. ;
3140 phySize = myAttSizeSpin->value();
3143 return false; // Local size should be more than 0
3145 if (myAttractorCheck->isChecked()){
3146 infDist = myAttDistSpin->value();
3148 if (myConstSizeCheck->isChecked()){
3149 constDist = myAttDistSpin2->value();
3151 std::ostringstream oss;
3152 std::ostringstream oss2;
3153 std::ostringstream oss3;
3157 QString sizeMap = QString::fromStdString(oss.str());
3158 QString infDistString = QString::fromStdString(oss2.str());
3159 QString constDistString = QString::fromStdString(oss3.str());
3161 QTreeWidgetItem* item;
3162 QTreeWidgetItem* child = 0;
3163 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3165 int rowToChange = findRowFromEntry(shapeEntry);
3166 item = mySizeMapTable->topLevelItem( rowToChange );
3168 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3169 if (( child = item->child( i )))
3170 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3172 TAttractorVec & attVec = myATTMap[shapeEntry];
3173 for ( size_t i = 0; i < attVec.size(); ++i )
3174 if ( attVec[i].attEntry == attEntry )
3176 attVec[i] = attParams;
3181 // if (that->mySMPMap.contains(shapeEntry)) {
3182 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3183 // // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3187 int rowToChange = findRowFromEntry(shapeEntry);
3188 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3190 item = mySizeMapTable->topLevelItem( rowToChange );
3193 item = new QTreeWidgetItem();
3194 mySizeMapTable->addTopLevelItem(item);
3196 child = new QTreeWidgetItem();
3197 item->addChild(child);
3198 bool exists = false;
3199 TAttractorVec & attVec = myATTMap[shapeEntry];
3200 for ( size_t i = 0; i < attVec.size(); ++i )
3201 if ( attVec[i].attEntry == attEntry )
3203 attVec[i] = attParams;
3208 myATTMap[shapeEntry].push_back( attParams );
3210 mySMPMap.insert(shapeEntry,sizeMap);
3211 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3212 item->setExpanded(true);
3213 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3214 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3215 if (infDist > std::numeric_limits<double>::epsilon()){
3216 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3218 else if (constDist > std::numeric_limits<double>::epsilon()){
3219 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3221 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3223 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3224 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3225 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3227 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3228 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3229 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3231 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3232 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3233 myStdWidget->onPhysicalMeshChanged();
3235 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
3239 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3241 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
3242 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3243 for ( ; row < nbRows; ++row )
3244 if (! sizeMapValidationFromRow(row))
3249 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3251 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
3252 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3253 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3254 mySizeMapTable->setFocus();
3258 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3260 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
3261 MESSAGE("myEntry = "<<myEntry.toStdString())
3263 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3265 if (! that->mySMPMap.contains(myEntry)) {
3266 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
3269 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3270 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
3276 if (that->mySMPMap[myEntry].startsWith("def")) {
3277 // MESSAGE("custom function" );
3278 expr = that->mySMPMap[myEntry].toStdString();
3280 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3281 // MESSAGE("Attractor" );
3282 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)) {
3285 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])" );
3291 // case size map is empty
3292 if (that->mySMPMap[myEntry].isEmpty()) {
3294 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3298 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3299 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3300 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3301 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3302 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3303 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3306 //assert(Py_IsInitialized());
3307 if (! Py_IsInitialized())
3308 throw ("Erreur: Python interpreter is not initialized");
3309 PyGILState_STATE gstate;
3310 gstate = PyGILState_Ensure();
3312 string err_description="";
3313 PyObject* obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3317 PyObject* new_stderr = newPyStdOut(err_description);
3318 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3319 Py_INCREF(old_stderr);
3320 PySys_SetObject((char*)"stderr", new_stderr);
3322 PySys_SetObject((char*)"stderr", old_stderr);
3323 Py_DECREF(new_stderr);
3325 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3326 PyGILState_Release(gstate);
3331 PyObject* func = PyObject_GetAttrString(main_mod, "f");
3335 PyObject* new_stderr = newPyStdOut(err_description);
3336 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3337 Py_INCREF(old_stderr);
3338 PySys_SetObject((char*)"stderr", new_stderr);
3340 PySys_SetObject((char*)"stderr", old_stderr);
3341 Py_DECREF(new_stderr);
3343 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3344 PyGILState_Release(gstate);
3348 PyGILState_Release(gstate);
3350 // MESSAGE("SizeMap expression "<<expr<<" is valid");
3355 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3357 return tr( "BLSURF_TITLE" );
3360 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3362 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3365 QString BLSURFPluginGUI_HypothesisCreator::type() const
3367 return tr( "BLSURF_HYPOTHESIS" );
3370 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3372 return "blsurf_hypo_page.html";
3375 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3378 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3380 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3385 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3387 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
3388 SALOMEDS::Study_var myStudy = smeshGen_i->GetStudy();
3389 CORBA::Object_var obj;
3390 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
3391 if (!aSObj->_is_nil()) {
3392 obj = aSObj->GetObject();
3393 aSObj->UnRegister();
3398 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3399 int endRow = mySizeMapTable->topLevelItemCount()-1;
3401 for ( ; row <= endRow; ++row )
3403 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3404 if (entry == entryForChecking )
3407 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)