1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPluginGUI_HypothesisCreator.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPluginGUI_HypothesisCreator.h"
28 #include "BLSURFPluginGUI_Dlg.h"
30 #include "GeometryGUI.h"
32 #include <SMESHGUI_Utils.h>
33 #include <SMESHGUI_HypothesesUtils.h>
34 #include <SMESHGUI_Dialog.h>
35 #include "SMESHGUI_SpinBox.h"
36 #include "SMESH_NumberFilter.hxx"
38 #include <SUIT_Session.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_ResourceMgr.h>
41 #include <SalomeApp_Tools.h>
43 #include <QApplication>
47 #include <QHBoxLayout>
48 #include <QHeaderView>
49 #include <QGridLayout>
55 #include <QPushButton>
56 #include <QRadioButton>
58 #include <QTableWidget>
60 #include <QVBoxLayout>
63 #include <QStandardItemModel>
64 #include <QStandardItem>
65 #include <QTreeWidget>
66 #include <QTreeWidgetItem>
67 #include <QModelIndexList>
69 #include <LightApp_SelectionMgr.h>
70 #include <SalomeApp_Application.h>
71 #include <SALOME_ListIO.hxx>
72 #include "SALOME_LifeCycleCORBA.hxx"
74 #include <TopoDS_Shape.hxx>
75 #include <TopoDS_Iterator.hxx>
76 #include <SMESH_Gen_i.hxx>
77 #include <boost/shared_ptr.hpp>
78 #include <boost/algorithm/string.hpp>
79 #include <structmember.h>
95 // Enforced vertices array columns
96 ENF_VER_NAME_COLUMN = 0,
97 ENF_VER_FACE_ENTRY_COLUMN,
101 ENF_VER_ENTRY_COLUMN,
102 ENF_VER_GROUP_COLUMN,
105 PERIODICITY_OBJ_SOURCE_COLUMN = 0,
106 PERIODICITY_OBJ_TARGET_COLUMN,
107 PERIODICITY_P1_SOURCE_COLUMN,
108 PERIODICITY_P2_SOURCE_COLUMN,
109 PERIODICITY_P3_SOURCE_COLUMN,
110 PERIODICITY_P1_TARGET_COLUMN,
111 PERIODICITY_P2_TARGET_COLUMN,
112 PERIODICITY_P3_TARGET_COLUMN,
113 PERIODICITY_SHAPE_TYPE,
115 // PERIODICITY_OBJ_SOURCE_COLUMN = 0,
116 // PERIODICITY_ENTRY_SOURCE_COLUMN,
117 // PERIODICITY_OBJ_TARGET_COLUMN,
118 // PERIODICITY_ENTRY_TARGET_COLUMN,
119 // PERIODICITY_P1_SOURCE_COLUMN,
120 // PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
121 // PERIODICITY_P2_SOURCE_COLUMN,
122 // PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
123 // PERIODICITY_P3_SOURCE_COLUMN,
124 // PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
125 // PERIODICITY_P1_TARGET_COLUMN,
126 // PERIODICITY_P1_ENTRY_TARGET_COLUMN,
127 // PERIODICITY_P2_TARGET_COLUMN,
128 // PERIODICITY_P2_ENTRY_TARGET_COLUMN,
129 // PERIODICITY_P3_TARGET_COLUMN,
130 // PERIODICITY_P3_ENTRY_TARGET_COLUMN,
132 PERIODICITY_NB_COLUMN
158 // Enforced vertices inputs
166 // ENF_VER_GROUP_CHECK,
170 ENF_VER_INTERNAL_ALL_FACES,
171 ENF_VER_INTERNAL_ALL_FACES_GROUP,
172 // ENF_VER_VERTEX_BTN,
173 // ENF_VER_REMOVE_BTN,
174 // ENF_VER_SEPARATOR,
179 /**************************************************
180 Begin initialization Python structures and objects
181 ***************************************************/
191 PyStdOut_dealloc(PyStdOut *self)
197 PyStdOut_write(PyStdOut *self, PyObject *args)
201 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
204 *(self->out)=*(self->out)+c;
210 static PyMethodDef PyStdOut_methods[] = {
211 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
212 PyDoc_STR("write(string) -> None")},
213 {NULL, NULL} /* sentinel */
216 static PyMemberDef PyStdOut_memberlist[] = {
217 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
218 (char*)"flag indicating that a space needs to be printed; used by print"},
219 {NULL} /* Sentinel */
222 static PyTypeObject PyStdOut_Type = {
223 /* The ob_type field must be initialized in the module init function
224 * to be portable to Windows without using C++. */
225 PyObject_HEAD_INIT(NULL)
228 sizeof(PyStdOut), /*tp_basicsize*/
231 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
238 0, /*tp_as_sequence*/
243 PyObject_GenericGetAttr, /*tp_getattro*/
244 /* softspace is writable: we must supply tp_setattro */
245 PyObject_GenericSetAttr, /* tp_setattro */
247 Py_TPFLAGS_DEFAULT, /*tp_flags*/
251 0, /*tp_richcompare*/
252 0, /*tp_weaklistoffset*/
255 PyStdOut_methods, /*tp_methods*/
256 PyStdOut_memberlist, /*tp_members*/
270 PyObject * newPyStdOut( std::string& out )
272 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
277 return (PyObject*)self;
281 /*************************************************
282 End initialization Python structures and objects
283 **************************************************/
287 // BEGIN EnforcedTreeWidgetDelegate
290 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
291 : QItemDelegate(parent)
295 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
296 const QStyleOptionViewItem & option ,
297 const QModelIndex & index ) const
299 QModelIndex father = index.parent();
300 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
302 if (index.column() == ENF_VER_X_COLUMN || \
303 index.column() == ENF_VER_Y_COLUMN || \
304 index.column() == ENF_VER_Z_COLUMN)
306 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
307 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
308 editor->setReadOnly(!entry.isEmpty());
309 editor->setDisabled(!entry.isEmpty());
314 QLineEdit *editor = new QLineEdit(parent);
315 if (index.column() != ENF_VER_GROUP_COLUMN) {
316 editor->setReadOnly(!entry.isEmpty());
317 editor->setDisabled(!entry.isEmpty());
323 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
324 const QModelIndex &index) const
326 QString value = index.model()->data(index, Qt::EditRole).toString();
328 if (index.column() == ENF_VER_X_COLUMN ||
329 index.column() == ENF_VER_Y_COLUMN ||
330 index.column() == ENF_VER_Z_COLUMN)
332 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
333 lineEdit->setText(value);
336 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
337 lineEdit->setText(value);
341 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
342 const QModelIndex &index) const
344 QModelIndex parent = index.parent();
345 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
346 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
347 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
348 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
349 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
350 } else if (index.column() == ENF_VER_NAME_COLUMN) {
351 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
352 QString value = lineEdit->text();
353 if (entry.isEmpty() && !vertexExists(model, index, value))
354 model->setData(index, value, Qt::EditRole);
355 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
356 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
357 QString value = lineEdit->text();
358 if (!vertexExists(model, index, value))
359 model->setData(index, value, Qt::EditRole);
360 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
361 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
362 model->setData(index, lineEdit->text(), Qt::EditRole);
366 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
367 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
369 editor->setGeometry(option.rect);
372 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
373 const QModelIndex &index, QString value) const
376 QModelIndex parent = index.parent();
377 int row = index.row();
378 int col = index.column();
380 if (parent.isValid() && !value.isEmpty()) {
381 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
383 if (col == ENF_VER_X_COLUMN) {
384 x = value.toDouble();
385 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
386 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
388 if (col == ENF_VER_Y_COLUMN) {
389 y = value.toDouble();
390 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
391 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
393 if (col == ENF_VER_Z_COLUMN) {
394 z = value.toDouble();
395 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
396 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
398 int nbChildren = model->rowCount(parent);
399 for (int i = 0 ; i < nbChildren ; i++) {
401 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
402 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
403 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
404 if ((childX == x) && (childY == y) && (childZ == z)) {
411 else if (col == ENF_VER_NAME_COLUMN) {
412 int nbChildren = model->rowCount(parent);
413 for (int i = 0 ; i < nbChildren ; i++) {
415 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
416 if (childName == value) {
429 // END EnforcedTreeWidgetDelegate
434 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
435 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
438 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
439 : SMESHGUI_GenericHypothesisCreator( theHypType )
441 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
442 this->mySMPMap.clear();
444 GeomToolSelected = NULL;
445 GeomToolSelected = getGeomSelectionTool();
447 aSel = GeomToolSelected->selectionMgr();
449 /* Initialize the Python interpreter */
450 if (! Py_IsInitialized())
451 throw ("Error: Python interpreter is not initialized");
452 PyGILState_STATE gstate;
453 gstate = PyGILState_Ensure();
456 main_mod = PyImport_AddModule("__main__");
459 main_dict = PyModule_GetDict(main_mod);
461 PyRun_SimpleString("from math import *");
462 PyGILState_Release(gstate);
466 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
471 * \brief {Get or create the geom selection tool for active study}
473 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() const
475 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
476 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
477 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
478 that->GeomToolSelected = new GeomSelectionTools(aStudy);
480 return that->GeomToolSelected;
483 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
485 return GeometryGUI::GetGeomGen();
488 void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
490 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
491 ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
492 for ( ; anIt != selectionWidgets.end(); anIt++)
494 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
496 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
497 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
498 ListOfWidgets::const_iterator anIt2 = anIt;
499 for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
500 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
502 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
503 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
504 w1->AvoidSimultaneousSelection( w2 );
506 if ( !widgetToActivate )
507 widgetToActivate = w1;
510 if ( widgetToActivate )
511 widgetToActivate->activateSelection();
514 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
516 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
519 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
520 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
524 myAdvWidget->myOptionTable->setFocus();
525 QApplication::instance()->processEvents();
527 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
528 for ( ; row < nbRows; ++row )
530 QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
531 QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
532 bool custom = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->data(Qt::UserRole).toBool();
533 if ( !value.isEmpty() && !custom ) {
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);
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);
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);
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 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
849 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
851 myEnforcedTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
853 myEnforcedTreeWidget->resizeColumnToContents(column);
855 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
856 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
857 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
859 // FACE AND VERTEX SELECTION
860 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
861 shapeTypes1.Add( TopAbs_FACE );
862 shapeTypes1.Add( TopAbs_COMPOUND );
863 shapeTypes2.Add( TopAbs_VERTEX );
864 shapeTypes2.Add( TopAbs_COMPOUND );
866 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
867 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true);
868 myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
870 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
871 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
872 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
874 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
876 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
877 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
878 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
880 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
881 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
882 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
884 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
885 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
886 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
888 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
889 myGroupName = new QLineEdit(myEnfGroup);
891 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
892 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
894 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
896 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
897 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
899 // myGlobalGroupName = new QCheckBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
900 // myGlobalGroupName->setChecked(false);
902 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
903 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
904 // FACE AND VERTEX SELECTION
905 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
906 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
907 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
908 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
909 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
910 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
911 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
912 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
913 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
914 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
915 // anEnfLayout2->addWidget(myGlobalGroupName, ENF_VER_GROUP_CHECK, 0, 1, 2);
916 // anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
917 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
918 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
919 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
920 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
921 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
922 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
923 // anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
924 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
925 // anEnfLayout->setRowStretch(1, 1);
928 // Periodicity parameters
929 myPeriodicityGroup = new QWidget();
930 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
932 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
933 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
934 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
936 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
938 QStringList myPeriodicityTreeHeaders;
939 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
940 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
941 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
942 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
943 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
944 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
945 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
946 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
947 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
948 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
950 // Hide the vertex name to make the widget more readable
951 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
952 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
953 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
954 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
955 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
956 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
957 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
960 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
961 myPeriodicityTreeWidget->setSortingEnabled(true);
963 myPeriodicityTreeWidget->setAlternatingRowColors(true);
964 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
965 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
967 int periodicityVisibleColumns = 2;
968 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
969 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
970 myPeriodicityTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
972 myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
974 myPeriodicityTreeWidget->resizeColumnToContents(column);
976 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
978 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
980 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
982 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
983 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
984 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
986 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
988 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
989 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
991 myPeriodicityOnFaceRadioButton->setChecked(true);
993 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
994 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
997 // FACE, EDGE AND VERTEX SELECTION
998 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
999 shapeTypesFace.Add( TopAbs_FACE );
1000 shapeTypesFace.Add( TopAbs_EDGE );
1001 shapeTypesFace.Add( TopAbs_COMPOUND );
1002 shapeTypesEdge.Add( TopAbs_EDGE );
1003 shapeTypesEdge.Add( TopAbs_COMPOUND );
1005 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
1007 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1008 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1010 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1011 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false);
1012 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1013 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1015 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1016 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1017 // myPeriodicitySourceEdgeWdg->hide();
1018 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1020 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1021 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1023 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1024 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false);
1025 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1026 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1028 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1029 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1030 // myPeriodicityTargetEdgeWdg->hide();
1031 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1033 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1034 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1035 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1037 myPeriodicityGroupBox2->setCheckable(true);
1038 myPeriodicityGroupBox2->setChecked(false);
1040 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1041 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1043 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1044 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1047 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1048 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1051 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1052 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false);
1053 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1056 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1057 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1059 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1060 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false);
1061 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1064 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1065 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1067 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1068 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false);
1069 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1072 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1073 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1075 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1076 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false);
1077 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1080 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1081 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1083 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1084 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false);
1085 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1088 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1089 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1091 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1092 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false);
1093 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1095 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1096 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1099 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1100 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1102 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1103 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1105 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1107 myPeriodicitySelectionWidgets.clear();
1108 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1109 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1110 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1111 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1112 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1113 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1114 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1115 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1116 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1119 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1120 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1121 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1122 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1123 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1125 myTabWidget->setCurrentIndex( STD_TAB );
1127 connect( myAdvWidget->addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1128 connect( myAdvWidget->addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1129 connect( myAdvWidget->rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1130 connect( myAdvWidget->myOptionTable, SIGNAL( cellPressed( int, int ) ), this, SLOT( onEditOption( int, int ) ) );
1131 connect( myAdvWidget->myOptionTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( onChangeOptionName( int, int ) ) );
1132 connect( myStdWidget->myAllowQuadrangles, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChange() ));
1135 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1136 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1137 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1138 // connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1139 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1140 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1141 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1142 connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1143 // connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1144 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1145 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1146 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1147 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1148 connect( myTabWidget, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1150 // Enforced vertices
1151 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1152 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1153 // connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1154 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1155 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1156 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1157 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1158 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1159 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1160 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1163 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1164 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1165 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1166 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1168 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1169 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1171 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1172 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1175 // connect( myPeriodicitySourceFaceWdg, SIGNAL(contentModified()), this, SLOT(onPeriodicityContentModified()));
1179 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1180 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1182 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1184 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1185 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1186 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1187 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1188 // myEnfFaceWdg->deactivateSelection();
1189 // myEnfVertexWdg->deactivateSelection();
1193 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1195 myStdWidget->onPhysicalMeshChanged();
1199 * This method resets the content of the X, Y, Z widgets;
1201 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1203 myXCoord->setCleared(true);
1204 myYCoord->setCleared(true);
1205 myZCoord->setCleared(true);
1206 myXCoord->setText("");
1207 myYCoord->setText("");
1208 myZCoord->setText("");
1209 // myGroupName->setText("");
1212 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1213 This method updates the tooltip of a modified item. The QLineEdit widgets content
1214 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1216 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1217 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1218 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1219 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1220 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1221 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1222 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1223 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1224 QTreeWidgetItem* parent = item->parent();
1226 clearEnforcedVertexWidgets();
1228 if (parent && (!x.isNull() || !entry.isNull())) {
1229 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1230 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1231 if (entry.isNull()) {
1232 toolTip += QString("(") + x.toString();
1233 toolTip += QString(", ") + y.toString();
1234 toolTip += QString(", ") + z.toString();
1235 toolTip += QString(")");
1238 if (!groupName.isEmpty())
1239 toolTip += QString(" [") + groupName + QString("]");
1241 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1244 myXCoord->SetValue(x.toDouble());
1245 myYCoord->SetValue(y.toDouble());
1246 myZCoord->SetValue(z.toDouble());
1249 if (!groupName.isEmpty())
1250 myGroupName->setText(groupName);
1254 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1255 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1256 clearEnforcedVertexWidgets();
1257 if (nbSelEnfVertex == 1)
1259 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1262 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1263 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1264 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1265 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1266 if (CORBA::is_nil(measureOp))
1269 CORBA::Double x,y,z;
1270 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1271 if ( measureOp->IsDone() )
1273 myXCoord->SetValue(x);
1274 myYCoord->SetValue(y);
1275 myZCoord->SetValue(z);
1281 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1282 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1283 of the enforced vertex clicked in the tree widget.
1285 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1286 clearEnforcedVertexWidgets();
1287 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1288 if (! items.isEmpty() && items.size() == 1) {
1289 QTreeWidgetItem *item = items[0];
1290 // for (int i=0 ; i < items.size() ; i++) {
1292 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1293 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1294 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1295 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1296 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1297 if (!x.isNull()/* && entry.isNull()*/) {
1298 myXCoord->SetValue(x.toDouble());
1299 myYCoord->SetValue(y.toDouble());
1300 myZCoord->SetValue(z.toDouble());
1303 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1304 myGroupName->setText(group.toString());
1309 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1310 This method adds a face containing enforced vertices in the tree widget.
1312 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1313 // Find theFaceEntry item
1314 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1315 QTreeWidgetItem* theItem;
1316 if (theItemList.empty()) {
1317 theItem = new QTreeWidgetItem();
1318 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1319 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1320 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1321 myEnforcedTreeWidget->addTopLevelItem(theItem);
1324 theItem = theItemList[0];
1329 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1330 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1332 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(QTreeWidgetItem* theItem, double x, double y, double z,
1333 std::string vertexName, std::string geomEntry, std::string groupName) {
1335 std::string theFaceName = theItem->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
1336 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1337 bool okToCreate = true;
1339 const int nbVert = theItem->childCount();
1340 // MESSAGE("Number of child rows: " << nbVert);
1342 double childValueX,childValueY,childValueZ;
1343 QString childEntry, childGroupName;
1344 QTreeWidgetItem* child;
1345 for (int row = 0;row<nbVert;row++) {
1346 child = theItem->child(row);
1347 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1348 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1349 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1350 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1351 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1352 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1353 // update group name
1354 if (childGroupName.toStdString() != groupName) {
1355 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1356 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1364 if (geomEntry.empty()) {
1365 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1368 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1373 if (geomEntry.empty()) {
1374 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1377 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1380 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1381 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1382 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1383 QSize iconSize = iconSelect.size()*0.7;
1385 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1386 QString myVertexName;
1388 while(indexRef != vertexIndex) {
1389 indexRef = vertexIndex;
1390 if (vertexName.empty())
1391 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1393 myVertexName = QString(vertexName.c_str());
1395 for (int row = 0;row<nbVert;row++) {
1396 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1397 if (myVertexName == name) {
1403 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1404 if (geomEntry.empty()) {
1405 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1406 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1407 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1410 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1411 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1413 if (groupName != "")
1414 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1416 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1417 if (geomEntry.empty()) {
1418 toolTip += QString(" (%1, ").arg(x);
1419 toolTip += QString("%1, ").arg(y);
1420 toolTip += QString("%1)").arg(z);
1422 if (groupName != "")
1423 toolTip += QString(" [%1]").arg(groupName.c_str());
1425 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1426 theItem->setExpanded(true);
1427 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1430 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1431 This method is called when a item is added into the enforced vertices tree widget
1433 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1434 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1436 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1438 getGeomSelectionTool()->selectionMgr()->clearFilters();
1439 myEnfFaceWdg->deactivateSelection();
1440 myEnfVertexWdg->deactivateSelection();
1442 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1443 myEnforcedTreeWidget->resizeColumnToContents(column);
1446 int selEnfFace = myEnfFaceWdg->NbObjects();
1447 int selEnfVertex = myEnfVertexWdg->NbObjects();
1448 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1450 if (selEnfFace == 0)
1453 if ((selEnfVertex == 0) && coordsEmpty)
1456 string entry, shapeName;
1458 for (int i = 0 ; i < selEnfFace ; i++) {
1459 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1460 entry = myEnfFace->GetStudyEntry();
1461 shapeName = myEnfFace->GetName();
1463 QTreeWidgetItem * faceItem = addEnforcedFace(entry, shapeName);
1465 std::string groupName = myGroupName->text().toStdString();
1467 if (boost::trim_copy(groupName).empty())
1470 if (selEnfVertex <= 1)
1473 x = myXCoord->GetValue();
1474 y = myYCoord->GetValue();
1475 z = myZCoord->GetValue();
1476 if (selEnfVertex == 1) {
1477 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1478 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1481 addEnforcedVertex(faceItem, x, y, z, "", "", groupName);
1485 if ( CORBA::is_nil(getGeomEngine()))
1488 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1489 if (CORBA::is_nil(measureOp))
1492 CORBA::Double x,y,z;
1494 for (int j = 0 ; j < selEnfVertex ; j++)
1496 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1497 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1498 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1499 if ( measureOp->IsDone() )
1500 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1501 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1502 addEnforcedVertex(faceItem, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1508 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1509 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1511 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1512 myEnforcedTreeWidget->resizeColumnToContents(column);
1514 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1515 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1516 myStdWidget->onPhysicalMeshChanged();
1520 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1521 This method is called when a item is removed from the enforced vertices tree widget
1523 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1524 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1525 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1526 QList<QTreeWidgetItem *> selectedVertices;
1527 QSet<QTreeWidgetItem *> selectedEntries;
1528 QTreeWidgetItem* item;
1530 foreach( item, selectedItems ) {
1531 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1532 if (! value.isNull())
1533 selectedVertices.append(item);
1535 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1536 if (! value.isNull())
1537 selectedVertices.append(item);
1539 selectedEntries.insert(item);
1543 foreach(item,selectedVertices) {
1544 QTreeWidgetItem* parent = item->parent();
1545 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1546 parent->removeChild(item);
1548 if (parent->childCount() == 0) {
1549 if (selectedEntries.contains(parent))
1550 selectedEntries.remove(parent);
1555 foreach(item,selectedEntries) {
1556 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1560 myEnforcedTreeWidget->selectionModel()->clearSelection();
1564 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1566 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1569 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1570 This method is called when a item is added into the periodicity table widget
1572 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1573 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1575 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1577 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1578 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1579 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1581 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1582 w1->deactivateSelection();
1586 // Source-Target selection
1587 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1588 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1590 if (selSource == 0 || selTarget == 0)
1593 // Vertices selection
1594 if (myPeriodicityGroupBox2->isChecked())
1596 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1597 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1598 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1599 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1600 int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1601 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1603 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1605 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1606 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1611 // Add Source-Target in table
1612 string shapeEntry, sourceEntry, targetEntry;
1613 string shapeName, sourceName, targetName;
1614 GEOM::GEOM_Object_var shape;
1616 QTreeWidgetItem* item = new QTreeWidgetItem();
1617 myPeriodicityTreeWidget->addTopLevelItem(item);
1619 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1623 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1625 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1626 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1627 shapeName = shape->GetName();
1628 shapeEntry = shape->GetStudyEntry();
1629 item->setData(k, Qt::EditRole, shapeName.c_str() );
1630 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1631 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1635 // Add shape type in tree
1636 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1637 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1639 // Blank input fields
1640 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1642 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1643 w1->SetObject(GEOM::GEOM_Object::_nil());
1646 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1647 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1651 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1652 This method is called when a item is removed from the periodicity tree widget
1654 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1655 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1656 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1657 QTreeWidgetItem* item;
1659 foreach(item,selectedItems) {
1660 MESSAGE("Remove " << item->text(0).toStdString());
1664 myEnforcedTreeWidget->selectionModel()->clearSelection();
1667 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1668 This method enable clears the field for periodicity by vertices
1670 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1674 for (size_t k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1676 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1677 w1->deactivateSelection();
1678 w1->SetObject(CORBA::Object::_nil());
1683 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1684 This method enable the proper shape selection widget to Face or Edge shapes
1686 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1688 // if (myPeriodicityOnFaceRadioButton->isChecked())
1690 // MESSAGE("Show Face");
1691 // myPeriodicitySourceEdgeWdg->hide();
1692 // myPeriodicityTargetEdgeWdg->hide();
1693 // myPeriodicitySourceFaceWdg->show();
1694 // myPeriodicityTargetFaceWdg->show();
1698 // MESSAGE("Show Edge");
1699 // myPeriodicitySourceFaceWdg->hide();
1700 // myPeriodicityTargetFaceWdg->hide();
1701 // myPeriodicitySourceEdgeWdg->show();
1702 // myPeriodicityTargetEdgeWdg->show();
1706 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1708 QString shapeName, shapeEntry;
1709 CORBA::Object_var shape;
1711 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1712 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1714 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1716 shapeName = item->data(k, Qt::EditRole).toString();
1717 shapeEntry = item->data(k, Qt::UserRole).toString();
1718 if (! shapeEntry.isEmpty())
1720 shape = entryToObject(shapeEntry);
1721 w1->SetObject(shape);
1722 w1->deactivateSelection();
1724 myPeriodicityGroupBox2->setChecked(1);
1727 myPeriodicityGroupBox2->setChecked(0);
1730 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1731 myPeriodicityOnFaceRadioButton->setChecked(true);
1733 myPeriodicityOnEdgeRadioButton->setChecked(true);
1738 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1739 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1741 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1743 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1745 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1747 // find wich selection widget is activated
1748 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1750 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1751 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1753 // don't activate vertex selection if the group box is not checked
1754 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1756 // clear the selection, to avoid to put the same object in the other widget
1757 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1758 // activate the next widget
1759 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1760 w2->activateSelection();
1767 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1768 This method updates the GUI widgets with the hypothesis data
1770 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1772 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1773 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1775 BlsurfHypothesisData data;
1776 that->readParamsFromHypo( data );
1779 myName->setText( data.myName );
1780 QFontMetrics metrics( myName->font() );
1781 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1783 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1784 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1785 if (data.myPhySize <= 0)
1786 myStdWidget->myPhySize->setText("");
1788 myStdWidget->myPhySize->SetValue( data.myPhySize );
1789 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1790 if (data.myMinSize < 0)
1791 myStdWidget->myMinSize->setText("");
1793 myStdWidget->myMinSize->SetValue( data.myMinSize );
1794 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1795 if (data.myMaxSize < 0)
1796 myStdWidget->myMaxSize->setText("");
1798 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1799 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1800 if (data.myGradation <= 0)
1801 myStdWidget->myGradation->setText("");
1803 myStdWidget->myGradation->SetValue( data.myGradation );
1804 myStdWidget->myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1806 if (data.myAngleMesh < 0)
1807 myStdWidget->myAngleMesh->setText("");
1809 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1810 if (data.myChordalError <= 0)
1811 myStdWidget->myChordalError->setText("");
1813 myStdWidget->myChordalError->SetValue( data.myChordalError );
1814 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1815 if (data.myAnisotropicRatio <= 0)
1816 myStdWidget->myAnisotropicRatio->setText("");
1818 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1819 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1820 if (data.myTinyEdgeLength <= 0)
1821 myStdWidget->myTinyEdgeLength->setText("");
1823 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1824 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1825 if (data.myBadElementAspectRatio <= 0)
1826 myStdWidget->myBadElementAspectRatio->setText("");
1828 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1829 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1830 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1832 myStdWidget->resizeWidgets();
1834 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1835 myAdvWidget->myPreCADGroupBox->setChecked(data.myTopology == PreCAD);
1836 myAdvWidget->myPreCADMergeEdges->setChecked( data.myPreCADMergeEdges );
1837 myAdvWidget->myPreCADProcess3DTopology->setChecked( data.myPreCADProcess3DTopology );
1838 myAdvWidget->myPreCADDiscardInput->setChecked( data.myPreCADDiscardInput );
1840 if ( myOptions.operator->() ) {
1841 // MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
1842 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1843 QString option = that->myOptions[i].in();
1844 QStringList name_value_type = option.split( ":", QString::KeepEmptyParts );
1845 bool custom = ( name_value_type.size() == 3 ) ? name_value_type[2].toInt() : false;
1846 if ( name_value_type.count() > 1 ) {
1847 QString idStr = QString("%1").arg( i );
1848 int row = myAdvWidget->myOptionTable->rowCount();
1849 myAdvWidget->myOptionTable->setRowCount( row+1 );
1850 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1851 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1852 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "BLSURF" ) );
1853 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
1854 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value_type[0] ) );
1856 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( Qt::ItemIsSelectable |
1857 Qt::ItemIsEditable |
1858 Qt::ItemIsEnabled );
1859 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setData( Qt::UserRole, QVariant(true) );
1862 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1863 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value_type[1] ) );
1864 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1865 Qt::ItemIsEditable |
1866 Qt::ItemIsEnabled );
1870 if ( myPreCADOptions.operator->() ) {
1871 // MESSAGE("retrieveParams():myPreCADOptions->length() = " << myPreCADOptions->length());
1872 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
1873 QString option = that->myPreCADOptions[i].in();
1874 QStringList name_value_type = option.split( ":", QString::KeepEmptyParts );
1875 bool custom = ( name_value_type.size() == 3 ) ? name_value_type[2].toInt() : false;
1876 if ( name_value_type.count() > 1 ) {
1877 QString idStr = QString("%1").arg( i );
1878 int row = myAdvWidget->myOptionTable->rowCount();
1879 myAdvWidget->myOptionTable->setRowCount( row+1 );
1880 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1881 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1882 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "PRECAD" ) );
1883 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
1884 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value_type[0] ) );
1886 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( Qt::ItemIsSelectable |
1887 Qt::ItemIsEditable |
1888 Qt::ItemIsEnabled );
1889 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setData( Qt::UserRole, QVariant(true) );
1892 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1893 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value_type[1] ) );
1894 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1895 Qt::ItemIsEditable |
1896 Qt::ItemIsEnabled );
1900 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1901 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1902 // myGMFFileMode->setChecked(data.myGMFFileMode);
1905 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1906 QMapIterator<QString, QString> i(that->mySMPMap);
1907 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1908 while (i.hasNext()) {
1910 const QString entry = i.key();
1911 const QString sizeMap = i.value();
1912 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1913 int row = mySizeMapTable->topLevelItemCount();
1914 QTreeWidgetItem* item = new QTreeWidgetItem();
1915 mySizeMapTable->addTopLevelItem( item );
1916 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1917 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1918 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1919 if (that->myATTMap.contains(entry)) {
1920 TAttractorVec & attVec = that->myATTMap[entry];
1921 for ( size_t i = 0; i < attVec.size(); ++i )
1923 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
1924 QTreeWidgetItem* child = new QTreeWidgetItem();
1925 item->addChild( child );
1926 item->setExpanded(true);
1927 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
1928 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
1929 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
1931 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
1932 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
1935 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
1941 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1944 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1945 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1946 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1948 // Enforced vertices
1949 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1950 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1952 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1953 TEntry entry = (*evmIt).first;
1954 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1955 MESSAGE("Face entry: " << entry);
1956 MESSAGE("Face name: " << shapeName);
1958 QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1960 TEnfVertexList evs = (*evmIt).second;
1962 TEnfVertexList::const_iterator evsIt = evs.begin();
1963 TEnfVertex *enfVertex;
1964 for ( ; evsIt != evs.end() ; ++evsIt) {
1965 enfVertex = (*evsIt);
1966 MESSAGE("Name: " << enfVertex->name);
1968 if (enfVertex->coords.size()) {
1969 x = enfVertex->coords[0];
1970 y = enfVertex->coords[1];
1971 z = enfVertex->coords[2];
1973 that->addEnforcedVertex(faceItem, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1977 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1978 myEnforcedTreeWidget->resizeColumnToContents(column);
1980 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1981 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1982 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1985 MESSAGE("retrieveParams(): periodicity ");
1988 // Add an item in the tree widget for each association
1989 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
1991 QTreeWidgetItem* item = new QTreeWidgetItem();
1992 myPeriodicityTreeWidget->addTopLevelItem(item);
1993 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1994 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
1995 for (size_t k=0; k<periodicity_i.size(); k++)
1997 string shapeEntry = periodicity_i[k];
1998 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
1999 item->setData(k, Qt::EditRole, shapeName.c_str() );
2000 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
2005 that->myStdWidget->onPhysicalMeshChanged();
2006 that->myStdWidget->onGeometricMeshChanged();
2007 that->onStateChange();
2010 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
2011 This method updates the hypothesis data with the GUI widgets content.
2013 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
2015 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParams");
2016 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2018 BlsurfHypothesisData data;
2019 QString guiHyp = that->readParamsFromWidgets( data );
2020 that->storeParamsToHypo( data );
2025 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
2026 Updates the hypothesis data from hypothesis values.
2028 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
2030 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
2031 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2032 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2034 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
2035 h_data.myName = isCreation() && data ? hypName() : "";
2037 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
2038 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
2039 h_data.myPhySize = h->GetPhySize();
2040 h_data.myPhySizeRel = h->IsPhySizeRel();
2041 double minSize = h->GetMinSize();
2042 double maxSize = h->GetMaxSize();
2043 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2044 h_data.myMinSizeRel = h->IsMinSizeRel();
2045 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2046 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2047 h_data.myGradation = h->GetGradation();
2048 h_data.myAllowQuadrangles = h->GetQuadAllowed();
2049 double angle = h->GetAngleMesh();
2050 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2051 double chordalError = h->GetChordalError();
2052 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2053 h_data.myAnisotropic = h->GetAnisotropic();
2054 double myAnisotropicRatio = h->GetAnisotropicRatio();
2055 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2056 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2057 double myTinyEdgeLength = h->GetTinyEdgeLength();
2058 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2059 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2060 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2061 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2062 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2063 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2064 h_data.myVerbosity = h->GetVerbosity();
2065 h_data.myTopology = (int) h->GetTopology();
2066 h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2067 h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2068 h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2071 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2072 that->myOptions = h->GetOptionValues();
2073 that->myPreCADOptions = h->GetPreCADOptionValues();
2075 h_data.myGMFFileName = h->GetGMFFile();
2076 // h_data.myGMFFileMode = h->GetGMFFileMode();
2078 that->mySMPMap.clear();
2079 that->myATTMap.clear();
2080 // that->myAttDistMap.clear();
2081 // that->myDistMap.clear();
2083 // classic size maps
2084 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2085 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
2086 QString fullSizeMaps;
2087 QStringList fullSizeMapList;
2088 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2089 for ( int i = 0;i<mySizeMaps->length(); ++i ) {
2090 fullSizeMaps = mySizeMaps[i].in();
2091 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
2092 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2093 if ( fullSizeMapList.count() > 1 ) {
2094 string fullSizeMap = fullSizeMapList[1].toStdString();
2095 int pos = fullSizeMap.find("return")+7;
2096 // MESSAGE("pos:" << pos);
2099 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2104 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2105 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
2106 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2107 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
2113 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2114 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
2116 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2117 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2118 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2119 if ( fullCustomSizeMapList.count() > 1 ) {
2120 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2121 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2122 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
2123 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
2128 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2129 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
2131 for ( int i = 0;i<allMyAttractors->length(); ++i ) {
2132 QString myAttractors = allMyAttractors[i].in();
2133 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2134 if ( myAttractorList.count() > 1 ) {
2135 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2136 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2137 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
2138 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
2142 // attractor new version
2143 MESSAGE("readParamsFromHypo, Attractors")
2144 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2145 for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
2146 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2147 QString faceEntry = myAttractorParams.faceEntry.in();
2148 QString attEntry = myAttractorParams.attEntry.in();
2149 MESSAGE("attEntry = "<<attEntry.toStdString())
2150 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2151 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2152 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2153 myAttractorParams.startSize,
2154 myAttractorParams.infDist,
2155 myAttractorParams.constDist ));
2158 // Enforced vertices
2159 h_data.enfVertexList.clear();
2160 h_data.faceEntryEnfVertexListMap.clear();
2162 h_data.groupNameEnfVertexListMap.clear();
2165 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2166 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
2168 for ( int i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
2169 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2170 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
2171 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2172 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
2174 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
2176 for (int j=0 ; j<vertexList.length(); ++j) {
2177 TEnfVertex *enfVertex = new TEnfVertex();
2179 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
2180 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
2181 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
2182 for (int k=0 ; k< vertexList[j].coords.length();k++)
2183 enfVertex->coords.push_back(vertexList[j].coords[k]);
2185 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2188 if (groupName != "") {
2189 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2193 // h_data.enfVertMap[entry] = evs;
2194 // h_data.entryCoordsListMap[entry] = coordsList;
2196 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2197 h_data.faceEntryEnfVertexListMap.erase(entry);
2200 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2201 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2204 MESSAGE("readParamsFromHypo, Periodicity")
2206 h_data.preCadPeriodicityVector.clear();
2208 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2209 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2211 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2212 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2216 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2217 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2220 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2222 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2223 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2224 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2226 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2227 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2229 if (sourceVertices.length()!=0)
2231 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2232 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2233 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2236 if (targetVertices.length()!=0)
2238 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2239 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2240 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2244 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2246 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2248 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2252 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2253 Saves the hypothesis data to hypothesis values.
2255 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2257 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
2258 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2259 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2265 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2267 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2268 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2269 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2270 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2272 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2273 if ( h->GetPhySize() != h_data.myPhySize ||
2274 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2275 if ( h_data.myPhySizeRel )
2276 h->SetPhySizeRel( h_data.myPhySize );
2278 h->SetPhySize( h_data.myPhySize );
2281 if (h->GetMinSize() != h_data.myMinSize ||
2282 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2283 if ( h_data.myMinSizeRel )
2284 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2286 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2288 if (h->GetMaxSize() != h_data.myMaxSize ||
2289 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2290 if ( h_data.myMaxSizeRel )
2291 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2293 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2295 if ( h->GetGradation() != h_data.myGradation )
2296 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2297 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
2298 h->SetQuadAllowed( h_data.myAllowQuadrangles );
2300 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2301 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2302 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2303 if ( h->GetChordalError() != h_data.myChordalError )
2304 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2307 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2308 h->SetAnisotropic( h_data.myAnisotropic );
2309 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2310 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2312 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2313 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2314 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2315 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2317 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2318 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2319 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2320 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2322 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2323 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2325 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2326 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2328 if ( h->GetVerbosity() != h_data.myVerbosity )
2329 h->SetVerbosity( h_data.myVerbosity );
2330 if ( h->GetTopology() != h_data.myTopology )
2331 h->SetTopology( (int) h_data.myTopology );
2332 if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2333 h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2334 if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2335 h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2336 if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2337 h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2339 h->SetOptionValues( myOptions ); // is set in checkParams()
2340 h->SetPreCADOptionValues( myPreCADOptions ); // is set in checkParams()
2342 if ( h->GetGMFFile() != h_data.myGMFFileName )
2343 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2344 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2345 h->SetGMFFile( h_data.myGMFFileName.c_str());
2347 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2348 QMapIterator<QString,QString> i(that->mySMPMap);
2349 while (i.hasNext()) {
2351 const QString entry = i.key();
2352 const QString sizeMap = i.value();
2354 if (sizeMap == "__TO_DELETE__") {
2355 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
2356 h->UnsetEntry(entry.toLatin1().constData());
2358 else if (sizeMap.startsWith("ATTRACTOR")) {
2359 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2360 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2362 else if (sizeMap.startsWith("def")) {
2363 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
2364 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2367 if (!myATTMap[entry].empty()){
2368 const TAttractorVec& attVec = myATTMap[entry];
2369 for ( size_t i = 0; i < attVec.size(); ++i )
2371 if ( attVec[i].IsToDelete() )
2372 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2373 attVec[i].attEntry.c_str() );
2375 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2376 attVec[i].attEntry.c_str(),
2377 attVec[i].startSize,
2380 attVec[i].constDist );
2384 QString fullSizeMap;
2385 fullSizeMap = QString("");
2386 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2387 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2388 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2389 fullSizeMap = QString("def f(t): return ") + sizeMap;
2390 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2391 fullSizeMap = QString("def f(): return ") + sizeMap;
2392 MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
2393 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2398 // Enforced vertices
2401 std::string enfName;
2403 std::string groupName = "";
2406 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2407 // 1. Clear all enforced vertices in hypothesis
2408 // 2. Add new enforced vertex according to h_data
2410 if ( h->GetAllEnforcedVertices()->length() > 0 )
2411 h->ClearAllEnforcedVertices();
2414 TEnfVertexList::const_iterator evsIt;
2415 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2417 faceEntry = evmIt->first;
2418 evs = evmIt->second;
2419 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
2420 evsIt = evs.begin();
2421 for ( ; evsIt != evs.end() ; ++evsIt)
2424 if ((*evsIt)->coords.size()) {
2425 x = (*evsIt)->coords[0];
2426 y = (*evsIt)->coords[1];
2427 z = (*evsIt)->coords[2];
2429 ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2433 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2434 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2435 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2436 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2439 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2440 h->ClearPreCadPeriodicityVectors();
2442 MESSAGE("h_data.preCadPeriodicityVector.size(): " << h_data.preCadPeriodicityVector.size());
2443 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2444 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2446 TPreCadPeriodicity periodicity_i = *pIt;
2447 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2448 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2449 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2450 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2451 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2452 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2453 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2454 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2455 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2457 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2458 if (! p1Source.empty())
2460 sourceVertices->length(3);
2461 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2462 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2463 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2467 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2468 if (! p1Target.empty())
2470 targetVertices->length(3);
2471 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2472 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2473 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2477 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2479 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2482 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end periodicity");
2486 catch(const std::exception& ex) {
2487 std::cout << "Exception: " << ex.what() << std::endl;
2490 // catch(const SALOME::SALOME_Exception& ex)
2493 // // SalomeApp_Tools::QtCatchCorbaException(ex);
2496 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo end");
2500 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2501 Stores the widgets content to the hypothesis data.
2503 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2505 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
2506 h_data.myName = myName ? myName->text() : "";
2507 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2508 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2509 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2510 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2511 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2512 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2513 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2514 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2515 h_data.myGradation = myStdWidget->myGradation->text().isEmpty() ? -1.0 : myStdWidget->myGradation->GetValue();
2516 h_data.myAllowQuadrangles = myStdWidget->myAllowQuadrangles->isChecked();
2517 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2518 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2519 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2520 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2521 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2522 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2523 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2524 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2525 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2526 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2527 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2528 h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2529 h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2530 h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2531 h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2534 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2535 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2536 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2537 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2538 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2539 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2540 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2541 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2542 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2543 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2544 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2545 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2546 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2547 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2550 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2551 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2552 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2553 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2554 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2555 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2558 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2559 guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2560 guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2561 guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2563 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2564 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
2565 for ( ; row < nbRows; ++row )
2567 int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2568 std::string optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
2569 bool custom = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->data(Qt::UserRole).toBool();
2570 if ( optionType == "BLSURF" && custom ) {
2571 id = that->myOptions->length();
2572 that->myOptions->length( that->myOptions->length() + 1 );
2574 if ( optionType == "PRECAD" && custom ) {
2575 id = that->myPreCADOptions->length();
2576 that->myPreCADOptions->length( that->myPreCADOptions->length() + 1 );
2578 if ( custom || ( id >= 0 && ( ( optionType == "BLSURF" && id < myOptions->length() ) || ( optionType == "PRECAD" && id < myPreCADOptions->length() ) ) ) )
2580 QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
2581 QString value = myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
2582 if ( value.isNull() )
2584 if (optionType == "PRECAD")
2585 that->myPreCADOptions[ id ] = ( name + ":" + value + ":" + ( custom ? "1" : "0" ) ).toLatin1().constData();
2587 that->myOptions[ id ] = ( name + ":" + value + ":" + ( custom ? "1" : "0" ) ).toLatin1().constData();
2589 if ( value != "" ) {
2590 if (optionType == "PRECAD")
2591 guiHyp += "PRECAD_";
2592 guiHyp += name + " = " + value + "; ";
2597 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2598 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2601 row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2602 for ( ; row < nbRows; ++row )
2604 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2605 if ( that->mySMPMap.contains(entry) )
2606 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2609 // Enforced vertices
2610 h_data.enfVertexList.clear();
2611 h_data.faceEntryEnfVertexListMap.clear();
2613 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2614 int nbEnforcedVertices = 0;
2615 std::string groupName = "";
2616 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
2617 for (int i=0 ; i<nbEnforcedShapes ; i++) {
2618 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
2620 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2621 nbEnforcedVertices = shapeItem->childCount();
2622 if (nbEnforcedVertices >0) {
2623 double childValueX,childValueY,childValueZ;
2624 std::string childName, vertexEntry;
2625 QTreeWidgetItem* child;
2628 for (row = 0;row<nbEnforcedVertices;row++) {
2629 child = shapeItem->child(row);
2630 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2631 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2632 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2633 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2634 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2635 // if (myGlobalGroupName->isChecked())
2636 // groupName = myGlobalGroupName->text().toStdString();
2638 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2640 TEnfVertex *enfVertex = new TEnfVertex();
2641 enfVertex->name = childName;
2642 if (vertexEntry.empty()) {
2643 enfVertex->coords.push_back(childValueX);
2644 enfVertex->coords.push_back(childValueY);
2645 enfVertex->coords.push_back(childValueZ);
2648 enfVertex->geomEntry = vertexEntry;
2649 enfVertex->grpName = groupName;
2650 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2651 // if (it == h_data.enfVertexList.end())
2652 h_data.enfVertexList.insert(enfVertex);
2653 evs.insert(enfVertex);
2655 if (groupName != "")
2656 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2659 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2664 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2665 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2668 h_data.preCadPeriodicityVector.clear();
2669 // For each tree item, store each value. Shapes are stored as entries.
2670 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2671 for (size_t i=0 ; i<nbPeriodicityDescriptions ; i++) {
2672 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2673 TPreCadPeriodicity periodicity_i;
2675 for (size_t k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2678 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2680 periodicity_i.push_back(entry);
2682 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2684 guiHyp += "PERIODICITY = yes; ";
2687 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2691 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2693 QMenu* menu = (QMenu*)sender();
2694 // fill popup with option names
2696 QStringList name_value_type;
2697 if ( myOptions.operator->() ) {
2698 QMenu* blsurfMenu = menu->addMenu(tr("OPTION_MENU_BLSURF"));
2699 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
2700 name_value_type = QString( myOptions[i].in() ).split( ":", QString::KeepEmptyParts );
2701 bool custom = ( name_value_type.size() == 3 ) ? name_value_type[2].toInt() : false;
2702 if ( !custom && !name_value_type[0].isEmpty() )
2703 blsurfMenu->addAction( name_value_type[0] );
2705 // this user-customized action must be last in the menu
2706 blsurfMenu->addAction( QString( "<" + tr("BLSURF_OTHER_OPTION") + ">" ) );
2708 if ( myPreCADOptions.operator->() ) {
2709 QMenu* preCADmenu = menu->addMenu(tr("OPTION_MENU_PRECAD"));
2710 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
2711 name_value_type = QString( myPreCADOptions[i].in() ).split( ":", QString::KeepEmptyParts );
2712 bool custom = ( name_value_type.size() == 3 ) ? name_value_type[2].toInt() : false;
2713 if ( !custom && !name_value_type[0].isEmpty() )
2714 preCADmenu->addAction( name_value_type[0] );
2716 // this user-customized action must be last in the menu
2717 preCADmenu->addAction( QString( "<" + tr("BLSURF_OTHER_OPTION") + ">" ) );
2721 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
2723 myAdvWidget->myOptionTable->setFocus();
2724 QMenu* menu = (QMenu*)( a->parent() );
2726 int idx = menu->actions().indexOf( a );
2727 bool custom = menu->actions().last() == a;
2729 QString idStr = QString("%1").arg( idx );
2730 QString option, optionType;
2731 if (menu->title() == tr("OPTION_MENU_BLSURF")) {
2732 if (idx < myOptions->length())
2733 option = myOptions[idx].in();
2734 optionType = "BLSURF";
2736 else if (menu->title() == tr("OPTION_MENU_PRECAD")) {
2737 if (idx < myPreCADOptions->length())
2738 option = myPreCADOptions[idx].in();
2739 optionType = "PRECAD";
2741 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
2743 // look for a row with optionName
2744 int row = 0, nbRows = myAdvWidget->myOptionTable->rowCount();
2745 for ( ; row < nbRows; ++row )
2746 if ( myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
2747 if ( myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text() == optionType )
2751 // add a row if not found
2752 if ( row == nbRows ) {
2753 myAdvWidget->myOptionTable->setRowCount( row+1 );
2754 myAdvWidget->myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
2755 myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
2756 myAdvWidget->myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( optionType ) );
2757 myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
2759 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( "" ) );
2760 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( Qt::ItemIsSelectable |
2761 Qt::ItemIsEditable |
2762 Qt::ItemIsEnabled );
2763 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setData( Qt::UserRole, QVariant(true) );
2766 myAdvWidget->myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
2767 myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
2769 myAdvWidget->myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
2770 myAdvWidget->myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
2771 Qt::ItemIsEditable |
2772 Qt::ItemIsEnabled );
2773 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2775 myAdvWidget->myOptionTable->clearSelection();
2776 int activeColumn = custom ? OPTION_NAME_COLUMN : OPTION_VALUE_COLUMN;
2777 myAdvWidget->myOptionTable->scrollToItem( myAdvWidget->myOptionTable->item( row, activeColumn ) );
2778 //myAdvWidget->myOptionTable->item( row, activeColumn )->setSelected( true );
2779 myAdvWidget->myOptionTable->setCurrentCell( row, activeColumn );
2780 //myAdvWidget->myOptionTable->openPersistentEditor( myOptionTable->item( row, activeColumn ) );
2783 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
2785 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2786 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2787 // clear option values and remember selected row
2788 QList<int> selectedRows;
2789 QList<QTableWidgetItem*> selected = myAdvWidget->myOptionTable->selectedItems();
2790 QTableWidgetItem* item;
2791 foreach( item, selected ) {
2792 int row = item->row();
2793 if ( !selectedRows.contains( row ) ) {
2794 selectedRows.append( row );
2795 int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2796 QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text();
2797 bool custom = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->data(Qt::UserRole).toBool();
2798 QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
2800 if ( optionType == "BLSURF" && id < myOptions->length() )
2802 h->UnsetOption( name.toLatin1().constData() );
2806 myOptions[id] = name.toLatin1().constData();
2807 else if ( optionType == "PRECAD" && id < myPreCADOptions->length() )
2809 h->UnsetPreCADOption( name.toLatin1().constData() );
2810 myPreCADOptions[id] = "";
2813 myPreCADOptions[id] = name.toLatin1().constData();
2816 qSort( selectedRows );
2817 QListIterator<int> it( selectedRows );
2819 while ( it.hasPrevious() )
2820 myAdvWidget->myOptionTable->removeRow( it.previous() );
2823 void BLSURFPluginGUI_HypothesisCreator::onEditOption( int row, int column )
2825 if ( column != OPTION_NAME_COLUMN )
2827 bool custom = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->data(Qt::UserRole).toBool();
2831 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2832 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2834 int id = myAdvWidget->myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2835 QString optionType = myAdvWidget->myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed();
2836 QString name = myAdvWidget->myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
2837 if ( optionType == "PRECAD" && id < myPreCADOptions->length() ) {
2838 h->UnsetPreCADOption(name.toLatin1().constData());
2839 myPreCADOptions[id] = "";
2841 else if ( optionType == "BLSURF" && id < myOptions->length() ) {
2842 h->UnsetOption(name.toLatin1().constData());
2847 void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int row, int column )
2849 if ( column != OPTION_NAME_COLUMN )
2851 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2853 // **********************
2854 // *** BEGIN SIZE MAP ***
2855 // **********************
2857 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2859 if ( myGeomSelWdg2->IsObjectSelected() ){
2860 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2862 else if ( myGeomSelWdg1->IsObjectSelected() ){
2863 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2866 mySMapObject = GEOM::GEOM_Object::_nil();
2868 bool dataAvailable = !mySMapObject->_is_nil();
2870 if ( dataAvailable )
2871 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2873 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2874 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2875 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2876 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2877 ( myATTMap.contains( qEntry )))
2880 QString attEntry = myAttSelWdg->GetValue();
2881 const TAttractorVec& attVec = myATTMap[ qEntry ];
2882 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2883 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2886 addMapButton->setEnabled( !mapExists && dataAvailable );
2887 modifyMapButton->setEnabled( mapExists && dataAvailable );
2890 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2892 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2893 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2894 if (col == SMP_SIZEMAP_COLUMN) {
2895 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2897 if (!mySMPMap.contains(entry))
2899 if ( QTreeWidgetItem* parent = item->parent() )
2903 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2905 if (!mySMPMap.contains(entry))
2908 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2909 CORBA::Object_var obj = entryToObject(entry);
2910 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2911 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2912 // Retrieve values of the selected item in the current tab widgets
2913 const TAttractorVec& attVec = myATTMap[entry];
2914 if ( !attVec.empty() )
2917 if ( !childEntry.isEmpty() )
2918 for ( size_t i = 0; i < attVec.size(); ++i )
2919 if ( childEntry == attVec[i].attEntry.c_str() )
2924 double phySize = attVec[iAtt].startSize;
2925 double infDist = attVec[iAtt].infDist;
2926 double constDist = attVec[iAtt].constDist;
2927 QString attEntry = attVec[iAtt].attEntry.c_str();
2928 CORBA::Object_var attObj = entryToObject(attEntry);
2929 myAttSizeSpin->setValue(phySize);
2930 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2931 myAttDistSpin->setValue(infDist);
2932 myAttractorCheck->setChecked(true);
2935 myAttractorCheck->setChecked(false);
2937 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2938 myAttDistSpin2->setValue(constDist);
2939 myConstSizeCheck->setChecked(true);
2942 myConstSizeCheck->setChecked(false);
2944 myGeomSelWdg2->SetObject(obj);
2945 myAttSelWdg->SetObject(attObj);
2948 else { // CLASSIC MAPS
2949 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2950 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2951 if (!sizeMap.startsWith("def")){
2952 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2958 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2960 getGeomSelectionTool()->selectionMgr()->clearFilters();
2961 if ( sender() == myTabWidget )
2963 myGeomSelWdg1 ->deactivateSelection();
2964 myGeomSelWdg2 ->deactivateSelection();
2965 myAttSelWdg ->deactivateSelection();
2966 myEnfFaceWdg ->deactivateSelection();
2967 myEnfVertexWdg ->deactivateSelection();
2968 myPeriodicitySourceFaceWdg->deactivateSelection();
2969 myPeriodicityTargetFaceWdg->deactivateSelection();
2970 myPeriodicityP1SourceWdg ->deactivateSelection();
2971 myPeriodicityP2SourceWdg ->deactivateSelection();
2972 myPeriodicityP3SourceWdg ->deactivateSelection();
2973 myPeriodicityP1TargetWdg ->deactivateSelection();
2974 myPeriodicityP2TargetWdg ->deactivateSelection();
2975 myPeriodicityP3TargetWdg ->deactivateSelection();
2978 else if ( sender() == smpTab )
2980 myAttDistSpin->setValue(0.); // Reinitialize widgets
2981 myAttSizeSpin->setValue(0.);
2982 myAttDistSpin2->setValue(0.);
2983 mySmpSizeSpin->setValue(0.);
2984 myGeomSelWdg1->deactivateSelection();
2985 myGeomSelWdg2->deactivateSelection();
2986 myAttSelWdg->deactivateSelection();
2987 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2988 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2989 myAttSelWdg->SetObject(CORBA::Object::_nil());
2990 myAttractorCheck->setChecked(false);
2991 myConstSizeCheck->setChecked(false);
2995 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2997 if (state == Qt::Checked){
2998 myAttSelWdg->setEnabled(true);
2999 myAttSizeSpin->setEnabled(true);
3000 myAttSizeLabel->setEnabled(true);
3001 myAttDistSpin->setEnabled(true);
3002 myAttDistLabel->setEnabled(true);
3003 if (!myAttSelWdg->IsObjectSelected()){
3004 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
3007 if (state == Qt::Unchecked){
3008 myAttDistSpin->setEnabled(false);
3009 myAttDistLabel->setEnabled(false);
3010 myAttDistSpin->setValue(0.);
3011 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
3012 myAttSelWdg->setEnabled(false);
3013 myAttSizeSpin->setEnabled(false);
3014 myAttSizeLabel->setEnabled(false);
3015 myAttDistSpin2->setEnabled(false);
3016 myAttDistLabel2->setEnabled(false);
3018 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
3019 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
3022 onMapGeomContentModified();
3025 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
3027 if (state == Qt::Checked){
3028 myAttSelWdg->setEnabled(true);
3029 myAttSizeSpin->setEnabled(true);
3030 myAttSizeLabel->setEnabled(true);
3031 myAttDistSpin2->setEnabled(true);
3032 myAttDistLabel2->setEnabled(true);
3033 if (myAttractorCheck->checkState() == Qt::Unchecked &&
3034 !myAttSelWdg->IsObjectSelected()){
3035 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
3038 if (state == Qt::Unchecked){
3039 myAttDistSpin2->setEnabled(false);
3040 myAttDistLabel2->setEnabled(false);
3041 myAttDistSpin2->setValue(0.);
3042 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
3043 myAttSelWdg->setEnabled(false);
3044 myAttSizeSpin->setEnabled(false);
3045 myAttSizeLabel->setEnabled(false);
3046 myAttDistSpin->setEnabled(false);
3047 myAttDistLabel->setEnabled(false);
3049 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
3050 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
3053 onMapGeomContentModified();
3056 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
3058 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
3059 QList<int> selectedRows;
3060 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
3061 QTreeWidgetItem* item;
3062 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3064 qSort( selectedRows );
3065 QListIterator<QTreeWidgetItem*> it( selected );
3067 while ( it.hasPrevious() ) {
3068 item = it.previous();
3069 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
3070 QString parentEntry;
3071 if ( QTreeWidgetItem* parent = item->parent() )
3072 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
3073 if (that->mySMPMap.contains(entry))
3075 that->mySMPMap[entry] = "__TO_DELETE__";
3076 if ( myATTMap.contains( entry ))
3078 TAttractorVec& attVec = myATTMap[entry];
3079 for ( size_t i = 0; i < attVec.size(); ++i )
3080 attVec[i].SetToDelete();
3083 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
3085 TAttractorVec& attVec = myATTMap[parentEntry];
3086 for ( size_t i = 0; i < attVec.size(); ++i )
3088 if ( entry == attVec[i].attEntry.c_str() )
3089 attVec[i].SetToDelete();
3092 if (that->mySMPShapeTypeMap.contains(entry))
3093 that->mySMPShapeTypeMap.remove(entry);
3094 // if (that->myDistMap.contains(entry))
3095 // that->myDistMap.remove(entry);
3096 // if (that->myAttDistMap.contains(entry))
3097 // that->myAttDistMap.remove(entry);
3100 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
3101 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
3104 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
3106 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
3107 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
3108 if (col == SMP_SIZEMAP_COLUMN) {
3109 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3110 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
3111 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
3112 MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
3113 if (! that->mySMPShapeTypeMap.contains(entry))
3114 MESSAGE("no such entry in mySMPShapeTypeMap")
3116 if (that->mySMPMap.contains(entry))
3117 if (that->mySMPMap[entry] == sizeMap
3118 || sizeMap.startsWith("Attractor")
3119 || sizeMap.startsWith("Constant") ){
3122 if (! sizeMap.isEmpty()) {
3123 that->mySMPMap[entry] = sizeMap;
3124 sizeMapValidationFromEntry(entry);
3127 MESSAGE("Size map empty: reverse to precedent value" );
3128 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
3130 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
3134 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
3137 if ( smpTab->currentIndex() == ATT_TAB ){
3138 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3139 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3140 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3141 res = insertAttractor(mySMapObject, myAttObject);
3144 if (smpTab->currentIndex() == SMP_STD_TAB ){
3145 if ( myGeomSelWdg1->IsObjectSelected() ){
3146 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3147 res = insertElement(mySMapObject);
3151 // Local size should be more than 0
3152 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3153 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3156 getGeomSelectionTool()->selectionMgr()->clearFilters();
3157 myAttDistSpin->setValue(0.);
3158 myAttSizeSpin->setValue(0.);
3159 myAttDistSpin2->setValue(0.);
3160 mySmpSizeSpin->setValue(0.);
3161 myConstSizeCheck->setChecked(false);
3162 myAttractorCheck->setChecked(false);
3163 myGeomSelWdg1->deactivateSelection();
3164 myGeomSelWdg2->deactivateSelection();
3165 myAttSelWdg->deactivateSelection();
3166 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3167 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3168 myAttSelWdg->SetObject(CORBA::Object::_nil());
3171 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
3173 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
3175 if ( smpTab->currentIndex() == ATT_TAB ){
3176 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3177 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3178 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3179 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
3182 if (smpTab->currentIndex() == SMP_STD_TAB ){
3183 if ( myGeomSelWdg1->IsObjectSelected() ){
3184 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3185 res = insertElement(mySMapObject, /*modify = */true);
3189 // Local size should be more than 0
3190 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3191 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3194 getGeomSelectionTool()->selectionMgr()->clearFilters();
3195 myAttDistSpin->setValue(0.);
3196 myAttSizeSpin->setValue(0.);
3197 myAttDistSpin2->setValue(0.);
3198 mySmpSizeSpin->setValue(0.);
3199 myConstSizeCheck->setChecked(false);
3200 myAttractorCheck->setChecked(false);
3201 myGeomSelWdg1->deactivateSelection();
3202 myGeomSelWdg2->deactivateSelection();
3203 myAttSelWdg->deactivateSelection();
3204 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3205 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3206 myAttSelWdg->SetObject(CORBA::Object::_nil());
3209 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3211 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
3212 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3213 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3215 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3217 TopAbs_ShapeEnum shapeType;
3218 string entry, shapeName;
3219 entry = (string) anObject->GetStudyEntry();
3220 MESSAGE("entry = "<<entry);
3221 shapeName = anObject->GetName();
3222 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3223 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3224 // in order to write the size map with the right syntax in StoreParamsToHypo
3225 // (f(t) for edges, f(u,v) for faces ...)
3226 if (shapeType == TopAbs_COMPOUND){
3227 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3228 TopoDS_Shape childShape;
3229 TopoDS_Iterator anIt(theShape);
3230 for(;anIt.More();anIt.Next()){
3231 childShape = anIt.Value();
3232 shapeType = childShape.ShapeType();
3233 if(!childShape.IsNull()){
3238 mySizeMapTable->setFocus();
3240 shapeEntry = QString::fromStdString(entry);
3241 double phySize = mySmpSizeSpin->value();
3244 return false; // Local size should be more than 0
3246 std::ostringstream oss;
3249 sizeMap = QString::fromStdString(oss.str());
3250 QTreeWidgetItem* item = new QTreeWidgetItem();
3252 int rowToChange = findRowFromEntry(shapeEntry);
3253 item = mySizeMapTable->topLevelItem( rowToChange );
3256 if (that->mySMPMap.contains(shapeEntry)) {
3257 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3258 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3262 mySizeMapTable->addTopLevelItem(item);
3264 that->mySMPMap[shapeEntry] = sizeMap;
3265 //that->myDistMap[shapeEntry] = 0. ;
3266 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3267 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3268 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3269 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3270 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3271 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3272 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3273 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3274 mySizeMapTable->clearSelection();
3276 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3277 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3278 myStdWidget->onPhysicalMeshChanged();
3283 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3285 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
3286 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3287 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3289 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3291 TopAbs_ShapeEnum shapeType;
3292 string entry, attEntry, faceName, attName;
3293 entry = (string) aFace->GetStudyEntry();
3294 attEntry = (string) anAttractor->GetStudyEntry();
3295 faceName = aFace->GetName();
3296 attName = anAttractor->GetName();
3297 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3298 mySizeMapTable->setFocus();
3299 QString shapeEntry = QString::fromStdString(entry);
3300 QString qAttEntry = QString::fromStdString(attEntry);
3302 double phySize = h->GetPhySize();
3303 double infDist = 0. ;
3304 double constDist = 0. ;
3305 phySize = myAttSizeSpin->value();
3308 return false; // Local size should be more than 0
3310 if (myAttractorCheck->isChecked()){
3311 infDist = myAttDistSpin->value();
3313 if (myConstSizeCheck->isChecked()){
3314 constDist = myAttDistSpin2->value();
3316 std::ostringstream oss;
3317 std::ostringstream oss2;
3318 std::ostringstream oss3;
3322 QString sizeMap = QString::fromStdString(oss.str());
3323 QString infDistString = QString::fromStdString(oss2.str());
3324 QString constDistString = QString::fromStdString(oss3.str());
3326 QTreeWidgetItem* item;
3327 QTreeWidgetItem* child;
3328 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3330 int rowToChange = findRowFromEntry(shapeEntry);
3331 item = mySizeMapTable->topLevelItem( rowToChange );
3333 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3334 if (( child = item->child( i )))
3335 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3337 TAttractorVec & attVec = myATTMap[shapeEntry];
3338 for ( size_t i = 0; i < attVec.size(); ++i )
3339 if ( attVec[i].attEntry == attEntry )
3341 attVec[i] = attParams;
3346 // if (that->mySMPMap.contains(shapeEntry)) {
3347 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3348 // // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
3352 int rowToChange = findRowFromEntry(shapeEntry);
3353 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3355 item = mySizeMapTable->topLevelItem( rowToChange );
3358 item = new QTreeWidgetItem();
3359 mySizeMapTable->addTopLevelItem(item);
3361 child = new QTreeWidgetItem();
3362 item->addChild(child);
3363 bool exists = false;
3364 TAttractorVec & attVec = myATTMap[shapeEntry];
3365 for ( size_t i = 0; i < attVec.size(); ++i )
3366 if ( attVec[i].attEntry == attEntry )
3368 attVec[i] = attParams;
3373 myATTMap[shapeEntry].push_back( attParams );
3375 mySMPMap.insert(shapeEntry,sizeMap);
3376 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3377 item->setExpanded(true);
3378 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3379 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3380 if (infDist > std::numeric_limits<double>::epsilon()){
3381 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3383 else if (constDist > std::numeric_limits<double>::epsilon()){
3384 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3386 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3388 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3389 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3390 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3392 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3393 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3394 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3396 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3397 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3398 myStdWidget->onPhysicalMeshChanged();
3400 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
3404 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3406 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
3407 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3408 for ( ; row < nbRows; ++row )
3409 if (! sizeMapValidationFromRow(row))
3414 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3416 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
3417 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3418 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3419 mySizeMapTable->setFocus();
3423 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3425 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
3426 MESSAGE("myEntry = "<<myEntry.toStdString())
3428 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3430 if (! that->mySMPMap.contains(myEntry)) {
3431 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
3434 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3435 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
3441 if (that->mySMPMap[myEntry].startsWith("def")) {
3442 // MESSAGE("custom function" );
3443 expr = that->mySMPMap[myEntry].toStdString();
3445 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3446 // MESSAGE("Attractor" );
3447 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)) {
3450 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])" );
3456 // case size map is empty
3457 if (that->mySMPMap[myEntry].isEmpty()) {
3459 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3463 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3464 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3465 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3466 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3467 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3468 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3471 //assert(Py_IsInitialized());
3472 if (! Py_IsInitialized())
3473 throw ("Erreur: Python interpreter is not initialized");
3474 PyGILState_STATE gstate;
3475 gstate = PyGILState_Ensure();
3477 string err_description="";
3478 PyObject* obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3482 PyObject* new_stderr = newPyStdOut(err_description);
3483 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3484 Py_INCREF(old_stderr);
3485 PySys_SetObject((char*)"stderr", new_stderr);
3487 PySys_SetObject((char*)"stderr", old_stderr);
3488 Py_DECREF(new_stderr);
3490 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3491 PyGILState_Release(gstate);
3496 PyObject* func = PyObject_GetAttrString(main_mod, "f");
3500 PyObject* new_stderr = newPyStdOut(err_description);
3501 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3502 Py_INCREF(old_stderr);
3503 PySys_SetObject((char*)"stderr", new_stderr);
3505 PySys_SetObject((char*)"stderr", old_stderr);
3506 Py_DECREF(new_stderr);
3508 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3509 PyGILState_Release(gstate);
3513 PyGILState_Release(gstate);
3515 // MESSAGE("SizeMap expression "<<expr<<" is valid");
3520 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3522 return tr( "BLSURF_TITLE" );
3525 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3527 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3530 QString BLSURFPluginGUI_HypothesisCreator::type() const
3532 return tr( "BLSURF_HYPOTHESIS" );
3535 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3537 return "blsurf_hypo_page.html";
3540 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3543 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3545 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3550 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3552 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
3553 SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
3554 CORBA::Object_var obj;
3555 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
3556 if (!aSObj->_is_nil()) {
3557 obj = aSObj->GetObject();
3558 aSObj->UnRegister();
3563 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3564 int endRow = mySizeMapTable->topLevelItemCount()-1;
3566 for ( ; row <= endRow; ++row )
3568 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3569 if (entry == entryForChecking )
3572 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)