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 if (that->GeomToolSelected == NULL) {
482 that->GeomToolSelected = new GeomSelectionTools();
484 return that->GeomToolSelected;
487 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
489 return GeometryGUI::GetGeomGen();
492 void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
494 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
495 ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
496 for ( ; anIt != selectionWidgets.end(); anIt++)
498 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
500 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
501 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
502 ListOfWidgets::const_iterator anIt2 = anIt;
503 for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
504 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
506 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
507 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
508 w1->AvoidSimultaneousSelection( w2 );
510 if ( !widgetToActivate )
511 widgetToActivate = w1;
514 if ( widgetToActivate )
515 widgetToActivate->activateSelection();
518 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
520 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
523 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
524 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
528 myAdvWidget->myOptionTable->setFocus();
529 QApplication::instance()->processEvents();
533 int iTbl = 0, nbTbl = myAdvWidget->myOptionTable->topLevelItemCount();
534 for ( ; iTbl < nbTbl; ++iTbl )
536 QTreeWidgetItem* table = myAdvWidget->myOptionTable->topLevelItem( iTbl );
537 int nbRows = table->childCount();
538 for ( int iRow = 0; iRow < nbRows; ++iRow )
540 QTreeWidgetItem* row = table->child( iRow );
541 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
543 if ( name.simplified().isEmpty() )
544 continue; // invalid custom option
546 if ( isDefault ) // not selected option
553 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
556 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
559 h->AddOption( name.toLatin1().constData(), value.toLatin1().constData() );
563 catch ( const SALOME::SALOME_Exception& ex )
565 msg = ex.details.text.in();
574 h->SetOptionValues( myOptions ); // restore values
575 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
579 // SizeMap and attractors
582 mySizeMapTable->setFocus();
583 QApplication::instance()->processEvents();
585 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
586 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
588 for ( ; row < nbRows; ++row )
590 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
591 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
592 MESSAGE("entry ="<<entry.toStdString())
593 if ( !sizeMap.isEmpty() ) {
594 if (that->sizeMapValidationFromRow(row))
597 MESSAGE("entry ="<<entry.toStdString())
598 MESSAGE("sizeMap ="<<sizeMap.toStdString())
600 e = entry.toStdString();
601 s = that->mySMPMap[entry].toStdString();
602 MESSAGE("row = "<<row)
605 h->SetSizeMapEntry( e.c_str(), s.c_str() );
607 catch ( const SALOME::SALOME_Exception& ex )
609 msg = ex.details.text.in();
620 // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
623 // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
624 // So STD_TAB must be current tab to get correct value of it's spinbox.
625 myTabWidget->setCurrentIndex( STD_TAB );
629 if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
630 myStdWidget->myPhySize->text().toDouble() > 0.0 )))
631 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
635 if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
636 myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
637 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
641 if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
642 myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
643 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
647 if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
648 myStdWidget->myChordalError->text().toDouble() > 0.0 )))
649 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
658 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
660 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
662 QFrame* fr = new QFrame( 0 );
663 // fr-> setMinimumSize(600,400);
664 QVBoxLayout* lay = new QVBoxLayout( fr );
665 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
667 lay->setSpacing( 0 );
669 // main TabWidget of the dialog
670 myTabWidget = new QTabWidget( fr );
671 myTabWidget->setTabShape( QTabWidget::Rounded );
672 myTabWidget->setTabPosition( QTabWidget::North );
673 lay->addWidget( myTabWidget );
678 myStdGroup = new QWidget();
679 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
680 aStdLayout->setSpacing( 6 );
681 aStdLayout->setMargin( 11 );
684 myName = new QLineEdit( myStdGroup );
685 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
689 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
690 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
692 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
698 // row = max(row,maxrow)+1;
699 aStdLayout->setRowStretch(row,1);
700 aStdLayout->setColumnStretch(1,1);
704 // advanced parameters
705 myAdvGroup = new QWidget();
706 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
707 anAdvLayout->setSpacing( 6 );
708 anAdvLayout->setMargin( 11 );
709 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
710 //myAdvWidget->addBtn->setMenu( new QMenu() );
711 anAdvLayout->addWidget( myAdvWidget );
714 // Size Maps parameters
716 mySmpGroup = new QWidget();
717 // mySmpGroup->setMinimumWidth(500);
720 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
723 mySizeMapTable = new QTreeWidget( mySmpGroup );
724 mySizeMapTable ->setMinimumWidth(200);
725 QStringList sizeMapHeaders;
726 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
727 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
728 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
729 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
730 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
731 mySizeMapTable->setAlternatingRowColors(true);
734 smpTab = new QTabWidget( mySmpGroup );
735 smpTab->setTabShape( QTabWidget::Rounded );
736 smpTab->setTabPosition( QTabWidget::South );
737 lay->addWidget( smpTab );
739 // Filters of selection
740 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
742 SM_ShapeTypes.Add( TopAbs_VERTEX );
743 SM_ShapeTypes.Add( TopAbs_EDGE );
744 SM_ShapeTypes.Add( TopAbs_FACE );
745 SM_ShapeTypes.Add( TopAbs_COMPOUND );
747 ATT_ShapeTypes.Add( TopAbs_VERTEX );
748 ATT_ShapeTypes.Add( TopAbs_EDGE );
749 ATT_ShapeTypes.Add( TopAbs_WIRE );
750 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
752 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
753 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
754 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
756 // Standard size map tab
757 mySmpStdGroup = new QWidget();
758 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
759 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false);
760 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
761 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
762 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
763 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
766 myAttractorGroup = new QWidget();
767 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
768 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false);
769 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
770 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
771 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
772 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
773 QFrame* attLine = new QFrame(myAttractorGroup);
774 attLine->setFrameShape(QFrame::HLine);
775 attLine->setFrameShadow(QFrame::Sunken);
776 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false);
777 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
778 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
779 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
780 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
781 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
782 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
783 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
784 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
785 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
786 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
788 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
789 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
793 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
794 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
795 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
796 modifyMapButton->setEnabled(false);
799 myAttSelWdg->setEnabled(false);
800 myAttSizeSpin->setEnabled(false);
801 myAttSizeLabel->setEnabled(false);
802 myAttDistSpin->setEnabled(false);
803 myAttDistLabel->setEnabled(false);
804 myAttDistSpin2->setEnabled(false);
805 myAttDistLabel2->setEnabled(false);
806 myAttDistSpin->setValue(0.);
807 myAttDistSpin2->setValue(0.);
808 myAttSizeSpin->setValue(0.);
809 mySmpSizeSpin->setValue(0.);
812 // ADD WIDGETS (SIZEMAP TAB)
813 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
814 anSmpLayout->setColumnStretch(0, 1);
815 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
816 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
817 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
818 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
819 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
820 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
823 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
824 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
825 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
826 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
829 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
830 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
831 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
832 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
833 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
834 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
835 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
836 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
837 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
838 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
839 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
840 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
842 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
843 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
845 smpTab->setCurrentIndex( SMP_STD_TAB );
847 // Enforced vertices parameters
848 myEnfGroup = new QWidget();
849 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
851 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
852 // anEnfLayout->addWidget(myEnforcedVertexWidget);
853 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
854 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
856 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
857 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
858 myEnforcedTreeWidget->setSortingEnabled(true);
859 QStringList enforcedHeaders;
860 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
861 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
862 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
864 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
865 myEnforcedTreeWidget->header()->setStretchLastSection(true);
866 myEnforcedTreeWidget->setAlternatingRowColors(true);
867 myEnforcedTreeWidget->setUniformRowHeights(true);
868 myEnforcedTreeWidget->setAnimated(true);
869 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
870 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
871 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
872 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
873 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
875 myEnforcedTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
877 myEnforcedTreeWidget->resizeColumnToContents(column);
879 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
880 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
881 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
883 // FACE AND VERTEX SELECTION
884 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
885 shapeTypes1.Add( TopAbs_FACE );
886 shapeTypes1.Add( TopAbs_COMPOUND );
887 shapeTypes2.Add( TopAbs_VERTEX );
888 shapeTypes2.Add( TopAbs_COMPOUND );
890 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
891 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true);
892 myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
894 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
895 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
896 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
898 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
900 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
901 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
902 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
904 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
905 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
906 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
908 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
909 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
910 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
912 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
913 myGroupName = new QLineEdit(myEnfGroup);
915 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
916 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
918 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
920 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
921 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
923 // myGlobalGroupName = new QCheckBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
924 // myGlobalGroupName->setChecked(false);
926 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
927 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
928 // FACE AND VERTEX SELECTION
929 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
930 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
931 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
932 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
933 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
934 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
935 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
936 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
937 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
938 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
939 // anEnfLayout2->addWidget(myGlobalGroupName, ENF_VER_GROUP_CHECK, 0, 1, 2);
940 // anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
941 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
942 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
943 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
944 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
945 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
946 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
947 // anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
948 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
949 // anEnfLayout->setRowStretch(1, 1);
952 // Periodicity parameters
953 myPeriodicityGroup = new QWidget();
954 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
956 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
957 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
958 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
960 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
962 QStringList myPeriodicityTreeHeaders;
963 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
964 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
965 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
966 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
967 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
968 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
969 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
970 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
971 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
972 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
974 // Hide the vertex name to make the widget more readable
975 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
976 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
977 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
978 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
979 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
980 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
981 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
984 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
985 myPeriodicityTreeWidget->setSortingEnabled(true);
987 myPeriodicityTreeWidget->setAlternatingRowColors(true);
988 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
989 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
991 size_t periodicityVisibleColumns = 2;
992 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
993 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
994 myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
996 myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
998 myPeriodicityTreeWidget->resizeColumnToContents(column);
1000 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
1002 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
1004 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
1006 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
1007 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
1008 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
1010 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
1012 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
1013 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
1015 myPeriodicityOnFaceRadioButton->setChecked(true);
1017 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
1018 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
1021 // FACE, EDGE AND VERTEX SELECTION
1022 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
1023 shapeTypesFace.Add( TopAbs_FACE );
1024 shapeTypesFace.Add( TopAbs_EDGE );
1025 shapeTypesFace.Add( TopAbs_COMPOUND );
1026 shapeTypesEdge.Add( TopAbs_EDGE );
1027 shapeTypesEdge.Add( TopAbs_COMPOUND );
1029 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
1031 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1032 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1034 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1035 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false);
1036 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1037 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1039 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1040 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1041 // myPeriodicitySourceEdgeWdg->hide();
1042 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1044 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1045 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1047 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1048 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false);
1049 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1050 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1052 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1053 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1054 // myPeriodicityTargetEdgeWdg->hide();
1055 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1057 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1058 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1059 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1061 myPeriodicityGroupBox2->setCheckable(true);
1062 myPeriodicityGroupBox2->setChecked(false);
1064 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1065 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1067 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1068 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1071 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1072 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1075 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1076 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false);
1077 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1080 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1081 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1083 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1084 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false);
1085 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1088 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1089 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1091 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1092 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false);
1093 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1096 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1097 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1099 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1100 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false);
1101 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1104 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1105 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1107 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1108 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false);
1109 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1112 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1113 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1115 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1116 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false);
1117 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1119 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1120 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1123 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1124 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1126 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1127 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1129 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1131 myPeriodicitySelectionWidgets.clear();
1132 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1133 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1134 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1135 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1136 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1137 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1138 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1139 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1140 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1143 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1144 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1145 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1146 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1147 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1149 myTabWidget->setCurrentIndex( STD_TAB );
1151 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
1152 connect( myStdWidget->myAllowQuadrangles, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChange() ));
1155 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1156 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1157 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1158 // connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1159 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1160 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1161 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1162 connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1163 // connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1164 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1165 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1166 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1167 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1168 connect( myTabWidget, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1170 // Enforced vertices
1171 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1172 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1173 // connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1174 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1175 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1176 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1177 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1178 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1179 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1180 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1183 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1184 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1185 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1186 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1188 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1189 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1191 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1192 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1195 // connect( myPeriodicitySourceFaceWdg, SIGNAL(contentModified()), this, SLOT(onPeriodicityContentModified()));
1199 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1200 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1202 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1204 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1205 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1206 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1207 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1208 // myEnfFaceWdg->deactivateSelection();
1209 // myEnfVertexWdg->deactivateSelection();
1213 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1215 myStdWidget->onPhysicalMeshChanged();
1219 * This method resets the content of the X, Y, Z widgets;
1221 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1223 myXCoord->setCleared(true);
1224 myYCoord->setCleared(true);
1225 myZCoord->setCleared(true);
1226 myXCoord->setText("");
1227 myYCoord->setText("");
1228 myZCoord->setText("");
1229 // myGroupName->setText("");
1232 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1233 This method updates the tooltip of a modified item. The QLineEdit widgets content
1234 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1236 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1237 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1238 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1239 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1240 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1241 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1242 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1243 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1244 QTreeWidgetItem* parent = item->parent();
1246 clearEnforcedVertexWidgets();
1248 if (parent && (!x.isNull() || !entry.isNull())) {
1249 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1250 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1251 if (entry.isNull()) {
1252 toolTip += QString("(") + x.toString();
1253 toolTip += QString(", ") + y.toString();
1254 toolTip += QString(", ") + z.toString();
1255 toolTip += QString(")");
1258 if (!groupName.isEmpty())
1259 toolTip += QString(" [") + groupName + QString("]");
1261 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1264 myXCoord->SetValue(x.toDouble());
1265 myYCoord->SetValue(y.toDouble());
1266 myZCoord->SetValue(z.toDouble());
1269 if (!groupName.isEmpty())
1270 myGroupName->setText(groupName);
1274 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1275 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1276 clearEnforcedVertexWidgets();
1277 if (nbSelEnfVertex == 1)
1279 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1282 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1283 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1284 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1285 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1286 if (CORBA::is_nil(measureOp))
1289 CORBA::Double x,y,z;
1290 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1291 if ( measureOp->IsDone() )
1293 myXCoord->SetValue(x);
1294 myYCoord->SetValue(y);
1295 myZCoord->SetValue(z);
1301 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1302 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1303 of the enforced vertex clicked in the tree widget.
1305 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1306 clearEnforcedVertexWidgets();
1307 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1308 if (! items.isEmpty() && items.size() == 1) {
1309 QTreeWidgetItem *item = items[0];
1310 // for (int i=0 ; i < items.size() ; i++) {
1312 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1313 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1314 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1315 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1316 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1317 if (!x.isNull()/* && entry.isNull()*/) {
1318 myXCoord->SetValue(x.toDouble());
1319 myYCoord->SetValue(y.toDouble());
1320 myZCoord->SetValue(z.toDouble());
1323 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1324 myGroupName->setText(group.toString());
1329 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1330 This method adds a face containing enforced vertices in the tree widget.
1332 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1333 // Find theFaceEntry item
1334 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1335 QTreeWidgetItem* theItem;
1336 if (theItemList.empty()) {
1337 theItem = new QTreeWidgetItem();
1338 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1339 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1340 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1341 myEnforcedTreeWidget->addTopLevelItem(theItem);
1344 theItem = theItemList[0];
1349 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1350 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1352 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(QTreeWidgetItem* theItem, double x, double y, double z,
1353 std::string vertexName, std::string geomEntry, std::string groupName) {
1355 std::string theFaceName = theItem->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
1356 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1357 bool okToCreate = true;
1359 const int nbVert = theItem->childCount();
1360 // MESSAGE("Number of child rows: " << nbVert);
1362 double childValueX,childValueY,childValueZ;
1363 QString childEntry, childGroupName;
1364 QTreeWidgetItem* child;
1365 for (int row = 0;row<nbVert;row++) {
1366 child = theItem->child(row);
1367 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1368 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1369 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1370 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1371 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1372 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1373 // update group name
1374 if (childGroupName.toStdString() != groupName) {
1375 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1376 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1384 if (geomEntry.empty()) {
1385 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1388 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1393 if (geomEntry.empty()) {
1394 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1397 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1400 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1401 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1402 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1403 QSize iconSize = iconSelect.size()*0.7;
1405 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1406 QString myVertexName;
1408 while(indexRef != vertexIndex) {
1409 indexRef = vertexIndex;
1410 if (vertexName.empty())
1411 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1413 myVertexName = QString(vertexName.c_str());
1415 for (int row = 0;row<nbVert;row++) {
1416 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1417 if (myVertexName == name) {
1423 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1424 if (geomEntry.empty()) {
1425 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1426 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1427 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1430 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1431 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1433 if (groupName != "")
1434 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1436 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1437 if (geomEntry.empty()) {
1438 toolTip += QString(" (%1, ").arg(x);
1439 toolTip += QString("%1, ").arg(y);
1440 toolTip += QString("%1)").arg(z);
1442 if (groupName != "")
1443 toolTip += QString(" [%1]").arg(groupName.c_str());
1445 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1446 theItem->setExpanded(true);
1447 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1450 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1451 This method is called when a item is added into the enforced vertices tree widget
1453 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1454 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1456 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1458 getGeomSelectionTool()->selectionMgr()->clearFilters();
1459 myEnfFaceWdg->deactivateSelection();
1460 myEnfVertexWdg->deactivateSelection();
1462 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1463 myEnforcedTreeWidget->resizeColumnToContents(column);
1466 int selEnfFace = myEnfFaceWdg->NbObjects();
1467 int selEnfVertex = myEnfVertexWdg->NbObjects();
1468 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1470 if (selEnfFace == 0)
1473 if ((selEnfVertex == 0) && coordsEmpty)
1476 string entry, shapeName;
1478 for (int i = 0 ; i < selEnfFace ; i++) {
1479 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1480 entry = myEnfFace->GetStudyEntry();
1481 shapeName = myEnfFace->GetName();
1483 QTreeWidgetItem * faceItem = addEnforcedFace(entry, shapeName);
1485 std::string groupName = myGroupName->text().toStdString();
1487 if (boost::trim_copy(groupName).empty())
1490 if (selEnfVertex <= 1)
1493 x = myXCoord->GetValue();
1494 y = myYCoord->GetValue();
1495 z = myZCoord->GetValue();
1496 if (selEnfVertex == 1) {
1497 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1498 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1501 addEnforcedVertex(faceItem, x, y, z, "", "", groupName);
1505 if ( CORBA::is_nil(getGeomEngine()))
1508 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1509 if (CORBA::is_nil(measureOp))
1512 CORBA::Double x,y,z;
1514 for (int j = 0 ; j < selEnfVertex ; j++)
1516 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1517 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1518 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1519 if ( measureOp->IsDone() )
1520 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1521 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1522 addEnforcedVertex(faceItem, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1528 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1529 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1531 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1532 myEnforcedTreeWidget->resizeColumnToContents(column);
1534 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1535 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1536 myStdWidget->onPhysicalMeshChanged();
1540 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1541 This method is called when a item is removed from the enforced vertices tree widget
1543 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1544 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1545 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1546 QList<QTreeWidgetItem *> selectedVertices;
1547 QSet<QTreeWidgetItem *> selectedEntries;
1548 QTreeWidgetItem* item;
1550 foreach( item, selectedItems ) {
1551 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1552 if (! value.isNull())
1553 selectedVertices.append(item);
1555 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1556 if (! value.isNull())
1557 selectedVertices.append(item);
1559 selectedEntries.insert(item);
1563 foreach(item,selectedVertices) {
1564 QTreeWidgetItem* parent = item->parent();
1565 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1566 parent->removeChild(item);
1568 if (parent->childCount() == 0) {
1569 if (selectedEntries.contains(parent))
1570 selectedEntries.remove(parent);
1575 foreach(item,selectedEntries) {
1576 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1580 myEnforcedTreeWidget->selectionModel()->clearSelection();
1584 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1586 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1589 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1590 This method is called when a item is added into the periodicity table widget
1592 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1593 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1595 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1597 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1598 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1599 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1601 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1602 w1->deactivateSelection();
1606 // Source-Target selection
1607 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1608 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1610 if (selSource == 0 || selTarget == 0)
1613 // Vertices selection
1614 if (myPeriodicityGroupBox2->isChecked())
1616 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1617 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1618 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1619 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1620 //int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1621 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1623 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1625 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1626 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1631 // Add Source-Target in table
1632 string shapeEntry, sourceEntry, targetEntry;
1633 string shapeName, sourceName, targetName;
1634 GEOM::GEOM_Object_var shape;
1636 QTreeWidgetItem* item = new QTreeWidgetItem();
1637 myPeriodicityTreeWidget->addTopLevelItem(item);
1639 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1643 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1645 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1646 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1647 shapeName = shape->GetName();
1648 shapeEntry = shape->GetStudyEntry();
1649 item->setData(k, Qt::EditRole, shapeName.c_str() );
1650 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1651 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1655 // Add shape type in tree
1656 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1657 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1659 // Blank input fields
1660 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1662 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1663 w1->SetObject(GEOM::GEOM_Object::_nil());
1666 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1667 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1671 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1672 This method is called when a item is removed from the periodicity tree widget
1674 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1675 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1676 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1677 QTreeWidgetItem* item;
1679 foreach(item,selectedItems) {
1680 MESSAGE("Remove " << item->text(0).toStdString());
1684 myEnforcedTreeWidget->selectionModel()->clearSelection();
1687 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1688 This method enable clears the field for periodicity by vertices
1690 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1694 for (int k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1696 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1697 w1->deactivateSelection();
1698 w1->SetObject(CORBA::Object::_nil());
1703 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1704 This method enable the proper shape selection widget to Face or Edge shapes
1706 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1708 // if (myPeriodicityOnFaceRadioButton->isChecked())
1710 // MESSAGE("Show Face");
1711 // myPeriodicitySourceEdgeWdg->hide();
1712 // myPeriodicityTargetEdgeWdg->hide();
1713 // myPeriodicitySourceFaceWdg->show();
1714 // myPeriodicityTargetFaceWdg->show();
1718 // MESSAGE("Show Edge");
1719 // myPeriodicitySourceFaceWdg->hide();
1720 // myPeriodicityTargetFaceWdg->hide();
1721 // myPeriodicitySourceEdgeWdg->show();
1722 // myPeriodicityTargetEdgeWdg->show();
1726 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1728 QString shapeName, shapeEntry;
1729 CORBA::Object_var shape;
1731 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1732 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1734 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1736 shapeName = item->data(k, Qt::EditRole).toString();
1737 shapeEntry = item->data(k, Qt::UserRole).toString();
1738 if (! shapeEntry.isEmpty())
1740 shape = entryToObject(shapeEntry);
1741 w1->SetObject(shape);
1742 w1->deactivateSelection();
1744 myPeriodicityGroupBox2->setChecked(1);
1747 myPeriodicityGroupBox2->setChecked(0);
1750 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1751 myPeriodicityOnFaceRadioButton->setChecked(true);
1753 myPeriodicityOnEdgeRadioButton->setChecked(true);
1758 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1759 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1761 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1763 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1765 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1767 // find wich selection widget is activated
1768 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1770 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1771 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1773 // don't activate vertex selection if the group box is not checked
1774 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1776 // clear the selection, to avoid to put the same object in the other widget
1777 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1778 // activate the next widget
1779 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1780 w2->activateSelection();
1787 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1788 This method updates the GUI widgets with the hypothesis data
1790 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1792 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1793 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1795 BlsurfHypothesisData data;
1796 that->readParamsFromHypo( data );
1799 myName->setText( data.myName );
1800 QFontMetrics metrics( myName->font() );
1801 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1803 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1804 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1805 if (data.myPhySize <= 0)
1806 myStdWidget->myPhySize->setText("");
1808 myStdWidget->myPhySize->SetValue( data.myPhySize );
1809 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1810 if (data.myMinSize < 0)
1811 myStdWidget->myMinSize->setText("");
1813 myStdWidget->myMinSize->SetValue( data.myMinSize );
1814 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1815 if (data.myMaxSize < 0)
1816 myStdWidget->myMaxSize->setText("");
1818 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1819 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1820 myStdWidget->myUseGradation->setChecked( data.myUseGradation );
1821 if (data.myGradation <= 0 || !data.myUseGradation )
1822 myStdWidget->myGradation->setText("");
1824 myStdWidget->myGradation->SetValue( data.myGradation );
1825 myStdWidget->myUseVolumeGradation->setChecked( data.myUseVolumeGradation );
1826 if (data.myVolumeGradation <= 0 || !data.myUseVolumeGradation )
1827 myStdWidget->myVolumeGradation->setText("");
1829 myStdWidget->myVolumeGradation->SetValue( data.myVolumeGradation );
1830 myStdWidget->myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1832 if (data.myAngleMesh < 0)
1833 myStdWidget->myAngleMesh->setText("");
1835 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1836 if (data.myChordalError <= 0)
1837 myStdWidget->myChordalError->setText("");
1839 myStdWidget->myChordalError->SetValue( data.myChordalError );
1840 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1841 if (data.myAnisotropicRatio <= 0)
1842 myStdWidget->myAnisotropicRatio->setText("");
1844 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1845 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1846 if (data.myTinyEdgeLength <= 0)
1847 myStdWidget->myTinyEdgeLength->setText("");
1849 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1850 myStdWidget->myOptimiseTinyEdges->setChecked( data.myOptimiseTinyEdges );
1851 if (data.myTinyEdgeOptimisLength <= 0)
1852 myStdWidget->myTinyEdgeOptimisLength->setText("");
1854 myStdWidget->myTinyEdgeOptimisLength->SetValue( data.myTinyEdgeOptimisLength );
1855 myStdWidget->myCorrectSurfaceIntersection->setChecked( data.myCorrectSurfaceIntersection );
1856 if (data.myCorrectSurfaceIntersectionMaxCost <= 0)
1857 myStdWidget->myCorrectSurfaceIntersectionMaxCost->setText("");
1859 myStdWidget->myCorrectSurfaceIntersectionMaxCost->SetValue( data.myCorrectSurfaceIntersectionMaxCost );
1860 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1861 if (data.myBadElementAspectRatio <= 0)
1862 myStdWidget->myBadElementAspectRatio->setText("");
1864 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1865 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1866 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1868 myStdWidget->resizeWidgets();
1870 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1872 if ( myOptions.operator->() ) {
1873 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1874 myAdvWidget->AddOption( TBL_MESHING, that->myOptions[i].in() );
1876 if ( myPreCADOptions.operator->() ) {
1877 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i )
1878 myAdvWidget->AddOption( TBL_PRECAD, that->myPreCADOptions[i].in() );
1880 if ( myCustomOptions.operator->() ) {
1881 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1882 myAdvWidget->AddOption( TBL_CUSTOM, that->myCustomOptions[i].in() );
1884 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1885 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1886 // myGMFFileMode->setChecked(data.myGMFFileMode);
1889 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1890 QMapIterator<QString, QString> i(that->mySMPMap);
1891 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1892 while (i.hasNext()) {
1894 const QString entry = i.key();
1895 const QString sizeMap = i.value();
1896 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1897 //int row = mySizeMapTable->topLevelItemCount();
1898 QTreeWidgetItem* item = new QTreeWidgetItem();
1899 mySizeMapTable->addTopLevelItem( item );
1900 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1901 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1902 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1903 if (that->myATTMap.contains(entry)) {
1904 TAttractorVec & attVec = that->myATTMap[entry];
1905 for ( size_t i = 0; i < attVec.size(); ++i )
1907 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
1908 QTreeWidgetItem* child = new QTreeWidgetItem();
1909 item->addChild( child );
1910 item->setExpanded(true);
1911 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
1912 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
1913 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
1915 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
1916 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
1919 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
1925 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1928 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1929 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1930 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1932 // Enforced vertices
1933 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1934 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1936 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1937 TEntry entry = (*evmIt).first;
1938 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1939 MESSAGE("Face entry: " << entry);
1940 MESSAGE("Face name: " << shapeName);
1942 QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1944 TEnfVertexList evs = (*evmIt).second;
1946 TEnfVertexList::const_iterator evsIt = evs.begin();
1947 TEnfVertex *enfVertex;
1948 for ( ; evsIt != evs.end() ; ++evsIt) {
1949 enfVertex = (*evsIt);
1950 MESSAGE("Name: " << enfVertex->name);
1951 double x = 0, y = 0, z = 0;
1952 if (enfVertex->coords.size()) {
1953 x = enfVertex->coords[0];
1954 y = enfVertex->coords[1];
1955 z = enfVertex->coords[2];
1957 that->addEnforcedVertex(faceItem, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1961 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1962 myEnforcedTreeWidget->resizeColumnToContents(column);
1964 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1965 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1966 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1969 MESSAGE("retrieveParams(): periodicity ");
1972 // Add an item in the tree widget for each association
1973 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
1975 QTreeWidgetItem* item = new QTreeWidgetItem();
1976 myPeriodicityTreeWidget->addTopLevelItem(item);
1977 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1978 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
1979 for (size_t k=0; k<periodicity_i.size(); k++)
1981 string shapeEntry = periodicity_i[k];
1982 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
1983 item->setData(k, Qt::EditRole, shapeName.c_str() );
1984 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1989 that->myStdWidget->onPhysicalMeshChanged();
1990 that->myStdWidget->onGeometricMeshChanged();
1991 that->onStateChange();
1994 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1995 This method updates the hypothesis data with the GUI widgets content.
1997 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1999 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParams");
2000 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2002 BlsurfHypothesisData data;
2003 QString guiHyp = that->readParamsFromWidgets( data );
2004 that->storeParamsToHypo( data );
2009 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
2010 Updates the hypothesis data from hypothesis values.
2012 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
2014 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
2015 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2016 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2018 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
2019 h_data.myName = isCreation() && data ? hypName() : "";
2021 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
2022 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
2023 h_data.myPhySize = h->GetPhySize();
2024 h_data.myPhySizeRel = h->IsPhySizeRel();
2025 double minSize = h->GetMinSize();
2026 double maxSize = h->GetMaxSize();
2027 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2028 h_data.myMinSizeRel = h->IsMinSizeRel();
2029 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2030 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2031 h_data.myUseGradation = h->GetUseGradation();
2032 h_data.myGradation = h->GetGradation();
2033 h_data.myUseVolumeGradation = h->GetUseVolumeGradation();
2034 h_data.myVolumeGradation = h->GetVolumeGradation();
2035 h_data.myAllowQuadrangles = h->GetQuadAllowed();
2036 double angle = h->GetAngleMesh();
2037 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2038 double chordalError = h->GetChordalError();
2039 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2040 h_data.myAnisotropic = h->GetAnisotropic();
2041 double myAnisotropicRatio = h->GetAnisotropicRatio();
2042 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2043 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2044 double myTinyEdgeLength = h->GetTinyEdgeLength();
2045 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2046 h_data.myOptimiseTinyEdges = h->GetOptimiseTinyEdges();
2047 double myTinyEdgeOptimisLength = h->GetTinyEdgeOptimisationLength();
2048 h_data.myTinyEdgeOptimisLength = myTinyEdgeOptimisLength > 0 ? myTinyEdgeOptimisLength : -1.0;
2049 h_data.myCorrectSurfaceIntersection = h->GetCorrectSurfaceIntersection();
2050 double corrSurfaceIntersMaxCost = h->GetCorrectSurfaceIntersectionMaxCost();
2051 h_data.myCorrectSurfaceIntersectionMaxCost = corrSurfaceIntersMaxCost > 0 ? corrSurfaceIntersMaxCost : -1.0;
2052 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2053 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2054 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2055 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2056 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2057 h_data.myVerbosity = h->GetVerbosity();
2058 //h_data.myTopology = (int) h->GetTopology();
2059 //h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2060 // h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2061 // h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2064 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2065 that->myOptions = h->GetOptionValues();
2066 that->myPreCADOptions = h->GetPreCADOptionValues();
2067 that->myCustomOptions = h->GetAdvancedOptionValues();
2069 h_data.myGMFFileName = h->GetGMFFile();
2070 // h_data.myGMFFileMode = h->GetGMFFileMode();
2072 that->mySMPMap.clear();
2073 that->myATTMap.clear();
2074 // that->myAttDistMap.clear();
2075 // that->myDistMap.clear();
2077 // classic size maps
2078 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2079 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
2080 QString fullSizeMaps;
2081 QStringList fullSizeMapList;
2082 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2083 for ( CORBA::ULong i = 0;i<mySizeMaps->length(); ++i ) {
2084 fullSizeMaps = mySizeMaps[i].in();
2085 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
2086 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2087 if ( fullSizeMapList.count() > 1 ) {
2088 string fullSizeMap = fullSizeMapList[1].toStdString();
2089 int pos = fullSizeMap.find("return")+7;
2090 // MESSAGE("pos:" << pos);
2093 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2098 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2099 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
2100 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2101 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
2107 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2108 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
2110 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2111 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2112 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2113 if ( fullCustomSizeMapList.count() > 1 ) {
2114 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2115 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2116 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
2117 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
2122 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2123 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
2125 for ( CORBA::ULong i = 0;i<allMyAttractors->length(); ++i ) {
2126 QString myAttractors = allMyAttractors[i].in();
2127 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2128 if ( myAttractorList.count() > 1 ) {
2129 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2130 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2131 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
2132 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
2136 // attractor new version
2137 MESSAGE("readParamsFromHypo, Attractors")
2138 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2139 for ( CORBA::ULong i = 0;i<allMyAttractorParams->length(); ++i ) {
2140 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2141 QString faceEntry = myAttractorParams.faceEntry.in();
2142 QString attEntry = myAttractorParams.attEntry.in();
2143 MESSAGE("attEntry = "<<attEntry.toStdString())
2144 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2145 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2146 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2147 myAttractorParams.startSize,
2148 myAttractorParams.infDist,
2149 myAttractorParams.constDist ));
2152 // Enforced vertices
2153 h_data.enfVertexList.clear();
2154 h_data.faceEntryEnfVertexListMap.clear();
2156 h_data.groupNameEnfVertexListMap.clear();
2159 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2160 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
2162 for ( CORBA::ULong i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
2163 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2164 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
2165 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2166 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
2168 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
2170 for (CORBA::ULong j=0 ; j<vertexList.length(); ++j) {
2171 TEnfVertex *enfVertex = new TEnfVertex();
2173 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
2174 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
2175 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
2176 for (CORBA::ULong k=0 ; k< vertexList[j].coords.length();k++)
2177 enfVertex->coords.push_back(vertexList[j].coords[k]);
2179 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2182 if (groupName != "") {
2183 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2187 // h_data.enfVertMap[entry] = evs;
2188 // h_data.entryCoordsListMap[entry] = coordsList;
2190 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2191 h_data.faceEntryEnfVertexListMap.erase(entry);
2194 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2195 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2198 MESSAGE("readParamsFromHypo, Periodicity")
2200 h_data.preCadPeriodicityVector.clear();
2202 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2203 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2205 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2206 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2210 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2211 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2214 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2216 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2217 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2218 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2220 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2221 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2223 if (sourceVertices.length()!=0)
2225 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2226 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2227 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2230 if (targetVertices.length()!=0)
2232 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2233 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2234 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2238 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2240 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2242 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2246 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2247 Saves the hypothesis data to hypothesis values.
2249 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2251 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
2252 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2253 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2259 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2261 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2262 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2263 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2264 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2266 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2267 if ( h->GetPhySize() != h_data.myPhySize ||
2268 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2269 if ( h_data.myPhySizeRel )
2270 h->SetPhySizeRel( h_data.myPhySize );
2272 h->SetPhySize( h_data.myPhySize );
2275 if (h->GetMinSize() != h_data.myMinSize ||
2276 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2277 if ( h_data.myMinSizeRel )
2278 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2280 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2282 if (h->GetMaxSize() != h_data.myMaxSize ||
2283 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2284 if ( h_data.myMaxSizeRel )
2285 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2287 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2289 if ( h->GetUseGradation() != h_data.myUseGradation )
2290 h->SetUseGradation( h_data.myUseGradation );
2291 if ( h->GetGradation() != h_data.myGradation )
2292 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2293 if ( h->GetUseVolumeGradation() != h_data.myUseVolumeGradation )
2294 h->SetUseVolumeGradation( h_data.myUseVolumeGradation );
2295 if ( h->GetVolumeGradation() != h_data.myVolumeGradation )
2296 h->SetVolumeGradation( h_data.myVolumeGradation <= 0 ? -1 : h_data.myVolumeGradation );
2298 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
2299 h->SetQuadAllowed( h_data.myAllowQuadrangles );
2301 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2302 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2303 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2304 if ( h->GetChordalError() != h_data.myChordalError )
2305 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2308 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2309 h->SetAnisotropic( h_data.myAnisotropic );
2310 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2311 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2313 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2314 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2315 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2316 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2318 if ( h->GetOptimiseTinyEdges() != h_data.myOptimiseTinyEdges )
2319 h->SetOptimiseTinyEdges( h_data.myOptimiseTinyEdges );
2320 if ( h_data.myOptimiseTinyEdges && ( h->GetTinyEdgeOptimisationLength() != h_data.myTinyEdgeOptimisLength ) )
2321 h->SetTinyEdgeOptimisationLength( h_data.myTinyEdgeOptimisLength <= 0 ? -1 :h_data.myTinyEdgeOptimisLength );
2322 if ( h->GetCorrectSurfaceIntersection() != h_data.myCorrectSurfaceIntersection )
2323 h->SetCorrectSurfaceIntersection( h_data.myCorrectSurfaceIntersection );
2324 if ( h_data.myCorrectSurfaceIntersection && ( h->GetCorrectSurfaceIntersectionMaxCost() != h_data.myCorrectSurfaceIntersectionMaxCost ) )
2325 h->SetCorrectSurfaceIntersectionMaxCost( h_data.myCorrectSurfaceIntersectionMaxCost <= 0 ? -1 :h_data.myCorrectSurfaceIntersectionMaxCost );
2327 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2328 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2329 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2330 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2332 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2333 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2335 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2336 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2338 if ( h->GetVerbosity() != h_data.myVerbosity )
2339 h->SetVerbosity( h_data.myVerbosity );
2340 // if ( h->GetTopology() != h_data.myTopology )
2341 // h->SetTopology( (int) h_data.myTopology );
2342 // if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2343 // h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2344 // if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2345 // h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2346 // if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2347 // h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2349 // options are set in checkParams()
2350 //h->SetOptionValues( myOptions ); // is set in readParamsFromWidgets()
2351 //h->SetPreCADOptionValues( myPreCADOptions ); // is set in readParamsFromWidgets()
2353 if ( h->GetGMFFile() != h_data.myGMFFileName )
2354 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2355 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2356 h->SetGMFFile( h_data.myGMFFileName.c_str());
2358 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2359 QMapIterator<QString,QString> i(that->mySMPMap);
2360 while (i.hasNext()) {
2362 const QString entry = i.key();
2363 const QString sizeMap = i.value();
2365 if (sizeMap == "__TO_DELETE__") {
2366 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
2367 h->UnsetEntry(entry.toLatin1().constData());
2369 else if (sizeMap.startsWith("ATTRACTOR")) {
2370 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2371 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2373 else if (sizeMap.startsWith("def")) {
2374 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2375 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2378 if (!myATTMap[entry].empty()){
2379 const TAttractorVec& attVec = myATTMap[entry];
2380 for ( size_t i = 0; i < attVec.size(); ++i )
2382 if ( attVec[i].IsToDelete() )
2383 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2384 attVec[i].attEntry.c_str() );
2386 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2387 attVec[i].attEntry.c_str(),
2388 attVec[i].startSize,
2391 attVec[i].constDist );
2395 QString fullSizeMap;
2396 fullSizeMap = QString("");
2397 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2398 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2399 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2400 fullSizeMap = QString("def f(t): return ") + sizeMap;
2401 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2402 fullSizeMap = QString("def f(): return ") + sizeMap;
2403 MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
2404 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2409 // Enforced vertices
2412 std::string enfName;
2414 std::string groupName = "";
2417 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2418 // 1. Clear all enforced vertices in hypothesis
2419 // 2. Add new enforced vertex according to h_data
2421 if ( h->GetAllEnforcedVertices()->length() > 0 )
2422 h->ClearAllEnforcedVertices();
2425 TEnfVertexList::const_iterator evsIt;
2426 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2428 faceEntry = evmIt->first;
2429 evs = evmIt->second;
2430 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
2431 evsIt = evs.begin();
2432 for ( ; evsIt != evs.end() ; ++evsIt)
2435 if ((*evsIt)->coords.size()) {
2436 x = (*evsIt)->coords[0];
2437 y = (*evsIt)->coords[1];
2438 z = (*evsIt)->coords[2];
2441 h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2445 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2446 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2447 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2448 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2451 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2452 h->ClearPreCadPeriodicityVectors();
2454 MESSAGE("h_data.preCadPeriodicityVector.size(): " << h_data.preCadPeriodicityVector.size());
2455 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2456 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2458 TPreCadPeriodicity periodicity_i = *pIt;
2459 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2460 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2461 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2462 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2463 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2464 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2465 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2466 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2467 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2469 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2470 if (! p1Source.empty())
2472 sourceVertices->length(3);
2473 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2474 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2475 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2479 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2480 if (! p1Target.empty())
2482 targetVertices->length(3);
2483 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2484 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2485 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2489 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2491 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2494 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end periodicity");
2498 catch(const std::exception& ex) {
2499 std::cout << "Exception: " << ex.what() << std::endl;
2502 // catch(const SALOME::SALOME_Exception& ex)
2505 // // SalomeApp_Tools::QtCatchCorbaException(ex);
2508 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end");
2512 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2513 Stores the widgets content to the hypothesis data.
2515 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2517 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
2518 h_data.myName = myName ? myName->text() : "";
2519 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2520 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2521 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2522 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2523 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2524 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2525 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2526 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2527 h_data.myUseGradation = myStdWidget->myUseGradation->isChecked() && !myStdWidget->myGradation->text().isEmpty();
2528 h_data.myGradation = h_data.myUseGradation ? myStdWidget->myGradation->GetValue() : -1.0;
2529 h_data.myUseVolumeGradation = myStdWidget->myUseVolumeGradation->isChecked() && !myStdWidget->myVolumeGradation->text().isEmpty();
2530 h_data.myVolumeGradation = h_data.myUseVolumeGradation ? myStdWidget->myVolumeGradation->GetValue() : -1. ;
2531 h_data.myAllowQuadrangles = myStdWidget->myAllowQuadrangles->isChecked();
2532 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2533 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2534 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2535 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2536 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2537 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2538 h_data.myOptimiseTinyEdges = myStdWidget->myOptimiseTinyEdges->isChecked();
2539 h_data.myTinyEdgeOptimisLength = myStdWidget->myTinyEdgeOptimisLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeOptimisLength->GetValue();
2540 h_data.myCorrectSurfaceIntersection = myStdWidget->myCorrectSurfaceIntersection->isChecked();
2541 h_data.myCorrectSurfaceIntersectionMaxCost = myStdWidget->myCorrectSurfaceIntersectionMaxCost->text().isEmpty() ? -1.0 : myStdWidget->myCorrectSurfaceIntersectionMaxCost->GetValue();
2542 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2543 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2544 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2545 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2546 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2547 //h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2548 //h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2549 //h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2550 //h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2553 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2554 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2555 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2556 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2557 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2558 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2559 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2560 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2561 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2562 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2563 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2564 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2565 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2566 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2569 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2570 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2571 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2572 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2573 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2574 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2577 // guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2578 // guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2579 // guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2580 // guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2582 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2583 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2586 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2587 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2588 for ( ; row < nbRows; ++row )
2590 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2591 if ( that->mySMPMap.contains(entry) )
2592 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2595 // Enforced vertices
2596 h_data.enfVertexList.clear();
2597 h_data.faceEntryEnfVertexListMap.clear();
2599 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2600 int nbEnforcedVertices = 0;
2601 std::string groupName = "";
2602 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
2603 for (int i=0 ; i<nbEnforcedShapes ; i++) {
2604 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
2606 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2607 nbEnforcedVertices = shapeItem->childCount();
2608 if (nbEnforcedVertices >0) {
2609 double childValueX,childValueY,childValueZ;
2610 std::string childName, vertexEntry;
2611 QTreeWidgetItem* child;
2614 for (row = 0;row<nbEnforcedVertices;row++) {
2615 child = shapeItem->child(row);
2616 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2617 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2618 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2619 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2620 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2621 // if (myGlobalGroupName->isChecked())
2622 // groupName = myGlobalGroupName->text().toStdString();
2624 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2626 TEnfVertex *enfVertex = new TEnfVertex();
2627 enfVertex->name = childName;
2628 if (vertexEntry.empty()) {
2629 enfVertex->coords.push_back(childValueX);
2630 enfVertex->coords.push_back(childValueY);
2631 enfVertex->coords.push_back(childValueZ);
2634 enfVertex->geomEntry = vertexEntry;
2635 enfVertex->grpName = groupName;
2636 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2637 // if (it == h_data.enfVertexList.end())
2638 h_data.enfVertexList.insert(enfVertex);
2639 evs.insert(enfVertex);
2641 if (groupName != "")
2642 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2645 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2650 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2651 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2654 h_data.preCadPeriodicityVector.clear();
2655 // For each tree item, store each value. Shapes are stored as entries.
2656 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2657 for (int i=0 ; i<nbPeriodicityDescriptions ; i++) {
2658 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2659 TPreCadPeriodicity periodicity_i;
2661 for (int k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2664 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2666 periodicity_i.push_back(entry);
2668 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2670 guiHyp += "PERIODICITY = yes; ";
2673 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2677 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2679 myAdvWidget->AddOption( TBL_CUSTOM, NULL );
2682 void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int row, int column )
2684 // if ( column != OPTION_NAME_COLUMN )
2686 // myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2689 // **********************
2690 // *** BEGIN SIZE MAP ***
2691 // **********************
2693 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2695 if ( myGeomSelWdg2->IsObjectSelected() ){
2696 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2698 else if ( myGeomSelWdg1->IsObjectSelected() ){
2699 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2702 mySMapObject = GEOM::GEOM_Object::_nil();
2704 bool dataAvailable = !mySMapObject->_is_nil();
2706 if ( dataAvailable )
2707 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2709 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2710 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2711 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2712 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2713 ( myATTMap.contains( qEntry )))
2716 QString attEntry = myAttSelWdg->GetValue();
2717 const TAttractorVec& attVec = myATTMap[ qEntry ];
2718 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2719 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2722 addMapButton->setEnabled( !mapExists && dataAvailable );
2723 modifyMapButton->setEnabled( mapExists && dataAvailable );
2726 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2728 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2729 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2730 if (col == SMP_SIZEMAP_COLUMN) {
2731 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2733 if (!mySMPMap.contains(entry))
2735 if ( QTreeWidgetItem* parent = item->parent() )
2739 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2741 if (!mySMPMap.contains(entry))
2744 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2745 CORBA::Object_var obj = entryToObject(entry);
2746 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2747 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2748 // Retrieve values of the selected item in the current tab widgets
2749 const TAttractorVec& attVec = myATTMap[entry];
2750 if ( !attVec.empty() )
2753 if ( !childEntry.isEmpty() )
2754 for ( size_t i = 0; i < attVec.size(); ++i )
2755 if ( childEntry == attVec[i].attEntry.c_str() )
2760 double phySize = attVec[iAtt].startSize;
2761 double infDist = attVec[iAtt].infDist;
2762 double constDist = attVec[iAtt].constDist;
2763 QString attEntry = attVec[iAtt].attEntry.c_str();
2764 CORBA::Object_var attObj = entryToObject(attEntry);
2765 myAttSizeSpin->setValue(phySize);
2766 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2767 myAttDistSpin->setValue(infDist);
2768 myAttractorCheck->setChecked(true);
2771 myAttractorCheck->setChecked(false);
2773 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2774 myAttDistSpin2->setValue(constDist);
2775 myConstSizeCheck->setChecked(true);
2778 myConstSizeCheck->setChecked(false);
2780 myGeomSelWdg2->SetObject(obj);
2781 myAttSelWdg->SetObject(attObj);
2784 else { // CLASSIC MAPS
2785 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2786 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2787 if (!sizeMap.startsWith("def")){
2788 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2794 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2796 getGeomSelectionTool()->selectionMgr()->clearFilters();
2797 if ( sender() == myTabWidget )
2799 myGeomSelWdg1 ->deactivateSelection();
2800 myGeomSelWdg2 ->deactivateSelection();
2801 myAttSelWdg ->deactivateSelection();
2802 myEnfFaceWdg ->deactivateSelection();
2803 myEnfVertexWdg ->deactivateSelection();
2804 myPeriodicitySourceFaceWdg->deactivateSelection();
2805 myPeriodicityTargetFaceWdg->deactivateSelection();
2806 myPeriodicityP1SourceWdg ->deactivateSelection();
2807 myPeriodicityP2SourceWdg ->deactivateSelection();
2808 myPeriodicityP3SourceWdg ->deactivateSelection();
2809 myPeriodicityP1TargetWdg ->deactivateSelection();
2810 myPeriodicityP2TargetWdg ->deactivateSelection();
2811 myPeriodicityP3TargetWdg ->deactivateSelection();
2814 else if ( sender() == smpTab )
2816 myAttDistSpin->setValue(0.); // Reinitialize widgets
2817 myAttSizeSpin->setValue(0.);
2818 myAttDistSpin2->setValue(0.);
2819 mySmpSizeSpin->setValue(0.);
2820 myGeomSelWdg1->deactivateSelection();
2821 myGeomSelWdg2->deactivateSelection();
2822 myAttSelWdg->deactivateSelection();
2823 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2824 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2825 myAttSelWdg->SetObject(CORBA::Object::_nil());
2826 myAttractorCheck->setChecked(false);
2827 myConstSizeCheck->setChecked(false);
2831 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2833 if (state == Qt::Checked){
2834 myAttSelWdg->setEnabled(true);
2835 myAttSizeSpin->setEnabled(true);
2836 myAttSizeLabel->setEnabled(true);
2837 myAttDistSpin->setEnabled(true);
2838 myAttDistLabel->setEnabled(true);
2839 if (!myAttSelWdg->IsObjectSelected()){
2840 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2843 if (state == Qt::Unchecked){
2844 myAttDistSpin->setEnabled(false);
2845 myAttDistLabel->setEnabled(false);
2846 myAttDistSpin->setValue(0.);
2847 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2848 myAttSelWdg->setEnabled(false);
2849 myAttSizeSpin->setEnabled(false);
2850 myAttSizeLabel->setEnabled(false);
2851 myAttDistSpin2->setEnabled(false);
2852 myAttDistLabel2->setEnabled(false);
2854 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2855 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2858 onMapGeomContentModified();
2861 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2863 if (state == Qt::Checked){
2864 myAttSelWdg->setEnabled(true);
2865 myAttSizeSpin->setEnabled(true);
2866 myAttSizeLabel->setEnabled(true);
2867 myAttDistSpin2->setEnabled(true);
2868 myAttDistLabel2->setEnabled(true);
2869 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2870 !myAttSelWdg->IsObjectSelected()){
2871 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2874 if (state == Qt::Unchecked){
2875 myAttDistSpin2->setEnabled(false);
2876 myAttDistLabel2->setEnabled(false);
2877 myAttDistSpin2->setValue(0.);
2878 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2879 myAttSelWdg->setEnabled(false);
2880 myAttSizeSpin->setEnabled(false);
2881 myAttSizeLabel->setEnabled(false);
2882 myAttDistSpin->setEnabled(false);
2883 myAttDistLabel->setEnabled(false);
2885 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2886 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2889 onMapGeomContentModified();
2892 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2894 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
2895 QList<int> selectedRows;
2896 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2897 QTreeWidgetItem* item;
2898 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2900 qSort( selectedRows );
2901 QListIterator<QTreeWidgetItem*> it( selected );
2903 while ( it.hasPrevious() ) {
2904 item = it.previous();
2905 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2906 QString parentEntry;
2907 if ( QTreeWidgetItem* parent = item->parent() )
2908 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2909 if (that->mySMPMap.contains(entry))
2911 that->mySMPMap[entry] = "__TO_DELETE__";
2912 if ( myATTMap.contains( entry ))
2914 TAttractorVec& attVec = myATTMap[entry];
2915 for ( size_t i = 0; i < attVec.size(); ++i )
2916 attVec[i].SetToDelete();
2919 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
2921 TAttractorVec& attVec = myATTMap[parentEntry];
2922 for ( size_t i = 0; i < attVec.size(); ++i )
2924 if ( entry == attVec[i].attEntry.c_str() )
2925 attVec[i].SetToDelete();
2928 if (that->mySMPShapeTypeMap.contains(entry))
2929 that->mySMPShapeTypeMap.remove(entry);
2930 // if (that->myDistMap.contains(entry))
2931 // that->myDistMap.remove(entry);
2932 // if (that->myAttDistMap.contains(entry))
2933 // that->myAttDistMap.remove(entry);
2936 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2937 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2940 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2942 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
2943 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2944 if (col == SMP_SIZEMAP_COLUMN) {
2945 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2946 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2947 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2948 MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
2949 if (! that->mySMPShapeTypeMap.contains(entry))
2950 MESSAGE("no such entry in mySMPShapeTypeMap")
2952 if (that->mySMPMap.contains(entry))
2953 if (that->mySMPMap[entry] == sizeMap
2954 || sizeMap.startsWith("Attractor")
2955 || sizeMap.startsWith("Constant") ){
2958 if (! sizeMap.isEmpty()) {
2959 that->mySMPMap[entry] = sizeMap;
2960 sizeMapValidationFromEntry(entry);
2963 MESSAGE("Size map empty: reverse to precedent value" );
2964 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2966 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2970 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2973 if ( smpTab->currentIndex() == ATT_TAB ){
2974 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2975 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2976 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2977 res = insertAttractor(mySMapObject, myAttObject);
2980 if (smpTab->currentIndex() == SMP_STD_TAB ){
2981 if ( myGeomSelWdg1->IsObjectSelected() ){
2982 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2983 res = insertElement(mySMapObject);
2987 // Local size should be more than 0
2988 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
2989 SUIT_MessageBox::critical( dlg(),"Error" , msg );
2992 getGeomSelectionTool()->selectionMgr()->clearFilters();
2993 myAttDistSpin->setValue(0.);
2994 myAttSizeSpin->setValue(0.);
2995 myAttDistSpin2->setValue(0.);
2996 mySmpSizeSpin->setValue(0.);
2997 myConstSizeCheck->setChecked(false);
2998 myAttractorCheck->setChecked(false);
2999 myGeomSelWdg1->deactivateSelection();
3000 myGeomSelWdg2->deactivateSelection();
3001 myAttSelWdg->deactivateSelection();
3002 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3003 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3004 myAttSelWdg->SetObject(CORBA::Object::_nil());
3007 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
3009 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
3011 if ( smpTab->currentIndex() == ATT_TAB ){
3012 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3013 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3014 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3015 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
3018 if (smpTab->currentIndex() == SMP_STD_TAB ){
3019 if ( myGeomSelWdg1->IsObjectSelected() ){
3020 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3021 res = insertElement(mySMapObject, /*modify = */true);
3025 // Local size should be more than 0
3026 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3027 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3030 getGeomSelectionTool()->selectionMgr()->clearFilters();
3031 myAttDistSpin->setValue(0.);
3032 myAttSizeSpin->setValue(0.);
3033 myAttDistSpin2->setValue(0.);
3034 mySmpSizeSpin->setValue(0.);
3035 myConstSizeCheck->setChecked(false);
3036 myAttractorCheck->setChecked(false);
3037 myGeomSelWdg1->deactivateSelection();
3038 myGeomSelWdg2->deactivateSelection();
3039 myAttSelWdg->deactivateSelection();
3040 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3041 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3042 myAttSelWdg->SetObject(CORBA::Object::_nil());
3045 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3047 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
3048 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3049 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3051 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3053 TopAbs_ShapeEnum shapeType;
3054 string entry, shapeName;
3055 entry = (string) anObject->GetStudyEntry();
3056 MESSAGE("entry = "<<entry);
3057 shapeName = anObject->GetName();
3058 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3059 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3060 // in order to write the size map with the right syntax in StoreParamsToHypo
3061 // (f(t) for edges, f(u,v) for faces ...)
3062 if (shapeType == TopAbs_COMPOUND){
3063 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3064 TopoDS_Shape childShape;
3065 TopoDS_Iterator anIt(theShape);
3066 for(;anIt.More();anIt.Next()){
3067 childShape = anIt.Value();
3068 shapeType = childShape.ShapeType();
3069 if(!childShape.IsNull()){
3074 mySizeMapTable->setFocus();
3076 shapeEntry = QString::fromStdString(entry);
3077 double phySize = mySmpSizeSpin->value();
3080 return false; // Local size should be more than 0
3082 std::ostringstream oss;
3085 sizeMap = QString::fromStdString(oss.str());
3086 QTreeWidgetItem* item = new QTreeWidgetItem();
3088 int rowToChange = findRowFromEntry(shapeEntry);
3089 item = mySizeMapTable->topLevelItem( rowToChange );
3092 if (that->mySMPMap.contains(shapeEntry)) {
3093 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3094 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3098 mySizeMapTable->addTopLevelItem(item);
3100 that->mySMPMap[shapeEntry] = sizeMap;
3101 //that->myDistMap[shapeEntry] = 0. ;
3102 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3103 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3104 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3105 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3106 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3107 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3108 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3109 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3110 mySizeMapTable->clearSelection();
3112 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3113 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3114 myStdWidget->onPhysicalMeshChanged();
3119 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3121 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
3122 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3123 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3125 TopAbs_ShapeEnum shapeType;
3126 string entry, attEntry, faceName, attName;
3127 entry = (string) aFace->GetStudyEntry();
3128 attEntry = (string) anAttractor->GetStudyEntry();
3129 faceName = aFace->GetName();
3130 attName = anAttractor->GetName();
3131 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3132 mySizeMapTable->setFocus();
3133 QString shapeEntry = QString::fromStdString(entry);
3134 QString qAttEntry = QString::fromStdString(attEntry);
3136 double phySize = h->GetPhySize();
3137 double infDist = 0. ;
3138 double constDist = 0. ;
3139 phySize = myAttSizeSpin->value();
3142 return false; // Local size should be more than 0
3144 if (myAttractorCheck->isChecked()){
3145 infDist = myAttDistSpin->value();
3147 if (myConstSizeCheck->isChecked()){
3148 constDist = myAttDistSpin2->value();
3150 std::ostringstream oss;
3151 std::ostringstream oss2;
3152 std::ostringstream oss3;
3156 QString sizeMap = QString::fromStdString(oss.str());
3157 QString infDistString = QString::fromStdString(oss2.str());
3158 QString constDistString = QString::fromStdString(oss3.str());
3160 QTreeWidgetItem* item;
3161 QTreeWidgetItem* child = 0;
3162 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3164 int rowToChange = findRowFromEntry(shapeEntry);
3165 item = mySizeMapTable->topLevelItem( rowToChange );
3167 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3168 if (( child = item->child( i )))
3169 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3171 TAttractorVec & attVec = myATTMap[shapeEntry];
3172 for ( size_t i = 0; i < attVec.size(); ++i )
3173 if ( attVec[i].attEntry == attEntry )
3175 attVec[i] = attParams;
3180 // if (that->mySMPMap.contains(shapeEntry)) {
3181 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3182 // // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3186 int rowToChange = findRowFromEntry(shapeEntry);
3187 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3189 item = mySizeMapTable->topLevelItem( rowToChange );
3192 item = new QTreeWidgetItem();
3193 mySizeMapTable->addTopLevelItem(item);
3195 child = new QTreeWidgetItem();
3196 item->addChild(child);
3197 bool exists = false;
3198 TAttractorVec & attVec = myATTMap[shapeEntry];
3199 for ( size_t i = 0; i < attVec.size(); ++i )
3200 if ( attVec[i].attEntry == attEntry )
3202 attVec[i] = attParams;
3207 myATTMap[shapeEntry].push_back( attParams );
3209 mySMPMap.insert(shapeEntry,sizeMap);
3210 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3211 item->setExpanded(true);
3212 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3213 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3214 if (infDist > std::numeric_limits<double>::epsilon()){
3215 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3217 else if (constDist > std::numeric_limits<double>::epsilon()){
3218 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3220 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3222 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3223 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3224 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3226 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3227 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3228 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3230 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3231 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3232 myStdWidget->onPhysicalMeshChanged();
3234 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
3238 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3240 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
3241 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3242 for ( ; row < nbRows; ++row )
3243 if (! sizeMapValidationFromRow(row))
3248 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3250 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
3251 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3252 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3253 mySizeMapTable->setFocus();
3257 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3259 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
3260 MESSAGE("myEntry = "<<myEntry.toStdString())
3262 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3264 if (! that->mySMPMap.contains(myEntry)) {
3265 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
3268 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3269 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
3275 if (that->mySMPMap[myEntry].startsWith("def")) {
3276 // MESSAGE("custom function" );
3277 expr = that->mySMPMap[myEntry].toStdString();
3279 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3280 // MESSAGE("Attractor" );
3281 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)) {
3284 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])" );
3290 // case size map is empty
3291 if (that->mySMPMap[myEntry].isEmpty()) {
3293 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3297 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3298 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3299 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3300 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3301 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3302 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3305 //assert(Py_IsInitialized());
3306 if (! Py_IsInitialized())
3307 throw ("Erreur: Python interpreter is not initialized");
3308 PyGILState_STATE gstate;
3309 gstate = PyGILState_Ensure();
3311 string err_description="";
3312 PyObject* obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3316 PyObject* new_stderr = newPyStdOut(err_description);
3317 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3318 Py_INCREF(old_stderr);
3319 PySys_SetObject((char*)"stderr", new_stderr);
3321 PySys_SetObject((char*)"stderr", old_stderr);
3322 Py_DECREF(new_stderr);
3324 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3325 PyGILState_Release(gstate);
3330 PyObject* func = PyObject_GetAttrString(main_mod, "f");
3334 PyObject* new_stderr = newPyStdOut(err_description);
3335 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3336 Py_INCREF(old_stderr);
3337 PySys_SetObject((char*)"stderr", new_stderr);
3339 PySys_SetObject((char*)"stderr", old_stderr);
3340 Py_DECREF(new_stderr);
3342 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3343 PyGILState_Release(gstate);
3347 PyGILState_Release(gstate);
3349 // MESSAGE("SizeMap expression "<<expr<<" is valid");
3354 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3356 return tr( "BLSURF_TITLE" );
3359 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3361 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3364 QString BLSURFPluginGUI_HypothesisCreator::type() const
3366 return tr( "BLSURF_HYPOTHESIS" );
3369 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3371 return "blsurf_hypo_page.html";
3374 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3377 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3379 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3384 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3386 CORBA::Object_var obj;
3387 SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.toStdString().c_str() );
3388 if (!aSObj->_is_nil()) {
3389 obj = aSObj->GetObject();
3390 aSObj->UnRegister();
3395 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3396 int endRow = mySizeMapTable->topLevelItemCount()-1;
3398 for ( ; row <= endRow; ++row )
3400 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3401 if (entry == entryForChecking )
3404 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)