1 // Copyright (C) 2007-2010 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.
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 <DlgBlSurfHyp_Enforced.h>
30 #include <SMESHGUI_Utils.h>
31 #include <SMESHGUI_HypothesesUtils.h>
32 #include <SMESHGUI_Dialog.h>
33 #include "SMESHGUI_SpinBox.h"
35 #include <SUIT_Session.h>
36 #include <SUIT_MessageBox.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SalomeApp_Tools.h>
44 #include <QVBoxLayout>
45 #include <QHBoxLayout>
46 #include <QGridLayout>
51 #include <QPushButton>
53 #include <QTableWidget>
54 #include <QHeaderView>
55 #include <QApplication>
56 #include <QRadioButton>
58 #include <QStandardItemModel>
59 #include <QStandardItem>
60 #include <QTreeWidget>
61 #include <QTreeWidgetItem>
62 #include <QModelIndexList>
64 #include <LightApp_SelectionMgr.h>
65 #include <SalomeApp_Application.h>
66 #include <SALOME_ListIO.hxx>
67 #include <SALOME_ListIteratorOfListIO.hxx>
69 #include <GEOM_Client.hxx>
70 #include <TopoDS_Shape.hxx>
71 #include <SMESH_Gen_i.hxx>
72 #include <boost/shared_ptr.hpp>
73 #include <boost/algorithm/string.hpp>
74 #include <structmember.h>
76 #define WITH_SIZE_BOUNDARIES
102 OPTION_ID_COLUMN = 0,
106 SMP_ENTRY_COLUMN = 0,
110 // Enforced vertices array columns
111 ENF_VER_NAME_COLUMN = 0,
112 ENF_VER_ENTRY_COLUMN,
116 // ENF_VER_GROUP_COLUMN,
122 // SMP_ATTRACTOR_BTN,
132 // Enforced vertices inputs
142 // ENF_VER_SEPARATOR,
143 // ENF_VER_GROUP_CHECK,
148 /**************************************************
149 Begin initialization Python structures and objects
150 ***************************************************/
159 PyStdOut_dealloc(PyStdOut *self)
165 PyStdOut_write(PyStdOut *self, PyObject *args)
169 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
173 *(self->out)=*(self->out)+c;
179 static PyMethodDef PyStdOut_methods[] = {
180 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
181 PyDoc_STR("write(string) -> None")},
182 {NULL, NULL} /* sentinel */
185 static PyMemberDef PyStdOut_memberlist[] = {
186 {"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
187 "flag indicating that a space needs to be printed; used by print"},
188 {NULL} /* Sentinel */
191 static PyTypeObject PyStdOut_Type = {
192 /* The ob_type field must be initialized in the module init function
193 * to be portable to Windows without using C++. */
194 PyObject_HEAD_INIT(NULL)
197 sizeof(PyStdOut), /*tp_basicsize*/
200 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
207 0, /*tp_as_sequence*/
212 PyObject_GenericGetAttr, /*tp_getattro*/
213 /* softspace is writable: we must supply tp_setattro */
214 PyObject_GenericSetAttr, /* tp_setattro */
216 Py_TPFLAGS_DEFAULT, /*tp_flags*/
220 0, /*tp_richcompare*/
221 0, /*tp_weaklistoffset*/
224 PyStdOut_methods, /*tp_methods*/
225 PyStdOut_memberlist, /*tp_members*/
239 PyObject * newPyStdOut( std::string& out )
242 self = PyObject_New(PyStdOut, &PyStdOut_Type);
247 return (PyObject*)self;
250 /*************************************************
251 End initialization Python structures and objects
252 **************************************************/
255 class QDoubleValidator;
258 // BEGIN EnforcedTreeWidgetDelegate
261 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
262 : QItemDelegate(parent)
266 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
267 const QStyleOptionViewItem & option ,
268 const QModelIndex & index ) const
270 // QLineEdit *editor = new QLineEdit(parent);
271 if (index.column() == ENF_VER_X_COLUMN || \
272 index.column() == ENF_VER_Y_COLUMN || \
273 index.column() == ENF_VER_Z_COLUMN)
275 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
276 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
279 // editor->setValidator(new QDoubleValidator(parent));
282 QLineEdit *editor = new QLineEdit(parent);
289 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
290 const QModelIndex &index) const
292 QString value = index.model()->data(index, Qt::EditRole).toString();
293 if (index.column() == ENF_VER_X_COLUMN || \
294 index.column() == ENF_VER_Y_COLUMN || \
295 index.column() == ENF_VER_Z_COLUMN) {
296 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
297 lineEdit->setText(value);
298 // lineEdit->editor()->setText(value);
301 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
302 lineEdit->setText(value);
306 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
307 const QModelIndex &index) const
309 // QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
311 if (index.column() == ENF_VER_X_COLUMN || \
312 index.column() == ENF_VER_Y_COLUMN || \
313 index.column() == ENF_VER_Z_COLUMN)
315 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
316 if (! vertexExists(model, index, lineEdit->GetString())) {
317 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
320 else if (index.column() == ENF_VER_NAME_COLUMN) {
321 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
322 QString value = lineEdit->text();
323 if (! vertexExists(model, index, value)) {
324 model->setData(index, value, Qt::EditRole);
326 // MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")");
329 else if (index.column() == ENF_VER_GROUP_COLUMN) {
330 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
331 model->setData(index, lineEdit->text(), Qt::EditRole);
332 // MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")");
337 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
338 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
340 editor->setGeometry(option.rect);
343 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
344 const QModelIndex &index, QString value) const
347 QModelIndex parent = index.parent();
348 int row = index.row();
349 int col = index.column();
351 if (parent.isValid()) {
352 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
354 if (col == ENF_VER_X_COLUMN) {
355 x = value.toDouble();
356 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
357 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
359 if (col == ENF_VER_Y_COLUMN) {
360 y = value.toDouble();
361 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
362 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
364 if (col == ENF_VER_Z_COLUMN) {
365 z = value.toDouble();
366 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
367 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
369 // MESSAGE("Checking for existing vertex " << x << ", " << y << "," << z);
370 int nbChildren = model->rowCount(parent);
371 for (int i = 0 ; i < nbChildren ; i++) {
373 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
374 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
375 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
376 // MESSAGE("Vertex: " << childX << ", " << childY << "," << childZ);
377 if ((childX == x) && (childY == y) && (childZ == z)) {
378 // MESSAGE("Found !");
385 else if (index.column() == ENF_VER_NAME_COLUMN) {
386 int nbChildren = model->rowCount(parent);
387 for (int i = 0 ; i < nbChildren ; i++) {
389 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
390 if (childName == value) {
403 // END EnforcedTreeWidgetDelegate
408 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
409 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
412 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
413 : SMESHGUI_GenericHypothesisCreator( theHypType )
415 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
416 this->mySMPMap.clear();
418 GeomToolSelected = NULL;
419 GeomToolSelected = getGeomSelectionTool();
421 aSel = GeomToolSelected->selectionMgr();
423 /* Initialize the Python interpreter */
424 if (! Py_IsInitialized())
425 throw ("Error: Python interpreter is not initialized");
426 PyGILState_STATE gstate;
427 gstate = PyGILState_Ensure();
430 main_mod = PyImport_AddModule("__main__");
433 main_dict = PyModule_GetDict(main_mod);
435 PyRun_SimpleString("from math import *");
436 PyGILState_Release(gstate);
440 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
445 * \brief {Get or create the geom selection tool for active study}
447 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool()
449 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool");
450 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
451 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
452 // MESSAGE("aStudy->StudyId(): " << aStudy->StudyId());
453 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
454 // MESSAGE("GeomToolSelected is created");
455 that->GeomToolSelected = new GeomSelectionTools(aStudy);
458 // MESSAGE("GeomToolSelected already exists");
459 // MESSAGE("that->GeomToolSelected->getMyStudy()->StudyId(): " << that->GeomToolSelected->getMyStudy()->StudyId());
460 return that->GeomToolSelected;
464 inline bool isDouble( const QString& theText, const bool emptyOK=false ) {
465 QString str = theText.trimmed();
467 if ( !str.isEmpty() )
476 bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
478 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
480 // if ( !isDouble( myPhySize->text(), false )) {
481 // if ( myPhySize->text().isEmpty() )
482 // myPhySize->setText(tr("OBLIGATORY_VALUE"));
483 // myPhySize->selectAll();
486 // if ( !isDouble( myPhyMin->text(), true )) {
487 // myPhyMin->selectAll();
490 // if ( !isDouble( myPhyMax->text(), true )) {
491 // myPhyMax->selectAll();
494 // if ( !isDouble( myGeoMin->text(), true )) {
495 // myGeoMin->selectAll();
498 // if ( !isDouble( myGeoMin->text(), true )) {
499 // myGeoMin->selectAll();
504 myOptionTable->setFocus();
505 QApplication::instance()->processEvents();
507 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
508 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
510 int row = 0, nbRows = myOptionTable->rowCount();
511 for ( ; row < nbRows; ++row )
513 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
514 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
515 if ( !value.isEmpty() ) {
517 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
519 catch ( const SALOME::SALOME_Exception& ex )
521 SUIT_MessageBox::critical( dlg(),
523 ex.details.text.in() );
528 h->SetOptionValues( myOptions ); // restore values
531 // SizeMap and attractors
534 mySizeMapTable->setFocus();
535 QApplication::instance()->processEvents();
537 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
538 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
540 int row = 0, nbRows = mySizeMapTable->rowCount();
541 for ( ; row < nbRows; ++row )
543 QString entry = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text();
544 QString sizeMap = mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->text().trimmed();
545 if ( !sizeMap.isEmpty() ) {
546 if (that->sizeMapValidationFromRow(row))
549 const char* e = entry.toLatin1().constData();
550 const char* s = that->mySMPMap[entry].toLatin1().constData();
551 h->SetSizeMapEntry( e, s );
553 catch ( const SALOME::SALOME_Exception& ex )
555 SUIT_MessageBox::critical( dlg(),
557 ex.details.text.in() );
574 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
576 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
578 QFrame* fr = new QFrame( 0 );
579 QVBoxLayout* lay = new QVBoxLayout( fr );
581 lay->setSpacing( 0 );
584 QTabWidget* tab = new QTabWidget( fr );
585 tab->setTabShape( QTabWidget::Rounded );
586 tab->setTabPosition( QTabWidget::North );
587 lay->addWidget( tab );
590 myStdGroup = new QWidget();
591 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
592 aStdLayout->setSpacing( 6 );
593 aStdLayout->setMargin( 11 );
597 myName = new QLineEdit( myStdGroup );
599 myGradation = new SMESHGUI_SpinBox( myStdGroup );
600 myGradation->RangeStepAndValidator(1.1, 2.5, 0.1, "length_precision");
602 myPhysicalMesh = new QComboBox( myStdGroup );
603 QStringList physicalTypes;
604 physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ) << tr( "BLSURF_SIZE_MAP");
605 myPhysicalMesh->addItems( physicalTypes );
607 myPhySize = new SMESHGUI_SpinBox( myStdGroup );
608 myPhySize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
610 #ifdef WITH_SIZE_BOUNDARIES
611 myPhyMin = new SMESHGUI_SpinBox( myStdGroup );
612 myPhyMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
613 myPhyMin->setText("");
614 myPhyMax = new SMESHGUI_SpinBox( myStdGroup );
615 myPhyMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
616 myPhyMax->setText("");
619 myGeometricMesh = new QComboBox( myStdGroup );
621 types << tr( "BLSURF_DEFAULT_GEOM" ) << tr( "BLSURF_CUSTOM_GEOM" );
622 myGeometricMesh->addItems( types );
624 myAngleMeshS = new SMESHGUI_SpinBox( myStdGroup );
625 myAngleMeshS->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
627 myAngleMeshC = new SMESHGUI_SpinBox( myStdGroup );
628 myAngleMeshC->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
630 #ifdef WITH_SIZE_BOUNDARIES
631 myGeoMin = new SMESHGUI_SpinBox( myStdGroup );
632 myGeoMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
633 myGeoMin->setText("");
634 myGeoMax = new SMESHGUI_SpinBox( myStdGroup );
635 myGeoMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
636 myGeoMax->setText("");
638 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup );
639 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
641 // ADD WIDGETS (STANDARD TAB)
644 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
645 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
647 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 );
648 aStdLayout->addWidget( myGradation, row++, 1, 1, 1 );
649 aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ), row, 0, 1, 1 );
650 aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 );
651 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 );
652 aStdLayout->addWidget( myPhySize, row++, 1, 1, 1 );
653 #ifdef WITH_SIZE_BOUNDARIES
654 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ), row, 0, 1, 1 );
655 aStdLayout->addWidget( myPhyMin, row++, 1, 1, 1 );
656 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ), row, 0, 1, 1 );
657 aStdLayout->addWidget( myPhyMax, row++, 1, 1, 1 );
659 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ), row, 0, 1, 1 );
660 aStdLayout->addWidget( myGeometricMesh, row++, 1, 1, 1 );
661 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 0, 1, 1 );
662 aStdLayout->addWidget( myAngleMeshS, row++, 1, 1, 1 );
663 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 0, 1, 1 );
664 aStdLayout->addWidget( myAngleMeshC, row++, 1, 1, 1 );
665 #ifdef WITH_SIZE_BOUNDARIES
666 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ), row, 0, 1, 1 );
667 aStdLayout->addWidget( myGeoMin, row++, 1, 1, 1 );
668 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ), row, 0, 1, 1 );
669 aStdLayout->addWidget( myGeoMax, row++, 1, 1, 1 );
671 aStdLayout->addWidget( myAllowQuadrangles, row++, 0, 1, 2 );
672 aStdLayout->addWidget( myDecimesh, row++, 0, 1, 2 );
674 // advanced parameters
675 myAdvGroup = new QWidget();
676 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
677 anAdvLayout->setSpacing( 6 );
678 anAdvLayout->setMargin( 11 );
679 anAdvLayout->setRowStretch( 4, 5 );
680 anAdvLayout->setColumnStretch( 1, 5 );
682 myTopology = new QComboBox( myAdvGroup );
683 QStringList topologyTypes;
684 topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) << tr( "BLSURF_TOPOLOGY_PROCESS" ) << tr( "BLSURF_TOPOLOGY_PROCESS2" );
685 myTopology->addItems( topologyTypes );
687 myVerbosity = new QSpinBox( myAdvGroup );
688 myVerbosity->setMinimum( 0 );
689 myVerbosity->setMaximum( 100 );
690 myVerbosity->setSingleStep( 5 );
692 myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup );
694 headers << tr( "OPTION_ID_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" );
695 myOptionTable->setHorizontalHeaderLabels( headers );
696 myOptionTable->horizontalHeader()->hideSection( OPTION_ID_COLUMN );
697 //myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );//////
698 //myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE );/////
699 myOptionTable->verticalHeader()->hide();
700 //myOptionTable->setSelectionBehavior( QAbstractItemView::SelectRows );
702 QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup );
703 addBtn->setMenu( new QMenu() );
704 QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup );
707 // ADD WIDGETS (ADVANCED TAB)
708 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 );
709 anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 );
710 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 1, 0, 1, 1 );
711 anAdvLayout->addWidget( myVerbosity, 1, 1, 1, 1 );
712 anAdvLayout->addWidget( myOptionTable, 2, 0, 3, 2 );
713 anAdvLayout->addWidget( addBtn, 2, 2, 1, 1 );
714 anAdvLayout->addWidget( rmBtn, 3, 2, 1, 1 );
717 // Size Maps parameters
719 mySmpGroup = new QWidget();
720 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
722 mySizeMapTable = new QTableWidget( 0, SMP_NB_COLUMNS, mySmpGroup );
723 QStringList sizeMapHeaders;
724 sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" );
725 mySizeMapTable->setHorizontalHeaderLabels(sizeMapHeaders);
726 mySizeMapTable->horizontalHeader()->hideSection( SMP_ENTRY_COLUMN );
727 mySizeMapTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
728 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
729 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
730 mySizeMapTable->setAlternatingRowColors(true);
731 mySizeMapTable->verticalHeader()->hide();
733 addAttractorButton = new QPushButton(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup);
734 QFrame *line = new QFrame(mySmpGroup);
735 line->setFrameShape(QFrame::HLine);
736 line->setFrameShadow(QFrame::Sunken);
738 addSurfaceButton = new QPushButton(tr("BLSURF_SM_SURFACE"),mySmpGroup);
739 addEdgeButton = new QPushButton(tr("BLSURF_SM_EDGE"),mySmpGroup);
740 addPointButton = new QPushButton(tr("BLSURF_SM_POINT"),mySmpGroup);
741 QFrame *line2 = new QFrame(mySmpGroup);
742 line2->setFrameShape(QFrame::HLine);
743 line2->setFrameShadow(QFrame::Sunken);
744 removeButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
747 // ADD WIDGETS (SIZEMAP TAB)
748 anSmpLayout->addWidget(mySizeMapTable, SMP_POINT_BTN, 0, SMP_NB_LINES+1, 1);
749 // anSmpLayout->addWidget(addAttractorButton, SMP_ATTRACTOR_BTN, 1, 1, 1);
750 // anSmpLayout->addWidget(line, SMP_SEPARATOR1, 1, 1, 1);
751 anSmpLayout->addWidget(addPointButton, SMP_POINT_BTN, 1, 1, 1);
752 anSmpLayout->addWidget(addEdgeButton, SMP_EDGE_BTN, 1, 1, 1);
753 anSmpLayout->addWidget(addSurfaceButton, SMP_SURFACE_BTN, 1, 1, 1);
754 anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 1, 1);
755 anSmpLayout->addWidget(removeButton, SMP_REMOVE_BTN, 1, 1, 1);
758 // Enforced vertices parameters
759 myEnfGroup = new QWidget();
760 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
762 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
763 // anEnfLayout->addWidget(myEnforcedVertexWidget);
764 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
765 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
767 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
768 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
769 myEnforcedTreeWidget->setSortingEnabled(true);
770 QStringList enforcedHeaders;
771 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" );
773 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ) << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
775 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
776 myEnforcedTreeWidget->setAlternatingRowColors(true);
777 myEnforcedTreeWidget->setUniformRowHeights(true);
778 myEnforcedTreeWidget->setAnimated(true);
779 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
780 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
781 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
782 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
783 myEnforcedTreeWidget->resizeColumnToContents(column);
785 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
786 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
788 /* TODO FACE AND VERTEX SELECTION
789 selectFaceButton = new QPushButton(myEnfGroup);
790 QPixmap imageSel1(SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "BLSURF_ICON_SELECT")));
791 selectFaceButton->setIcon(imageSel1);
793 mySelectedFace = new QLineEdit(myEnfGroup);
794 mySelectedFace->setReadOnly(true);
795 mySelectedFace->setText(tr( "BLSURF_ENF_SELECT_FACE"));
796 mySelectedFace->setStyleSheet("QLineEdit { color: grey }");
798 selectVertexButton = new QPushButton(myEnfGroup);
799 QPixmap imageSel2(SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "BLSURF_ICON_SELECT")));
800 selectVertexButton->setIcon(imageSel2);
802 mySelectedEnforcedVertex = new QLineEdit(myEnfGroup);
803 mySelectedEnforcedVertex->setReadOnly(true);
804 mySelectedEnforcedVertex->setText(tr( "BLSURF_ENF_SELECT_VERTEX"));
805 mySelectedEnforcedVertex->setStyleSheet("QLineEdit { color: grey }");
807 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
808 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
809 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
811 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
812 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
813 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
815 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
816 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
817 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
820 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
821 myGroupName = new QLineEdit(myEnfGroup);
824 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
825 // QFrame *line = new QFrame(myEnfGroup);
826 // line->setFrameShape(QFrame::HLine);
827 // line->setFrameShadow(QFrame::Sunken);
828 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
831 // CheckBox for groups generation
832 makeGroupsCheck = new QGroupBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
833 makeGroupsCheck->setCheckable(true);
834 makeGroupsCheck->setChecked(false);
835 QGridLayout* aGroupLayout = new QGridLayout(makeGroupsCheck);
836 myGlobalGroupName = new QLineEdit(makeGroupsCheck);
837 aGroupLayout->addWidget(myGlobalGroupName);
841 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES+1, 1);
842 /* TODO FACE AND VERTEX SELECTION
843 anEnfLayout->addWidget(selectFaceButton, ENF_VER_FACE, 1, 1, 1);
844 anEnfLayout->addWidget(mySelectedFace, ENF_VER_FACE, 2, 1, 1);
845 anEnfLayout->addWidget(selectVertexButton, ENF_VER_VERTEX, 1, 1, 1);
846 anEnfLayout->addWidget(mySelectedEnforcedVertex, ENF_VER_VERTEX, 2, 1, 1);
848 anEnfLayout->addWidget(myXCoordLabel, ENF_VER_X_COORD, 1, 1, 1);
849 anEnfLayout->addWidget(myXCoord, ENF_VER_X_COORD, 2, 1, 1);
850 anEnfLayout->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 1, 1, 1);
851 anEnfLayout->addWidget(myYCoord, ENF_VER_Y_COORD, 2, 1, 1);
852 anEnfLayout->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 1, 1, 1);
853 anEnfLayout->addWidget(myZCoord, ENF_VER_Z_COORD, 2, 1, 1);
855 anEnfLayout->addWidget(myGroupNameLabel, ENF_VER_GROUP, 1, 1, 1);
856 anEnfLayout->addWidget(myGroupName, ENF_VER_GROUP, 2, 1, 1);
858 anEnfLayout->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 1, 1, 2);
859 anEnfLayout->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 1, 1, 2);
860 // anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 1, 1, 2);
862 anEnfLayout->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 1, 1, 2);
866 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
867 tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
868 tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) );
869 tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
870 // tab->insertTab( ENF_TAB, myEnforcedVertexWidget, tr( "BLSURF_ENF_VER" ) );
872 tab->setCurrentIndex( STD_TAB );
875 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
876 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
877 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
878 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
879 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
881 connect( addSurfaceButton, SIGNAL( clicked()), this, SLOT( onAddMapOnSurface() ) );
882 connect( addEdgeButton, SIGNAL( clicked()), this, SLOT( onAddMapOnEdge() ) );
883 connect( addPointButton, SIGNAL( clicked()), this, SLOT( onAddMapOnPoint() ) );
884 connect( removeButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
885 connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
887 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
888 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
889 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
890 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
891 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
896 /** BLSURFPluginGUI_HypothesisCreator::update(item, column)
897 This method updates the tooltip of a modified item. The QLineEdit widgets content
898 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
900 void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column) {
901 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateVertexList");
902 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
904 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
905 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
906 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
908 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
911 QTreeWidgetItem* parent = item->parent();
913 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
914 QString toolTip = shapeName + QString(": ") + vertexName.toString();
915 toolTip += QString("(") + x.toString();
916 toolTip += QString(", ") + y.toString();
917 toolTip += QString(", ") + z.toString();
918 toolTip += QString(")");
919 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
921 myXCoord->SetValue(x.toDouble());
922 myYCoord->SetValue(y.toDouble());
923 myZCoord->SetValue(z.toDouble());
925 myGroupName->setText(groupName);
930 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
931 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
932 of the enforced vertex clicked in the tree widget.
934 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
935 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::synchronizeCoords");
936 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
937 if (! items.isEmpty()) {
938 QTreeWidgetItem *item;
939 for (int i=0 ; i < items.size() ; i++) {
941 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
943 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
944 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
945 myXCoord->SetValue(x.toDouble());
946 myYCoord->SetValue(y.toDouble());
947 myZCoord->SetValue(z.toDouble());
949 myGroupName->setText(item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString());
957 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
958 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
961 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName,
962 double x, double y, double z, std::string groupName) {
964 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName,
965 double x, double y, double z) {
967 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(entry.c_str()),Qt::MatchExactly,ENF_VER_ENTRY_COLUMN);
968 QTreeWidgetItem* theItem;
969 if (theItemList.empty()) {
970 theItem = new QTreeWidgetItem();
971 theItem->setData(ENF_VER_ENTRY_COLUMN, Qt::EditRole, QVariant(entry.c_str()));
972 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(shapeName.c_str()));
973 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(entry.c_str()));
974 myEnforcedTreeWidget->addTopLevelItem(theItem);
977 theItem = theItemList[0];
980 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
981 bool okToCreate = true;
983 const int nbVert = theItem->childCount();
984 // MESSAGE("Number of child rows: " << nbVert);
986 double childValueX,childValueY,childValueZ;
987 // QString childGrouName;
988 QTreeWidgetItem* child;
989 for (int row = 0;row<nbVert;row++) {
990 child = theItem->child(row);
991 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
992 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
993 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
994 if ((childValueX == x) && (childValueY == y) && (childValueZ == z)) {
997 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1005 MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1007 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1008 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1012 while(indexRef != vertexIndex) {
1013 indexRef = vertexIndex;
1014 vertexName = QString("Vertex #%1").arg(vertexIndex);
1015 for (int row = 0;row<nbVert;row++) {
1016 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1017 if (vertexName == name) {
1023 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, vertexName );
1024 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1025 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1026 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1028 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1030 QString toolTip = QString(shapeName.c_str())+QString(": ")+vertexName;
1031 toolTip += QString(" (%1, ").arg(x);
1032 toolTip += QString("%1, ").arg(y);
1033 toolTip += QString("%1)").arg(z);
1034 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1035 theItem->setExpanded(true);
1036 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1040 MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z <<
1041 " already exist: dont create again, only group name is updated with " << groupName);
1043 MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1046 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1047 This method is called when a item is added into the enforced vertices tree widget
1049 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1050 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1052 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1053 myEnforcedTreeWidget->resizeColumnToContents(column);
1055 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1057 if ((myXCoord->text().isEmpty()) ||
1058 (myYCoord->text().isEmpty()) ||
1059 (myZCoord->text().isEmpty())) return;
1061 double x = myXCoord->GetValue();
1062 double y = myYCoord->GetValue();
1063 double z = myZCoord->GetValue();
1066 std::string groupName = myGroupName->text().toStdString();
1067 if (makeGroupsCheck->isChecked())
1068 groupName = myGlobalGroupName->text().toStdString();
1070 if (boost::trim_copy(groupName) == "")
1074 TopAbs_ShapeEnum shapeType;
1075 string entry, shapeName;
1076 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1077 LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr();
1078 SALOME_ListIO ListSelectedObjects;
1079 mySel->selectedObjects(ListSelectedObjects, NULL, false );
1080 if (!ListSelectedObjects.IsEmpty()) {
1081 SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
1082 for (; Object_It.More(); Object_It.Next()) {
1083 Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
1084 entry = myGeomToolSelected->getEntryOfObject(anObject);
1085 shapeName = anObject->getName();
1086 shapeType = myGeomToolSelected->entryToShapeType(entry);
1087 // MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType);
1088 if (shapeType == TopAbs_FACE) {
1090 addEnforcedVertex(entry, shapeName, x, y, z, groupName);
1092 addEnforcedVertex(entry, shapeName, x, y, z);
1096 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1097 myEnforcedTreeWidget->resizeColumnToContents(column);
1099 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
1100 myPhysicalMesh->setCurrentIndex( SizeMap );
1101 onPhysicalMeshChanged();
1105 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1106 This method is called when a item is removed from the enforced vertices tree widget
1108 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1109 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1110 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1111 QList<QTreeWidgetItem *> selectedVertices;
1112 QSet<QTreeWidgetItem *> selectedEntries;
1113 QTreeWidgetItem* item;
1115 foreach( item, selectedItems ) {
1116 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1117 if (! value.isNull())
1118 selectedVertices.append(item);
1120 selectedEntries.insert(item);
1123 foreach(item,selectedVertices) {
1124 QTreeWidgetItem* parent = item->parent();
1125 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1126 parent->removeChild(item);
1128 if (parent->childCount() == 0) {
1129 if (selectedEntries.contains(parent))
1130 selectedEntries.remove(parent);
1135 foreach(item,selectedEntries) {
1136 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1140 myEnforcedTreeWidget->selectionModel()->clearSelection();
1143 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1144 This method updates the GUI widgets with the hypothesis data
1146 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1148 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1149 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1151 BlsurfHypothesisData data;
1152 that->readParamsFromHypo( data );
1155 myName->setText( data.myName );
1156 QFontMetrics metrics( myName->font() );
1157 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1159 myTopology->setCurrentIndex( data.myTopology );
1160 myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1161 myPhySize->SetValue( data.myPhySize );
1162 #ifdef WITH_SIZE_BOUNDARIES
1163 MESSAGE("data.myPhyMin: "<<data.myPhyMin)
1164 if (data.myPhyMin < 0)
1165 myPhyMin->setText("");
1167 myPhyMin->SetValue( data.myPhyMin );
1168 MESSAGE("data.myPhyMax: "<<data.myPhyMax)
1169 if (data.myPhyMax < 0)
1170 myPhyMax->setText("");
1172 myPhyMax->SetValue( data.myPhyMax );
1173 MESSAGE("data.myGeoMin: "<<data.myGeoMin)
1174 if (data.myGeoMin < 0)
1175 myGeoMin->setText("");
1177 myGeoMin->SetValue( data.myGeoMin );
1178 MESSAGE("data.myGeoMax: "<<data.myGeoMax)
1179 if (data.myGeoMax < 0)
1180 myGeoMax->setText("");
1182 myGeoMax->SetValue( data.myGeoMax );
1184 myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1185 // myAngleMeshS->setValue( data.myAngleMeshS );
1186 // myAngleMeshC->setValue( data.myAngleMeshC );
1187 // myGradation->setValue( data.myGradation );
1188 myAngleMeshS->SetValue( data.myAngleMeshS );
1189 myAngleMeshC->SetValue( data.myAngleMeshC );
1190 myGradation->SetValue( data.myGradation );
1191 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1192 myDecimesh->setChecked( data.myDecimesh );
1193 myVerbosity->setValue( data.myVerbosity );
1195 if ( myOptions.operator->() ) {
1196 // MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
1197 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1198 QString option = that->myOptions[i].in();
1199 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1200 if ( name_value.count() > 1 ) {
1201 QString idStr = QString("%1").arg( i );
1202 int row = myOptionTable->rowCount();
1203 myOptionTable->setRowCount( row+1 );
1204 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1205 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1206 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1207 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1208 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1209 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1210 Qt::ItemIsEditable |
1211 Qt::ItemIsEnabled );
1215 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1218 // MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1219 QMapIterator<QString, QString> i(that->mySMPMap);
1220 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1221 while (i.hasNext()) {
1223 const QString entry = i.key();
1224 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1225 const QString sizeMap = i.value();
1226 int row = mySizeMapTable->rowCount();
1227 mySizeMapTable->setRowCount( row+1 );
1228 mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( entry ) );
1229 mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 );
1230 mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) );
1231 mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 );
1232 mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) );
1233 mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |
1234 Qt::ItemIsEditable |
1235 Qt::ItemIsEnabled );
1238 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1239 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1241 // Enforced vertices
1242 // MESSAGE("retrieveParams(): data.entryEnfVertexListMap.size() = " << data.entryEnfVertexListMap.size());
1243 std::map<std::string, std::set<std::vector<double> > >::const_iterator evmIt = data.entryEnfVertexListMap.begin();
1244 for ( ; evmIt != data.entryEnfVertexListMap.end() ; ++evmIt) {
1245 std::string entry = (*evmIt).first;
1246 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1248 std::set<std::vector<double> > evs;
1249 std::set<std::vector<double> >::const_iterator evsIt;
1251 evs = (*evmIt).second;
1254 // MESSAGE("evs = (*evmIt)[entry]: FAIL");
1258 evsIt = evs.begin();
1259 for ( ; evsIt != evs.end() ; ++evsIt) {
1265 std::string groupName = data.enfVertexGroupNameMap[(*evsIt)];
1266 MESSAGE("Vertex "<<x<<" "<<y<<" "<<z<<" has group name "<<groupName);
1267 that->addEnforcedVertex(entry, shapeName, x, y, z, groupName);
1269 that->addEnforcedVertex(entry, shapeName, x, y, z);
1272 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1273 myEnforcedTreeWidget->resizeColumnToContents(column);
1276 that->onPhysicalMeshChanged();
1277 that->onGeometricMeshChanged();
1280 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1281 This method updates the hypothesis data with the GUI widgets content.
1283 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1285 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1287 BlsurfHypothesisData data;
1288 QString guiHyp = that->readParamsFromWidgets( data );
1289 that->storeParamsToHypo( data );
1294 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1295 Updates the hypothesis data from hypothesis values.
1297 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
1299 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
1300 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1301 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1303 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1304 h_data.myName = isCreation() && data ? hypName() : "";
1306 h_data.myTopology = (int) h->GetTopology();
1307 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
1308 h_data.myPhySize = h->GetPhySize();
1309 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
1310 h_data.myAngleMeshS = h->GetAngleMeshS();
1311 h_data.myAngleMeshC = h->GetAngleMeshC();
1312 h_data.myGradation = h->GetGradation();
1313 h_data.myAllowQuadrangles = h->GetQuadAllowed();
1314 h_data.myDecimesh = h->GetDecimesh();
1315 h_data.myVerbosity = h->GetVerbosity();
1317 #ifdef WITH_SIZE_BOUNDARIES
1318 double PhyMin = h->GetPhyMin();
1319 double PhyMax = h->GetPhyMax();
1320 double GeoMin = h->GetGeoMin();
1321 double GeoMax = h->GetGeoMax();
1322 // if ( PhyMin > 0 )
1323 // h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString("");
1324 // h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString("");
1325 // h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString("");
1326 // h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString("");
1327 h_data.myPhyMin = PhyMin > 0 ? PhyMin : -1.0;
1328 h_data.myPhyMax = PhyMax > 0 ? PhyMax : -1.0;
1329 h_data.myGeoMin = GeoMin > 0 ? GeoMin : -1.0;
1330 h_data.myGeoMax = GeoMax > 0 ? GeoMax : -1.0;
1333 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1334 that->myOptions = h->GetOptionValues();
1336 that->mySMPMap.clear();
1338 // classic size maps
1339 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
1340 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
1341 QString fullSizeMaps;
1342 QStringList fullSizeMapList;
1343 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1344 for ( int i = 0;i<mySizeMaps->length(); ++i ) {
1345 fullSizeMaps = mySizeMaps[i].in();
1346 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
1347 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
1348 if ( fullSizeMapList.count() > 1 ) {
1349 string fullSizeMap = fullSizeMapList[1].toStdString();
1350 int pos = fullSizeMap.find("return")+7;
1351 // MESSAGE("pos:" << pos);
1354 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
1359 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
1360 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
1361 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
1362 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
1368 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
1369 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
1371 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
1372 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
1373 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
1374 if ( fullCustomSizeMapList.count() > 1 ) {
1375 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
1376 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
1377 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
1378 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
1383 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
1384 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
1386 for ( int i = 0;i<allMyAttractors->length(); ++i ) {
1387 QString myAttractors = allMyAttractors[i].in();
1388 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
1389 if ( myAttractorList.count() > 1 ) {
1390 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
1391 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
1392 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
1393 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
1397 // Enforced vertices
1398 h_data.enfVertexList.clear();
1399 h_data.entryEnfVertexListMap.clear();
1401 h_data.groupNameEnfVertexListMap.clear();
1402 // h_data.enfVertexGroupNameMap.clear();
1405 BLSURFPlugin::TEntryEnfVertexListMap_var entryEnfVertexListMap = h->GetAllEnforcedVertices();
1406 // MESSAGE("entryEnfVertexListMap->length() = " << entryEnfVertexListMap->length());
1408 for ( int i = 0;i<entryEnfVertexListMap->length(); ++i ) {
1409 std::string entry = entryEnfVertexListMap[i].entry.in();
1410 BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
1411 std::set<std::vector<double> > evs;
1413 std::string groupName = "";
1415 for (int j=0 ; j<vertexList->length(); ++j) {
1416 double x = vertexList[j][0];
1417 double y = vertexList[j][1];
1418 double z = vertexList[j][2];
1419 std::vector<double> ev;
1424 h_data.enfVertexList.insert(ev);
1426 groupName.assign(h->GetEnforcedVertexGroupName(x, y, z));
1427 MESSAGE("readParamsFromHypo, groupName = "<<groupName)
1428 h_data.enfVertexGroupNameMap[ev] = groupName;
1429 if (groupName != "") {
1430 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
1433 // MESSAGE("New enf vertex for entry " << entry << ": " << x << ", " << y << ", " << z);
1435 // h_data.enfVertMap[entry] = evs;
1436 h_data.entryEnfVertexListMap[entry] = evs;
1437 if (evs.size() == 0) {
1438 // MESSAGE("No enf vertex for entry " << entry << ": key is erased");
1439 // h_data.enfVertMap.erase(entry);
1440 h_data.entryEnfVertexListMap.erase(entry);
1447 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
1448 Saves the hypothesis data to hypothesis values.
1450 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
1452 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
1453 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1454 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
1460 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1462 if ( h->GetTopology() != h_data.myTopology ) // avoid duplication of DumpPython commands
1463 h->SetTopology( (int) h_data.myTopology );
1464 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh )
1465 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
1466 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
1467 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
1468 if ( h->GetGradation() != h_data.myGradation )
1469 h->SetGradation( h_data.myGradation );
1470 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
1471 h->SetQuadAllowed( h_data.myAllowQuadrangles );
1472 if ( h->GetDecimesh() != h_data.myDecimesh )
1473 h->SetDecimesh( h_data.myDecimesh );
1474 if ( h->GetVerbosity() != h_data.myVerbosity )
1475 h->SetVerbosity( h_data.myVerbosity );
1477 if( ((int) h_data.myPhysicalMesh == PhysicalUserDefined)||((int) h_data.myPhysicalMesh == SizeMap) ) {
1478 if ( h->GetPhySize() != h_data.myPhySize )
1479 h->SetPhySize( h_data.myPhySize );
1481 if( (int) h_data.myGeometricMesh == UserDefined ) {
1482 if ( h->GetAngleMeshS() != h_data.myAngleMeshS )
1483 h->SetAngleMeshS( h_data.myAngleMeshS );
1484 if ( h->GetAngleMeshC() != h_data.myAngleMeshC )
1485 h->SetAngleMeshC( h_data.myAngleMeshC );
1487 #ifdef WITH_SIZE_BOUNDARIES
1488 // if ( !isDouble( h_data.myPhyMin ))
1489 // h->SetPhyMin( -1 );
1490 // else if ( h->GetPhyMin() != h_data.myPhyMin.toDouble() )
1491 // h->SetPhyMin( h_data.myPhyMin.toDouble() );
1492 // if ( !isDouble( h_data.myPhyMax ))
1493 // h->SetPhyMax( -1 );
1494 // else if ( h->GetPhyMax() != h_data.myPhyMax.toDouble() )
1495 // h->SetPhyMax( h_data.myPhyMax.toDouble() );
1496 // if ( !isDouble( h_data.myGeoMin ))
1497 // h->SetGeoMin( -1 );
1498 // else if ( h->GetGeoMin() != h_data.myGeoMin.toDouble() )
1499 // h->SetGeoMin( h_data.myGeoMin.toDouble() );
1500 // if ( !isDouble( h_data.myGeoMax ))
1501 // h->SetGeoMax( -1 );
1502 // else if ( h->GetGeoMax() != h_data.myGeoMax.toDouble() )
1503 // h->SetGeoMax( h_data.myGeoMax.toDouble() );
1504 if (h_data.myPhyMin > 0)
1505 h->SetPhyMin( h_data.myPhyMin );
1506 if (h_data.myPhyMax > 0)
1507 h->SetPhyMax( h_data.myPhyMax );
1508 if (h_data.myGeoMin > 0)
1509 h->SetGeoMin( h_data.myGeoMin );
1510 if (h_data.myGeoMax > 0)
1511 h->SetGeoMax( h_data.myGeoMax );
1514 //printf("storeParamsToHypo():myOptions->length()=%d\n",myOptions->length());
1515 h->SetOptionValues( myOptions ); // is set in checkParams()
1517 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1518 QMapIterator<QString,QString> i(that->mySMPMap);
1519 // Iterate over each size map
1520 while (i.hasNext()) {
1522 const QString entry = i.key();
1523 const QString sizeMap = i.value();
1525 if (sizeMap == "__TO_DELETE__") {
1526 // MESSAGE("Delete entry " << entry.toStdString() << " from engine");
1527 h->UnsetEntry(entry.toLatin1().constData());
1529 else if (sizeMap.startsWith("ATTRACTOR")) {
1530 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1531 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
1533 else if (sizeMap.startsWith("def")) {
1534 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1535 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
1538 QString fullSizeMap;
1539 fullSizeMap = QString("");
1540 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
1541 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
1542 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
1543 fullSizeMap = QString("def f(t): return ") + sizeMap;
1544 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
1545 fullSizeMap = QString("def f(): return ") + sizeMap;
1547 // MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
1548 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
1552 // Enforced vertices
1553 std::map<std::string, std::set<std::vector<double> > >::const_iterator evmIt = h_data.entryEnfVertexListMap.begin();
1554 for ( ; evmIt != h_data.entryEnfVertexListMap.end() ; ++evmIt) {
1555 std::string entry = evmIt->first;
1556 std::set<std::vector<double> > evs;
1557 std::set<std::vector<double> >::const_iterator evsIt;
1560 std::string groupName = "";
1562 BLSURFPlugin::TEnfVertexList_var hypVertexList;
1563 int hypNbVertex = 0;
1565 hypVertexList = h->GetEnforcedVerticesEntry(entry.c_str());
1566 hypNbVertex = hypVertexList->length();
1570 evs = evmIt->second;
1571 evsIt = evs.begin();
1572 for ( ; evsIt != evs.end() ; ++evsIt) {
1578 std::map<std::vector<double> , std::string >::const_iterator grpIt = h_data.enfVertexGroupNameMap.find(*evsIt);
1579 if (grpIt != h_data.enfVertexGroupNameMap.end())
1580 groupName = grpIt->second;
1581 // MESSAGE("SetEnforcedVertexEntry("<<entry<<", "<<x<<", "<<y<<", "<<z<<")");
1582 h->SetEnforcedVertexEntryWithGroup( entry.c_str(), x, y, z, groupName.c_str() );
1584 h->SetEnforcedVertexEntry( entry.c_str(), x, y, z );
1586 // Remove old vertices
1587 if (hypNbVertex >0) {
1588 for (int i =0 ; i<hypNbVertex ; i++) {
1589 x = hypVertexList[i][0];
1590 y = hypVertexList[i][1];
1591 z = hypVertexList[i][2];
1592 std::vector<double> vertex;
1593 vertex.push_back(x);
1594 vertex.push_back(y);
1595 vertex.push_back(z);
1596 if (evs.find(vertex) == evs.end()) {
1597 // MESSAGE("UnsetEnforcedVertexEntry("<<entry<<", "<<x<<", "<<y<<", "<<z<<")");
1598 h->UnsetEnforcedVertexEntry( entry.c_str(), x, y, z );
1604 catch(const SALOME::SALOME_Exception& ex)
1606 SalomeApp_Tools::QtCatchCorbaException(ex);
1612 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
1613 Stores the widgets content to the hypothesis data.
1615 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
1617 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
1618 h_data.myName = myName ? myName->text() : "";
1619 h_data.myTopology = myTopology->currentIndex();
1620 h_data.myPhysicalMesh = myPhysicalMesh->currentIndex();
1621 h_data.myPhySize = myPhySize->GetValue();
1622 #ifdef WITH_SIZE_BOUNDARIES
1623 h_data.myPhyMin = myPhyMin->GetValue();
1624 h_data.myPhyMax = myPhyMax->GetValue();
1625 h_data.myGeoMin = myGeoMin->GetValue();
1626 h_data.myGeoMax = myGeoMax->GetValue();
1628 h_data.myGeometricMesh = myGeometricMesh->currentIndex();
1629 h_data.myAngleMeshS = myAngleMeshS->GetValue();
1630 h_data.myAngleMeshC = myAngleMeshC->GetValue();
1631 h_data.myGradation = myGradation->GetValue();
1632 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
1633 h_data.myDecimesh = myDecimesh->isChecked();
1634 h_data.myVerbosity = myVerbosity->value();
1637 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
1638 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
1639 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
1640 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
1641 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; ";
1642 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
1643 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
1644 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; ";
1645 #ifdef WITH_SIZE_BOUNDARIES
1646 guiHyp += "hphymin = " + QString::number( h_data.myPhyMin ) + "; ";
1647 guiHyp += "hphymax = " + QString::number( h_data.myPhyMax ) + "; ";
1648 guiHyp += "hgeomin = " + QString::number( h_data.myGeoMin ) + "; ";
1649 guiHyp += "hgeomax = " + QString::number( h_data.myGeoMax ) + "; ";
1652 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1653 int row = 0, nbRows = myOptionTable->rowCount();
1654 for ( ; row < nbRows; ++row )
1656 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
1657 if ( id >= 0 && id < myOptions->length() )
1659 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
1660 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
1661 if ( value.isNull() )
1663 that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
1665 guiHyp += name + " = " + value + "; ";
1670 row = 0, nbRows = mySizeMapTable->rowCount();
1671 for ( ; row < nbRows; ++row )
1673 QString entry = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text();
1674 if ( that->mySMPMap.contains(entry) )
1675 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
1678 // Enforced vertices
1679 h_data.enfVertexList.clear();
1680 h_data.entryEnfVertexListMap.clear();
1682 h_data.groupNameEnfVertexListMap.clear();
1683 h_data.enfVertexGroupNameMap.clear();
1686 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
1687 int nbEnforcedVertices = 0;
1688 std::string groupName = "";
1689 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
1690 for (int i=0 ; i<nbEnforcedShapes ; i++) {
1691 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
1693 std::string entry = shapeItem->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
1694 nbEnforcedVertices = shapeItem->childCount();
1695 if (nbEnforcedVertices >0) {
1696 double childValueX,childValueY,childValueZ;
1697 QTreeWidgetItem* child;
1698 std::set<std::vector<double> > evs;
1699 for (row = 0;row<nbEnforcedVertices;row++) {
1700 child = shapeItem->child(row);
1701 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1702 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1703 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1704 std::vector<double> vertex;
1705 vertex.push_back(childValueX);
1706 vertex.push_back(childValueY);
1707 vertex.push_back(childValueZ);
1709 h_data.enfVertexList.insert(vertex);
1711 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
1713 if (makeGroupsCheck->isChecked())
1714 groupName = myGlobalGroupName->text().toStdString();
1715 h_data.enfVertexGroupNameMap[vertex] = groupName;
1716 if (groupName != "")
1717 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
1720 h_data.entryEnfVertexListMap[entry] = evs;
1725 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
1729 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
1730 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged");
1731 bool isPhysicalUserDefined = (myPhysicalMesh->currentIndex() == PhysicalUserDefined);
1732 bool isSizeMap = (myPhysicalMesh->currentIndex() == SizeMap);
1733 bool isCustom = (isPhysicalUserDefined || isSizeMap) ;
1734 bool geomIsCustom = (myGeometricMesh->currentIndex() == UserDefined);
1736 myGradation->setEnabled(!isPhysicalUserDefined || geomIsCustom);
1737 myPhySize->setEnabled(isCustom);
1738 myPhyMax->setEnabled(isCustom);
1739 myPhyMin->setEnabled(isCustom);
1741 if ( !myGradation->isEnabled())
1742 // myGradation->setValue( 1.1 );
1743 myGradation->SetValue( 1.1 );
1746 // QString aPhySize = "";
1747 // switch( myPhysicalMesh->currentIndex() ) {
1748 // case DefaultSize:
1753 // myPhySize->setText( aPhySize );
1754 // if ( !isDouble( myPhyMin->text(), true ))
1755 // myPhyMin->setText("");
1756 // if ( !isDouble( myPhyMax->text(), true ))
1757 // myPhyMax->setText("");
1758 if ( myGeometricMesh->currentIndex() == DefaultGeom ) {
1759 myGeometricMesh->setCurrentIndex( UserDefined );
1760 onGeometricMeshChanged();
1765 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
1766 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged");
1767 bool isCustom = (myGeometricMesh->currentIndex() == UserDefined);
1768 bool phyIsSizemap = (myPhysicalMesh->currentIndex() == SizeMap);
1770 myAngleMeshS->setEnabled(isCustom);
1771 myAngleMeshC->setEnabled(isCustom);
1772 myGradation->setEnabled(isCustom || phyIsSizemap);
1773 myGeoMax->setEnabled(isCustom);
1774 myGeoMin->setEnabled(isCustom);
1776 if ( !myGradation->isEnabled())
1777 myGradation->SetValue( 1.1 );
1780 // double aAngleMeshS;
1781 // switch( myGeometricMesh->currentIndex() ) {
1782 // case DefaultGeom:
1787 // myAngleMeshS->SetValue( aAngleMeshS );
1788 // myAngleMeshC->SetValue( aAngleMeshS );
1789 // if ( !isDouble( myGeoMin->text(), true ))
1790 // myGeoMin->setText("");
1791 // if ( !isDouble( myGeoMax->text(), true ))
1792 // myGeoMax->setText("");
1793 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
1794 if ( myPhysicalMesh->currentIndex() == DefaultSize ) {
1795 myPhysicalMesh->setCurrentIndex( PhysicalUserDefined );
1796 onPhysicalMeshChanged();
1801 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
1803 QMenu* menu = (QMenu*)sender();
1804 // fill popup with option names
1806 if ( myOptions.operator->() ) {
1807 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1808 QString name_value = myOptions[i].in();
1809 QString name = name_value.split( ":", QString::KeepEmptyParts )[0];
1810 menu->addAction( name );
1815 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
1817 myOptionTable->setFocus();
1818 QMenu* menu = (QMenu*)( a->parent() );
1820 int idx = menu->actions().indexOf( a );
1821 QString idStr = QString("%1").arg( idx );
1822 QString option = myOptions[idx].in();
1823 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
1825 // look for a row with optionName
1826 int row = 0, nbRows = myOptionTable->rowCount();
1827 for ( ; row < nbRows; ++row )
1828 if ( myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
1830 // add a row if not found
1831 if ( row == nbRows ) {
1832 myOptionTable->setRowCount( row+1 );
1833 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1834 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1835 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
1836 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1837 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
1838 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1839 Qt::ItemIsEditable |
1840 Qt::ItemIsEnabled );
1841 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1843 myOptionTable->clearSelection();
1844 myOptionTable->scrollToItem( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
1845 //myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
1846 myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
1847 //myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
1850 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
1852 // clear option values and remember selected row
1853 QList<int> selectedRows;
1854 QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
1855 QTableWidgetItem* item;
1856 foreach( item, selected ) {
1857 int row = item->row();
1858 if ( !selectedRows.contains( row ) ) {
1859 selectedRows.append( row );
1860 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
1861 if ( id >= 0 && id < myOptions->length() )
1862 myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
1865 qSort( selectedRows );
1866 QListIterator<int> it( selectedRows );
1868 while ( it.hasPrevious() )
1869 myOptionTable->removeRow( it.previous() );
1872 // **********************
1873 // *** BEGIN SIZE MAP ***
1874 // **********************
1877 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
1879 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
1880 QList<int> selectedRows;
1881 QList<QTableWidgetItem*> selected = mySizeMapTable->selectedItems();
1882 QTableWidgetItem* item;
1884 foreach( item, selected ) {
1886 if ( !selectedRows.contains( row ) )
1887 selectedRows.append( row );
1890 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1892 qSort( selectedRows );
1893 QListIterator<int> it( selectedRows );
1895 while ( it.hasPrevious() ) {
1896 row = it.previous();
1897 QString entry = mySizeMapTable->item(row,SMP_ENTRY_COLUMN)->text();
1898 if (that->mySMPMap.contains(entry))
1899 that->mySMPMap[entry] = "__TO_DELETE__";
1900 if (that->mySMPShapeTypeMap.contains(entry))
1901 that->mySMPShapeTypeMap.remove(entry);
1902 mySizeMapTable->removeRow(row );
1904 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
1905 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1908 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col)
1910 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< row << "," << col << ")");
1911 if (col == SMP_SIZEMAP_COLUMN) {
1912 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1913 QString entry = that->mySizeMapTable->item(row, SMP_ENTRY_COLUMN)->text();
1914 QString sizeMap = that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->text().trimmed();
1915 // MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
1916 if (! that->mySMPShapeTypeMap.contains(entry))
1918 if (that->mySMPMap.contains(entry))
1919 if (that->mySMPMap[entry] == sizeMap)
1921 QColor* bgColor = new QColor("white");
1922 QColor* fgColor = new QColor("black");
1923 if (! sizeMap.isEmpty()) {
1924 that->mySMPMap[entry] = sizeMap;
1925 if (! sizeMapValidationFromRow(row)) {
1926 bgColor->setRgb(255,0,0);
1927 fgColor->setRgb(255,255,255);
1931 // MESSAGE("Size map empty: reverse to precedent value" );
1932 that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setText(that->mySMPMap[entry]);
1934 that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setBackground(QBrush(*bgColor));
1935 that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setBackground(QBrush(*bgColor));
1936 that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setForeground(QBrush(*fgColor));
1937 that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setForeground(QBrush(*fgColor));
1938 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1942 void BLSURFPluginGUI_HypothesisCreator::onAddMapOnSurface()
1944 insertElementType(TopAbs_FACE);
1947 void BLSURFPluginGUI_HypothesisCreator::onAddMapOnEdge()
1949 insertElementType(TopAbs_EDGE);
1952 void BLSURFPluginGUI_HypothesisCreator::onAddMapOnPoint()
1954 insertElementType(TopAbs_VERTEX);
1957 void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeShapeAsked)
1959 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElementType()");
1961 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1962 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
1964 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1966 TopAbs_ShapeEnum shapeType;
1967 string entry, shapeName;
1968 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1970 LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr();
1972 SALOME_ListIO ListSelectedObjects;
1973 mySel->selectedObjects(ListSelectedObjects, NULL, false );
1974 if (!ListSelectedObjects.IsEmpty())
1976 SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
1977 for (; Object_It.More(); Object_It.Next())
1979 Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
1980 entry = myGeomToolSelected->getEntryOfObject(anObject);
1981 shapeName = anObject->getName();
1982 shapeType = myGeomToolSelected->entryToShapeType(entry);
1983 // MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType);
1984 if (shapeType == typeShapeAsked)
1986 mySizeMapTable->setFocus();
1988 shapeEntry = QString::fromStdString(entry);
1989 double phySize = h->GetPhySize();
1990 std::ostringstream oss;
1993 sizeMap = QString::fromStdString(oss.str());
1994 if (that->mySMPMap.contains(shapeEntry)) {
1995 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
1996 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2000 that->mySMPMap[shapeEntry] = sizeMap;
2001 that->mySMPShapeTypeMap[shapeEntry] = typeShapeAsked;
2002 int row = mySizeMapTable->rowCount() ;
2003 mySizeMapTable->setRowCount( row+1 );
2004 mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( shapeEntry ) );
2005 mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 );
2006 mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) );
2007 mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 );
2008 mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) );
2009 mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2010 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2011 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2012 mySizeMapTable->clearSelection();
2013 mySizeMapTable->scrollToItem( mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN ) );
2015 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2016 myPhysicalMesh->setCurrentIndex( SizeMap );
2017 onPhysicalMeshChanged();
2024 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
2026 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
2027 int row = 0, nbRows = mySizeMapTable->rowCount();
2028 for ( ; row < nbRows; ++row )
2029 if (! sizeMapValidationFromRow(row))
2034 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
2036 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow()");
2037 QString myEntry = mySizeMapTable->item( myRow, SMP_ENTRY_COLUMN )->text();
2038 bool res = sizeMapValidationFromEntry(myEntry,displayError);
2039 mySizeMapTable->setFocus();
2043 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
2045 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
2047 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2049 if (! that->mySMPMap.contains(myEntry)) {
2050 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
2053 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
2054 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
2060 if (that->mySMPMap[myEntry].startsWith("def")) {
2061 // MESSAGE("custom function" );
2062 expr = that->mySMPMap[myEntry].toStdString();
2064 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
2065 // MESSAGE("Attractor" );
2066 if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$")) != 1)) {
2067 // if ((that->mySMPMap[myEntry].count('(') != 1) or
2068 // (that->mySMPMap[myEntry].count(')') != 1) or
2069 // (that->mySMPMap[myEntry].count(';') != 4) or
2070 // (that->mySMPMap[myEntry].size() == 15)){
2072 SUIT_MessageBox::warning( dlg(),"Definition of attractor : Error" ,"An attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)" );
2078 // case size map is empty
2079 if (that->mySMPMap[myEntry].isEmpty()) {
2081 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
2085 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
2086 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
2087 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
2088 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
2089 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
2090 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
2093 //assert(Py_IsInitialized());
2094 if (! Py_IsInitialized())
2095 throw ("Erreur: Python interpreter is not initialized");
2096 PyGILState_STATE gstate;
2097 gstate = PyGILState_Ensure();
2099 PyObject * obj = NULL;
2100 PyObject* new_stderr = NULL;
2101 string err_description="";
2102 obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
2106 new_stderr=newPyStdOut(err_description);
2107 PySys_SetObject("stderr", new_stderr);
2109 PySys_SetObject("stderr", PySys_GetObject("__stderr__"));
2110 Py_DECREF(new_stderr);
2112 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
2113 PyGILState_Release(gstate);
2118 PyObject * func = NULL;
2119 func = PyObject_GetAttrString(main_mod, "f");
2123 new_stderr=newPyStdOut(err_description);
2124 PySys_SetObject("stderr", new_stderr);
2126 PySys_SetObject("stderr", PySys_GetObject("__stderr__"));
2127 Py_DECREF(new_stderr);
2129 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
2130 PyGILState_Release(gstate);
2134 PyGILState_Release(gstate);
2136 // MESSAGE("SizeMap expression "<<expr<<" is valid");
2142 void BLSURFPluginGUI_HypothesisCreator::OnEditMapFunction(QModelIndex* index) {
2143 int myRow = index->row();
2144 int myColumn = index->column();
2148 myEditor = new BLSURFPluginGUI_MapFunctionEditor(sizeMapModel->item(myRow,0)->text());
2149 connect(myEditor, SIGNAL(FunctionEntered(QString)), this, SLOT(FunctionLightValidation(QString)));
2152 // myEditor->show();
2153 // myEditor->raise();
2154 // myEditor->activateWindow();
2157 // BLSURFPluginGUI_MapFunctionEditor* myEditor = new BLSURFPluginGUI_MapFunctionEditor(sizeMapModel->item(myRow,0)->text());
2158 // myEditor->exec();
2159 QString myFunction = myEditor->GetFunctionText();
2160 // FIN RECUPERATION FONCTION
2162 if (! myFunction.isEmpty()) {
2166 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2167 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2169 // h->SetSizeMapEntry(sizeMapModel->item(myRow,1)->text().toLatin1().constData(),
2170 // item->text().toLatin1().constData());
2171 h->SetSizeMapEntry(sizeMapModel->item(myRow,1)->text().toLatin1().constData(),
2172 myFunction.toLatin1().constData());
2173 // FIN MAJ DE LA MAP
2178 QString BLSURFPluginGUI_HypothesisCreator::caption() const
2180 return tr( "BLSURF_TITLE" );
2183 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
2185 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
2188 QString BLSURFPluginGUI_HypothesisCreator::type() const
2190 return tr( "BLSURF_HYPOTHESIS" );
2193 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
2195 return "blsurf_hypo_page.html";
2198 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
2201 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2203 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );