1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPluginGUI_HypothesisCreator.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPluginGUI_HypothesisCreator.h"
28 #include "BLSURFPluginGUI_Dlg.h"
30 #include "GeometryGUI.h"
32 #include <SMESHGUI_Utils.h>
33 #include <SMESHGUI_HypothesesUtils.h>
34 #include <SMESHGUI_Dialog.h>
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESH_NumberFilter.hxx"
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Tools.h>
43 #include <QApplication>
47 #include <QHBoxLayout>
48 #include <QHeaderView>
49 #include <QGridLayout>
55 #include <QPushButton>
56 #include <QRadioButton>
58 #include <QTableWidget>
60 #include <QVBoxLayout>
63 #include <QStandardItemModel>
64 #include <QStandardItem>
65 #include <QTreeWidget>
66 #include <QTreeWidgetItem>
67 #include <QModelIndexList>
69 #include <LightApp_SelectionMgr.h>
70 #include <SalomeApp_Application.h>
71 #include <SALOME_ListIO.hxx>
72 #include <SALOME_ListIteratorOfListIO.hxx>
73 #include "SALOME_LifeCycleCORBA.hxx"
75 #include <TopoDS_Shape.hxx>
76 #include <TopoDS_Iterator.hxx>
77 #include <SMESH_Gen_i.hxx>
78 #include <boost/shared_ptr.hpp>
79 #include <boost/algorithm/string.hpp>
80 #include <structmember.h>
96 // Enforced vertices array columns
97 ENF_VER_NAME_COLUMN = 0,
98 ENF_VER_FACE_ENTRY_COLUMN,
102 ENF_VER_ENTRY_COLUMN,
103 ENF_VER_GROUP_COLUMN,
106 PERIODICITY_OBJ_SOURCE_COLUMN = 0,
107 PERIODICITY_OBJ_TARGET_COLUMN,
108 PERIODICITY_P1_SOURCE_COLUMN,
109 PERIODICITY_P2_SOURCE_COLUMN,
110 PERIODICITY_P3_SOURCE_COLUMN,
111 PERIODICITY_P1_TARGET_COLUMN,
112 PERIODICITY_P2_TARGET_COLUMN,
113 PERIODICITY_P3_TARGET_COLUMN,
114 PERIODICITY_SHAPE_TYPE,
116 // PERIODICITY_OBJ_SOURCE_COLUMN = 0,
117 // PERIODICITY_ENTRY_SOURCE_COLUMN,
118 // PERIODICITY_OBJ_TARGET_COLUMN,
119 // PERIODICITY_ENTRY_TARGET_COLUMN,
120 // PERIODICITY_P1_SOURCE_COLUMN,
121 // PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
122 // PERIODICITY_P2_SOURCE_COLUMN,
123 // PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
124 // PERIODICITY_P3_SOURCE_COLUMN,
125 // PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
126 // PERIODICITY_P1_TARGET_COLUMN,
127 // PERIODICITY_P1_ENTRY_TARGET_COLUMN,
128 // PERIODICITY_P2_TARGET_COLUMN,
129 // PERIODICITY_P2_ENTRY_TARGET_COLUMN,
130 // PERIODICITY_P3_TARGET_COLUMN,
131 // PERIODICITY_P3_ENTRY_TARGET_COLUMN,
133 PERIODICITY_NB_COLUMN
159 // Enforced vertices inputs
167 // ENF_VER_GROUP_CHECK,
171 ENF_VER_INTERNAL_ALL_FACES,
172 ENF_VER_INTERNAL_ALL_FACES_GROUP,
173 // ENF_VER_VERTEX_BTN,
174 // ENF_VER_REMOVE_BTN,
175 // ENF_VER_SEPARATOR,
180 /**************************************************
181 Begin initialization Python structures and objects
182 ***************************************************/
191 PyStdOut_dealloc(PyStdOut *self)
197 PyStdOut_write(PyStdOut *self, PyObject *args)
201 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
205 *(self->out)=*(self->out)+c;
211 static PyMethodDef PyStdOut_methods[] = {
212 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
213 PyDoc_STR("write(string) -> None")},
214 {NULL, NULL} /* sentinel */
217 static PyMemberDef PyStdOut_memberlist[] = {
218 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
219 (char*)"flag indicating that a space needs to be printed; used by print"},
220 {NULL} /* Sentinel */
223 static PyTypeObject PyStdOut_Type = {
224 /* The ob_type field must be initialized in the module init function
225 * to be portable to Windows without using C++. */
226 PyObject_HEAD_INIT(NULL)
229 sizeof(PyStdOut), /*tp_basicsize*/
232 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
239 0, /*tp_as_sequence*/
244 PyObject_GenericGetAttr, /*tp_getattro*/
245 /* softspace is writable: we must supply tp_setattro */
246 PyObject_GenericSetAttr, /* tp_setattro */
248 Py_TPFLAGS_DEFAULT, /*tp_flags*/
252 0, /*tp_richcompare*/
253 0, /*tp_weaklistoffset*/
256 PyStdOut_methods, /*tp_methods*/
257 PyStdOut_memberlist, /*tp_members*/
271 PyObject * newPyStdOut( std::string& out )
274 self = PyObject_New(PyStdOut, &PyStdOut_Type);
279 return (PyObject*)self;
282 /*************************************************
283 End initialization Python structures and objects
284 **************************************************/
288 // BEGIN EnforcedTreeWidgetDelegate
291 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
292 : QItemDelegate(parent)
296 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
297 const QStyleOptionViewItem & option ,
298 const QModelIndex & index ) const
300 QModelIndex father = index.parent();
301 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
303 if (index.column() == ENF_VER_X_COLUMN || \
304 index.column() == ENF_VER_Y_COLUMN || \
305 index.column() == ENF_VER_Z_COLUMN)
307 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
308 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
309 editor->setReadOnly(!entry.isEmpty());
310 editor->setDisabled(!entry.isEmpty());
315 QLineEdit *editor = new QLineEdit(parent);
316 if (index.column() != ENF_VER_GROUP_COLUMN) {
317 editor->setReadOnly(!entry.isEmpty());
318 editor->setDisabled(!entry.isEmpty());
324 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
325 const QModelIndex &index) const
327 QString value = index.model()->data(index, Qt::EditRole).toString();
329 if (index.column() == ENF_VER_X_COLUMN ||
330 index.column() == ENF_VER_Y_COLUMN ||
331 index.column() == ENF_VER_Z_COLUMN)
333 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
334 lineEdit->setText(value);
337 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
338 lineEdit->setText(value);
342 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
343 const QModelIndex &index) const
345 QModelIndex parent = index.parent();
346 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
347 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
348 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
349 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
350 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
351 } else if (index.column() == ENF_VER_NAME_COLUMN) {
352 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
353 QString value = lineEdit->text();
354 if (entry.isEmpty() && !vertexExists(model, index, value))
355 model->setData(index, value, Qt::EditRole);
356 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
357 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
358 QString value = lineEdit->text();
359 if (!vertexExists(model, index, value))
360 model->setData(index, value, Qt::EditRole);
361 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
362 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
363 model->setData(index, lineEdit->text(), Qt::EditRole);
367 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
368 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
370 editor->setGeometry(option.rect);
373 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
374 const QModelIndex &index, QString value) const
377 QModelIndex parent = index.parent();
378 int row = index.row();
379 int col = index.column();
381 if (parent.isValid() && !value.isEmpty()) {
382 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
384 if (col == ENF_VER_X_COLUMN) {
385 x = value.toDouble();
386 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
387 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
389 if (col == ENF_VER_Y_COLUMN) {
390 y = value.toDouble();
391 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
392 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
394 if (col == ENF_VER_Z_COLUMN) {
395 z = value.toDouble();
396 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
397 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
399 int nbChildren = model->rowCount(parent);
400 for (int i = 0 ; i < nbChildren ; i++) {
402 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
403 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
404 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
405 if ((childX == x) && (childY == y) && (childZ == z)) {
412 else if (col == ENF_VER_NAME_COLUMN) {
413 int nbChildren = model->rowCount(parent);
414 for (int i = 0 ; i < nbChildren ; i++) {
416 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
417 if (childName == value) {
430 // END EnforcedTreeWidgetDelegate
435 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
436 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
439 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
440 : SMESHGUI_GenericHypothesisCreator( theHypType )
442 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
443 this->mySMPMap.clear();
445 GeomToolSelected = NULL;
446 GeomToolSelected = getGeomSelectionTool();
448 aSel = GeomToolSelected->selectionMgr();
450 /* Initialize the Python interpreter */
451 if (! Py_IsInitialized())
452 throw ("Error: Python interpreter is not initialized");
453 PyGILState_STATE gstate;
454 gstate = PyGILState_Ensure();
457 main_mod = PyImport_AddModule("__main__");
460 main_dict = PyModule_GetDict(main_mod);
462 PyRun_SimpleString("from math import *");
463 PyGILState_Release(gstate);
467 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
472 * \brief {Get or create the geom selection tool for active study}
474 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool()
476 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
477 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
478 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
479 that->GeomToolSelected = new GeomSelectionTools(aStudy);
481 return that->GeomToolSelected;
484 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
486 return GeometryGUI::GetGeomGen();
489 void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
491 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
492 ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
493 for ( ; anIt != selectionWidgets.end(); anIt++)
495 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
497 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
498 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
499 ListOfWidgets::const_iterator anIt2 = anIt;
500 for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
501 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
503 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
504 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
505 w1->AvoidSimultaneousSelection( w2 );
507 if ( !widgetToActivate )
508 widgetToActivate = w1;
511 if ( widgetToActivate )
512 widgetToActivate->activateSelection();
515 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
517 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
520 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
521 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
525 myAdvWidget->myOptionTable->setFocus();
526 QApplication::instance()->processEvents();
528 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
529 for ( ; row < nbRows; ++row )
531 QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
532 QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
533 if ( !value.isEmpty() ) {
535 QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed();
536 if (optionType == "PRECAD")
537 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
538 else if (optionType == "BLSURF")
539 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
541 catch ( const SALOME::SALOME_Exception& ex )
543 msg = ex.details.text.in();
551 h->SetOptionValues( myOptions ); // restore values
552 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
555 // SizeMap and attractors
558 mySizeMapTable->setFocus();
559 QApplication::instance()->processEvents();
561 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
562 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
564 for ( ; row < nbRows; ++row )
566 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
567 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
568 MESSAGE("entry ="<<entry.toStdString())
569 if ( !sizeMap.isEmpty() ) {
570 if (that->sizeMapValidationFromRow(row))
573 MESSAGE("entry ="<<entry.toStdString())
574 MESSAGE("sizeMap ="<<sizeMap.toStdString())
576 e = entry.toStdString();
577 s = that->mySMPMap[entry].toStdString();
578 MESSAGE("row = "<<row)
581 h->SetSizeMapEntry( e.c_str(), s.c_str() );
583 catch ( const SALOME::SALOME_Exception& ex )
585 msg = ex.details.text.in();
596 // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
599 // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
600 // So STD_TAB must be current tab to get correct value of it's spinbox.
601 myTabWidget->setCurrentIndex( STD_TAB );
605 if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
606 myStdWidget->myPhySize->text().toDouble() > 0.0 )))
607 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
611 if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
612 myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
613 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
617 if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
618 myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
619 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
623 if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
624 myStdWidget->myChordalError->text().toDouble() > 0.0 )))
625 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
634 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
636 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
638 QFrame* fr = new QFrame( 0 );
639 // fr-> setMinimumSize(600,400);
640 QVBoxLayout* lay = new QVBoxLayout( fr );
641 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
643 lay->setSpacing( 0 );
645 // main TabWidget of the dialog
646 myTabWidget = new QTabWidget( fr );
647 myTabWidget->setTabShape( QTabWidget::Rounded );
648 myTabWidget->setTabPosition( QTabWidget::North );
649 lay->addWidget( myTabWidget );
654 myStdGroup = new QWidget();
655 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
656 aStdLayout->setSpacing( 6 );
657 aStdLayout->setMargin( 11 );
660 myName = new QLineEdit( myStdGroup );
661 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
665 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
666 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
668 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
674 // row = max(row,maxrow)+1;
675 aStdLayout->setRowStretch(row,1);
676 aStdLayout->setColumnStretch(1,1);
680 // advanced parameters
681 myAdvGroup = new QWidget();
682 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
683 anAdvLayout->setSpacing( 6 );
684 anAdvLayout->setMargin( 11 );
685 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
686 myAdvWidget->addBtn->setMenu( new QMenu() );
687 anAdvLayout->addWidget( myAdvWidget);
690 // Size Maps parameters
692 mySmpGroup = new QWidget();
693 // mySmpGroup->setMinimumWidth(500);
696 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
699 mySizeMapTable = new QTreeWidget( mySmpGroup );
700 mySizeMapTable ->setMinimumWidth(200);
701 QStringList sizeMapHeaders;
702 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
703 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
704 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
705 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
706 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
707 mySizeMapTable->setAlternatingRowColors(true);
710 smpTab = new QTabWidget( mySmpGroup );
711 smpTab->setTabShape( QTabWidget::Rounded );
712 smpTab->setTabPosition( QTabWidget::South );
713 lay->addWidget( smpTab );
715 // Filters of selection
716 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
718 SM_ShapeTypes.Add( TopAbs_VERTEX );
719 SM_ShapeTypes.Add( TopAbs_EDGE );
720 SM_ShapeTypes.Add( TopAbs_FACE );
721 SM_ShapeTypes.Add( TopAbs_COMPOUND );
723 ATT_ShapeTypes.Add( TopAbs_VERTEX );
724 ATT_ShapeTypes.Add( TopAbs_EDGE );
725 ATT_ShapeTypes.Add( TopAbs_WIRE );
726 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
728 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
729 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
730 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
732 // Standard size map tab
733 mySmpStdGroup = new QWidget();
734 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
735 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false);
736 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
737 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
738 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
739 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
742 myAttractorGroup = new QWidget();
743 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
744 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false,/*stretch=*/false);
745 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
746 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
747 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
748 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
749 QFrame* attLine = new QFrame(myAttractorGroup);
750 attLine->setFrameShape(QFrame::HLine);
751 attLine->setFrameShadow(QFrame::Sunken);
752 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false);
753 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
754 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
755 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
756 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
757 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
758 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
759 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
760 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
761 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
762 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
764 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
765 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
769 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
770 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
771 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
772 modifyMapButton->setEnabled(false);
775 myAttSelWdg->setEnabled(false);
776 myAttSizeSpin->setEnabled(false);
777 myAttSizeLabel->setEnabled(false);
778 myAttDistSpin->setEnabled(false);
779 myAttDistLabel->setEnabled(false);
780 myAttDistSpin2->setEnabled(false);
781 myAttDistLabel2->setEnabled(false);
782 myAttDistSpin->setValue(0.);
783 myAttDistSpin2->setValue(0.);
784 myAttSizeSpin->setValue(0.);
785 mySmpSizeSpin->setValue(0.);
788 // ADD WIDGETS (SIZEMAP TAB)
789 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
790 anSmpLayout->setColumnStretch(0, 1);
791 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
792 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
793 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
794 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
795 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
796 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
799 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
800 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
801 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
802 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
805 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
806 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
807 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
808 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
809 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
810 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
811 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
812 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
813 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
814 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
815 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
816 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
818 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
819 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
821 smpTab->setCurrentIndex( SMP_STD_TAB );
823 // Enforced vertices parameters
824 myEnfGroup = new QWidget();
825 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
827 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
828 // anEnfLayout->addWidget(myEnforcedVertexWidget);
829 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
830 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
832 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
833 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
834 myEnforcedTreeWidget->setSortingEnabled(true);
835 QStringList enforcedHeaders;
836 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
837 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
838 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
840 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
841 myEnforcedTreeWidget->header()->setStretchLastSection(true);
842 myEnforcedTreeWidget->setAlternatingRowColors(true);
843 myEnforcedTreeWidget->setUniformRowHeights(true);
844 myEnforcedTreeWidget->setAnimated(true);
845 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
846 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
847 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
848 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
849 myEnforcedTreeWidget->resizeColumnToContents(column);
851 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
852 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
853 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
855 // FACE AND VERTEX SELECTION
856 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
857 shapeTypes1.Add( TopAbs_FACE );
858 shapeTypes1.Add( TopAbs_COMPOUND );
859 shapeTypes2.Add( TopAbs_VERTEX );
860 shapeTypes2.Add( TopAbs_COMPOUND );
862 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
863 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true, /*stretch=*/false);
864 myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
866 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
867 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
868 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
870 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
872 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
873 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
874 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
876 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
877 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
878 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
880 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
881 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
882 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
884 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
885 myGroupName = new QLineEdit(myEnfGroup);
887 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
888 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
890 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
892 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
893 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
895 // myGlobalGroupName = new QCheckBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
896 // myGlobalGroupName->setChecked(false);
898 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
899 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
900 // FACE AND VERTEX SELECTION
901 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
902 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
903 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
904 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
905 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
906 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
907 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
908 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
909 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
910 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
911 // anEnfLayout2->addWidget(myGlobalGroupName, ENF_VER_GROUP_CHECK, 0, 1, 2);
912 // anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
913 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
914 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
915 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
916 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
917 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
918 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
919 // anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
920 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
921 // anEnfLayout->setRowStretch(1, 1);
924 // Periodicity parameters
925 myPeriodicityGroup = new QWidget();
926 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
928 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
929 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
930 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
932 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
934 QStringList myPeriodicityTreeHeaders;
935 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
936 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
937 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
938 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
939 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
940 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
941 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
942 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
943 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
944 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
946 // Hide the vertex name to make the widget more readable
947 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
948 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
949 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
950 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
951 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
952 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
953 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
956 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
957 myPeriodicityTreeWidget->setSortingEnabled(true);
959 myPeriodicityTreeWidget->setAlternatingRowColors(true);
960 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
961 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
963 int periodicityVisibleColumns = 2;
964 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
965 myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
966 myPeriodicityTreeWidget->resizeColumnToContents(column);
968 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
970 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
972 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
974 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
975 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
976 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
978 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
980 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
981 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
983 myPeriodicityOnFaceRadioButton->setChecked(true);
985 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
986 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
989 // FACE, EDGE AND VERTEX SELECTION
990 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
991 shapeTypesFace.Add( TopAbs_FACE );
992 shapeTypesFace.Add( TopAbs_EDGE );
993 shapeTypesFace.Add( TopAbs_COMPOUND );
994 shapeTypesEdge.Add( TopAbs_EDGE );
995 shapeTypesEdge.Add( TopAbs_COMPOUND );
997 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
999 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1000 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1002 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1003 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1004 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1005 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1007 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1008 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1009 // myPeriodicitySourceEdgeWdg->hide();
1010 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1012 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1013 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1015 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1016 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1017 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1018 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1020 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1021 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1022 // myPeriodicityTargetEdgeWdg->hide();
1023 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1025 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1026 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1027 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1029 myPeriodicityGroupBox2->setCheckable(true);
1030 myPeriodicityGroupBox2->setChecked(false);
1032 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1033 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1035 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1036 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1039 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1040 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1043 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1044 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1045 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1048 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1049 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1051 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1052 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1053 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1056 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1057 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1059 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1060 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1061 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1064 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1065 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1067 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1068 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1069 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1072 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1073 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1075 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1076 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1077 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1080 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1081 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1083 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1084 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false, /*stretch=*/false);
1085 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1087 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1088 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1091 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1092 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1094 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1095 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1097 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1099 myPeriodicitySelectionWidgets.clear();
1100 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1101 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1102 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1103 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1104 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1105 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1106 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1107 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1108 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1111 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1112 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1113 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1114 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1115 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1117 myTabWidget->setCurrentIndex( STD_TAB );
1119 connect( myAdvWidget->addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1120 connect( myAdvWidget->addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1121 connect( myAdvWidget->rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1122 connect( myStdWidget->myAllowQuadrangles, SIGNAL( stateChanged( int )),this, SLOT( onStateChange() ));
1125 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1126 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1127 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1128 // connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1129 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1130 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1131 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1132 // connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1133 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1134 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1135 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1136 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onSmpTabChanged( int ) ) );
1138 // Enforced vertices
1139 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1140 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1141 // connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1142 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1143 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1144 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1145 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1146 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1147 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1148 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1151 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1152 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1153 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1154 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1156 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1157 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1159 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1160 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1163 // connect( myPeriodicitySourceFaceWdg, SIGNAL(contentModified()), this, SLOT(onPeriodicityContentModified()));
1167 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1168 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1170 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1172 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1173 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1174 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1175 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1176 // myEnfFaceWdg->deactivateSelection();
1177 // myEnfVertexWdg->deactivateSelection();
1181 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1183 myStdWidget->myGradation->setEnabled( !myStdWidget->myAllowQuadrangles->isChecked() );
1187 * This method resets the content of the X, Y, Z widgets;
1189 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1191 myXCoord->setCleared(true);
1192 myYCoord->setCleared(true);
1193 myZCoord->setCleared(true);
1194 myXCoord->setText("");
1195 myYCoord->setText("");
1196 myZCoord->setText("");
1197 // myGroupName->setText("");
1200 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1201 This method updates the tooltip of a modified item. The QLineEdit widgets content
1202 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1204 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1205 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1206 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1207 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1208 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1209 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1210 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1211 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1212 QTreeWidgetItem* parent = item->parent();
1214 clearEnforcedVertexWidgets();
1216 if (parent && (!x.isNull() || !entry.isNull())) {
1217 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1218 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1219 if (entry.isNull()) {
1220 toolTip += QString("(") + x.toString();
1221 toolTip += QString(", ") + y.toString();
1222 toolTip += QString(", ") + z.toString();
1223 toolTip += QString(")");
1226 if (!groupName.isEmpty())
1227 toolTip += QString(" [") + groupName + QString("]");
1229 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1232 myXCoord->SetValue(x.toDouble());
1233 myYCoord->SetValue(y.toDouble());
1234 myZCoord->SetValue(z.toDouble());
1237 if (!groupName.isEmpty())
1238 myGroupName->setText(groupName);
1242 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1243 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1244 clearEnforcedVertexWidgets();
1245 if (nbSelEnfVertex == 1)
1247 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1250 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1251 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1252 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1253 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1254 if (CORBA::is_nil(measureOp))
1257 CORBA::Double x,y,z;
1258 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1259 if ( measureOp->IsDone() )
1261 myXCoord->SetValue(x);
1262 myYCoord->SetValue(y);
1263 myZCoord->SetValue(z);
1269 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1270 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1271 of the enforced vertex clicked in the tree widget.
1273 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1274 clearEnforcedVertexWidgets();
1275 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1276 if (! items.isEmpty() && items.size() == 1) {
1277 QTreeWidgetItem *item = items[0];
1278 // for (int i=0 ; i < items.size() ; i++) {
1280 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1281 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1282 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1283 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1284 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1285 if (!x.isNull()/* && entry.isNull()*/) {
1286 myXCoord->SetValue(x.toDouble());
1287 myYCoord->SetValue(y.toDouble());
1288 myZCoord->SetValue(z.toDouble());
1291 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1292 myGroupName->setText(group.toString());
1297 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1298 This method adds a face containing enforced vertices in the tree widget.
1300 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1301 // Find theFaceEntry item
1302 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1303 QTreeWidgetItem* theItem;
1304 if (theItemList.empty()) {
1305 theItem = new QTreeWidgetItem();
1306 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1307 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1308 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1309 myEnforcedTreeWidget->addTopLevelItem(theItem);
1312 theItem = theItemList[0];
1317 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1318 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1320 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(QTreeWidgetItem* theItem, double x, double y, double z,
1321 std::string vertexName, std::string geomEntry, std::string groupName) {
1323 std::string theFaceName = theItem->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
1324 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1325 bool okToCreate = true;
1327 const int nbVert = theItem->childCount();
1328 // MESSAGE("Number of child rows: " << nbVert);
1330 double childValueX,childValueY,childValueZ;
1331 QString childEntry, childGroupName;
1332 QTreeWidgetItem* child;
1333 for (int row = 0;row<nbVert;row++) {
1334 child = theItem->child(row);
1335 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1336 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1337 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1338 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1339 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1340 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1341 // update group name
1342 if (childGroupName.toStdString() != groupName) {
1343 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1344 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1352 if (geomEntry.empty()) {
1353 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1356 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1361 if (geomEntry.empty()) {
1362 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1365 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1368 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1369 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1370 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1371 QSize iconSize = iconSelect.size()*0.7;
1373 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1374 QString myVertexName;
1376 while(indexRef != vertexIndex) {
1377 indexRef = vertexIndex;
1378 if (vertexName.empty())
1379 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1381 myVertexName = QString(vertexName.c_str());
1383 for (int row = 0;row<nbVert;row++) {
1384 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1385 if (myVertexName == name) {
1391 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1392 if (geomEntry.empty()) {
1393 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1394 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1395 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1398 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1399 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1401 if (groupName != "")
1402 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1404 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1405 if (geomEntry.empty()) {
1406 toolTip += QString(" (%1, ").arg(x);
1407 toolTip += QString("%1, ").arg(y);
1408 toolTip += QString("%1)").arg(z);
1410 if (groupName != "")
1411 toolTip += QString(" [%1]").arg(groupName.c_str());
1413 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1414 theItem->setExpanded(true);
1415 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1418 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1419 This method is called when a item is added into the enforced vertices tree widget
1421 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1422 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1424 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1426 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1427 myEnfFaceWdg->deactivateSelection();
1428 myEnfVertexWdg->deactivateSelection();
1430 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1431 myEnforcedTreeWidget->resizeColumnToContents(column);
1434 int selEnfFace = myEnfFaceWdg->NbObjects();
1435 int selEnfVertex = myEnfVertexWdg->NbObjects();
1436 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1438 if (selEnfFace == 0)
1441 if ((selEnfVertex == 0) && coordsEmpty)
1444 string entry, shapeName;
1446 for (int i = 0 ; i < selEnfFace ; i++) {
1447 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1448 entry = myEnfFace->GetStudyEntry();
1449 shapeName = myEnfFace->GetName();
1451 QTreeWidgetItem * faceItem = addEnforcedFace(entry, shapeName);
1453 std::string groupName = myGroupName->text().toStdString();
1455 if (boost::trim_copy(groupName).empty())
1458 if (selEnfVertex <= 1)
1461 x = myXCoord->GetValue();
1462 y = myYCoord->GetValue();
1463 z = myZCoord->GetValue();
1464 if (selEnfVertex == 1) {
1465 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1466 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1469 addEnforcedVertex(faceItem, x, y, z, "", "", groupName);
1473 if ( CORBA::is_nil(getGeomEngine()))
1476 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1477 if (CORBA::is_nil(measureOp))
1480 CORBA::Double x,y,z;
1482 for (int j = 0 ; j < selEnfVertex ; j++)
1484 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1485 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1486 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1487 if ( measureOp->IsDone() )
1488 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1489 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1490 addEnforcedVertex(faceItem, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1496 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1497 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1499 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1500 myEnforcedTreeWidget->resizeColumnToContents(column);
1502 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1503 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1504 myStdWidget->onPhysicalMeshChanged();
1508 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1509 This method is called when a item is removed from the enforced vertices tree widget
1511 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1512 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1513 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1514 QList<QTreeWidgetItem *> selectedVertices;
1515 QSet<QTreeWidgetItem *> selectedEntries;
1516 QTreeWidgetItem* item;
1518 foreach( item, selectedItems ) {
1519 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1520 if (! value.isNull())
1521 selectedVertices.append(item);
1523 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1524 if (! value.isNull())
1525 selectedVertices.append(item);
1527 selectedEntries.insert(item);
1531 foreach(item,selectedVertices) {
1532 QTreeWidgetItem* parent = item->parent();
1533 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1534 parent->removeChild(item);
1536 if (parent->childCount() == 0) {
1537 if (selectedEntries.contains(parent))
1538 selectedEntries.remove(parent);
1543 foreach(item,selectedEntries) {
1544 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1548 myEnforcedTreeWidget->selectionModel()->clearSelection();
1552 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1554 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1557 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1558 This method is called when a item is added into the periodicity table widget
1560 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1561 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1563 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1565 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1566 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1567 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1569 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1570 w1->deactivateSelection();
1574 // Source-Target selection
1575 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1576 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1578 if (selSource == 0 || selTarget == 0)
1581 // Vertices selection
1582 if (myPeriodicityGroupBox2->isChecked())
1584 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1585 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1586 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1587 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1588 int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1589 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1591 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1593 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1594 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1599 // Add Source-Target in table
1600 string shapeEntry, sourceEntry, targetEntry;
1601 string shapeName, sourceName, targetName;
1602 GEOM::GEOM_Object_var shape;
1604 QTreeWidgetItem* item = new QTreeWidgetItem();
1605 myPeriodicityTreeWidget->addTopLevelItem(item);
1607 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1611 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1613 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1614 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1615 shapeName = shape->GetName();
1616 shapeEntry = shape->GetStudyEntry();
1617 item->setData(k, Qt::EditRole, shapeName.c_str() );
1618 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1619 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1623 // Add shape type in tree
1624 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1625 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1627 // Blank input fields
1628 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1630 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1631 w1->SetObject(GEOM::GEOM_Object::_nil());
1634 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1635 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1639 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1640 This method is called when a item is removed from the periodicity tree widget
1642 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1643 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1644 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1645 QTreeWidgetItem* item;
1647 foreach(item,selectedItems) {
1648 MESSAGE("Remove " << item->text(0).toStdString());
1652 myEnforcedTreeWidget->selectionModel()->clearSelection();
1655 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1656 This method enable clears the field for periodicity by vertices
1658 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1662 for (size_t k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1664 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1665 w1->deactivateSelection();
1666 w1->SetObject(CORBA::Object::_nil());
1671 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1672 This method enable the proper shape selection widget to Face or Edge shapes
1674 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1676 // if (myPeriodicityOnFaceRadioButton->isChecked())
1678 // MESSAGE("Show Face");
1679 // myPeriodicitySourceEdgeWdg->hide();
1680 // myPeriodicityTargetEdgeWdg->hide();
1681 // myPeriodicitySourceFaceWdg->show();
1682 // myPeriodicityTargetFaceWdg->show();
1686 // MESSAGE("Show Edge");
1687 // myPeriodicitySourceFaceWdg->hide();
1688 // myPeriodicityTargetFaceWdg->hide();
1689 // myPeriodicitySourceEdgeWdg->show();
1690 // myPeriodicityTargetEdgeWdg->show();
1694 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1696 QString shapeName, shapeEntry;
1697 CORBA::Object_var shape;
1699 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1700 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1702 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1704 shapeName = item->data(k, Qt::EditRole).toString();
1705 shapeEntry = item->data(k, Qt::UserRole).toString();
1706 if (! shapeEntry.isEmpty())
1708 shape = entryToObject(shapeEntry);
1709 w1->SetObject(shape);
1710 w1->deactivateSelection();
1712 myPeriodicityGroupBox2->setChecked(1);
1715 myPeriodicityGroupBox2->setChecked(0);
1718 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1719 myPeriodicityOnFaceRadioButton->setChecked(true);
1721 myPeriodicityOnEdgeRadioButton->setChecked(true);
1726 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1727 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1729 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1731 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1733 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1735 // find wich selection widget is activated
1736 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1738 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1739 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1741 // don't activate vertex selection if the group box is not checked
1742 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1744 // clear the selection, to avoid to put the same object in the other widget
1745 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1746 // activate the next widget
1747 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1748 w2->activateSelection();
1755 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1756 This method updates the GUI widgets with the hypothesis data
1758 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1760 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1761 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1763 BlsurfHypothesisData data;
1764 that->readParamsFromHypo( data );
1767 myName->setText( data.myName );
1768 QFontMetrics metrics( myName->font() );
1769 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1771 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1772 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1773 if (data.myPhySize <= 0)
1774 myStdWidget->myPhySize->setText("");
1776 myStdWidget->myPhySize->SetValue( data.myPhySize );
1777 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1778 if (data.myMinSize < 0)
1779 myStdWidget->myMinSize->setText("");
1781 myStdWidget->myMinSize->SetValue( data.myMinSize );
1782 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1783 if (data.myMaxSize < 0)
1784 myStdWidget->myMaxSize->setText("");
1786 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1787 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1788 if (data.myGradation <= 0)
1789 myStdWidget->myGradation->setText("");
1791 myStdWidget->myGradation->SetValue( data.myGradation );
1792 myStdWidget->myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1794 if (data.myAngleMesh < 0)
1795 myStdWidget->myAngleMesh->setText("");
1797 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1798 if (data.myChordalError <= 0)
1799 myStdWidget->myChordalError->setText("");
1801 myStdWidget->myChordalError->SetValue( data.myChordalError );
1802 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1803 if (data.myAnisotropicRatio <= 0)
1804 myStdWidget->myAnisotropicRatio->setText("");
1806 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1807 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1808 if (data.myTinyEdgeLength <= 0)
1809 myStdWidget->myTinyEdgeLength->setText("");
1811 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1812 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1813 if (data.myBadElementAspectRatio <= 0)
1814 myStdWidget->myBadElementAspectRatio->setText("");
1816 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1817 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1818 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1820 myStdWidget->resizeWidgets();
1822 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1823 myAdvWidget->myPreCADGroupBox->setChecked(data.myTopology == PreCAD);
1824 myAdvWidget->myPreCADMergeEdges->setChecked( data.myPreCADMergeEdges );
1825 myAdvWidget->myPreCADProcess3DTopology->setChecked( data.myPreCADProcess3DTopology );
1826 myAdvWidget->myPreCADDiscardInput->setChecked( data.myPreCADDiscardInput );
1828 if ( myOptions.operator->() ) {
1829 // MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
1830 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1831 QString option = that->myOptions[i].in();
1832 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1833 if ( name_value.count() > 1 ) {
1834 QString idStr = QString("%1").arg( i );
1835 int row = myAdvWidget->myOptionTable->rowCount();
1836 myAdvWidget->myOptionTable->setRowCount( row+1 );
1837 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1838 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1839 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "BLSURF" ) );
1840 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
1841 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1842 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1843 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1844 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1845 Qt::ItemIsEditable |
1846 Qt::ItemIsEnabled );
1850 if ( myPreCADOptions.operator->() ) {
1851 // MESSAGE("retrieveParams():myPreCADOptions->length() = " << myPreCADOptions->length());
1852 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
1853 QString option = that->myPreCADOptions[i].in();
1854 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1855 if ( name_value.count() > 1 ) {
1856 QString idStr = QString("%1").arg( i );
1857 int row = myAdvWidget->myOptionTable->rowCount();
1858 myAdvWidget->myOptionTable->setRowCount( row+1 );
1859 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1860 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1861 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "PRECAD" ) );
1862 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
1863 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1864 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1865 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1866 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1867 Qt::ItemIsEditable |
1868 Qt::ItemIsEnabled );
1872 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1873 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1874 // myGMFFileMode->setChecked(data.myGMFFileMode);
1877 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1878 QMapIterator<QString, QString> i(that->mySMPMap);
1879 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1880 while (i.hasNext()) {
1882 const QString entry = i.key();
1883 const QString sizeMap = i.value();
1884 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1885 int row = mySizeMapTable->topLevelItemCount();
1886 QTreeWidgetItem* item = new QTreeWidgetItem();
1887 mySizeMapTable->addTopLevelItem( item );
1888 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1889 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1890 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1891 if (that->myATTMap.contains(entry)){
1892 const QString attEntry = that->myATTMap[entry];
1893 std::string attName = myGeomToolSelected->getNameFromEntry(attEntry.toStdString());
1894 QTreeWidgetItem* child = new QTreeWidgetItem();
1895 item->addChild( child );
1896 item->setExpanded(true);
1897 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1898 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attEntry ) );
1899 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString( attName ) ) );
1901 if (that->myAttDistMap[entry] > std::numeric_limits<double>::epsilon()){
1902 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Attractor" ) ) );
1905 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Constant Size" ) ) );
1910 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1913 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1914 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1915 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1917 // Enforced vertices
1918 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1919 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1921 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1922 TEntry entry = (*evmIt).first;
1923 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1924 MESSAGE("Face entry: " << entry);
1925 MESSAGE("Face name: " << shapeName);
1927 QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1929 TEnfVertexList evs = (*evmIt).second;
1931 TEnfVertexList::const_iterator evsIt = evs.begin();
1932 TEnfVertex *enfVertex;
1933 for ( ; evsIt != evs.end() ; ++evsIt) {
1934 enfVertex = (*evsIt);
1935 MESSAGE("Name: " << enfVertex->name);
1937 if (enfVertex->coords.size()) {
1938 x = enfVertex->coords[0];
1939 y = enfVertex->coords[1];
1940 z = enfVertex->coords[2];
1942 that->addEnforcedVertex(faceItem, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1946 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1947 myEnforcedTreeWidget->resizeColumnToContents(column);
1949 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1950 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1951 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1954 MESSAGE("retrieveParams(): periodicity ");
1957 // Add an item in the tree widget for each association
1958 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
1960 QTreeWidgetItem* item = new QTreeWidgetItem();
1961 myPeriodicityTreeWidget->addTopLevelItem(item);
1962 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1963 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
1964 for (size_t k=0; k<periodicity_i.size(); k++)
1966 string shapeEntry = periodicity_i[k];
1967 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
1968 item->setData(k, Qt::EditRole, shapeName.c_str() );
1969 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1974 that->myStdWidget->onPhysicalMeshChanged();
1975 that->myStdWidget->onGeometricMeshChanged();
1976 that->onStateChange();
1979 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1980 This method updates the hypothesis data with the GUI widgets content.
1982 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1984 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParams");
1985 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1987 BlsurfHypothesisData data;
1988 QString guiHyp = that->readParamsFromWidgets( data );
1989 that->storeParamsToHypo( data );
1994 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1995 Updates the hypothesis data from hypothesis values.
1997 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
1999 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
2000 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2001 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2003 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
2004 h_data.myName = isCreation() && data ? hypName() : "";
2006 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
2007 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
2008 h_data.myPhySize = h->GetPhySize();
2009 h_data.myPhySizeRel = h->IsPhySizeRel();
2010 double minSize = h->GetMinSize();
2011 double maxSize = h->GetMaxSize();
2012 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2013 h_data.myMinSizeRel = h->IsMinSizeRel();
2014 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2015 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2016 h_data.myGradation = h->GetGradation();
2017 h_data.myAllowQuadrangles = h->GetQuadAllowed();
2018 double angle = h->GetAngleMesh();
2019 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2020 double chordalError = h->GetChordalError();
2021 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2022 h_data.myAnisotropic = h->GetAnisotropic();
2023 double myAnisotropicRatio = h->GetAnisotropicRatio();
2024 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2025 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2026 double myTinyEdgeLength = h->GetTinyEdgeLength();
2027 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2028 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2029 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2030 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2031 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2032 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2033 h_data.myVerbosity = h->GetVerbosity();
2034 h_data.myTopology = (int) h->GetTopology();
2035 h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2036 h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2037 h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2040 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2041 that->myOptions = h->GetOptionValues();
2042 that->myPreCADOptions = h->GetPreCADOptionValues();
2044 h_data.myGMFFileName = h->GetGMFFile();
2045 // h_data.myGMFFileMode = h->GetGMFFileMode();
2047 that->mySMPMap.clear();
2048 that->myATTMap.clear();
2049 that->myAttDistMap.clear();
2050 that->myDistMap.clear();
2052 // classic size maps
2053 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2054 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
2055 QString fullSizeMaps;
2056 QStringList fullSizeMapList;
2057 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2058 for ( int i = 0;i<mySizeMaps->length(); ++i ) {
2059 fullSizeMaps = mySizeMaps[i].in();
2060 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
2061 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2062 if ( fullSizeMapList.count() > 1 ) {
2063 string fullSizeMap = fullSizeMapList[1].toStdString();
2064 int pos = fullSizeMap.find("return")+7;
2065 // MESSAGE("pos:" << pos);
2068 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2073 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2074 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
2075 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2076 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
2082 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2083 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
2085 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2086 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2087 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2088 if ( fullCustomSizeMapList.count() > 1 ) {
2089 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2090 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2091 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
2092 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
2097 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2098 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
2100 for ( int i = 0;i<allMyAttractors->length(); ++i ) {
2101 QString myAttractors = allMyAttractors[i].in();
2102 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2103 if ( myAttractorList.count() > 1 ) {
2104 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2105 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2106 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
2107 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
2111 // attractor new version
2112 MESSAGE("readParamsFromHypo, Attractors")
2113 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2114 for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
2115 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2116 QString faceEntry = myAttractorParams.faceEntry.in();
2117 QString attEntry = myAttractorParams.attEntry.in();
2118 MESSAGE("attEntry = "<<attEntry.toStdString())
2119 double startSize = myAttractorParams.startSize;
2120 double endSize = myAttractorParams.endSize;
2121 double infDist = myAttractorParams.infDist;
2122 double constDist = myAttractorParams.constDist;
2123 that->mySMPMap[faceEntry] = QString::number( startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2124 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2125 that->myATTMap[faceEntry] = attEntry;
2126 that->myAttDistMap[faceEntry] = infDist;
2127 that->myDistMap[faceEntry] = constDist;
2130 // Enforced vertices
2131 h_data.enfVertexList.clear();
2132 h_data.faceEntryEnfVertexListMap.clear();
2134 h_data.groupNameEnfVertexListMap.clear();
2137 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2138 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
2140 for ( int i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
2141 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2142 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
2143 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2144 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
2146 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
2148 for (int j=0 ; j<vertexList.length(); ++j) {
2149 TEnfVertex *enfVertex = new TEnfVertex();
2151 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
2152 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
2153 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
2154 for (int k=0 ; k< vertexList[j].coords.length();k++)
2155 enfVertex->coords.push_back(vertexList[j].coords[k]);
2157 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2160 if (groupName != "") {
2161 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2165 // h_data.enfVertMap[entry] = evs;
2166 // h_data.entryCoordsListMap[entry] = coordsList;
2168 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2169 h_data.faceEntryEnfVertexListMap.erase(entry);
2172 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2173 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2176 MESSAGE("readParamsFromHypo, Periodicity")
2178 h_data.preCadPeriodicityVector.clear();
2180 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2181 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2183 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2184 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2188 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2189 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2192 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2194 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2195 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2196 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2198 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2199 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2201 if (sourceVertices.length()!=0)
2203 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2204 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2205 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2208 if (targetVertices.length()!=0)
2210 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2211 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2212 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2216 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2218 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2220 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2224 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2225 Saves the hypothesis data to hypothesis values.
2227 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2229 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
2230 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2231 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2237 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2239 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2240 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2241 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2242 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2244 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2245 if ( h->GetPhySize() != h_data.myPhySize ||
2246 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2247 if ( h_data.myPhySizeRel )
2248 h->SetPhySizeRel( h_data.myPhySize );
2250 h->SetPhySize( h_data.myPhySize );
2253 if (h->GetMinSize() != h_data.myMinSize ||
2254 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2255 if ( h_data.myMinSizeRel )
2256 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2258 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2260 if (h->GetMaxSize() != h_data.myMaxSize ||
2261 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2262 if ( h_data.myMaxSizeRel )
2263 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2265 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2267 if ( h->GetGradation() != h_data.myGradation )
2268 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2269 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
2270 h->SetQuadAllowed( h_data.myAllowQuadrangles );
2272 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2273 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2274 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2275 if ( h->GetChordalError() != h_data.myChordalError )
2276 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2279 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2280 h->SetAnisotropic( h_data.myAnisotropic );
2281 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2282 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2284 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2285 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2286 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2287 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2289 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2290 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2291 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2292 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2294 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2295 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2297 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2298 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2300 if ( h->GetVerbosity() != h_data.myVerbosity )
2301 h->SetVerbosity( h_data.myVerbosity );
2302 if ( h->GetTopology() != h_data.myTopology )
2303 h->SetTopology( (int) h_data.myTopology );
2304 if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2305 h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2306 if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2307 h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2308 if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2309 h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2311 h->SetOptionValues( myOptions ); // is set in checkParams()
2312 h->SetPreCADOptionValues( myPreCADOptions ); // is set in checkParams()
2314 if ( h->GetGMFFile() != h_data.myGMFFileName )
2315 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2316 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2317 h->SetGMFFile( h_data.myGMFFileName.c_str());
2319 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2320 QMapIterator<QString,QString> i(that->mySMPMap);
2321 while (i.hasNext()) {
2323 const QString entry = i.key();
2324 const QString sizeMap = i.value();
2326 if (sizeMap == "__TO_DELETE__") {
2327 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
2328 h->UnsetEntry(entry.toLatin1().constData());
2330 else if (sizeMap.startsWith("ATTRACTOR")) {
2331 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2332 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2334 else if (sizeMap.startsWith("def")) {
2335 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2336 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2339 if (!myATTMap[entry].isEmpty()){
2340 QString att_entry = myATTMap[entry];
2341 double infDist = myAttDistMap[entry];
2342 double constDist = myDistMap[entry];
2343 double phySize = h->GetPhySize();
2344 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
2345 h->SetClassAttractorEntry( entry.toLatin1().constData(), att_entry.toLatin1().constData(), sizeMap.toDouble() , phySize, infDist, constDist );
2346 QApplication::restoreOverrideCursor();
2349 QString fullSizeMap;
2350 fullSizeMap = QString("");
2351 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2352 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2353 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2354 fullSizeMap = QString("def f(t): return ") + sizeMap;
2355 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2356 fullSizeMap = QString("def f(): return ") + sizeMap;
2357 MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
2358 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2363 // Enforced vertices
2366 std::string enfName;
2368 std::string groupName = "";
2371 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2372 // 1. Clear all enforced vertices in hypothesis
2373 // 2. Add new enforced vertex according to h_data
2375 if ( h->GetAllEnforcedVertices()->length() > 0 )
2376 h->ClearAllEnforcedVertices();
2379 TEnfVertexList::const_iterator evsIt;
2380 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2382 faceEntry = evmIt->first;
2383 evs = evmIt->second;
2384 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
2385 evsIt = evs.begin();
2386 for ( ; evsIt != evs.end() ; ++evsIt)
2389 if ((*evsIt)->coords.size()) {
2390 x = (*evsIt)->coords[0];
2391 y = (*evsIt)->coords[1];
2392 z = (*evsIt)->coords[2];
2394 ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2398 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2399 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2400 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2401 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2404 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2405 h->ClearPreCadPeriodicityVectors();
2407 MESSAGE("h_data.preCadPeriodicityVector.size(): " << h_data.preCadPeriodicityVector.size());
2408 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2409 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2411 TPreCadPeriodicity periodicity_i = *pIt;
2412 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2413 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2414 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2415 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2416 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2417 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2418 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2419 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2420 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2422 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2423 if (! p1Source.empty())
2425 sourceVertices->length(3);
2426 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2427 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2428 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2432 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2433 if (! p1Target.empty())
2435 targetVertices->length(3);
2436 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2437 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2438 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2442 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2444 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2447 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end periodicity");
2451 catch(const std::exception& ex) {
2452 std::cout << "Exception: " << ex.what() << std::endl;
2455 // catch(const SALOME::SALOME_Exception& ex)
2458 // // SalomeApp_Tools::QtCatchCorbaException(ex);
2461 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end");
2465 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2466 Stores the widgets content to the hypothesis data.
2468 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2470 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
2471 h_data.myName = myName ? myName->text() : "";
2472 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2473 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2474 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2475 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2476 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2477 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2478 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2479 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2480 h_data.myGradation = myStdWidget->myGradation->text().isEmpty() ? -1.0 : myStdWidget->myGradation->GetValue();
2481 h_data.myAllowQuadrangles = myStdWidget->myAllowQuadrangles->isChecked();
2482 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2483 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2484 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2485 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2486 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2487 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2488 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2489 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2490 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2491 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2492 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2493 h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2494 h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2495 h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2496 h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2499 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2500 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2501 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2502 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2503 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2504 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2505 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2506 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2507 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2508 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2509 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2510 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2511 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2512 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2515 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2516 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2517 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2518 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2519 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2520 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2523 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2524 guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2525 guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2526 guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2528 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2529 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
2530 for ( ; row < nbRows; ++row )
2532 int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2533 std::string optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
2534 if ( id >= 0 && ( ( optionType == "BLSURF" && id < myOptions->length() ) || ( optionType == "PRECAD" && id < myPreCADOptions->length() ) ) )
2536 QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
2537 QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
2538 if ( value.isNull() )
2540 if (optionType == "PRECAD")
2541 that->myPreCADOptions[ id ] = ( name + ":" + value).toLatin1().constData();
2543 that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
2545 if ( value != "" ) {
2546 if (optionType == "PRECAD")
2547 guiHyp += "PRECAD_";
2548 guiHyp += name + " = " + value + "; ";
2553 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2554 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2557 row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2558 for ( ; row < nbRows; ++row )
2560 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2561 if ( that->mySMPMap.contains(entry) )
2562 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2565 // Enforced vertices
2566 h_data.enfVertexList.clear();
2567 h_data.faceEntryEnfVertexListMap.clear();
2569 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2570 int nbEnforcedVertices = 0;
2571 std::string groupName = "";
2572 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
2573 for (int i=0 ; i<nbEnforcedShapes ; i++) {
2574 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
2576 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2577 nbEnforcedVertices = shapeItem->childCount();
2578 if (nbEnforcedVertices >0) {
2579 double childValueX,childValueY,childValueZ;
2580 std::string childName, vertexEntry;
2581 QTreeWidgetItem* child;
2584 for (row = 0;row<nbEnforcedVertices;row++) {
2585 child = shapeItem->child(row);
2586 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2587 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2588 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2589 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2590 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2591 // if (myGlobalGroupName->isChecked())
2592 // groupName = myGlobalGroupName->text().toStdString();
2594 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2596 TEnfVertex *enfVertex = new TEnfVertex();
2597 enfVertex->name = childName;
2598 if (vertexEntry.empty()) {
2599 enfVertex->coords.push_back(childValueX);
2600 enfVertex->coords.push_back(childValueY);
2601 enfVertex->coords.push_back(childValueZ);
2604 enfVertex->geomEntry = vertexEntry;
2605 enfVertex->grpName = groupName;
2606 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2607 // if (it == h_data.enfVertexList.end())
2608 h_data.enfVertexList.insert(enfVertex);
2609 evs.insert(enfVertex);
2611 if (groupName != "")
2612 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2615 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2620 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2621 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2624 h_data.preCadPeriodicityVector.clear();
2625 // For each tree item, store each value. Shapes are stored as entries.
2626 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2627 for (size_t i=0 ; i<nbPeriodicityDescriptions ; i++) {
2628 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2629 TPreCadPeriodicity periodicity_i;
2631 for (size_t k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2634 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2636 periodicity_i.push_back(entry);
2638 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2640 guiHyp += "PERIODICITY = yes; ";
2643 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2647 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2649 QMenu* menu = (QMenu*)sender();
2650 // fill popup with option names
2652 QString name_value, name;
2653 if ( myOptions.operator->() ) {
2654 QMenu* blsurfMenu = menu->addMenu(tr("OPTION_MENU_BLSURF"));
2655 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
2656 name_value = myOptions[i].in();
2657 name = name_value.split( ":", QString::KeepEmptyParts )[0];
2658 blsurfMenu->addAction( name );
2661 if ( myPreCADOptions.operator->() ) {
2662 QMenu* preCADmenu = menu->addMenu(tr("OPTION_MENU_PRECAD"));
2663 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
2664 name_value = myPreCADOptions[i].in();
2665 name = name_value.split( ":", QString::KeepEmptyParts )[0];
2666 preCADmenu->addAction( name );
2671 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
2673 myAdvWidget->myOptionTable->setFocus();
2674 QMenu* menu = (QMenu*)( a->parent() );
2676 int idx = menu->actions().indexOf( a );
2677 QString idStr = QString("%1").arg( idx );
2678 QString option, optionType;
2679 if (menu->title() == tr("OPTION_MENU_BLSURF")) {
2680 option = myOptions[idx].in();
2681 optionType = "BLSURF";
2683 else if (menu->title() == tr("OPTION_MENU_PRECAD")) {
2684 option = myPreCADOptions[idx].in();
2685 optionType = "PRECAD";
2687 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
2689 // look for a row with optionName
2690 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
2691 for ( ; row < nbRows; ++row )
2692 if ( myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
2693 if ( myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text() == optionType )
2695 // add a row if not found
2696 if ( row == nbRows ) {
2697 myAdvWidget->myOptionTable->setRowCount( row+1 );
2698 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
2699 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
2700 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( optionType ) );
2701 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
2702 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
2703 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
2704 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
2705 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
2706 Qt::ItemIsEditable |
2707 Qt::ItemIsEnabled );
2708 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2710 myAdvWidget->myOptionTable->clearSelection();
2711 myAdvWidget->myOptionTable->scrollToItem( myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2712 //myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
2713 myAdvWidget->myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
2714 //myAdvWidget->myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2717 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
2719 // clear option values and remember selected row
2720 QList<int> selectedRows;
2721 QList<QTableWidgetItem*> selected = myAdvWidget->myOptionTable->selectedItems();
2722 QTableWidgetItem* item;
2723 foreach( item, selected ) {
2724 int row = item->row();
2725 if ( !selectedRows.contains( row ) ) {
2726 selectedRows.append( row );
2727 int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2728 QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text();
2730 if (optionType == "BLSURF" && id < myOptions->length() )
2731 myOptions[ id ] = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2732 else if (optionType == "PRECAD" && id < myPreCADOptions->length() )
2733 myPreCADOptions[ id ] = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2736 qSort( selectedRows );
2737 QListIterator<int> it( selectedRows );
2739 while ( it.hasPrevious() )
2740 myAdvWidget->myOptionTable->removeRow( it.previous() );
2743 // **********************
2744 // *** BEGIN SIZE MAP ***
2745 // **********************
2747 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2749 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2751 if ( myGeomSelWdg2->IsObjectSelected() ){
2752 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2754 else if ( myGeomSelWdg1->IsObjectSelected() ){
2755 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2757 std::string entry = (string) mySMapObject->GetStudyEntry();
2758 QString qEntry = QString::fromStdString(entry);
2759 if (that->mySMPMap.contains(qEntry) && that->mySMPMap[qEntry] != "__TO_DELETE__" ) {
2760 addMapButton->setEnabled(false);
2761 modifyMapButton->setEnabled(true);
2764 addMapButton->setEnabled(true);
2765 modifyMapButton->setEnabled(false);
2770 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2772 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2773 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2774 if (col == SMP_SIZEMAP_COLUMN){
2775 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2776 if (!mySMPMap.contains(entry))
2778 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2779 CORBA::Object_var obj = entryToObject(entry);
2780 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){ // ADVANCED MAPS
2781 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2782 double phySize = that->mySMPMap[entry].toDouble(); // Retrieve values of the selected item in the current tab widgets
2783 double infDist = that->myAttDistMap[entry];
2784 double constDist = that->myDistMap[entry];
2785 QString attEntry = that->myATTMap[entry];
2786 CORBA::Object_var attObj = entryToObject(attEntry);
2787 myAttSizeSpin->setValue(phySize);
2788 if (sizeMap.startsWith("Attractor")){
2789 myAttDistSpin->setValue(infDist);
2790 myAttractorCheck->setChecked(true);
2793 myAttractorCheck->setChecked(false);
2795 if (sizeMap.startsWith("Constant") || constDist > std::numeric_limits<double>::epsilon()){
2796 myAttDistSpin2->setValue(constDist);
2797 myConstSizeCheck->setChecked(true);
2800 myConstSizeCheck->setChecked(false);
2802 myGeomSelWdg2->SetObject(obj);
2803 myAttSelWdg->SetObject(attObj);
2805 else { // CLASSIC MAPS
2806 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2807 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2808 if (!sizeMap.startsWith("def")){
2809 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2815 void BLSURFPluginGUI_HypothesisCreator::onSmpTabChanged(int tab)
2817 myAttDistSpin->setValue(0.); // Reinitialize widgets
2818 myAttSizeSpin->setValue(0.);
2819 myAttDistSpin2->setValue(0.);
2820 mySmpSizeSpin->setValue(0.);
2821 myGeomSelWdg1->deactivateSelection();
2822 myGeomSelWdg2->deactivateSelection();
2823 myAttSelWdg->deactivateSelection();
2824 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2825 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2826 myAttSelWdg->SetObject(CORBA::Object::_nil());
2827 myAttractorCheck->setChecked(false);
2828 myConstSizeCheck->setChecked(false);
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 }");
2860 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2862 if (state == Qt::Checked){
2863 myAttSelWdg->setEnabled(true);
2864 myAttSizeSpin->setEnabled(true);
2865 myAttSizeLabel->setEnabled(true);
2866 myAttDistSpin2->setEnabled(true);
2867 myAttDistLabel2->setEnabled(true);
2868 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2869 !myAttSelWdg->IsObjectSelected()){
2870 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2873 if (state == Qt::Unchecked){
2874 myAttDistSpin2->setEnabled(false);
2875 myAttDistLabel2->setEnabled(false);
2876 myAttDistSpin2->setValue(0.);
2877 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2878 myAttSelWdg->setEnabled(false);
2879 myAttSizeSpin->setEnabled(false);
2880 myAttSizeLabel->setEnabled(false);
2881 myAttDistSpin->setEnabled(false);
2882 myAttDistLabel->setEnabled(false);
2884 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2885 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2890 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2892 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
2893 QList<int> selectedRows;
2894 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2895 QTreeWidgetItem* item;
2896 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2898 qSort( selectedRows );
2899 QListIterator<QTreeWidgetItem*> it( selected );
2901 while ( it.hasPrevious() ) {
2902 item = it.previous();
2903 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2904 if (that->mySMPMap.contains(entry))
2905 that->mySMPMap[entry] = "__TO_DELETE__";
2906 if (that->mySMPShapeTypeMap.contains(entry))
2907 that->mySMPShapeTypeMap.remove(entry);
2908 if (that->myATTMap.contains(entry))
2909 that->myATTMap.remove(entry);
2910 if (that->myDistMap.contains(entry))
2911 that->myDistMap.remove(entry);
2912 if (that->myAttDistMap.contains(entry))
2913 that->myAttDistMap.remove(entry);
2916 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2917 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2920 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2922 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
2923 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2924 if (col == SMP_SIZEMAP_COLUMN) {
2925 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2926 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2927 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2928 MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
2929 if (! that->mySMPShapeTypeMap.contains(entry))
2930 MESSAGE("no such entry in mySMPShapeTypeMap")
2932 if (that->mySMPMap.contains(entry))
2933 if (that->mySMPMap[entry] == sizeMap
2934 || sizeMap.startsWith("Attractor")
2935 || sizeMap.startsWith("Constant") ){
2938 if (! sizeMap.isEmpty()) {
2939 that->mySMPMap[entry] = sizeMap;
2940 sizeMapValidationFromEntry(entry);
2943 MESSAGE("Size map empty: reverse to precedent value" );
2944 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2946 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2950 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2953 if ( smpTab->currentIndex() == ATT_TAB ){
2954 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2955 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2956 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2957 res = insertAttractor(mySMapObject, myAttObject);
2960 if (smpTab->currentIndex() == SMP_STD_TAB ){
2961 if ( myGeomSelWdg1->IsObjectSelected() ){
2962 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2963 res = insertElement(mySMapObject);
2967 // Local size should be more than 0
2968 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
2969 SUIT_MessageBox::critical( dlg(),"Error" , msg );
2972 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2973 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2974 myAttDistSpin->setValue(0.);
2975 myAttSizeSpin->setValue(0.);
2976 myAttDistSpin2->setValue(0.);
2977 mySmpSizeSpin->setValue(0.);
2978 myConstSizeCheck->setChecked(false);
2979 myAttractorCheck->setChecked(false);
2980 myGeomSelWdg1->deactivateSelection();
2981 myGeomSelWdg2->deactivateSelection();
2982 myAttSelWdg->deactivateSelection();
2983 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2984 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2985 myAttSelWdg->SetObject(CORBA::Object::_nil());
2988 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
2990 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
2992 if ( smpTab->currentIndex() == ATT_TAB ){
2993 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2994 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2995 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2996 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
2999 if (smpTab->currentIndex() == SMP_STD_TAB ){
3000 if ( myGeomSelWdg1->IsObjectSelected() ){
3001 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3002 res = insertElement(mySMapObject, /*modify = */true);
3006 // Local size should be more than 0
3007 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3008 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3011 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3012 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
3013 myAttDistSpin->setValue(0.);
3014 myAttSizeSpin->setValue(0.);
3015 myAttDistSpin2->setValue(0.);
3016 mySmpSizeSpin->setValue(0.);
3017 myConstSizeCheck->setChecked(false);
3018 myAttractorCheck->setChecked(false);
3019 myGeomSelWdg1->deactivateSelection();
3020 myGeomSelWdg2->deactivateSelection();
3021 myAttSelWdg->deactivateSelection();
3022 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3023 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3024 myAttSelWdg->SetObject(CORBA::Object::_nil());
3027 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3029 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
3030 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3031 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3033 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3035 TopAbs_ShapeEnum shapeType;
3036 string entry, shapeName;
3037 entry = (string) anObject->GetStudyEntry();
3038 MESSAGE("entry = "<<entry);
3039 shapeName = anObject->GetName();
3040 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3041 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3042 // in order to write the size map with the right syntax in StoreParamsToHypo
3043 // (f(t) for edges, f(u,v) for faces ...)
3044 if (shapeType == TopAbs_COMPOUND){
3045 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3046 TopoDS_Shape childShape;
3047 TopoDS_Iterator anIt(theShape);
3048 for(;anIt.More();anIt.Next()){
3049 childShape = anIt.Value();
3050 shapeType = childShape.ShapeType();
3051 if(!childShape.IsNull()){
3056 mySizeMapTable->setFocus();
3058 shapeEntry = QString::fromStdString(entry);
3059 double phySize = mySmpSizeSpin->value();
3062 return false; // Local size should be more than 0
3064 std::ostringstream oss;
3067 sizeMap = QString::fromStdString(oss.str());
3068 QTreeWidgetItem* item = new QTreeWidgetItem();
3070 int rowToChange = findRowFromEntry(shapeEntry);
3071 item = mySizeMapTable->topLevelItem( rowToChange );
3074 if (that->mySMPMap.contains(shapeEntry)) {
3075 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3076 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3080 mySizeMapTable->addTopLevelItem(item);
3082 that->mySMPMap[shapeEntry] = sizeMap;
3083 that->myDistMap[shapeEntry] = 0. ;
3084 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3085 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3086 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3087 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3088 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3089 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3090 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3091 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3092 mySizeMapTable->clearSelection();
3094 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3095 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3096 myStdWidget->onPhysicalMeshChanged();
3101 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3103 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
3104 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3105 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3107 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3109 TopAbs_ShapeEnum shapeType;
3110 string entry, attEntry, faceName, attName;
3111 entry = (string) aFace->GetStudyEntry();
3112 attEntry = (string) anAttractor->GetStudyEntry();
3113 faceName = aFace->GetName();
3114 attName = anAttractor->GetName();
3115 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3116 mySizeMapTable->setFocus();
3117 QString shapeEntry = QString::fromStdString(entry);
3118 QString qAttEntry = QString::fromStdString(attEntry);
3120 double phySize = h->GetPhySize();
3121 double infDist = 0. ;
3122 double constDist = 0. ;
3123 phySize = myAttSizeSpin->value();
3126 return false; // Local size should be more than 0
3128 if (myAttractorCheck->isChecked()){
3129 infDist = myAttDistSpin->value();
3131 if (myConstSizeCheck->isChecked()){
3132 constDist = myAttDistSpin2->value();
3134 std::ostringstream oss;
3135 std::ostringstream oss2;
3136 std::ostringstream oss3;
3140 QString sizeMap = QString::fromStdString(oss.str());
3141 QString infDistString = QString::fromStdString(oss2.str());
3142 QString constDistString = QString::fromStdString(oss3.str());
3144 QTreeWidgetItem* item;
3145 QTreeWidgetItem* child;
3147 int rowToChange = findRowFromEntry(shapeEntry);
3148 item = mySizeMapTable->topLevelItem( rowToChange );
3149 child = item->child( 0 );
3152 if (that->mySMPMap.contains(shapeEntry)) {
3153 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3154 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3158 item = new QTreeWidgetItem();
3159 child = new QTreeWidgetItem();
3160 mySizeMapTable->addTopLevelItem(item);
3161 item->addChild(child);
3163 that->mySMPMap.insert(shapeEntry,sizeMap);
3164 that->myATTMap.insert(shapeEntry,qAttEntry);
3165 that->myAttDistMap.insert(shapeEntry,infDist);
3166 that->myDistMap.insert(shapeEntry,constDist);
3167 that->mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3168 item->setExpanded(true);
3169 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3170 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3171 if (infDist > std::numeric_limits<double>::epsilon()){
3172 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3174 else if (constDist > std::numeric_limits<double>::epsilon()){
3175 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3177 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3179 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3180 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3181 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3183 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3184 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3185 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3187 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3188 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3189 myStdWidget->onPhysicalMeshChanged();
3191 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
3195 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3197 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
3198 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3199 for ( ; row < nbRows; ++row )
3200 if (! sizeMapValidationFromRow(row))
3205 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3207 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
3208 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3209 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3210 mySizeMapTable->setFocus();
3214 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3216 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
3217 MESSAGE("myEntry = "<<myEntry.toStdString())
3219 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3221 if (! that->mySMPMap.contains(myEntry)) {
3222 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
3225 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3226 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
3232 if (that->mySMPMap[myEntry].startsWith("def")) {
3233 // MESSAGE("custom function" );
3234 expr = that->mySMPMap[myEntry].toStdString();
3236 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3237 // MESSAGE("Attractor" );
3238 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)) {
3241 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])" );
3247 // case size map is empty
3248 if (that->mySMPMap[myEntry].isEmpty()) {
3250 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3254 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3255 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3256 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3257 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3258 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3259 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3262 //assert(Py_IsInitialized());
3263 if (! Py_IsInitialized())
3264 throw ("Erreur: Python interpreter is not initialized");
3265 PyGILState_STATE gstate;
3266 gstate = PyGILState_Ensure();
3268 PyObject * obj = NULL;
3269 PyObject* new_stderr = NULL;
3270 string err_description="";
3271 obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3275 new_stderr=newPyStdOut(err_description);
3276 PySys_SetObject((char*)"stderr", new_stderr);
3278 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
3279 Py_DECREF(new_stderr);
3281 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3282 PyGILState_Release(gstate);
3287 PyObject * func = NULL;
3288 func = PyObject_GetAttrString(main_mod, "f");
3292 new_stderr=newPyStdOut(err_description);
3293 PySys_SetObject((char*)"stderr", new_stderr);
3295 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
3296 Py_DECREF(new_stderr);
3298 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3299 PyGILState_Release(gstate);
3303 PyGILState_Release(gstate);
3305 // MESSAGE("SizeMap expression "<<expr<<" is valid");
3310 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3312 return tr( "BLSURF_TITLE" );
3315 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3317 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3320 QString BLSURFPluginGUI_HypothesisCreator::type() const
3322 return tr( "BLSURF_HYPOTHESIS" );
3325 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3327 return "blsurf_hypo_page.html";
3330 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3333 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3335 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3340 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3342 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
3343 SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
3344 CORBA::Object_var obj;
3345 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
3346 if (!aSObj->_is_nil()) {
3347 obj = aSObj->GetObject();
3348 aSObj->UnRegister();
3353 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3354 QString entryForChecking;
3355 int endRow = mySizeMapTable->topLevelItemCount()-1;
3357 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3358 while (entry != entryForChecking && row <= endRow){
3360 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3362 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)