1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPluginGUI_HypothesisCreator.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPluginGUI_HypothesisCreator.h"
28 // #include <DlgBlSurfHyp_Enforced.h>
30 #include "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 <SMESH_Gen_i.hxx>
76 #include <boost/shared_ptr.hpp>
77 #include <boost/algorithm/string.hpp>
78 #include <structmember.h>
81 #define WITH_SIZE_BOUNDARIES
107 OPTION_ID_COLUMN = 0,
116 // Enforced vertices array columns
117 ENF_VER_NAME_COLUMN = 0,
118 ENF_VER_FACE_ENTRY_COLUMN,
122 ENF_VER_ENTRY_COLUMN,
123 ENF_VER_GROUP_COLUMN,
150 // Enforced vertices inputs
161 // ENF_VER_SEPARATOR,
167 /**************************************************
168 Begin initialization Python structures and objects
169 ***************************************************/
178 PyStdOut_dealloc(PyStdOut *self)
184 PyStdOut_write(PyStdOut *self, PyObject *args)
188 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
192 *(self->out)=*(self->out)+c;
198 static PyMethodDef PyStdOut_methods[] = {
199 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
200 PyDoc_STR("write(string) -> None")},
201 {NULL, NULL} /* sentinel */
204 static PyMemberDef PyStdOut_memberlist[] = {
205 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
206 (char*)"flag indicating that a space needs to be printed; used by print"},
207 {NULL} /* Sentinel */
210 static PyTypeObject PyStdOut_Type = {
211 /* The ob_type field must be initialized in the module init function
212 * to be portable to Windows without using C++. */
213 PyObject_HEAD_INIT(NULL)
216 sizeof(PyStdOut), /*tp_basicsize*/
219 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
226 0, /*tp_as_sequence*/
231 PyObject_GenericGetAttr, /*tp_getattro*/
232 /* softspace is writable: we must supply tp_setattro */
233 PyObject_GenericSetAttr, /* tp_setattro */
235 Py_TPFLAGS_DEFAULT, /*tp_flags*/
239 0, /*tp_richcompare*/
240 0, /*tp_weaklistoffset*/
243 PyStdOut_methods, /*tp_methods*/
244 PyStdOut_memberlist, /*tp_members*/
258 PyObject * newPyStdOut( std::string& out )
261 self = PyObject_New(PyStdOut, &PyStdOut_Type);
266 return (PyObject*)self;
269 /*************************************************
270 End initialization Python structures and objects
271 **************************************************/
275 // BEGIN EnforcedTreeWidgetDelegate
278 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
279 : QItemDelegate(parent)
283 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
284 const QStyleOptionViewItem & option ,
285 const QModelIndex & index ) const
287 QModelIndex father = index.parent();
288 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
290 if (index.column() == ENF_VER_X_COLUMN || \
291 index.column() == ENF_VER_Y_COLUMN || \
292 index.column() == ENF_VER_Z_COLUMN)
294 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
295 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
296 editor->setReadOnly(!entry.isEmpty());
297 editor->setDisabled(!entry.isEmpty());
302 QLineEdit *editor = new QLineEdit(parent);
303 if (index.column() != ENF_VER_GROUP_COLUMN) {
304 editor->setReadOnly(!entry.isEmpty());
305 editor->setDisabled(!entry.isEmpty());
311 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
312 const QModelIndex &index) const
314 QString value = index.model()->data(index, Qt::EditRole).toString();
316 if (index.column() == ENF_VER_X_COLUMN ||
317 index.column() == ENF_VER_Y_COLUMN ||
318 index.column() == ENF_VER_Z_COLUMN)
320 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
321 lineEdit->setText(value);
324 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
325 lineEdit->setText(value);
329 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
330 const QModelIndex &index) const
332 QModelIndex parent = index.parent();
333 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
334 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
335 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
336 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
337 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
338 } else if (index.column() == ENF_VER_NAME_COLUMN) {
339 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
340 QString value = lineEdit->text();
341 if (entry.isEmpty() && !vertexExists(model, index, value))
342 model->setData(index, value, Qt::EditRole);
343 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
344 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
345 QString value = lineEdit->text();
346 if (! vertexExists(model, index, value))
347 model->setData(index, value, Qt::EditRole);
348 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
349 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
350 model->setData(index, lineEdit->text(), Qt::EditRole);
354 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
355 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
357 editor->setGeometry(option.rect);
360 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
361 const QModelIndex &index, QString value) const
364 QModelIndex parent = index.parent();
365 int row = index.row();
366 int col = index.column();
368 if (parent.isValid() && !value.isEmpty()) {
369 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
371 if (col == ENF_VER_X_COLUMN) {
372 x = value.toDouble();
373 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
374 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
376 if (col == ENF_VER_Y_COLUMN) {
377 y = value.toDouble();
378 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
379 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
381 if (col == ENF_VER_Z_COLUMN) {
382 z = value.toDouble();
383 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
384 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
386 int nbChildren = model->rowCount(parent);
387 for (int i = 0 ; i < nbChildren ; i++) {
389 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
390 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
391 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
392 if ((childX == x) && (childY == y) && (childZ == z)) {
399 else if (col == ENF_VER_NAME_COLUMN) {
400 int nbChildren = model->rowCount(parent);
401 for (int i = 0 ; i < nbChildren ; i++) {
403 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
404 if (childName == value) {
417 // END EnforcedTreeWidgetDelegate
421 // BEGIN BLSURFPluginGUI_ObjectReferenceParamWdg
423 //================================================================================
425 // BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
426 // ( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection)
427 // : StdMeshersGUI_ObjectReferenceParamWdg(f, parent, multiSelection)
433 // BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
434 // ( MeshObjectType objType, QWidget* parent, bool multiSelection )
435 // : StdMeshersGUI_ObjectReferenceParamWdg( objType, parent, multiSelection )
440 // BLSURFPluginGUI_ObjectReferenceParamWdg::~BLSURFPluginGUI_ObjectReferenceParamWdg()
444 // mySelectionMgr->removeFilter( myFilter );
449 // void BLSURFPluginGUI_ObjectReferenceParamWdg::init()
451 // StdMeshersGUI_ObjectReferenceParamWdg::init();
452 // disconnect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection()));
453 // connect( mySelButton, SIGNAL(toggled(bool)), SLOT(setActivationStatus(bool)));
456 // void BLSURFPluginGUI_ObjectReferenceParamWdg::setActivationStatus(bool status)
459 // activateSelection();
461 // deactivateSelection();
464 // void BLSURFPluginGUI_ObjectReferenceParamWdg::activateSelectionOnly()
466 // if ( !mySelectionActivated && mySelectionMgr )
468 // mySelectionActivated = true;
469 // mySelectionMgr->clearFilters();
470 // if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
471 // aViewWindow->SetSelectionMode(ActorSelection);
473 // mySelectionMgr->installFilter( myFilter );
474 // connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
476 // emit selectionActivated();
479 // void BLSURFPluginGUI_ObjectReferenceParamWdg::deactivateSelectionOnly()
481 // mySelectionActivated = false;
482 // disconnect(mySelectionMgr, 0, this, 0 );
483 // mySelectionMgr->removeFilter( myFilter );
487 // END BLSURFPluginGUI_ObjectReferenceParamWdg
491 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
492 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
495 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
496 : SMESHGUI_GenericHypothesisCreator( theHypType )
498 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
499 this->mySMPMap.clear();
501 GeomToolSelected = NULL;
502 GeomToolSelected = getGeomSelectionTool();
504 aSel = GeomToolSelected->selectionMgr();
506 /* Initialize the Python interpreter */
507 if (! Py_IsInitialized())
508 throw ("Error: Python interpreter is not initialized");
509 PyGILState_STATE gstate;
510 gstate = PyGILState_Ensure();
513 main_mod = PyImport_AddModule("__main__");
516 main_dict = PyModule_GetDict(main_mod);
518 PyRun_SimpleString("from math import *");
519 PyGILState_Release(gstate);
523 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
528 * \brief {Get or create the geom selection tool for active study}
530 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool()
532 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
533 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
534 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
535 that->GeomToolSelected = new GeomSelectionTools(aStudy);
537 return that->GeomToolSelected;
540 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
542 return GeometryGUI::GetGeomGen();
546 bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
548 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
553 myOptionTable->setFocus();
554 QApplication::instance()->processEvents();
556 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
557 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
559 int row = 0, nbRows = myOptionTable->rowCount();
560 for ( ; row < nbRows; ++row )
562 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
563 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
564 if ( !value.isEmpty() ) {
566 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
568 catch ( const SALOME::SALOME_Exception& ex )
570 SUIT_MessageBox::critical( dlg(),
572 ex.details.text.in() );
577 h->SetOptionValues( myOptions ); // restore values
580 // SizeMap and attractors
583 mySizeMapTable->setFocus();
584 QApplication::instance()->processEvents();
586 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
587 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
589 // int row = 0, nbRows = mySizeMapTable->rowCount();
590 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
591 for ( ; row < nbRows; ++row )
593 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
594 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
595 if ( !sizeMap.isEmpty() ) {
596 if (that->sizeMapValidationFromRow(row))
599 const char* e = entry.toLatin1().constData();
600 const char* s = that->mySMPMap[entry].toLatin1().constData();
601 h->SetSizeMapEntry( e, s );
603 catch ( const SALOME::SALOME_Exception& ex )
605 SUIT_MessageBox::critical( dlg(),
607 ex.details.text.in() );
624 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
626 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
628 QFrame* fr = new QFrame( 0 );
629 // fr-> setMinimumSize(600,400);
630 QVBoxLayout* lay = new QVBoxLayout( fr );
631 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
633 lay->setSpacing( 0 );
636 QTabWidget* tab = new QTabWidget( fr );
637 tab->setTabShape( QTabWidget::Rounded );
638 tab->setTabPosition( QTabWidget::North );
639 lay->addWidget( tab );
642 myStdGroup = new QWidget();
643 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
644 aStdLayout->setSpacing( 6 );
645 aStdLayout->setMargin( 11 );
649 myName = new QLineEdit( myStdGroup );
651 myGradation = new SMESHGUI_SpinBox( myStdGroup );
652 myGradation->RangeStepAndValidator(1.1, 2.5, 0.1, "length_precision");
654 myPhysicalMesh = new QComboBox( myStdGroup );
655 QStringList physicalTypes;
656 physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ) << tr( "BLSURF_SIZE_MAP");
657 myPhysicalMesh->addItems( physicalTypes );
659 myPhySize = new SMESHGUI_SpinBox( myStdGroup );
660 myPhySize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
662 #ifdef WITH_SIZE_BOUNDARIES
663 myPhyMin = new SMESHGUI_SpinBox( myStdGroup );
664 myPhyMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
665 myPhyMin->setText("");
666 myPhyMax = new SMESHGUI_SpinBox( myStdGroup );
667 myPhyMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
668 myPhyMax->setText("");
671 myGeometricMesh = new QComboBox( myStdGroup );
673 types << tr( "BLSURF_DEFAULT_GEOM" ) << tr( "BLSURF_CUSTOM_GEOM" );
674 myGeometricMesh->addItems( types );
676 myAngleMeshS = new SMESHGUI_SpinBox( myStdGroup );
677 myAngleMeshS->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
679 myAngleMeshC = new SMESHGUI_SpinBox( myStdGroup );
680 myAngleMeshC->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
682 #ifdef WITH_SIZE_BOUNDARIES
683 myGeoMin = new SMESHGUI_SpinBox( myStdGroup );
684 myGeoMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
685 myGeoMin->setText("");
686 myGeoMax = new SMESHGUI_SpinBox( myStdGroup );
687 myGeoMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
688 myGeoMax->setText("");
690 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup );
691 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
693 // ADD WIDGETS (STANDARD TAB)
696 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
697 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
699 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 );
700 aStdLayout->addWidget( myGradation, row++, 1, 1, 1 );
701 aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ), row, 0, 1, 1 );
702 aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 );
703 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 );
704 aStdLayout->addWidget( myPhySize, row++, 1, 1, 1 );
705 #ifdef WITH_SIZE_BOUNDARIES
706 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ), row, 0, 1, 1 );
707 aStdLayout->addWidget( myPhyMin, row++, 1, 1, 1 );
708 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ), row, 0, 1, 1 );
709 aStdLayout->addWidget( myPhyMax, row++, 1, 1, 1 );
711 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ), row, 0, 1, 1 );
712 aStdLayout->addWidget( myGeometricMesh, row++, 1, 1, 1 );
713 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 0, 1, 1 );
714 aStdLayout->addWidget( myAngleMeshS, row++, 1, 1, 1 );
715 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 0, 1, 1 );
716 aStdLayout->addWidget( myAngleMeshC, row++, 1, 1, 1 );
717 #ifdef WITH_SIZE_BOUNDARIES
718 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ), row, 0, 1, 1 );
719 aStdLayout->addWidget( myGeoMin, row++, 1, 1, 1 );
720 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ), row, 0, 1, 1 );
721 aStdLayout->addWidget( myGeoMax, row++, 1, 1, 1 );
723 aStdLayout->addWidget( myAllowQuadrangles, row++, 0, 1, 1 );
724 aStdLayout->addWidget( myDecimesh, row++, 0, 1, 1 );
726 // advanced parameters
727 myAdvGroup = new QWidget();
728 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
729 anAdvLayout->setSpacing( 6 );
730 anAdvLayout->setMargin( 11 );
731 anAdvLayout->setRowStretch( 4, 5 );
732 anAdvLayout->setColumnStretch( 1, 5 );
734 myTopology = new QComboBox( myAdvGroup );
735 QStringList topologyTypes;
736 topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) << tr( "BLSURF_TOPOLOGY_PROCESS" ) << tr( "BLSURF_TOPOLOGY_PROCESS2" );
737 myTopology->addItems( topologyTypes );
739 myVerbosity = new QSpinBox( myAdvGroup );
740 myVerbosity->setMinimum( 0 );
741 myVerbosity->setMaximum( 100 );
742 myVerbosity->setSingleStep( 5 );
744 myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup );
746 headers << tr( "OPTION_ID_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" );
747 myOptionTable->setHorizontalHeaderLabels( headers );
748 myOptionTable->horizontalHeader()->hideSection( OPTION_ID_COLUMN );
749 myOptionTable->horizontalHeader()->setStretchLastSection(true);
750 myOptionTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
751 //myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );//////
752 //myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE );/////
753 myOptionTable->verticalHeader()->hide();
754 //myOptionTable->setSelectionBehavior( QAbstractItemView::SelectRows );
756 QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup );
757 addBtn->setMenu( new QMenu() );
758 QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup );
761 // ADD WIDGETS (ADVANCED TAB)
762 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 );
763 anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 );
764 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 1, 0, 1, 1 );
765 anAdvLayout->addWidget( myVerbosity, 1, 1, 1, 1 );
766 anAdvLayout->addWidget( myOptionTable, 2, 0, 3, 2 );
767 anAdvLayout->addWidget( addBtn, 2, 2, 1, 1 );
768 anAdvLayout->addWidget( rmBtn, 3, 2, 1, 1 );
771 // Size Maps parameters
773 mySmpGroup = new QWidget();
774 // mySmpGroup->setMinimumWidth(500);
777 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
780 mySizeMapTable = new QTreeWidget( mySmpGroup );
781 mySizeMapTable ->setMinimumWidth(200);
782 QStringList sizeMapHeaders;
783 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
784 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
785 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
786 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
787 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
788 mySizeMapTable->setAlternatingRowColors(true);
791 smpTab = new QTabWidget( mySmpGroup );
792 smpTab->setTabShape( QTabWidget::Rounded );
793 smpTab->setTabPosition( QTabWidget::South );
794 lay->addWidget( smpTab );
796 // Filters of selection
797 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
799 SM_ShapeTypes.Add( TopAbs_VERTEX );
800 SM_ShapeTypes.Add( TopAbs_EDGE );
801 SM_ShapeTypes.Add( TopAbs_FACE );
803 ATT_ShapeTypes.Add( TopAbs_VERTEX );
804 ATT_ShapeTypes.Add( TopAbs_EDGE );
805 ATT_ShapeTypes.Add( TopAbs_WIRE );
806 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
808 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
809 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
810 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
812 // Standard size map tab
813 mySmpStdGroup = new QWidget();
814 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
815 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false);
816 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
817 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
818 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
819 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
822 myAttractorGroup = new QWidget();
823 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
824 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false,/*stretch=*/false);
825 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
826 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
827 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
828 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
829 QFrame* attLine = new QFrame(myAttractorGroup);
830 attLine->setFrameShape(QFrame::HLine);
831 attLine->setFrameShadow(QFrame::Sunken);
832 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false);
833 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
834 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
835 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
836 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
837 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
838 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
839 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
840 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
841 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
842 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
844 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
845 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
849 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
850 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
851 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
852 modifyMapButton->setEnabled(false);
855 myAttSelWdg->setEnabled(false);
856 myAttSizeSpin->setEnabled(false);
857 myAttSizeLabel->setEnabled(false);
858 myAttDistSpin->setEnabled(false);
859 myAttDistLabel->setEnabled(false);
860 myAttDistSpin2->setEnabled(false);
861 myAttDistLabel2->setEnabled(false);
862 myAttDistSpin->setValue(0.);
863 myAttDistSpin2->setValue(0.);
864 myAttSizeSpin->setValue(0.);
865 mySmpSizeSpin->setValue(0.);
868 // ADD WIDGETS (SIZEMAP TAB)
869 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
870 anSmpLayout->setColumnStretch(0, 1);
871 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
872 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
873 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
874 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
875 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
876 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
879 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
880 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
881 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
882 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
885 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
886 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
887 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
888 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
889 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
890 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
891 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
892 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
893 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
894 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
895 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
896 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
898 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
899 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
901 smpTab->setCurrentIndex( SMP_STD_TAB );
903 // Enforced vertices parameters
904 myEnfGroup = new QWidget();
905 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
907 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
908 // anEnfLayout->addWidget(myEnforcedVertexWidget);
909 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
910 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
912 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
913 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
914 myEnforcedTreeWidget->setSortingEnabled(true);
915 QStringList enforcedHeaders;
916 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
917 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
918 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
920 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
921 myEnforcedTreeWidget->setAlternatingRowColors(true);
922 myEnforcedTreeWidget->setUniformRowHeights(true);
923 myEnforcedTreeWidget->setAnimated(true);
924 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
925 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
926 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
927 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
928 myEnforcedTreeWidget->resizeColumnToContents(column);
930 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
931 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
932 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
934 // FACE AND VERTEX SELECTION
935 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
936 shapeTypes1.Add( TopAbs_FACE );
937 shapeTypes1.Add( TopAbs_COMPOUND );
938 shapeTypes2.Add( TopAbs_VERTEX );
939 shapeTypes2.Add( TopAbs_COMPOUND );
941 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
942 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true, /*stretch=*/false);
943 myEnfFaceWdg->SetDefaultText("Select Faces", "QLineEdit { color: grey }");
945 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
946 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
947 myEnfVertexWdg->SetDefaultText("Select Vertices", "QLineEdit { color: grey }");
949 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
951 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
952 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
953 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
955 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
956 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
957 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
959 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
960 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
961 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
963 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
964 myGroupName = new QLineEdit(myEnfGroup);
966 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
967 // QFrame *line = new QFrame(myEnfGroup);
968 // line->setFrameShape(QFrame::HLine);
969 // line->setFrameShadow(QFrame::Sunken);
970 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
972 // CheckBox for groups generation
973 makeGroupsCheck = new QGroupBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
974 makeGroupsCheck->setCheckable(true);
975 makeGroupsCheck->setChecked(false);
976 QGridLayout* aGroupLayout = new QGridLayout(makeGroupsCheck);
977 myGlobalGroupName = new QLineEdit(makeGroupsCheck);
978 aGroupLayout->addWidget(myGlobalGroupName);
980 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES+1, 1);
981 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
982 // FACE AND VERTEX SELECTION
983 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
984 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
986 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
987 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
988 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
989 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
990 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
991 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
992 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
993 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
994 anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
995 anEnfLayout2->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 0, 1, 2);
996 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 0, 1, 2);
997 // anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 0, 1, 2);
998 anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
999 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
1002 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1003 tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1004 tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) );
1005 tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1007 tab->setCurrentIndex( STD_TAB );
1010 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
1011 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
1012 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1013 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1014 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1016 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1017 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1018 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1019 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1020 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1021 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1022 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1023 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1024 // connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(deactivateSelection(QWidget*, QWidget*)));
1025 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
1026 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
1027 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1028 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1029 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1031 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1032 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1033 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1034 connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1035 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1036 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1037 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1038 connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1039 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1040 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1041 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1042 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onSmpTabChanged( int ) ) );
1044 // Enforced vertices
1045 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1046 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1047 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1048 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1049 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1050 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1055 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1056 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1058 void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1060 if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1061 || (now = myGroupName) || (now = makeGroupsCheck) || (now = myEnforcedTreeWidget)) {
1062 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1063 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1064 myEnfFaceWdg->deactivateSelection();
1065 myEnfVertexWdg->deactivateSelection();
1070 * This method resets the content of the X, Y, Z and GroupNAme widgets;
1072 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1074 myXCoord->setCleared(true);
1075 myYCoord->setCleared(true);
1076 myZCoord->setCleared(true);
1077 myXCoord->setText("");
1078 myYCoord->setText("");
1079 myZCoord->setText("");
1080 myGroupName->setText("");
1083 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1084 This method updates the tooltip of a modified item. The QLineEdit widgets content
1085 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1087 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1088 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1089 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1090 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1091 QVariant y = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1092 QVariant z = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1093 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1094 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1095 QTreeWidgetItem* parent = item->parent();
1097 clearEnforcedVertexWidgets();
1099 if (parent && (!x.isNull() || !entry.isNull())) {
1100 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1101 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1102 if (entry.isNull()) {
1103 toolTip += QString("(") + x.toString();
1104 toolTip += QString(", ") + y.toString();
1105 toolTip += QString(", ") + z.toString();
1106 toolTip += QString(")");
1109 if (!groupName.isEmpty())
1110 toolTip += QString(" [") + groupName + QString("]");
1112 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1115 myXCoord->SetValue(x.toDouble());
1116 myYCoord->SetValue(y.toDouble());
1117 myZCoord->SetValue(z.toDouble());
1120 if (!groupName.isEmpty())
1121 myGroupName->setText(groupName);
1125 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1126 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1127 clearEnforcedVertexWidgets();
1128 if (nbSelEnfVertex == 1)
1130 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1133 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1134 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1135 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1136 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1137 if (CORBA::is_nil(measureOp))
1140 CORBA::Double x,y,z;
1141 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1142 if ( measureOp->IsDone() )
1144 myXCoord->SetValue(x);
1145 myYCoord->SetValue(y);
1146 myZCoord->SetValue(z);
1152 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1153 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1154 of the enforced vertex clicked in the tree widget.
1156 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1157 clearEnforcedVertexWidgets();
1158 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1159 if (! items.isEmpty() && items.size() == 1) {
1160 QTreeWidgetItem *item = items[0];
1161 // for (int i=0 ; i < items.size() ; i++) {
1163 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1164 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1165 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1166 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1167 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1168 if (!x.isNull()/* && entry.isNull()*/) {
1169 myXCoord->SetValue(x.toDouble());
1170 myYCoord->SetValue(y.toDouble());
1171 myZCoord->SetValue(z.toDouble());
1174 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1175 myGroupName->setText(group.toString());
1180 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1181 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1183 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEntry, std::string theFaceName,
1184 double x, double y, double z, std::string vertexName, std::string geomEntry, std::string groupName) {
1185 // Find theFaceEntry item
1186 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1187 QTreeWidgetItem* theItem;
1188 if (theItemList.empty()) {
1189 theItem = new QTreeWidgetItem();
1190 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1191 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1192 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1193 myEnforcedTreeWidget->addTopLevelItem(theItem);
1196 theItem = theItemList[0];
1199 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1200 bool okToCreate = true;
1202 const int nbVert = theItem->childCount();
1203 // MESSAGE("Number of child rows: " << nbVert);
1205 double childValueX,childValueY,childValueZ;
1206 QString childEntry, childGroupName;
1207 QTreeWidgetItem* child;
1208 for (int row = 0;row<nbVert;row++) {
1209 child = theItem->child(row);
1210 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1211 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1212 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1213 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1214 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1215 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1216 // update group name
1217 if (childGroupName.toStdString() != groupName) {
1218 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1219 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1227 if (geomEntry.empty()) {
1228 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1231 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1236 if (geomEntry.empty()) {
1237 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1240 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1243 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1244 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1245 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1246 QSize iconSize = iconSelect.size()*0.7;
1248 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1249 QString myVertexName;
1251 while(indexRef != vertexIndex) {
1252 indexRef = vertexIndex;
1253 if (vertexName.empty())
1254 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1256 myVertexName = QString(vertexName.c_str());
1258 for (int row = 0;row<nbVert;row++) {
1259 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1260 if (myVertexName == name) {
1266 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1267 if (geomEntry.empty()) {
1268 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1269 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1270 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1273 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1274 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1276 if (groupName != "")
1277 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1279 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1280 if (geomEntry.empty()) {
1281 toolTip += QString(" (%1, ").arg(x);
1282 toolTip += QString("%1, ").arg(y);
1283 toolTip += QString("%1)").arg(z);
1285 if (groupName != "")
1286 toolTip += QString(" [%1]").arg(groupName.c_str());
1288 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1289 theItem->setExpanded(true);
1290 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1293 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1294 This method is called when a item is added into the enforced vertices tree widget
1296 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1297 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1299 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1301 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1302 myEnfFaceWdg->deactivateSelection();
1303 myEnfVertexWdg->deactivateSelection();
1305 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1306 myEnforcedTreeWidget->resizeColumnToContents(column);
1309 int selEnfFace = myEnfFaceWdg->NbObjects();
1310 int selEnfVertex = myEnfVertexWdg->NbObjects();
1311 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1313 if (selEnfFace == 0)
1316 if ((selEnfVertex == 0) && coordsEmpty)
1319 string entry, shapeName;
1321 for (int i = 0 ; i < selEnfFace ; i++) {
1322 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1323 entry = myEnfFace->GetStudyEntry();
1324 shapeName = myEnfFace->GetName();
1326 std::string groupName = myGroupName->text().toStdString();
1327 if (makeGroupsCheck->isChecked())
1328 groupName = myGlobalGroupName->text().toStdString();
1330 if (boost::trim_copy(groupName).empty())
1333 if (selEnfVertex <= 1)
1336 x = myXCoord->GetValue();
1337 y = myYCoord->GetValue();
1338 z = myZCoord->GetValue();
1339 if (selEnfVertex == 1) {
1340 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1341 addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1344 addEnforcedVertex(entry, shapeName, x, y, z, "", "", groupName);
1348 if ( CORBA::is_nil(getGeomEngine()))
1351 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1352 if (CORBA::is_nil(measureOp))
1355 CORBA::Double x,y,z;
1357 for (int j = 0 ; j < selEnfVertex ; j++)
1359 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1360 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1361 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1362 if ( measureOp->IsDone() )
1363 addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1364 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1365 addEnforcedVertex(entry, shapeName, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1371 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1372 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1374 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1375 myEnforcedTreeWidget->resizeColumnToContents(column);
1377 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
1378 myPhysicalMesh->setCurrentIndex( SizeMap );
1379 onPhysicalMeshChanged();
1383 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1384 This method is called when a item is removed from the enforced vertices tree widget
1386 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1387 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1388 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1389 QList<QTreeWidgetItem *> selectedVertices;
1390 QSet<QTreeWidgetItem *> selectedEntries;
1391 QTreeWidgetItem* item;
1393 foreach( item, selectedItems ) {
1394 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1395 if (! value.isNull())
1396 selectedVertices.append(item);
1398 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1399 if (! value.isNull())
1400 selectedVertices.append(item);
1402 selectedEntries.insert(item);
1406 foreach(item,selectedVertices) {
1407 QTreeWidgetItem* parent = item->parent();
1408 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1409 parent->removeChild(item);
1411 if (parent->childCount() == 0) {
1412 if (selectedEntries.contains(parent))
1413 selectedEntries.remove(parent);
1418 foreach(item,selectedEntries) {
1419 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1423 myEnforcedTreeWidget->selectionModel()->clearSelection();
1426 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1427 This method updates the GUI widgets with the hypothesis data
1429 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1431 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1432 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1434 BlsurfHypothesisData data;
1435 that->readParamsFromHypo( data );
1438 myName->setText( data.myName );
1439 QFontMetrics metrics( myName->font() );
1440 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1442 myTopology->setCurrentIndex( data.myTopology );
1443 myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1444 myPhySize->SetValue( data.myPhySize );
1445 #ifdef WITH_SIZE_BOUNDARIES
1446 MESSAGE("data.myPhyMin: "<<data.myPhyMin)
1447 if (data.myPhyMin < 0)
1448 myPhyMin->setText("");
1450 myPhyMin->SetValue( data.myPhyMin );
1451 MESSAGE("data.myPhyMax: "<<data.myPhyMax)
1452 if (data.myPhyMax < 0)
1453 myPhyMax->setText("");
1455 myPhyMax->SetValue( data.myPhyMax );
1456 MESSAGE("data.myGeoMin: "<<data.myGeoMin)
1457 if (data.myGeoMin < 0)
1458 myGeoMin->setText("");
1460 myGeoMin->SetValue( data.myGeoMin );
1461 MESSAGE("data.myGeoMax: "<<data.myGeoMax)
1462 if (data.myGeoMax < 0)
1463 myGeoMax->setText("");
1465 myGeoMax->SetValue( data.myGeoMax );
1467 myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1468 // myAngleMeshS->setValue( data.myAngleMeshS );
1469 // myAngleMeshC->setValue( data.myAngleMeshC );
1470 // myGradation->setValue( data.myGradation );
1471 myAngleMeshS->SetValue( data.myAngleMeshS );
1472 myAngleMeshC->SetValue( data.myAngleMeshC );
1473 myGradation->SetValue( data.myGradation );
1474 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1475 myDecimesh->setChecked( data.myDecimesh );
1476 myVerbosity->setValue( data.myVerbosity );
1478 if ( myOptions.operator->() ) {
1479 // MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
1480 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1481 QString option = that->myOptions[i].in();
1482 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1483 if ( name_value.count() > 1 ) {
1484 QString idStr = QString("%1").arg( i );
1485 int row = myOptionTable->rowCount();
1486 myOptionTable->setRowCount( row+1 );
1487 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1488 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1489 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1490 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1491 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1492 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1493 Qt::ItemIsEditable |
1494 Qt::ItemIsEnabled );
1498 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1501 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1502 QMapIterator<QString, QString> i(that->mySMPMap);
1503 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1504 while (i.hasNext()) {
1506 const QString entry = i.key();
1507 const QString sizeMap = i.value();
1508 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1509 int row = mySizeMapTable->topLevelItemCount();
1510 QTreeWidgetItem* item = new QTreeWidgetItem();
1511 mySizeMapTable->addTopLevelItem( item );
1512 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1513 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1514 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1515 if (that->myATTMap.contains(entry)){
1516 const QString attEntry = that->myATTMap[entry];
1517 std::string attName = myGeomToolSelected->getNameFromEntry(attEntry.toStdString());
1518 QTreeWidgetItem* child = new QTreeWidgetItem();
1519 item->addChild( child );
1520 item->setExpanded(true);
1521 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1522 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attEntry ) );
1523 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString( attName ) ) );
1525 if (that->myAttDistMap[entry] > std::numeric_limits<double>::epsilon()){
1526 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Attractor" ) ) );
1529 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Constant Size" ) ) );
1534 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1537 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1538 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1539 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1541 // Enforced vertices
1542 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1543 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1544 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1545 TEntry entry = (*evmIt).first;
1546 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1547 MESSAGE("Face entry: " << entry);
1548 MESSAGE("Face name: " << shapeName);
1550 TEnfVertexList evs = (*evmIt).second;
1552 // evs = (*evmIt).second;
1555 // MESSAGE("evs = (*evmIt).second: FAIL");
1559 TEnfVertexList::const_iterator evsIt = evs.begin();
1560 TEnfVertex *enfVertex;
1561 for ( ; evsIt != evs.end() ; ++evsIt) {
1562 enfVertex = (*evsIt);
1563 MESSAGE("Name: " << enfVertex->name);
1565 if (enfVertex->coords.size()) {
1566 x = enfVertex->coords[0];
1567 y = enfVertex->coords[1];
1568 z = enfVertex->coords[2];
1570 that->addEnforcedVertex(entry, shapeName, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1574 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1575 myEnforcedTreeWidget->resizeColumnToContents(column);
1578 that->onPhysicalMeshChanged();
1579 that->onGeometricMeshChanged();
1582 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1583 This method updates the hypothesis data with the GUI widgets content.
1585 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1587 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1589 BlsurfHypothesisData data;
1590 QString guiHyp = that->readParamsFromWidgets( data );
1591 that->storeParamsToHypo( data );
1596 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1597 Updates the hypothesis data from hypothesis values.
1599 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
1601 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
1602 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1603 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1605 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1606 h_data.myName = isCreation() && data ? hypName() : "";
1608 h_data.myTopology = (int) h->GetTopology();
1609 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
1610 h_data.myPhySize = h->GetPhySize();
1611 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
1612 h_data.myAngleMeshS = h->GetAngleMeshS();
1613 h_data.myAngleMeshC = h->GetAngleMeshC();
1614 h_data.myGradation = h->GetGradation();
1615 h_data.myAllowQuadrangles = h->GetQuadAllowed();
1616 h_data.myDecimesh = h->GetDecimesh();
1617 h_data.myVerbosity = h->GetVerbosity();
1619 #ifdef WITH_SIZE_BOUNDARIES
1620 double PhyMin = h->GetPhyMin();
1621 double PhyMax = h->GetPhyMax();
1622 double GeoMin = h->GetGeoMin();
1623 double GeoMax = h->GetGeoMax();
1624 // if ( PhyMin > 0 )
1625 // h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString("");
1626 // h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString("");
1627 // h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString("");
1628 // h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString("");
1629 h_data.myPhyMin = PhyMin > 0 ? PhyMin : -1.0;
1630 h_data.myPhyMax = PhyMax > 0 ? PhyMax : -1.0;
1631 h_data.myGeoMin = GeoMin > 0 ? GeoMin : -1.0;
1632 h_data.myGeoMax = GeoMax > 0 ? GeoMax : -1.0;
1635 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1636 that->myOptions = h->GetOptionValues();
1638 that->mySMPMap.clear();
1639 that->myATTMap.clear();
1640 that->myAttDistMap.clear();
1641 that->myDistMap.clear();
1643 // classic size maps
1644 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
1645 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
1646 QString fullSizeMaps;
1647 QStringList fullSizeMapList;
1648 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1649 for ( int i = 0;i<mySizeMaps->length(); ++i ) {
1650 fullSizeMaps = mySizeMaps[i].in();
1651 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
1652 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
1653 if ( fullSizeMapList.count() > 1 ) {
1654 string fullSizeMap = fullSizeMapList[1].toStdString();
1655 int pos = fullSizeMap.find("return")+7;
1656 // MESSAGE("pos:" << pos);
1659 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
1664 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
1665 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
1666 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
1667 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
1673 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
1674 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
1676 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
1677 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
1678 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
1679 if ( fullCustomSizeMapList.count() > 1 ) {
1680 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
1681 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
1682 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
1683 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
1688 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
1689 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
1691 for ( int i = 0;i<allMyAttractors->length(); ++i ) {
1692 QString myAttractors = allMyAttractors[i].in();
1693 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
1694 if ( myAttractorList.count() > 1 ) {
1695 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
1696 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
1697 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
1698 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
1702 // attractor new version
1703 MESSAGE("retriveParams, Attractors")
1704 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
1705 for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
1706 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
1707 QString faceEntry = myAttractorParams.faceEntry.in();
1708 QString attEntry = myAttractorParams.attEntry.in();
1709 MESSAGE("attEntry = "<<attEntry.toStdString())
1710 double startSize = myAttractorParams.startSize;
1711 double endSize = myAttractorParams.endSize;
1712 double infDist = myAttractorParams.infDist;
1713 double constDist = myAttractorParams.constDist;
1714 that->mySMPMap[faceEntry] = QString::number( startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
1715 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
1716 that->myATTMap[faceEntry] = attEntry;
1717 that->myAttDistMap[faceEntry] = infDist;
1718 that->myDistMap[faceEntry] = constDist;
1721 // Enforced vertices
1722 h_data.enfVertexList.clear();
1723 h_data.faceEntryEnfVertexListMap.clear();
1725 h_data.groupNameEnfVertexListMap.clear();
1728 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
1729 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
1731 for ( int i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
1732 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
1733 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
1734 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
1735 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
1737 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
1739 for (int j=0 ; j<vertexList.length(); ++j) {
1740 TEnfVertex *enfVertex = new TEnfVertex();
1742 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
1743 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
1744 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
1745 for (int k=0 ; k< vertexList[j].coords.length();k++)
1746 enfVertex->coords.push_back(vertexList[j].coords[k]);
1748 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
1751 if (groupName != "") {
1752 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
1756 // h_data.enfVertMap[entry] = evs;
1757 // h_data.entryCoordsListMap[entry] = coordsList;
1759 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
1760 h_data.faceEntryEnfVertexListMap.erase(entry);
1767 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
1768 Saves the hypothesis data to hypothesis values.
1770 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
1772 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
1773 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1774 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
1780 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1782 if ( h->GetTopology() != h_data.myTopology ) // avoid duplication of DumpPython commands
1783 h->SetTopology( (int) h_data.myTopology );
1784 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh )
1785 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
1786 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
1787 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
1788 if ( h->GetGradation() != h_data.myGradation )
1789 h->SetGradation( h_data.myGradation );
1790 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
1791 h->SetQuadAllowed( h_data.myAllowQuadrangles );
1792 if ( h->GetDecimesh() != h_data.myDecimesh )
1793 h->SetDecimesh( h_data.myDecimesh );
1794 if ( h->GetVerbosity() != h_data.myVerbosity )
1795 h->SetVerbosity( h_data.myVerbosity );
1797 if( ((int) h_data.myPhysicalMesh == PhysicalUserDefined)||((int) h_data.myPhysicalMesh == SizeMap) ) {
1798 if ( h->GetPhySize() != h_data.myPhySize )
1799 h->SetPhySize( h_data.myPhySize );
1801 if( (int) h_data.myGeometricMesh == UserDefined ) {
1802 if ( h->GetAngleMeshS() != h_data.myAngleMeshS )
1803 h->SetAngleMeshS( h_data.myAngleMeshS );
1804 if ( h->GetAngleMeshC() != h_data.myAngleMeshC )
1805 h->SetAngleMeshC( h_data.myAngleMeshC );
1807 #ifdef WITH_SIZE_BOUNDARIES
1808 if (h_data.myPhyMin > 0)
1809 h->SetPhyMin( h_data.myPhyMin );
1810 if (h_data.myPhyMax > 0)
1811 h->SetPhyMax( h_data.myPhyMax );
1812 if (h_data.myGeoMin > 0)
1813 h->SetGeoMin( h_data.myGeoMin );
1814 if (h_data.myGeoMax > 0)
1815 h->SetGeoMax( h_data.myGeoMax );
1818 h->SetOptionValues( myOptions ); // is set in checkParams()
1820 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1821 QMapIterator<QString,QString> i(that->mySMPMap);
1822 while (i.hasNext()) {
1824 const QString entry = i.key();
1825 const QString sizeMap = i.value();
1827 if (sizeMap == "__TO_DELETE__") {
1828 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
1829 h->UnsetEntry(entry.toLatin1().constData());
1831 else if (sizeMap.startsWith("ATTRACTOR")) {
1832 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1833 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
1835 else if (sizeMap.startsWith("def")) {
1836 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1837 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
1840 if (!myATTMap[entry].isEmpty()){
1841 QString att_entry = myATTMap[entry];
1842 double infDist = myAttDistMap[entry];
1843 double constDist = myDistMap[entry];
1844 double phySize = h->GetPhySize();
1845 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1846 h->SetClassAttractorEntry( entry.toLatin1().constData(), att_entry.toLatin1().constData(), sizeMap.toDouble() , phySize, infDist, constDist );
1847 QApplication::restoreOverrideCursor();
1850 QString fullSizeMap;
1851 fullSizeMap = QString("");
1852 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
1853 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
1854 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
1855 fullSizeMap = QString("def f(t): return ") + sizeMap;
1856 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
1857 fullSizeMap = QString("def f(): return ") + sizeMap;
1858 // MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
1859 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
1864 // Enforced vertices
1868 std::string enfName;
1870 std::string groupName = "";
1873 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
1875 BLSURFPlugin::TFaceEntryEnfVertexListMap_var allEnforcedVerticesByFace = h->GetAllEnforcedVerticesByFace();
1876 hypNbVertex = allEnforcedVerticesByFace->length();
1879 // All enforced vertices were deleted
1880 if (evmIt == h_data.faceEntryEnfVertexListMap.end() && hypNbVertex!=0) {
1881 h->ClearAllEnforcedVertices();
1885 // All enforced vertices for a specific entry were deleted
1886 for (int i=0 ; i<hypNbVertex; i++) {
1887 BLSURFPlugin::TFaceEntryEnfVertexListMapElement el = allEnforcedVerticesByFace[i];
1888 TEnfName entry = el.faceEntry.in();
1889 if (h_data.faceEntryEnfVertexListMap.find(entry) == h_data.faceEntryEnfVertexListMap.end()) {
1890 MESSAGE("Remove all enforced vertices for entry " << entry);
1891 h->UnsetEnforcedVerticesEntry(entry.c_str());
1895 // One or several enforced vertices are added or removed for a specific entry
1896 TEnfVertexList enfVertexFromHyp;
1897 BLSURFPlugin::TEnfVertexList_var hypEnfVertexList;
1900 TEnfVertexList::const_iterator evsIt, enfVertexToRemove;
1901 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1902 faceEntry = evmIt->first;
1903 evs = evmIt->second;
1904 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
1905 evsIt = evs.begin();
1907 hypEnfVertexList = h->GetEnforcedVerticesEntry(faceEntry.c_str());
1908 hypNbVertex = hypEnfVertexList->length();
1909 MESSAGE("Number of enforced vertices from hypothesis: " << hypNbVertex);
1910 enfVertexFromHyp.clear();
1911 for (int i =0 ; i<hypNbVertex ; i++) {
1912 TEnfVertex *_enfVertex = new TEnfVertex();
1913 _enfVertex->name = string("");
1914 _enfVertex->name = CORBA::string_dup(hypEnfVertexList[i].name.in());
1915 _enfVertex->geomEntry = string("");
1916 _enfVertex->geomEntry = CORBA::string_dup(hypEnfVertexList[i].geomEntry.in());
1917 _enfVertex->grpName = string("");
1918 _enfVertex->grpName = CORBA::string_dup(hypEnfVertexList[i].grpName.in());
1919 for (int j=0 ; j< hypEnfVertexList[i].coords.length() ; j++)
1920 _enfVertex->coords.push_back(hypEnfVertexList[i].coords[j]);
1921 enfVertexFromHyp.insert(_enfVertex);
1922 MESSAGE("From hyp: enf vertex " << _enfVertex->name);
1923 // MESSAGE("From hyp: enf. vertex at " << _coords[0]<<", "<<_coords[1]<<", "<<_coords[2]);
1926 // TEnfVertex *enfVertex;
1927 for ( ; evsIt != evs.end() ; ++evsIt) {
1929 // enfVertex = (*evsIt);
1930 if ((*evsIt)->coords.size()) {
1931 x = (*evsIt)->coords[0];
1932 y = (*evsIt)->coords[1];
1933 z = (*evsIt)->coords[2];
1935 ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
1936 enfVertexFromHyp.erase((*evsIt));
1938 // for (enfVertexToRemove = enfVertexFromHyp.begin() ; enfVertexToRemove != enfVertexFromHyp.end() ; ++enfVertexToRemove) {
1939 // if (!TEnfVertexGUICmp(&enfVertex, &(*enfVertexToRemove))) {
1940 // MESSAGE("Enf vertex " << enfVertex.name << " must not be deleted")
1941 // enfVertexFromHyp.erase(enfVertexToRemove);
1946 // Remove old vertices
1947 enfVertexToRemove = enfVertexFromHyp.begin();
1948 for ( ; enfVertexToRemove!=enfVertexFromHyp.end() ; ++enfVertexToRemove) {
1949 // enfVertex = (*enfVertexToRemove);
1950 if (h_data.enfVertexList.find((*enfVertexToRemove)) != h_data.enfVertexList.end()) {
1952 // for ( evsIt=h_data.enfVertexList.begin();evsIt!=h_data.enfVertexList.end();evsIt++) {
1953 // if (TEnfVertexGUICmp(&(*evsIt),&enfVertex)) {
1954 MESSAGE("Remove enf vertex " << (*enfVertexToRemove)->name);
1955 if ((*enfVertexToRemove)->coords.size()) {
1956 x = (*enfVertexToRemove)->coords[0];
1957 y = (*enfVertexToRemove)->coords[1];
1958 z = (*enfVertexToRemove)->coords[2];
1960 ret = h->UnsetEnforcedVertexEntry(faceEntry.c_str(), x, y, z, (*enfVertexToRemove)->geomEntry.c_str());
1970 catch(const std::exception& ex) {
1971 std::cout << "Exception: " << ex.what() << std::endl;
1974 // catch(const SALOME::SALOME_Exception& ex)
1977 // // SalomeApp_Tools::QtCatchCorbaException(ex);
1983 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
1984 Stores the widgets content to the hypothesis data.
1986 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
1988 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
1989 h_data.myName = myName ? myName->text() : "";
1990 h_data.myTopology = myTopology->currentIndex();
1991 h_data.myPhysicalMesh = myPhysicalMesh->currentIndex();
1992 h_data.myPhySize = myPhySize->GetValue();
1993 #ifdef WITH_SIZE_BOUNDARIES
1994 h_data.myPhyMin = myPhyMin->GetValue();
1995 h_data.myPhyMax = myPhyMax->GetValue();
1996 h_data.myGeoMin = myGeoMin->GetValue();
1997 h_data.myGeoMax = myGeoMax->GetValue();
1999 h_data.myGeometricMesh = myGeometricMesh->currentIndex();
2000 h_data.myAngleMeshS = myAngleMeshS->GetValue();
2001 h_data.myAngleMeshC = myAngleMeshC->GetValue();
2002 h_data.myGradation = myGradation->GetValue();
2003 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
2004 h_data.myDecimesh = myDecimesh->isChecked();
2005 h_data.myVerbosity = myVerbosity->value();
2008 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2009 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2010 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2011 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2012 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; ";
2013 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2014 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2015 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; ";
2016 #ifdef WITH_SIZE_BOUNDARIES
2017 guiHyp += "hphymin = " + QString::number( h_data.myPhyMin ) + "; ";
2018 guiHyp += "hphymax = " + QString::number( h_data.myPhyMax ) + "; ";
2019 guiHyp += "hgeomin = " + QString::number( h_data.myGeoMin ) + "; ";
2020 guiHyp += "hgeomax = " + QString::number( h_data.myGeoMax ) + "; ";
2023 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2024 int row = 0, nbRows = myOptionTable->rowCount();
2025 for ( ; row < nbRows; ++row )
2027 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2028 if ( id >= 0 && id < myOptions->length() )
2030 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
2031 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
2032 if ( value.isNull() )
2034 that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
2036 guiHyp += name + " = " + value + "; ";
2041 row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2042 for ( ; row < nbRows; ++row )
2044 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2045 if ( that->mySMPMap.contains(entry) )
2046 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2049 // Enforced vertices
2050 h_data.enfVertexList.clear();
2051 h_data.faceEntryEnfVertexListMap.clear();
2053 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2054 int nbEnforcedVertices = 0;
2055 std::string groupName = "";
2056 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
2057 for (int i=0 ; i<nbEnforcedShapes ; i++) {
2058 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
2060 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2061 nbEnforcedVertices = shapeItem->childCount();
2062 if (nbEnforcedVertices >0) {
2063 double childValueX,childValueY,childValueZ;
2064 std::string childName, vertexEntry;
2065 QTreeWidgetItem* child;
2068 for (row = 0;row<nbEnforcedVertices;row++) {
2069 child = shapeItem->child(row);
2070 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2071 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2072 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2073 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2074 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2075 if (makeGroupsCheck->isChecked())
2076 groupName = myGlobalGroupName->text().toStdString();
2078 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2080 TEnfVertex *enfVertex = new TEnfVertex();
2081 enfVertex->name = childName;
2082 if (vertexEntry.empty()) {
2083 enfVertex->coords.push_back(childValueX);
2084 enfVertex->coords.push_back(childValueY);
2085 enfVertex->coords.push_back(childValueZ);
2088 enfVertex->geomEntry = vertexEntry;
2089 enfVertex->grpName = groupName;
2090 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2091 // if (it == h_data.enfVertexList.end())
2092 h_data.enfVertexList.insert(enfVertex);
2093 evs.insert(enfVertex);
2095 if (groupName != "")
2096 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2099 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2104 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2108 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
2109 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged");
2110 bool isPhysicalUserDefined = (myPhysicalMesh->currentIndex() == PhysicalUserDefined);
2111 bool isSizeMap = (myPhysicalMesh->currentIndex() == SizeMap);
2112 bool isCustom = (isPhysicalUserDefined || isSizeMap) ;
2113 bool geomIsCustom = (myGeometricMesh->currentIndex() == UserDefined);
2115 myGradation->setEnabled(!isPhysicalUserDefined || geomIsCustom);
2116 myPhySize->setEnabled(isCustom);
2117 myPhyMax->setEnabled(isCustom);
2118 myPhyMin->setEnabled(isCustom);
2120 if ( !myGradation->isEnabled())
2121 myGradation->SetValue( 1.1 );
2124 if ( myGeometricMesh->currentIndex() == DefaultGeom ) {
2125 myGeometricMesh->setCurrentIndex( UserDefined );
2126 onGeometricMeshChanged();
2131 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
2132 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged");
2133 bool isCustom = (myGeometricMesh->currentIndex() == UserDefined);
2134 bool phyIsSizemap = (myPhysicalMesh->currentIndex() == SizeMap);
2136 myAngleMeshS->setEnabled(isCustom);
2137 myAngleMeshC->setEnabled(isCustom);
2138 myGradation->setEnabled(isCustom || phyIsSizemap);
2139 myGeoMax->setEnabled(isCustom);
2140 myGeoMin->setEnabled(isCustom);
2142 if ( !myGradation->isEnabled())
2143 myGradation->SetValue( 1.1 );
2146 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
2147 if ( myPhysicalMesh->currentIndex() == DefaultSize ) {
2148 myPhysicalMesh->setCurrentIndex( PhysicalUserDefined );
2149 onPhysicalMeshChanged();
2154 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2156 QMenu* menu = (QMenu*)sender();
2157 // fill popup with option names
2159 if ( myOptions.operator->() ) {
2160 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
2161 QString name_value = myOptions[i].in();
2162 QString name = name_value.split( ":", QString::KeepEmptyParts )[0];
2163 menu->addAction( name );
2168 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
2170 myOptionTable->setFocus();
2171 QMenu* menu = (QMenu*)( a->parent() );
2173 int idx = menu->actions().indexOf( a );
2174 QString idStr = QString("%1").arg( idx );
2175 QString option = myOptions[idx].in();
2176 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
2178 // look for a row with optionName
2179 int row = 0, nbRows = myOptionTable->rowCount();
2180 for ( ; row < nbRows; ++row )
2181 if ( myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
2183 // add a row if not found
2184 if ( row == nbRows ) {
2185 myOptionTable->setRowCount( row+1 );
2186 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
2187 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
2188 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
2189 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
2190 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
2191 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
2192 Qt::ItemIsEditable |
2193 Qt::ItemIsEnabled );
2194 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2196 myOptionTable->clearSelection();
2197 myOptionTable->scrollToItem( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2198 //myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
2199 myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
2200 //myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2203 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
2205 // clear option values and remember selected row
2206 QList<int> selectedRows;
2207 QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
2208 QTableWidgetItem* item;
2209 foreach( item, selected ) {
2210 int row = item->row();
2211 if ( !selectedRows.contains( row ) ) {
2212 selectedRows.append( row );
2213 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2214 if ( id >= 0 && id < myOptions->length() )
2215 myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2218 qSort( selectedRows );
2219 QListIterator<int> it( selectedRows );
2221 while ( it.hasPrevious() )
2222 myOptionTable->removeRow( it.previous() );
2225 // **********************
2226 // *** BEGIN SIZE MAP ***
2227 // **********************
2229 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2231 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2233 if ( myGeomSelWdg2->IsObjectSelected() ){
2234 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2236 else if ( myGeomSelWdg1->IsObjectSelected() ){
2237 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2239 std::string entry = (string) mySMapObject->GetStudyEntry();
2240 QString qEntry = QString::fromStdString(entry);
2241 if (that->mySMPMap.contains(qEntry) && that->mySMPMap[qEntry] != "__TO_DELETE__" ) {
2242 addMapButton->setEnabled(false);
2243 modifyMapButton->setEnabled(true);
2246 addMapButton->setEnabled(true);
2247 modifyMapButton->setEnabled(false);
2252 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2254 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2255 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2256 if (col == SMP_SIZEMAP_COLUMN){
2257 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2258 if (!mySMPMap.contains(entry))
2260 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2261 CORBA::Object_var obj = entryToObject(entry);
2262 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){ // ADVANCED MAPS
2263 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2264 double phySize = that->mySMPMap[entry].toDouble(); // Retrieve values of the selected item in the current tab widgets
2265 double infDist = that->myAttDistMap[entry];
2266 double constDist = that->myDistMap[entry];
2267 QString attEntry = that->myATTMap[entry];
2268 CORBA::Object_var attObj = entryToObject(attEntry);
2269 myAttSizeSpin->setValue(phySize);
2270 if (sizeMap.startsWith("Attractor")){
2271 myAttDistSpin->setValue(infDist);
2272 myAttractorCheck->setChecked(true);
2275 myAttractorCheck->setChecked(false);
2277 if (sizeMap.startsWith("Constant") || constDist > std::numeric_limits<double>::epsilon()){
2278 myAttDistSpin2->setValue(constDist);
2279 myConstSizeCheck->setChecked(true);
2282 myConstSizeCheck->setChecked(false);
2284 myGeomSelWdg2->SetObject(obj);
2285 myAttSelWdg->SetObject(attObj);
2287 else { // CLASSIC MAPS
2288 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2289 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2290 if (!sizeMap.startsWith("def")){
2291 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2297 void BLSURFPluginGUI_HypothesisCreator::onSmpTabChanged(int tab)
2299 myAttDistSpin->setValue(0.); // Reinitialize widgets
2300 myAttSizeSpin->setValue(0.);
2301 myAttDistSpin2->setValue(0.);
2302 mySmpSizeSpin->setValue(0.);
2303 myGeomSelWdg1->deactivateSelection();
2304 myGeomSelWdg2->deactivateSelection();
2305 myAttSelWdg->deactivateSelection();
2306 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2307 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2308 myAttSelWdg->SetObject(CORBA::Object::_nil());
2309 myAttractorCheck->setChecked(false);
2310 myConstSizeCheck->setChecked(false);
2313 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2315 if (state == Qt::Checked){
2316 myAttSelWdg->setEnabled(true);
2317 myAttSizeSpin->setEnabled(true);
2318 myAttSizeLabel->setEnabled(true);
2319 myAttDistSpin->setEnabled(true);
2320 myAttDistLabel->setEnabled(true);
2321 if (!myAttSelWdg->IsObjectSelected()){
2322 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2325 if (state == Qt::Unchecked){
2326 myAttDistSpin->setEnabled(false);
2327 myAttDistLabel->setEnabled(false);
2328 myAttDistSpin->setValue(0.);
2329 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2330 myAttSelWdg->setEnabled(false);
2331 myAttSizeSpin->setEnabled(false);
2332 myAttSizeLabel->setEnabled(false);
2333 myAttDistSpin2->setEnabled(false);
2334 myAttDistLabel2->setEnabled(false);
2336 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2337 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2342 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2344 if (state == Qt::Checked){
2345 myAttSelWdg->setEnabled(true);
2346 myAttSizeSpin->setEnabled(true);
2347 myAttSizeLabel->setEnabled(true);
2348 myAttDistSpin2->setEnabled(true);
2349 myAttDistLabel2->setEnabled(true);
2350 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2351 !myAttSelWdg->IsObjectSelected()){
2352 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2355 if (state == Qt::Unchecked){
2356 myAttDistSpin2->setEnabled(false);
2357 myAttDistLabel2->setEnabled(false);
2358 myAttDistSpin2->setValue(0.);
2359 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2360 myAttSelWdg->setEnabled(false);
2361 myAttSizeSpin->setEnabled(false);
2362 myAttSizeLabel->setEnabled(false);
2363 myAttDistSpin->setEnabled(false);
2364 myAttDistLabel->setEnabled(false);
2366 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2367 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2372 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2374 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
2375 QList<int> selectedRows;
2376 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2377 QTreeWidgetItem* item;
2378 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2380 qSort( selectedRows );
2381 QListIterator<QTreeWidgetItem*> it( selected );
2383 while ( it.hasPrevious() ) {
2384 item = it.previous();
2385 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2386 if (that->mySMPMap.contains(entry))
2387 that->mySMPMap[entry] = "__TO_DELETE__";
2388 if (that->mySMPShapeTypeMap.contains(entry))
2389 that->mySMPShapeTypeMap.remove(entry);
2390 if (that->myATTMap.contains(entry))
2391 that->myATTMap.remove(entry);
2392 if (that->myDistMap.contains(entry))
2393 that->myDistMap.remove(entry);
2394 if (that->myAttDistMap.contains(entry))
2395 that->myAttDistMap.remove(entry);
2398 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2399 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2402 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2404 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
2405 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2406 if (col == SMP_SIZEMAP_COLUMN) {
2407 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2408 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2409 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2410 // MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
2411 if (! that->mySMPShapeTypeMap.contains(entry))
2413 if (that->mySMPMap.contains(entry))
2414 if (that->mySMPMap[entry] == sizeMap
2415 || sizeMap.startsWith("Attractor")
2416 || sizeMap.startsWith("Constant") ){
2419 if (! sizeMap.isEmpty()) {
2420 that->mySMPMap[entry] = sizeMap;
2421 sizeMapValidationFromEntry(entry);
2424 MESSAGE("Size map empty: reverse to precedent value" );
2425 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2427 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2431 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2433 if ( smpTab->currentIndex() == ATT_TAB ){
2434 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2435 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2436 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2437 insertAttractor(mySMapObject, myAttObject);
2440 if (smpTab->currentIndex() == SMP_STD_TAB ){
2441 if ( myGeomSelWdg1->IsObjectSelected() ){
2442 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2443 insertElement(mySMapObject);
2446 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2447 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2448 myAttDistSpin->setValue(0.);
2449 myAttSizeSpin->setValue(0.);
2450 myAttDistSpin2->setValue(0.);
2451 mySmpSizeSpin->setValue(0.);
2452 myConstSizeCheck->setChecked(false);
2453 myAttractorCheck->setChecked(false);
2454 myGeomSelWdg1->deactivateSelection();
2455 myGeomSelWdg2->deactivateSelection();
2456 myAttSelWdg->deactivateSelection();
2457 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2458 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2459 myAttSelWdg->SetObject(CORBA::Object::_nil());
2462 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
2464 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
2465 if ( smpTab->currentIndex() == ATT_TAB ){
2466 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2467 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2468 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2469 insertAttractor(mySMapObject, myAttObject, /*modify = */true);
2472 if (smpTab->currentIndex() == SMP_STD_TAB ){
2473 if ( myGeomSelWdg1->IsObjectSelected() ){
2474 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2475 insertElement(mySMapObject, /*modify = */true);
2478 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2479 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2480 myAttDistSpin->setValue(0.);
2481 myAttSizeSpin->setValue(0.);
2482 myAttDistSpin2->setValue(0.);
2483 mySmpSizeSpin->setValue(0.);
2484 myConstSizeCheck->setChecked(false);
2485 myAttractorCheck->setChecked(false);
2486 myGeomSelWdg1->deactivateSelection();
2487 myGeomSelWdg2->deactivateSelection();
2488 myAttSelWdg->deactivateSelection();
2489 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2490 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2491 myAttSelWdg->SetObject(CORBA::Object::_nil());
2494 void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
2496 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
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, shapeName;
2504 entry = (string) anObject->GetStudyEntry();
2505 MESSAGE("entry = "<<entry);
2506 shapeName = anObject->GetName();
2507 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
2508 mySizeMapTable->setFocus();
2510 shapeEntry = QString::fromStdString(entry);
2511 double phySize = mySmpSizeSpin->value();
2512 std::ostringstream oss;
2515 sizeMap = QString::fromStdString(oss.str());
2516 QTreeWidgetItem* item = new QTreeWidgetItem();
2518 int rowToChange = findRowFromEntry(shapeEntry);
2519 item = mySizeMapTable->topLevelItem( rowToChange );
2522 if (that->mySMPMap.contains(shapeEntry)) {
2523 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2524 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2528 mySizeMapTable->addTopLevelItem(item);
2530 that->mySMPMap[shapeEntry] = sizeMap;
2531 that->myDistMap[shapeEntry] = 0. ;
2532 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
2533 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2534 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
2535 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
2536 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
2537 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
2538 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2539 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2540 mySizeMapTable->clearSelection();
2542 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2543 myPhysicalMesh->setCurrentIndex( SizeMap );
2544 onPhysicalMeshChanged();
2548 void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
2550 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
2551 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2552 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2554 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2556 TopAbs_ShapeEnum shapeType;
2557 string entry, attEntry, faceName, attName;
2558 entry = (string) aFace->GetStudyEntry();
2559 attEntry = (string) anAttractor->GetStudyEntry();
2560 faceName = aFace->GetName();
2561 attName = anAttractor->GetName();
2562 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
2563 mySizeMapTable->setFocus();
2564 QString shapeEntry = QString::fromStdString(entry);
2565 QString qAttEntry = QString::fromStdString(attEntry);
2567 double phySize = h->GetPhySize();
2568 double infDist = 0. ;
2569 double constDist = 0. ;
2570 phySize = myAttSizeSpin->value();
2571 if (myAttractorCheck->isChecked()){
2572 infDist = myAttDistSpin->value();
2574 if (myConstSizeCheck->isChecked()){
2575 constDist = myAttDistSpin2->value();
2577 std::ostringstream oss;
2578 std::ostringstream oss2;
2579 std::ostringstream oss3;
2583 QString sizeMap = QString::fromStdString(oss.str());
2584 QString infDistString = QString::fromStdString(oss2.str());
2585 QString constDistString = QString::fromStdString(oss3.str());
2587 QTreeWidgetItem* item;
2588 QTreeWidgetItem* child;
2590 int rowToChange = findRowFromEntry(shapeEntry);
2591 item = mySizeMapTable->topLevelItem( rowToChange );
2592 child = item->child( 0 );
2595 if (that->mySMPMap.contains(shapeEntry)) {
2596 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2597 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2601 item = new QTreeWidgetItem();
2602 child = new QTreeWidgetItem();
2603 mySizeMapTable->addTopLevelItem(item);
2604 item->addChild(child);
2606 that->mySMPMap.insert(shapeEntry,sizeMap);
2607 that->myATTMap.insert(shapeEntry,qAttEntry);
2608 that->myAttDistMap.insert(shapeEntry,infDist);
2609 that->myDistMap.insert(shapeEntry,constDist);
2610 that->mySMPShapeTypeMap.insert(shapeEntry,shapeType);
2611 item->setExpanded(true);
2612 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
2613 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
2614 if (infDist > std::numeric_limits<double>::epsilon()){
2615 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
2617 else if (constDist > std::numeric_limits<double>::epsilon()){
2618 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
2620 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2622 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
2623 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
2624 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
2626 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2627 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2628 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
2630 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2631 myPhysicalMesh->setCurrentIndex( SizeMap );
2632 onPhysicalMeshChanged();
2634 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2637 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
2639 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
2640 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2641 for ( ; row < nbRows; ++row )
2642 if (! sizeMapValidationFromRow(row))
2647 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
2649 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
2650 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2651 bool res = sizeMapValidationFromEntry(myEntry,displayError);
2652 mySizeMapTable->setFocus();
2656 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
2658 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
2660 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2662 if (! that->mySMPMap.contains(myEntry)) {
2663 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
2666 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
2667 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
2673 if (that->mySMPMap[myEntry].startsWith("def")) {
2674 // MESSAGE("custom function" );
2675 expr = that->mySMPMap[myEntry].toStdString();
2677 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
2678 // MESSAGE("Attractor" );
2679 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)) {
2682 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])" );
2688 // case size map is empty
2689 if (that->mySMPMap[myEntry].isEmpty()) {
2691 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
2695 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
2696 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
2697 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
2698 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
2699 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
2700 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
2703 //assert(Py_IsInitialized());
2704 if (! Py_IsInitialized())
2705 throw ("Erreur: Python interpreter is not initialized");
2706 PyGILState_STATE gstate;
2707 gstate = PyGILState_Ensure();
2709 PyObject * obj = NULL;
2710 PyObject* new_stderr = NULL;
2711 string err_description="";
2712 obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
2716 new_stderr=newPyStdOut(err_description);
2717 PySys_SetObject((char*)"stderr", new_stderr);
2719 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
2720 Py_DECREF(new_stderr);
2722 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
2723 PyGILState_Release(gstate);
2728 PyObject * func = NULL;
2729 func = PyObject_GetAttrString(main_mod, "f");
2733 new_stderr=newPyStdOut(err_description);
2734 PySys_SetObject((char*)"stderr", new_stderr);
2736 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
2737 Py_DECREF(new_stderr);
2739 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
2740 PyGILState_Release(gstate);
2744 PyGILState_Release(gstate);
2746 // MESSAGE("SizeMap expression "<<expr<<" is valid");
2751 QString BLSURFPluginGUI_HypothesisCreator::caption() const
2753 return tr( "BLSURF_TITLE" );
2756 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
2758 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
2761 QString BLSURFPluginGUI_HypothesisCreator::type() const
2763 return tr( "BLSURF_HYPOTHESIS" );
2766 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
2768 return "blsurf_hypo_page.html";
2771 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
2774 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2776 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2781 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
2783 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
2784 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
2785 CORBA::Object_var obj;
2786 SALOMEDS::GenericAttribute_var anAttr;
2787 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
2788 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
2789 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2790 CORBA::String_var aVal = anIOR->Value();
2791 obj = myStudy->ConvertIORToObject(aVal);
2796 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
2797 QString entryForChecking;
2798 int endRow = mySizeMapTable->topLevelItemCount()-1;
2800 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2801 while (entry != entryForChecking && row <= endRow){
2803 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2805 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)