1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPluginGUI_HypothesisCreator.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPluginGUI_HypothesisCreator.h"
28 // #include <DlgBlSurfHyp_Enforced.h>
30 #include "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>
48 #include <QVBoxLayout>
49 #include <QHBoxLayout>
50 #include <QGridLayout>
55 #include <QPushButton>
57 #include <QTableWidget>
58 #include <QHeaderView>
59 #include <QApplication>
60 #include <QRadioButton>
62 #include <QStandardItemModel>
63 #include <QStandardItem>
64 #include <QTreeWidget>
65 #include <QTreeWidgetItem>
66 #include <QModelIndexList>
68 #include <LightApp_SelectionMgr.h>
69 #include <SalomeApp_Application.h>
70 #include <SALOME_ListIO.hxx>
71 #include <SALOME_ListIteratorOfListIO.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>
82 #define WITH_SIZE_BOUNDARIES
108 OPTION_ID_COLUMN = 0,
117 // Enforced vertices array columns
118 ENF_VER_NAME_COLUMN = 0,
119 ENF_VER_FACE_ENTRY_COLUMN,
123 ENF_VER_ENTRY_COLUMN,
124 ENF_VER_GROUP_COLUMN,
151 // Enforced vertices inputs
162 // ENF_VER_SEPARATOR,
168 /**************************************************
169 Begin initialization Python structures and objects
170 ***************************************************/
179 PyStdOut_dealloc(PyStdOut *self)
185 PyStdOut_write(PyStdOut *self, PyObject *args)
189 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
193 *(self->out)=*(self->out)+c;
199 static PyMethodDef PyStdOut_methods[] = {
200 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
201 PyDoc_STR("write(string) -> None")},
202 {NULL, NULL} /* sentinel */
205 static PyMemberDef PyStdOut_memberlist[] = {
206 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
207 (char*)"flag indicating that a space needs to be printed; used by print"},
208 {NULL} /* Sentinel */
211 static PyTypeObject PyStdOut_Type = {
212 /* The ob_type field must be initialized in the module init function
213 * to be portable to Windows without using C++. */
214 PyObject_HEAD_INIT(NULL)
217 sizeof(PyStdOut), /*tp_basicsize*/
220 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
227 0, /*tp_as_sequence*/
232 PyObject_GenericGetAttr, /*tp_getattro*/
233 /* softspace is writable: we must supply tp_setattro */
234 PyObject_GenericSetAttr, /* tp_setattro */
236 Py_TPFLAGS_DEFAULT, /*tp_flags*/
240 0, /*tp_richcompare*/
241 0, /*tp_weaklistoffset*/
244 PyStdOut_methods, /*tp_methods*/
245 PyStdOut_memberlist, /*tp_members*/
259 PyObject * newPyStdOut( std::string& out )
262 self = PyObject_New(PyStdOut, &PyStdOut_Type);
267 return (PyObject*)self;
270 /*************************************************
271 End initialization Python structures and objects
272 **************************************************/
276 // BEGIN EnforcedTreeWidgetDelegate
279 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
280 : QItemDelegate(parent)
284 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
285 const QStyleOptionViewItem & option ,
286 const QModelIndex & index ) const
288 QModelIndex father = index.parent();
289 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
291 if (index.column() == ENF_VER_X_COLUMN || \
292 index.column() == ENF_VER_Y_COLUMN || \
293 index.column() == ENF_VER_Z_COLUMN)
295 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
296 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
297 editor->setReadOnly(!entry.isEmpty());
298 editor->setDisabled(!entry.isEmpty());
303 QLineEdit *editor = new QLineEdit(parent);
304 if (index.column() != ENF_VER_GROUP_COLUMN) {
305 editor->setReadOnly(!entry.isEmpty());
306 editor->setDisabled(!entry.isEmpty());
312 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
313 const QModelIndex &index) const
315 QString value = index.model()->data(index, Qt::EditRole).toString();
317 if (index.column() == ENF_VER_X_COLUMN ||
318 index.column() == ENF_VER_Y_COLUMN ||
319 index.column() == ENF_VER_Z_COLUMN)
321 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
322 lineEdit->setText(value);
325 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
326 lineEdit->setText(value);
330 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
331 const QModelIndex &index) const
333 QModelIndex parent = index.parent();
334 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
335 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
336 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
337 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
338 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
339 } else if (index.column() == ENF_VER_NAME_COLUMN) {
340 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
341 QString value = lineEdit->text();
342 if (entry.isEmpty() && !vertexExists(model, index, value))
343 model->setData(index, value, Qt::EditRole);
344 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
345 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
346 QString value = lineEdit->text();
347 if (! vertexExists(model, index, value))
348 model->setData(index, value, Qt::EditRole);
349 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
350 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
351 model->setData(index, lineEdit->text(), Qt::EditRole);
355 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
356 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
358 editor->setGeometry(option.rect);
361 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
362 const QModelIndex &index, QString value) const
365 QModelIndex parent = index.parent();
366 int row = index.row();
367 int col = index.column();
369 if (parent.isValid() && !value.isEmpty()) {
370 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
372 if (col == ENF_VER_X_COLUMN) {
373 x = value.toDouble();
374 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
375 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
377 if (col == ENF_VER_Y_COLUMN) {
378 y = value.toDouble();
379 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
380 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
382 if (col == ENF_VER_Z_COLUMN) {
383 z = value.toDouble();
384 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
385 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
387 int nbChildren = model->rowCount(parent);
388 for (int i = 0 ; i < nbChildren ; i++) {
390 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
391 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
392 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
393 if ((childX == x) && (childY == y) && (childZ == z)) {
400 else if (col == ENF_VER_NAME_COLUMN) {
401 int nbChildren = model->rowCount(parent);
402 for (int i = 0 ; i < nbChildren ; i++) {
404 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
405 if (childName == value) {
418 // END EnforcedTreeWidgetDelegate
422 // BEGIN BLSURFPluginGUI_ObjectReferenceParamWdg
424 //================================================================================
426 // BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
427 // ( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection)
428 // : StdMeshersGUI_ObjectReferenceParamWdg(f, parent, multiSelection)
434 // BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
435 // ( MeshObjectType objType, QWidget* parent, bool multiSelection )
436 // : StdMeshersGUI_ObjectReferenceParamWdg( objType, parent, multiSelection )
441 // BLSURFPluginGUI_ObjectReferenceParamWdg::~BLSURFPluginGUI_ObjectReferenceParamWdg()
445 // mySelectionMgr->removeFilter( myFilter );
450 // void BLSURFPluginGUI_ObjectReferenceParamWdg::init()
452 // StdMeshersGUI_ObjectReferenceParamWdg::init();
453 // disconnect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection()));
454 // connect( mySelButton, SIGNAL(toggled(bool)), SLOT(setActivationStatus(bool)));
457 // void BLSURFPluginGUI_ObjectReferenceParamWdg::setActivationStatus(bool status)
460 // activateSelection();
462 // deactivateSelection();
465 // void BLSURFPluginGUI_ObjectReferenceParamWdg::activateSelectionOnly()
467 // if ( !mySelectionActivated && mySelectionMgr )
469 // mySelectionActivated = true;
470 // mySelectionMgr->clearFilters();
471 // if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
472 // aViewWindow->SetSelectionMode(ActorSelection);
474 // mySelectionMgr->installFilter( myFilter );
475 // connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
477 // emit selectionActivated();
480 // void BLSURFPluginGUI_ObjectReferenceParamWdg::deactivateSelectionOnly()
482 // mySelectionActivated = false;
483 // disconnect(mySelectionMgr, 0, this, 0 );
484 // mySelectionMgr->removeFilter( myFilter );
488 // END BLSURFPluginGUI_ObjectReferenceParamWdg
492 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
493 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
496 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
497 : SMESHGUI_GenericHypothesisCreator( theHypType )
499 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
500 this->mySMPMap.clear();
502 GeomToolSelected = NULL;
503 GeomToolSelected = getGeomSelectionTool();
505 aSel = GeomToolSelected->selectionMgr();
507 /* Initialize the Python interpreter */
508 if (! Py_IsInitialized())
509 throw ("Error: Python interpreter is not initialized");
510 PyGILState_STATE gstate;
511 gstate = PyGILState_Ensure();
514 main_mod = PyImport_AddModule("__main__");
517 main_dict = PyModule_GetDict(main_mod);
519 PyRun_SimpleString("from math import *");
520 PyGILState_Release(gstate);
524 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
529 * \brief {Get or create the geom selection tool for active study}
531 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool()
533 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
534 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
535 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
536 that->GeomToolSelected = new GeomSelectionTools(aStudy);
538 return that->GeomToolSelected;
541 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
543 return GeometryGUI::GetGeomGen();
547 bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
549 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
554 myOptionTable->setFocus();
555 QApplication::instance()->processEvents();
557 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
558 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
560 int row = 0, nbRows = myOptionTable->rowCount();
561 for ( ; row < nbRows; ++row )
563 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
564 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
565 if ( !value.isEmpty() ) {
567 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
569 catch ( const SALOME::SALOME_Exception& ex )
571 SUIT_MessageBox::critical( dlg(),
573 ex.details.text.in() );
578 h->SetOptionValues( myOptions ); // restore values
581 // SizeMap and attractors
584 mySizeMapTable->setFocus();
585 QApplication::instance()->processEvents();
587 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
588 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
590 // int row = 0, nbRows = mySizeMapTable->rowCount();
591 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
592 for ( ; row < nbRows; ++row )
594 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
595 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
596 if ( !sizeMap.isEmpty() ) {
597 if (that->sizeMapValidationFromRow(row))
600 const char* e = entry.toLatin1().constData();
601 const char* s = that->mySMPMap[entry].toLatin1().constData();
602 h->SetSizeMapEntry( e, s );
604 catch ( const SALOME::SALOME_Exception& ex )
606 SUIT_MessageBox::critical( dlg(),
608 ex.details.text.in() );
625 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
627 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
629 QFrame* fr = new QFrame( 0 );
630 // fr-> setMinimumSize(600,400);
631 QVBoxLayout* lay = new QVBoxLayout( fr );
632 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
634 lay->setSpacing( 0 );
637 QTabWidget* tab = new QTabWidget( fr );
638 tab->setTabShape( QTabWidget::Rounded );
639 tab->setTabPosition( QTabWidget::North );
640 lay->addWidget( tab );
643 myStdGroup = new QWidget();
644 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
645 aStdLayout->setSpacing( 6 );
646 aStdLayout->setMargin( 11 );
650 myName = new QLineEdit( myStdGroup );
652 myGradation = new SMESHGUI_SpinBox( myStdGroup );
653 myGradation->RangeStepAndValidator(1.1, 2.5, 0.1, "length_precision");
655 myPhysicalMesh = new QComboBox( myStdGroup );
656 QStringList physicalTypes;
657 physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ) << tr( "BLSURF_SIZE_MAP");
658 myPhysicalMesh->addItems( physicalTypes );
660 myPhySize = new SMESHGUI_SpinBox( myStdGroup );
661 myPhySize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
663 #ifdef WITH_SIZE_BOUNDARIES
664 myPhyMin = new SMESHGUI_SpinBox( myStdGroup );
665 myPhyMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
666 myPhyMin->setText("");
667 myPhyMax = new SMESHGUI_SpinBox( myStdGroup );
668 myPhyMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
669 myPhyMax->setText("");
672 myGeometricMesh = new QComboBox( myStdGroup );
674 types << tr( "BLSURF_DEFAULT_GEOM" ) << tr( "BLSURF_CUSTOM_GEOM" );
675 myGeometricMesh->addItems( types );
677 myAngleMeshS = new SMESHGUI_SpinBox( myStdGroup );
678 myAngleMeshS->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
680 myAngleMeshC = new SMESHGUI_SpinBox( myStdGroup );
681 myAngleMeshC->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
683 #ifdef WITH_SIZE_BOUNDARIES
684 myGeoMin = new SMESHGUI_SpinBox( myStdGroup );
685 myGeoMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
686 myGeoMin->setText("");
687 myGeoMax = new SMESHGUI_SpinBox( myStdGroup );
688 myGeoMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
689 myGeoMax->setText("");
691 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup );
692 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
694 // ADD WIDGETS (STANDARD TAB)
697 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
698 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
700 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 );
701 aStdLayout->addWidget( myGradation, row++, 1, 1, 1 );
702 aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ), row, 0, 1, 1 );
703 aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 );
704 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 );
705 aStdLayout->addWidget( myPhySize, row++, 1, 1, 1 );
706 #ifdef WITH_SIZE_BOUNDARIES
707 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ), row, 0, 1, 1 );
708 aStdLayout->addWidget( myPhyMin, row++, 1, 1, 1 );
709 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ), row, 0, 1, 1 );
710 aStdLayout->addWidget( myPhyMax, row++, 1, 1, 1 );
712 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ), row, 0, 1, 1 );
713 aStdLayout->addWidget( myGeometricMesh, row++, 1, 1, 1 );
714 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 0, 1, 1 );
715 aStdLayout->addWidget( myAngleMeshS, row++, 1, 1, 1 );
716 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 0, 1, 1 );
717 aStdLayout->addWidget( myAngleMeshC, row++, 1, 1, 1 );
718 #ifdef WITH_SIZE_BOUNDARIES
719 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ), row, 0, 1, 1 );
720 aStdLayout->addWidget( myGeoMin, row++, 1, 1, 1 );
721 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ), row, 0, 1, 1 );
722 aStdLayout->addWidget( myGeoMax, row++, 1, 1, 1 );
724 aStdLayout->addWidget( myAllowQuadrangles, row++, 0, 1, 1 );
725 aStdLayout->addWidget( myDecimesh, row++, 0, 1, 1 );
727 // advanced parameters
728 myAdvGroup = new QWidget();
729 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
730 anAdvLayout->setSpacing( 6 );
731 anAdvLayout->setMargin( 11 );
732 anAdvLayout->setRowStretch( 4, 5 );
733 anAdvLayout->setColumnStretch( 1, 5 );
735 myTopology = new QComboBox( myAdvGroup );
736 QStringList topologyTypes;
737 topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) << tr( "BLSURF_TOPOLOGY_PROCESS" ) << tr( "BLSURF_TOPOLOGY_PROCESS2" );
738 myTopology->addItems( topologyTypes );
740 myVerbosity = new QSpinBox( myAdvGroup );
741 myVerbosity->setMinimum( 0 );
742 myVerbosity->setMaximum( 100 );
743 myVerbosity->setSingleStep( 5 );
745 myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup );
747 headers << tr( "OPTION_ID_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" );
748 myOptionTable->setHorizontalHeaderLabels( headers );
749 myOptionTable->horizontalHeader()->hideSection( OPTION_ID_COLUMN );
750 myOptionTable->horizontalHeader()->setStretchLastSection(true);
751 myOptionTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
752 //myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );//////
753 //myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE );/////
754 myOptionTable->verticalHeader()->hide();
755 //myOptionTable->setSelectionBehavior( QAbstractItemView::SelectRows );
757 QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup );
758 addBtn->setMenu( new QMenu() );
759 QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup );
762 // ADD WIDGETS (ADVANCED TAB)
763 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 );
764 anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 );
765 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 1, 0, 1, 1 );
766 anAdvLayout->addWidget( myVerbosity, 1, 1, 1, 1 );
767 anAdvLayout->addWidget( myOptionTable, 2, 0, 3, 2 );
768 anAdvLayout->addWidget( addBtn, 2, 2, 1, 1 );
769 anAdvLayout->addWidget( rmBtn, 3, 2, 1, 1 );
772 // Size Maps parameters
774 mySmpGroup = new QWidget();
775 // mySmpGroup->setMinimumWidth(500);
778 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
781 mySizeMapTable = new QTreeWidget( mySmpGroup );
782 mySizeMapTable ->setMinimumWidth(200);
783 QStringList sizeMapHeaders;
784 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
785 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
786 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
787 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
788 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
789 mySizeMapTable->setAlternatingRowColors(true);
792 smpTab = new QTabWidget( mySmpGroup );
793 smpTab->setTabShape( QTabWidget::Rounded );
794 smpTab->setTabPosition( QTabWidget::South );
795 lay->addWidget( smpTab );
797 // Filters of selection
798 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
800 SM_ShapeTypes.Add( TopAbs_VERTEX );
801 SM_ShapeTypes.Add( TopAbs_EDGE );
802 SM_ShapeTypes.Add( TopAbs_FACE );
803 SM_ShapeTypes.Add( TopAbs_COMPOUND );
805 ATT_ShapeTypes.Add( TopAbs_VERTEX );
806 ATT_ShapeTypes.Add( TopAbs_EDGE );
807 ATT_ShapeTypes.Add( TopAbs_WIRE );
808 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
810 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
811 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
812 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
814 // Standard size map tab
815 mySmpStdGroup = new QWidget();
816 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
817 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false);
818 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
819 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
820 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
821 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
824 myAttractorGroup = new QWidget();
825 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
826 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false,/*stretch=*/false);
827 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
828 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
829 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
830 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
831 QFrame* attLine = new QFrame(myAttractorGroup);
832 attLine->setFrameShape(QFrame::HLine);
833 attLine->setFrameShadow(QFrame::Sunken);
834 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false);
835 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
836 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
837 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
838 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
839 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
840 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
841 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
842 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
843 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
844 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
846 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
847 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
851 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
852 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
853 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
854 modifyMapButton->setEnabled(false);
857 myAttSelWdg->setEnabled(false);
858 myAttSizeSpin->setEnabled(false);
859 myAttSizeLabel->setEnabled(false);
860 myAttDistSpin->setEnabled(false);
861 myAttDistLabel->setEnabled(false);
862 myAttDistSpin2->setEnabled(false);
863 myAttDistLabel2->setEnabled(false);
864 myAttDistSpin->setValue(0.);
865 myAttDistSpin2->setValue(0.);
866 myAttSizeSpin->setValue(0.);
867 mySmpSizeSpin->setValue(0.);
870 // ADD WIDGETS (SIZEMAP TAB)
871 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
872 anSmpLayout->setColumnStretch(0, 1);
873 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
874 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
875 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
876 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
877 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
878 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
881 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
882 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
883 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
884 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
887 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
888 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
889 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
890 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
891 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
892 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
893 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
894 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
895 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
896 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
897 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
898 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
900 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
901 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
903 smpTab->setCurrentIndex( SMP_STD_TAB );
905 // Enforced vertices parameters
906 myEnfGroup = new QWidget();
907 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
909 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
910 // anEnfLayout->addWidget(myEnforcedVertexWidget);
911 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
912 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
914 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
915 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
916 myEnforcedTreeWidget->setSortingEnabled(true);
917 QStringList enforcedHeaders;
918 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
919 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
920 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
922 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
923 myEnforcedTreeWidget->setAlternatingRowColors(true);
924 myEnforcedTreeWidget->setUniformRowHeights(true);
925 myEnforcedTreeWidget->setAnimated(true);
926 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
927 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
928 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
929 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
930 myEnforcedTreeWidget->resizeColumnToContents(column);
932 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
933 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
934 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
936 // FACE AND VERTEX SELECTION
937 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
938 shapeTypes1.Add( TopAbs_FACE );
939 shapeTypes1.Add( TopAbs_COMPOUND );
940 shapeTypes2.Add( TopAbs_VERTEX );
941 shapeTypes2.Add( TopAbs_COMPOUND );
943 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
944 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true, /*stretch=*/false);
945 myEnfFaceWdg->SetDefaultText("Select Faces", "QLineEdit { color: grey }");
947 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
948 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
949 myEnfVertexWdg->SetDefaultText("Select Vertices", "QLineEdit { color: grey }");
951 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
953 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
954 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
955 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
957 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
958 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
959 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
961 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
962 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
963 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
965 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
966 myGroupName = new QLineEdit(myEnfGroup);
968 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
969 // QFrame *line = new QFrame(myEnfGroup);
970 // line->setFrameShape(QFrame::HLine);
971 // line->setFrameShadow(QFrame::Sunken);
972 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
974 // CheckBox for groups generation
975 makeGroupsCheck = new QGroupBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
976 makeGroupsCheck->setCheckable(true);
977 makeGroupsCheck->setChecked(false);
978 QGridLayout* aGroupLayout = new QGridLayout(makeGroupsCheck);
979 myGlobalGroupName = new QLineEdit(makeGroupsCheck);
980 aGroupLayout->addWidget(myGlobalGroupName);
982 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES+1, 1);
983 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
984 // FACE AND VERTEX SELECTION
985 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
986 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
988 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
989 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
990 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
991 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
992 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
993 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
994 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
995 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
996 anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
997 anEnfLayout2->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 0, 1, 2);
998 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 0, 1, 2);
999 // anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 0, 1, 2);
1000 anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
1001 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
1004 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1005 tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1006 tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) );
1007 tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1009 tab->setCurrentIndex( STD_TAB );
1012 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
1013 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
1014 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1015 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1016 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1018 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1019 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1020 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1021 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1022 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1023 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1024 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1025 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1026 // connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(deactivateSelection(QWidget*, QWidget*)));
1027 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
1028 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
1029 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1030 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1031 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1033 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1034 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1035 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1036 connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1037 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1038 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1039 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1040 connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1041 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1042 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1043 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1044 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onSmpTabChanged( int ) ) );
1046 // Enforced vertices
1047 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1048 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1049 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1050 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1051 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1052 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1057 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1058 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1060 void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1062 if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1063 || (now = myGroupName) || (now = makeGroupsCheck) || (now = myEnforcedTreeWidget)) {
1064 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1065 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1066 myEnfFaceWdg->deactivateSelection();
1067 myEnfVertexWdg->deactivateSelection();
1072 * This method resets the content of the X, Y, Z and GroupNAme widgets;
1074 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1076 myXCoord->setCleared(true);
1077 myYCoord->setCleared(true);
1078 myZCoord->setCleared(true);
1079 myXCoord->setText("");
1080 myYCoord->setText("");
1081 myZCoord->setText("");
1082 myGroupName->setText("");
1085 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1086 This method updates the tooltip of a modified item. The QLineEdit widgets content
1087 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1089 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1090 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1091 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1092 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1093 QVariant y = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1094 QVariant z = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1095 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1096 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1097 QTreeWidgetItem* parent = item->parent();
1099 clearEnforcedVertexWidgets();
1101 if (parent && (!x.isNull() || !entry.isNull())) {
1102 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1103 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1104 if (entry.isNull()) {
1105 toolTip += QString("(") + x.toString();
1106 toolTip += QString(", ") + y.toString();
1107 toolTip += QString(", ") + z.toString();
1108 toolTip += QString(")");
1111 if (!groupName.isEmpty())
1112 toolTip += QString(" [") + groupName + QString("]");
1114 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1117 myXCoord->SetValue(x.toDouble());
1118 myYCoord->SetValue(y.toDouble());
1119 myZCoord->SetValue(z.toDouble());
1122 if (!groupName.isEmpty())
1123 myGroupName->setText(groupName);
1127 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1128 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1129 clearEnforcedVertexWidgets();
1130 if (nbSelEnfVertex == 1)
1132 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1135 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1136 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1137 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1138 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1139 if (CORBA::is_nil(measureOp))
1142 CORBA::Double x,y,z;
1143 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1144 if ( measureOp->IsDone() )
1146 myXCoord->SetValue(x);
1147 myYCoord->SetValue(y);
1148 myZCoord->SetValue(z);
1154 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1155 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1156 of the enforced vertex clicked in the tree widget.
1158 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1159 clearEnforcedVertexWidgets();
1160 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1161 if (! items.isEmpty() && items.size() == 1) {
1162 QTreeWidgetItem *item = items[0];
1163 // for (int i=0 ; i < items.size() ; i++) {
1165 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1166 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1167 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1168 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1169 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1170 if (!x.isNull()/* && entry.isNull()*/) {
1171 myXCoord->SetValue(x.toDouble());
1172 myYCoord->SetValue(y.toDouble());
1173 myZCoord->SetValue(z.toDouble());
1176 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1177 myGroupName->setText(group.toString());
1182 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1183 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1185 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEntry, std::string theFaceName,
1186 double x, double y, double z, std::string vertexName, std::string geomEntry, std::string groupName) {
1187 // Find theFaceEntry item
1188 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1189 QTreeWidgetItem* theItem;
1190 if (theItemList.empty()) {
1191 theItem = new QTreeWidgetItem();
1192 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1193 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1194 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1195 myEnforcedTreeWidget->addTopLevelItem(theItem);
1198 theItem = theItemList[0];
1201 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1202 bool okToCreate = true;
1204 const int nbVert = theItem->childCount();
1205 // MESSAGE("Number of child rows: " << nbVert);
1207 double childValueX,childValueY,childValueZ;
1208 QString childEntry, childGroupName;
1209 QTreeWidgetItem* child;
1210 for (int row = 0;row<nbVert;row++) {
1211 child = theItem->child(row);
1212 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1213 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1214 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1215 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1216 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1217 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1218 // update group name
1219 if (childGroupName.toStdString() != groupName) {
1220 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1221 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1229 if (geomEntry.empty()) {
1230 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1233 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1238 if (geomEntry.empty()) {
1239 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1242 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1245 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1246 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1247 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1248 QSize iconSize = iconSelect.size()*0.7;
1250 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1251 QString myVertexName;
1253 while(indexRef != vertexIndex) {
1254 indexRef = vertexIndex;
1255 if (vertexName.empty())
1256 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1258 myVertexName = QString(vertexName.c_str());
1260 for (int row = 0;row<nbVert;row++) {
1261 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1262 if (myVertexName == name) {
1268 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1269 if (geomEntry.empty()) {
1270 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1271 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1272 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1275 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1276 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1278 if (groupName != "")
1279 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1281 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1282 if (geomEntry.empty()) {
1283 toolTip += QString(" (%1, ").arg(x);
1284 toolTip += QString("%1, ").arg(y);
1285 toolTip += QString("%1)").arg(z);
1287 if (groupName != "")
1288 toolTip += QString(" [%1]").arg(groupName.c_str());
1290 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1291 theItem->setExpanded(true);
1292 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1295 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1296 This method is called when a item is added into the enforced vertices tree widget
1298 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1299 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1301 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1303 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1304 myEnfFaceWdg->deactivateSelection();
1305 myEnfVertexWdg->deactivateSelection();
1307 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1308 myEnforcedTreeWidget->resizeColumnToContents(column);
1311 int selEnfFace = myEnfFaceWdg->NbObjects();
1312 int selEnfVertex = myEnfVertexWdg->NbObjects();
1313 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1315 if (selEnfFace == 0)
1318 if ((selEnfVertex == 0) && coordsEmpty)
1321 string entry, shapeName;
1323 for (int i = 0 ; i < selEnfFace ; i++) {
1324 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1325 entry = myEnfFace->GetStudyEntry();
1326 shapeName = myEnfFace->GetName();
1328 std::string groupName = myGroupName->text().toStdString();
1329 if (makeGroupsCheck->isChecked())
1330 groupName = myGlobalGroupName->text().toStdString();
1332 if (boost::trim_copy(groupName).empty())
1335 if (selEnfVertex <= 1)
1338 x = myXCoord->GetValue();
1339 y = myYCoord->GetValue();
1340 z = myZCoord->GetValue();
1341 if (selEnfVertex == 1) {
1342 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1343 addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1346 addEnforcedVertex(entry, shapeName, x, y, z, "", "", groupName);
1350 if ( CORBA::is_nil(getGeomEngine()))
1353 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1354 if (CORBA::is_nil(measureOp))
1357 CORBA::Double x,y,z;
1359 for (int j = 0 ; j < selEnfVertex ; j++)
1361 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1362 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1363 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1364 if ( measureOp->IsDone() )
1365 addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1366 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1367 addEnforcedVertex(entry, shapeName, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1373 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1374 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1376 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1377 myEnforcedTreeWidget->resizeColumnToContents(column);
1379 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
1380 myPhysicalMesh->setCurrentIndex( SizeMap );
1381 onPhysicalMeshChanged();
1385 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1386 This method is called when a item is removed from the enforced vertices tree widget
1388 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1389 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1390 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1391 QList<QTreeWidgetItem *> selectedVertices;
1392 QSet<QTreeWidgetItem *> selectedEntries;
1393 QTreeWidgetItem* item;
1395 foreach( item, selectedItems ) {
1396 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1397 if (! value.isNull())
1398 selectedVertices.append(item);
1400 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1401 if (! value.isNull())
1402 selectedVertices.append(item);
1404 selectedEntries.insert(item);
1408 foreach(item,selectedVertices) {
1409 QTreeWidgetItem* parent = item->parent();
1410 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1411 parent->removeChild(item);
1413 if (parent->childCount() == 0) {
1414 if (selectedEntries.contains(parent))
1415 selectedEntries.remove(parent);
1420 foreach(item,selectedEntries) {
1421 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1425 myEnforcedTreeWidget->selectionModel()->clearSelection();
1428 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1429 This method updates the GUI widgets with the hypothesis data
1431 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1433 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1434 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1436 BlsurfHypothesisData data;
1437 that->readParamsFromHypo( data );
1440 myName->setText( data.myName );
1441 QFontMetrics metrics( myName->font() );
1442 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1444 myTopology->setCurrentIndex( data.myTopology );
1445 myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1446 myPhySize->SetValue( data.myPhySize );
1447 #ifdef WITH_SIZE_BOUNDARIES
1448 MESSAGE("data.myPhyMin: "<<data.myPhyMin)
1449 if (data.myPhyMin < 0)
1450 myPhyMin->setText("");
1452 myPhyMin->SetValue( data.myPhyMin );
1453 MESSAGE("data.myPhyMax: "<<data.myPhyMax)
1454 if (data.myPhyMax < 0)
1455 myPhyMax->setText("");
1457 myPhyMax->SetValue( data.myPhyMax );
1458 MESSAGE("data.myGeoMin: "<<data.myGeoMin)
1459 if (data.myGeoMin < 0)
1460 myGeoMin->setText("");
1462 myGeoMin->SetValue( data.myGeoMin );
1463 MESSAGE("data.myGeoMax: "<<data.myGeoMax)
1464 if (data.myGeoMax < 0)
1465 myGeoMax->setText("");
1467 myGeoMax->SetValue( data.myGeoMax );
1469 myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1470 // myAngleMeshS->setValue( data.myAngleMeshS );
1471 // myAngleMeshC->setValue( data.myAngleMeshC );
1472 // myGradation->setValue( data.myGradation );
1473 myAngleMeshS->SetValue( data.myAngleMeshS );
1474 myAngleMeshC->SetValue( data.myAngleMeshC );
1475 myGradation->SetValue( data.myGradation );
1476 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1477 myDecimesh->setChecked( data.myDecimesh );
1478 myVerbosity->setValue( data.myVerbosity );
1480 if ( myOptions.operator->() ) {
1481 // MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
1482 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1483 QString option = that->myOptions[i].in();
1484 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1485 if ( name_value.count() > 1 ) {
1486 QString idStr = QString("%1").arg( i );
1487 int row = myOptionTable->rowCount();
1488 myOptionTable->setRowCount( row+1 );
1489 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1490 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1491 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1492 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1493 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1494 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1495 Qt::ItemIsEditable |
1496 Qt::ItemIsEnabled );
1500 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1503 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1504 QMapIterator<QString, QString> i(that->mySMPMap);
1505 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1506 while (i.hasNext()) {
1508 const QString entry = i.key();
1509 const QString sizeMap = i.value();
1510 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1511 int row = mySizeMapTable->topLevelItemCount();
1512 QTreeWidgetItem* item = new QTreeWidgetItem();
1513 mySizeMapTable->addTopLevelItem( item );
1514 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1515 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1516 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1517 if (that->myATTMap.contains(entry)){
1518 const QString attEntry = that->myATTMap[entry];
1519 std::string attName = myGeomToolSelected->getNameFromEntry(attEntry.toStdString());
1520 QTreeWidgetItem* child = new QTreeWidgetItem();
1521 item->addChild( child );
1522 item->setExpanded(true);
1523 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1524 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attEntry ) );
1525 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString( attName ) ) );
1527 if (that->myAttDistMap[entry] > std::numeric_limits<double>::epsilon()){
1528 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Attractor" ) ) );
1531 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Constant Size" ) ) );
1536 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1539 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1540 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1541 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1543 // Enforced vertices
1544 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1545 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1546 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1547 TEntry entry = (*evmIt).first;
1548 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1549 MESSAGE("Face entry: " << entry);
1550 MESSAGE("Face name: " << shapeName);
1552 TEnfVertexList evs = (*evmIt).second;
1554 // evs = (*evmIt).second;
1557 // MESSAGE("evs = (*evmIt).second: FAIL");
1561 TEnfVertexList::const_iterator evsIt = evs.begin();
1562 TEnfVertex *enfVertex;
1563 for ( ; evsIt != evs.end() ; ++evsIt) {
1564 enfVertex = (*evsIt);
1565 MESSAGE("Name: " << enfVertex->name);
1567 if (enfVertex->coords.size()) {
1568 x = enfVertex->coords[0];
1569 y = enfVertex->coords[1];
1570 z = enfVertex->coords[2];
1572 that->addEnforcedVertex(entry, shapeName, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1576 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1577 myEnforcedTreeWidget->resizeColumnToContents(column);
1580 that->onPhysicalMeshChanged();
1581 that->onGeometricMeshChanged();
1584 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1585 This method updates the hypothesis data with the GUI widgets content.
1587 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1589 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1591 BlsurfHypothesisData data;
1592 QString guiHyp = that->readParamsFromWidgets( data );
1593 that->storeParamsToHypo( data );
1598 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1599 Updates the hypothesis data from hypothesis values.
1601 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
1603 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
1604 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1605 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1607 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1608 h_data.myName = isCreation() && data ? hypName() : "";
1610 h_data.myTopology = (int) h->GetTopology();
1611 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
1612 h_data.myPhySize = h->GetPhySize();
1613 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
1614 h_data.myAngleMeshS = h->GetAngleMeshS();
1615 h_data.myAngleMeshC = h->GetAngleMeshC();
1616 h_data.myGradation = h->GetGradation();
1617 h_data.myAllowQuadrangles = h->GetQuadAllowed();
1618 h_data.myDecimesh = h->GetDecimesh();
1619 h_data.myVerbosity = h->GetVerbosity();
1621 #ifdef WITH_SIZE_BOUNDARIES
1622 double PhyMin = h->GetPhyMin();
1623 double PhyMax = h->GetPhyMax();
1624 double GeoMin = h->GetGeoMin();
1625 double GeoMax = h->GetGeoMax();
1626 // if ( PhyMin > 0 )
1627 // h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString("");
1628 // h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString("");
1629 // h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString("");
1630 // h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString("");
1631 h_data.myPhyMin = PhyMin > 0 ? PhyMin : -1.0;
1632 h_data.myPhyMax = PhyMax > 0 ? PhyMax : -1.0;
1633 h_data.myGeoMin = GeoMin > 0 ? GeoMin : -1.0;
1634 h_data.myGeoMax = GeoMax > 0 ? GeoMax : -1.0;
1637 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1638 that->myOptions = h->GetOptionValues();
1640 that->mySMPMap.clear();
1641 that->myATTMap.clear();
1642 that->myAttDistMap.clear();
1643 that->myDistMap.clear();
1645 // classic size maps
1646 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
1647 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
1648 QString fullSizeMaps;
1649 QStringList fullSizeMapList;
1650 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1651 for ( int i = 0;i<mySizeMaps->length(); ++i ) {
1652 fullSizeMaps = mySizeMaps[i].in();
1653 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
1654 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
1655 if ( fullSizeMapList.count() > 1 ) {
1656 string fullSizeMap = fullSizeMapList[1].toStdString();
1657 int pos = fullSizeMap.find("return")+7;
1658 // MESSAGE("pos:" << pos);
1661 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
1666 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
1667 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
1668 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
1669 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
1675 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
1676 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
1678 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
1679 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
1680 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
1681 if ( fullCustomSizeMapList.count() > 1 ) {
1682 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
1683 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
1684 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
1685 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
1690 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
1691 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
1693 for ( int i = 0;i<allMyAttractors->length(); ++i ) {
1694 QString myAttractors = allMyAttractors[i].in();
1695 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
1696 if ( myAttractorList.count() > 1 ) {
1697 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
1698 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
1699 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
1700 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
1704 // attractor new version
1705 MESSAGE("retriveParams, Attractors")
1706 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
1707 for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
1708 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
1709 QString faceEntry = myAttractorParams.faceEntry.in();
1710 QString attEntry = myAttractorParams.attEntry.in();
1711 MESSAGE("attEntry = "<<attEntry.toStdString())
1712 double startSize = myAttractorParams.startSize;
1713 double endSize = myAttractorParams.endSize;
1714 double infDist = myAttractorParams.infDist;
1715 double constDist = myAttractorParams.constDist;
1716 that->mySMPMap[faceEntry] = QString::number( startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
1717 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
1718 that->myATTMap[faceEntry] = attEntry;
1719 that->myAttDistMap[faceEntry] = infDist;
1720 that->myDistMap[faceEntry] = constDist;
1723 // Enforced vertices
1724 h_data.enfVertexList.clear();
1725 h_data.faceEntryEnfVertexListMap.clear();
1727 h_data.groupNameEnfVertexListMap.clear();
1730 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
1731 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
1733 for ( int i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
1734 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
1735 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
1736 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
1737 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
1739 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
1741 for (int j=0 ; j<vertexList.length(); ++j) {
1742 TEnfVertex *enfVertex = new TEnfVertex();
1744 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
1745 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
1746 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
1747 for (int k=0 ; k< vertexList[j].coords.length();k++)
1748 enfVertex->coords.push_back(vertexList[j].coords[k]);
1750 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
1753 if (groupName != "") {
1754 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
1758 // h_data.enfVertMap[entry] = evs;
1759 // h_data.entryCoordsListMap[entry] = coordsList;
1761 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
1762 h_data.faceEntryEnfVertexListMap.erase(entry);
1769 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
1770 Saves the hypothesis data to hypothesis values.
1772 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
1774 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
1775 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1776 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
1782 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1784 if ( h->GetTopology() != h_data.myTopology ) // avoid duplication of DumpPython commands
1785 h->SetTopology( (int) h_data.myTopology );
1786 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh )
1787 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
1788 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
1789 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
1790 if ( h->GetGradation() != h_data.myGradation )
1791 h->SetGradation( h_data.myGradation );
1792 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
1793 h->SetQuadAllowed( h_data.myAllowQuadrangles );
1794 if ( h->GetDecimesh() != h_data.myDecimesh )
1795 h->SetDecimesh( h_data.myDecimesh );
1796 if ( h->GetVerbosity() != h_data.myVerbosity )
1797 h->SetVerbosity( h_data.myVerbosity );
1799 if( ((int) h_data.myPhysicalMesh == PhysicalUserDefined)||((int) h_data.myPhysicalMesh == SizeMap) ) {
1800 if ( h->GetPhySize() != h_data.myPhySize )
1801 h->SetPhySize( h_data.myPhySize );
1803 if( (int) h_data.myGeometricMesh == UserDefined ) {
1804 if ( h->GetAngleMeshS() != h_data.myAngleMeshS )
1805 h->SetAngleMeshS( h_data.myAngleMeshS );
1806 if ( h->GetAngleMeshC() != h_data.myAngleMeshC )
1807 h->SetAngleMeshC( h_data.myAngleMeshC );
1809 #ifdef WITH_SIZE_BOUNDARIES
1810 if (h_data.myPhyMin > 0)
1811 h->SetPhyMin( h_data.myPhyMin );
1812 if (h_data.myPhyMax > 0)
1813 h->SetPhyMax( h_data.myPhyMax );
1814 if (h_data.myGeoMin > 0)
1815 h->SetGeoMin( h_data.myGeoMin );
1816 if (h_data.myGeoMax > 0)
1817 h->SetGeoMax( h_data.myGeoMax );
1820 h->SetOptionValues( myOptions ); // is set in checkParams()
1822 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1823 QMapIterator<QString,QString> i(that->mySMPMap);
1824 while (i.hasNext()) {
1826 const QString entry = i.key();
1827 const QString sizeMap = i.value();
1829 if (sizeMap == "__TO_DELETE__") {
1830 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
1831 h->UnsetEntry(entry.toLatin1().constData());
1833 else if (sizeMap.startsWith("ATTRACTOR")) {
1834 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1835 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
1837 else if (sizeMap.startsWith("def")) {
1838 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1839 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
1842 if (!myATTMap[entry].isEmpty()){
1843 QString att_entry = myATTMap[entry];
1844 double infDist = myAttDistMap[entry];
1845 double constDist = myDistMap[entry];
1846 double phySize = h->GetPhySize();
1847 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1848 h->SetClassAttractorEntry( entry.toLatin1().constData(), att_entry.toLatin1().constData(), sizeMap.toDouble() , phySize, infDist, constDist );
1849 QApplication::restoreOverrideCursor();
1852 QString fullSizeMap;
1853 fullSizeMap = QString("");
1854 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
1855 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
1856 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
1857 fullSizeMap = QString("def f(t): return ") + sizeMap;
1858 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
1859 fullSizeMap = QString("def f(): return ") + sizeMap;
1860 // MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
1861 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
1866 // Enforced vertices
1870 std::string enfName;
1872 std::string groupName = "";
1875 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
1876 // 1. Clear all enforced vertices in hypothesis
1877 // 2. Add new enforced vertex according to h_data
1879 h->ClearAllEnforcedVertices();
1882 TEnfVertexList::const_iterator evsIt;
1883 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
1885 faceEntry = evmIt->first;
1886 evs = evmIt->second;
1887 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
1888 evsIt = evs.begin();
1889 for ( ; evsIt != evs.end() ; ++evsIt)
1892 if ((*evsIt)->coords.size()) {
1893 x = (*evsIt)->coords[0];
1894 y = (*evsIt)->coords[1];
1895 z = (*evsIt)->coords[2];
1897 ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
1901 catch(const std::exception& ex) {
1902 std::cout << "Exception: " << ex.what() << std::endl;
1905 // catch(const SALOME::SALOME_Exception& ex)
1908 // // SalomeApp_Tools::QtCatchCorbaException(ex);
1914 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
1915 Stores the widgets content to the hypothesis data.
1917 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
1919 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
1920 h_data.myName = myName ? myName->text() : "";
1921 h_data.myTopology = myTopology->currentIndex();
1922 h_data.myPhysicalMesh = myPhysicalMesh->currentIndex();
1923 h_data.myPhySize = myPhySize->GetValue();
1924 #ifdef WITH_SIZE_BOUNDARIES
1925 h_data.myPhyMin = myPhyMin->GetValue();
1926 h_data.myPhyMax = myPhyMax->GetValue();
1927 h_data.myGeoMin = myGeoMin->GetValue();
1928 h_data.myGeoMax = myGeoMax->GetValue();
1930 h_data.myGeometricMesh = myGeometricMesh->currentIndex();
1931 h_data.myAngleMeshS = myAngleMeshS->GetValue();
1932 h_data.myAngleMeshC = myAngleMeshC->GetValue();
1933 h_data.myGradation = myGradation->GetValue();
1934 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
1935 h_data.myDecimesh = myDecimesh->isChecked();
1936 h_data.myVerbosity = myVerbosity->value();
1939 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
1940 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
1941 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
1942 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
1943 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; ";
1944 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
1945 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
1946 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; ";
1947 #ifdef WITH_SIZE_BOUNDARIES
1948 guiHyp += "hphymin = " + QString::number( h_data.myPhyMin ) + "; ";
1949 guiHyp += "hphymax = " + QString::number( h_data.myPhyMax ) + "; ";
1950 guiHyp += "hgeomin = " + QString::number( h_data.myGeoMin ) + "; ";
1951 guiHyp += "hgeomax = " + QString::number( h_data.myGeoMax ) + "; ";
1954 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1955 int row = 0, nbRows = myOptionTable->rowCount();
1956 for ( ; row < nbRows; ++row )
1958 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
1959 if ( id >= 0 && id < myOptions->length() )
1961 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
1962 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
1963 if ( value.isNull() )
1965 that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
1967 guiHyp += name + " = " + value + "; ";
1972 row = 0, nbRows = mySizeMapTable->topLevelItemCount();
1973 for ( ; row < nbRows; ++row )
1975 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
1976 if ( that->mySMPMap.contains(entry) )
1977 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
1980 // Enforced vertices
1981 h_data.enfVertexList.clear();
1982 h_data.faceEntryEnfVertexListMap.clear();
1984 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
1985 int nbEnforcedVertices = 0;
1986 std::string groupName = "";
1987 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
1988 for (int i=0 ; i<nbEnforcedShapes ; i++) {
1989 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
1991 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
1992 nbEnforcedVertices = shapeItem->childCount();
1993 if (nbEnforcedVertices >0) {
1994 double childValueX,childValueY,childValueZ;
1995 std::string childName, vertexEntry;
1996 QTreeWidgetItem* child;
1999 for (row = 0;row<nbEnforcedVertices;row++) {
2000 child = shapeItem->child(row);
2001 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2002 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2003 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2004 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2005 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2006 if (makeGroupsCheck->isChecked())
2007 groupName = myGlobalGroupName->text().toStdString();
2009 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2011 TEnfVertex *enfVertex = new TEnfVertex();
2012 enfVertex->name = childName;
2013 if (vertexEntry.empty()) {
2014 enfVertex->coords.push_back(childValueX);
2015 enfVertex->coords.push_back(childValueY);
2016 enfVertex->coords.push_back(childValueZ);
2019 enfVertex->geomEntry = vertexEntry;
2020 enfVertex->grpName = groupName;
2021 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2022 // if (it == h_data.enfVertexList.end())
2023 h_data.enfVertexList.insert(enfVertex);
2024 evs.insert(enfVertex);
2026 if (groupName != "")
2027 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2030 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2035 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2039 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
2040 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged");
2041 bool isPhysicalUserDefined = (myPhysicalMesh->currentIndex() == PhysicalUserDefined);
2042 bool isSizeMap = (myPhysicalMesh->currentIndex() == SizeMap);
2043 bool isCustom = (isPhysicalUserDefined || isSizeMap) ;
2044 bool geomIsCustom = (myGeometricMesh->currentIndex() == UserDefined);
2046 myGradation->setEnabled(!isPhysicalUserDefined || geomIsCustom);
2047 myPhySize->setEnabled(isCustom);
2048 myPhyMax->setEnabled(isCustom);
2049 myPhyMin->setEnabled(isCustom);
2051 if ( !myGradation->isEnabled())
2052 myGradation->SetValue( 1.1 );
2055 if ( myGeometricMesh->currentIndex() == DefaultGeom ) {
2056 myGeometricMesh->setCurrentIndex( UserDefined );
2057 onGeometricMeshChanged();
2062 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
2063 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged");
2064 bool isCustom = (myGeometricMesh->currentIndex() == UserDefined);
2065 bool phyIsSizemap = (myPhysicalMesh->currentIndex() == SizeMap);
2067 myAngleMeshS->setEnabled(isCustom);
2068 myAngleMeshC->setEnabled(isCustom);
2069 myGradation->setEnabled(isCustom || phyIsSizemap);
2070 myGeoMax->setEnabled(isCustom);
2071 myGeoMin->setEnabled(isCustom);
2073 if ( !myGradation->isEnabled())
2074 myGradation->SetValue( 1.1 );
2077 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
2078 if ( myPhysicalMesh->currentIndex() == DefaultSize ) {
2079 myPhysicalMesh->setCurrentIndex( PhysicalUserDefined );
2080 onPhysicalMeshChanged();
2085 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2087 QMenu* menu = (QMenu*)sender();
2088 // fill popup with option names
2090 if ( myOptions.operator->() ) {
2091 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
2092 QString name_value = myOptions[i].in();
2093 QString name = name_value.split( ":", QString::KeepEmptyParts )[0];
2094 menu->addAction( name );
2099 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
2101 myOptionTable->setFocus();
2102 QMenu* menu = (QMenu*)( a->parent() );
2104 int idx = menu->actions().indexOf( a );
2105 QString idStr = QString("%1").arg( idx );
2106 QString option = myOptions[idx].in();
2107 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
2109 // look for a row with optionName
2110 int row = 0, nbRows = myOptionTable->rowCount();
2111 for ( ; row < nbRows; ++row )
2112 if ( myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
2114 // add a row if not found
2115 if ( row == nbRows ) {
2116 myOptionTable->setRowCount( row+1 );
2117 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
2118 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
2119 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
2120 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
2121 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
2122 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
2123 Qt::ItemIsEditable |
2124 Qt::ItemIsEnabled );
2125 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2127 myOptionTable->clearSelection();
2128 myOptionTable->scrollToItem( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2129 //myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
2130 myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
2131 //myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2134 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
2136 // clear option values and remember selected row
2137 QList<int> selectedRows;
2138 QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
2139 QTableWidgetItem* item;
2140 foreach( item, selected ) {
2141 int row = item->row();
2142 if ( !selectedRows.contains( row ) ) {
2143 selectedRows.append( row );
2144 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2145 if ( id >= 0 && id < myOptions->length() )
2146 myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2149 qSort( selectedRows );
2150 QListIterator<int> it( selectedRows );
2152 while ( it.hasPrevious() )
2153 myOptionTable->removeRow( it.previous() );
2156 // **********************
2157 // *** BEGIN SIZE MAP ***
2158 // **********************
2160 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2162 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2164 if ( myGeomSelWdg2->IsObjectSelected() ){
2165 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2167 else if ( myGeomSelWdg1->IsObjectSelected() ){
2168 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2170 std::string entry = (string) mySMapObject->GetStudyEntry();
2171 QString qEntry = QString::fromStdString(entry);
2172 if (that->mySMPMap.contains(qEntry) && that->mySMPMap[qEntry] != "__TO_DELETE__" ) {
2173 addMapButton->setEnabled(false);
2174 modifyMapButton->setEnabled(true);
2177 addMapButton->setEnabled(true);
2178 modifyMapButton->setEnabled(false);
2183 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2185 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2186 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2187 if (col == SMP_SIZEMAP_COLUMN){
2188 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2189 if (!mySMPMap.contains(entry))
2191 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2192 CORBA::Object_var obj = entryToObject(entry);
2193 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){ // ADVANCED MAPS
2194 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2195 double phySize = that->mySMPMap[entry].toDouble(); // Retrieve values of the selected item in the current tab widgets
2196 double infDist = that->myAttDistMap[entry];
2197 double constDist = that->myDistMap[entry];
2198 QString attEntry = that->myATTMap[entry];
2199 CORBA::Object_var attObj = entryToObject(attEntry);
2200 myAttSizeSpin->setValue(phySize);
2201 if (sizeMap.startsWith("Attractor")){
2202 myAttDistSpin->setValue(infDist);
2203 myAttractorCheck->setChecked(true);
2206 myAttractorCheck->setChecked(false);
2208 if (sizeMap.startsWith("Constant") || constDist > std::numeric_limits<double>::epsilon()){
2209 myAttDistSpin2->setValue(constDist);
2210 myConstSizeCheck->setChecked(true);
2213 myConstSizeCheck->setChecked(false);
2215 myGeomSelWdg2->SetObject(obj);
2216 myAttSelWdg->SetObject(attObj);
2218 else { // CLASSIC MAPS
2219 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2220 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2221 if (!sizeMap.startsWith("def")){
2222 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2228 void BLSURFPluginGUI_HypothesisCreator::onSmpTabChanged(int tab)
2230 myAttDistSpin->setValue(0.); // Reinitialize widgets
2231 myAttSizeSpin->setValue(0.);
2232 myAttDistSpin2->setValue(0.);
2233 mySmpSizeSpin->setValue(0.);
2234 myGeomSelWdg1->deactivateSelection();
2235 myGeomSelWdg2->deactivateSelection();
2236 myAttSelWdg->deactivateSelection();
2237 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2238 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2239 myAttSelWdg->SetObject(CORBA::Object::_nil());
2240 myAttractorCheck->setChecked(false);
2241 myConstSizeCheck->setChecked(false);
2244 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2246 if (state == Qt::Checked){
2247 myAttSelWdg->setEnabled(true);
2248 myAttSizeSpin->setEnabled(true);
2249 myAttSizeLabel->setEnabled(true);
2250 myAttDistSpin->setEnabled(true);
2251 myAttDistLabel->setEnabled(true);
2252 if (!myAttSelWdg->IsObjectSelected()){
2253 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2256 if (state == Qt::Unchecked){
2257 myAttDistSpin->setEnabled(false);
2258 myAttDistLabel->setEnabled(false);
2259 myAttDistSpin->setValue(0.);
2260 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2261 myAttSelWdg->setEnabled(false);
2262 myAttSizeSpin->setEnabled(false);
2263 myAttSizeLabel->setEnabled(false);
2264 myAttDistSpin2->setEnabled(false);
2265 myAttDistLabel2->setEnabled(false);
2267 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2268 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2273 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2275 if (state == Qt::Checked){
2276 myAttSelWdg->setEnabled(true);
2277 myAttSizeSpin->setEnabled(true);
2278 myAttSizeLabel->setEnabled(true);
2279 myAttDistSpin2->setEnabled(true);
2280 myAttDistLabel2->setEnabled(true);
2281 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2282 !myAttSelWdg->IsObjectSelected()){
2283 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2286 if (state == Qt::Unchecked){
2287 myAttDistSpin2->setEnabled(false);
2288 myAttDistLabel2->setEnabled(false);
2289 myAttDistSpin2->setValue(0.);
2290 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2291 myAttSelWdg->setEnabled(false);
2292 myAttSizeSpin->setEnabled(false);
2293 myAttSizeLabel->setEnabled(false);
2294 myAttDistSpin->setEnabled(false);
2295 myAttDistLabel->setEnabled(false);
2297 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2298 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2303 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2305 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
2306 QList<int> selectedRows;
2307 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2308 QTreeWidgetItem* item;
2309 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2311 qSort( selectedRows );
2312 QListIterator<QTreeWidgetItem*> it( selected );
2314 while ( it.hasPrevious() ) {
2315 item = it.previous();
2316 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2317 if (that->mySMPMap.contains(entry))
2318 that->mySMPMap[entry] = "__TO_DELETE__";
2319 if (that->mySMPShapeTypeMap.contains(entry))
2320 that->mySMPShapeTypeMap.remove(entry);
2321 if (that->myATTMap.contains(entry))
2322 that->myATTMap.remove(entry);
2323 if (that->myDistMap.contains(entry))
2324 that->myDistMap.remove(entry);
2325 if (that->myAttDistMap.contains(entry))
2326 that->myAttDistMap.remove(entry);
2329 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2330 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2333 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2335 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
2336 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2337 if (col == SMP_SIZEMAP_COLUMN) {
2338 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2339 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2340 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2341 // MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
2342 if (! that->mySMPShapeTypeMap.contains(entry))
2344 if (that->mySMPMap.contains(entry))
2345 if (that->mySMPMap[entry] == sizeMap
2346 || sizeMap.startsWith("Attractor")
2347 || sizeMap.startsWith("Constant") ){
2350 if (! sizeMap.isEmpty()) {
2351 that->mySMPMap[entry] = sizeMap;
2352 sizeMapValidationFromEntry(entry);
2355 MESSAGE("Size map empty: reverse to precedent value" );
2356 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2358 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2362 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2364 if ( smpTab->currentIndex() == ATT_TAB ){
2365 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2366 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2367 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2368 insertAttractor(mySMapObject, myAttObject);
2371 if (smpTab->currentIndex() == SMP_STD_TAB ){
2372 if ( myGeomSelWdg1->IsObjectSelected() ){
2373 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2374 insertElement(mySMapObject);
2377 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2378 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2379 myAttDistSpin->setValue(0.);
2380 myAttSizeSpin->setValue(0.);
2381 myAttDistSpin2->setValue(0.);
2382 mySmpSizeSpin->setValue(0.);
2383 myConstSizeCheck->setChecked(false);
2384 myAttractorCheck->setChecked(false);
2385 myGeomSelWdg1->deactivateSelection();
2386 myGeomSelWdg2->deactivateSelection();
2387 myAttSelWdg->deactivateSelection();
2388 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2389 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2390 myAttSelWdg->SetObject(CORBA::Object::_nil());
2393 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
2395 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
2396 if ( smpTab->currentIndex() == ATT_TAB ){
2397 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2398 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2399 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2400 insertAttractor(mySMapObject, myAttObject, /*modify = */true);
2403 if (smpTab->currentIndex() == SMP_STD_TAB ){
2404 if ( myGeomSelWdg1->IsObjectSelected() ){
2405 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2406 insertElement(mySMapObject, /*modify = */true);
2409 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2410 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2411 myAttDistSpin->setValue(0.);
2412 myAttSizeSpin->setValue(0.);
2413 myAttDistSpin2->setValue(0.);
2414 mySmpSizeSpin->setValue(0.);
2415 myConstSizeCheck->setChecked(false);
2416 myAttractorCheck->setChecked(false);
2417 myGeomSelWdg1->deactivateSelection();
2418 myGeomSelWdg2->deactivateSelection();
2419 myAttSelWdg->deactivateSelection();
2420 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2421 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2422 myAttSelWdg->SetObject(CORBA::Object::_nil());
2425 void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
2427 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
2428 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2429 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2431 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2433 TopAbs_ShapeEnum shapeType;
2434 string entry, shapeName;
2435 entry = (string) anObject->GetStudyEntry();
2436 MESSAGE("entry = "<<entry);
2437 shapeName = anObject->GetName();
2438 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
2439 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
2440 // in order to write the size map with the right syntax in StoreParamsToHypo
2441 // (f(t) for edges, f(u,v) for faces ...)
2442 if (shapeType == TopAbs_COMPOUND){
2443 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
2444 TopoDS_Shape childShape;
2445 TopoDS_Iterator anIt(theShape);
2446 for(;anIt.More();anIt.Next()){
2447 childShape = anIt.Value();
2448 shapeType = childShape.ShapeType();
2449 if(!childShape.IsNull()){
2454 mySizeMapTable->setFocus();
2456 shapeEntry = QString::fromStdString(entry);
2457 double phySize = mySmpSizeSpin->value();
2458 std::ostringstream oss;
2461 sizeMap = QString::fromStdString(oss.str());
2462 QTreeWidgetItem* item = new QTreeWidgetItem();
2464 int rowToChange = findRowFromEntry(shapeEntry);
2465 item = mySizeMapTable->topLevelItem( rowToChange );
2468 if (that->mySMPMap.contains(shapeEntry)) {
2469 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2470 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2474 mySizeMapTable->addTopLevelItem(item);
2476 that->mySMPMap[shapeEntry] = sizeMap;
2477 that->myDistMap[shapeEntry] = 0. ;
2478 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
2479 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2480 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
2481 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
2482 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
2483 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
2484 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2485 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2486 mySizeMapTable->clearSelection();
2488 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2489 myPhysicalMesh->setCurrentIndex( SizeMap );
2490 onPhysicalMeshChanged();
2494 void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
2496 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
2497 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2498 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2500 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2502 TopAbs_ShapeEnum shapeType;
2503 string entry, attEntry, faceName, attName;
2504 entry = (string) aFace->GetStudyEntry();
2505 attEntry = (string) anAttractor->GetStudyEntry();
2506 faceName = aFace->GetName();
2507 attName = anAttractor->GetName();
2508 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
2509 mySizeMapTable->setFocus();
2510 QString shapeEntry = QString::fromStdString(entry);
2511 QString qAttEntry = QString::fromStdString(attEntry);
2513 double phySize = h->GetPhySize();
2514 double infDist = 0. ;
2515 double constDist = 0. ;
2516 phySize = myAttSizeSpin->value();
2517 if (myAttractorCheck->isChecked()){
2518 infDist = myAttDistSpin->value();
2520 if (myConstSizeCheck->isChecked()){
2521 constDist = myAttDistSpin2->value();
2523 std::ostringstream oss;
2524 std::ostringstream oss2;
2525 std::ostringstream oss3;
2529 QString sizeMap = QString::fromStdString(oss.str());
2530 QString infDistString = QString::fromStdString(oss2.str());
2531 QString constDistString = QString::fromStdString(oss3.str());
2533 QTreeWidgetItem* item;
2534 QTreeWidgetItem* child;
2536 int rowToChange = findRowFromEntry(shapeEntry);
2537 item = mySizeMapTable->topLevelItem( rowToChange );
2538 child = item->child( 0 );
2541 if (that->mySMPMap.contains(shapeEntry)) {
2542 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2543 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2547 item = new QTreeWidgetItem();
2548 child = new QTreeWidgetItem();
2549 mySizeMapTable->addTopLevelItem(item);
2550 item->addChild(child);
2552 that->mySMPMap.insert(shapeEntry,sizeMap);
2553 that->myATTMap.insert(shapeEntry,qAttEntry);
2554 that->myAttDistMap.insert(shapeEntry,infDist);
2555 that->myDistMap.insert(shapeEntry,constDist);
2556 that->mySMPShapeTypeMap.insert(shapeEntry,shapeType);
2557 item->setExpanded(true);
2558 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
2559 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
2560 if (infDist > std::numeric_limits<double>::epsilon()){
2561 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
2563 else if (constDist > std::numeric_limits<double>::epsilon()){
2564 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
2566 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2568 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
2569 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
2570 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
2572 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2573 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2574 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
2576 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2577 myPhysicalMesh->setCurrentIndex( SizeMap );
2578 onPhysicalMeshChanged();
2580 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2583 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
2585 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
2586 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2587 for ( ; row < nbRows; ++row )
2588 if (! sizeMapValidationFromRow(row))
2593 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
2595 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
2596 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2597 bool res = sizeMapValidationFromEntry(myEntry,displayError);
2598 mySizeMapTable->setFocus();
2602 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
2604 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
2606 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2608 if (! that->mySMPMap.contains(myEntry)) {
2609 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
2612 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
2613 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
2619 if (that->mySMPMap[myEntry].startsWith("def")) {
2620 // MESSAGE("custom function" );
2621 expr = that->mySMPMap[myEntry].toStdString();
2623 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
2624 // MESSAGE("Attractor" );
2625 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)) {
2628 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])" );
2634 // case size map is empty
2635 if (that->mySMPMap[myEntry].isEmpty()) {
2637 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
2641 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
2642 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
2643 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
2644 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
2645 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
2646 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
2649 //assert(Py_IsInitialized());
2650 if (! Py_IsInitialized())
2651 throw ("Erreur: Python interpreter is not initialized");
2652 PyGILState_STATE gstate;
2653 gstate = PyGILState_Ensure();
2655 PyObject * obj = NULL;
2656 PyObject* new_stderr = NULL;
2657 string err_description="";
2658 obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
2662 new_stderr=newPyStdOut(err_description);
2663 PySys_SetObject((char*)"stderr", new_stderr);
2665 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
2666 Py_DECREF(new_stderr);
2668 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
2669 PyGILState_Release(gstate);
2674 PyObject * func = NULL;
2675 func = PyObject_GetAttrString(main_mod, "f");
2679 new_stderr=newPyStdOut(err_description);
2680 PySys_SetObject((char*)"stderr", new_stderr);
2682 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
2683 Py_DECREF(new_stderr);
2685 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
2686 PyGILState_Release(gstate);
2690 PyGILState_Release(gstate);
2692 // MESSAGE("SizeMap expression "<<expr<<" is valid");
2697 QString BLSURFPluginGUI_HypothesisCreator::caption() const
2699 return tr( "BLSURF_TITLE" );
2702 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
2704 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
2707 QString BLSURFPluginGUI_HypothesisCreator::type() const
2709 return tr( "BLSURF_HYPOTHESIS" );
2712 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
2714 return "blsurf_hypo_page.html";
2717 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
2720 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2722 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2727 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
2729 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
2730 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
2731 CORBA::Object_var obj;
2732 SALOMEDS::GenericAttribute_var anAttr;
2733 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
2734 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
2735 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2736 CORBA::String_var aVal = anIOR->Value();
2737 obj = myStudy->ConvertIORToObject(aVal);
2742 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
2743 QString entryForChecking;
2744 int endRow = mySizeMapTable->topLevelItemCount()-1;
2746 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2747 while (entry != entryForChecking && row <= endRow){
2749 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2751 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)