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());
312 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
313 const QModelIndex &index) const
315 QString value = index.model()->data(index, Qt::EditRole).toString();
317 if (index.column() == ENF_VER_X_COLUMN ||
318 index.column() == ENF_VER_Y_COLUMN ||
319 index.column() == ENF_VER_Z_COLUMN)
321 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
322 lineEdit->setText(value);
325 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
326 lineEdit->setText(value);
330 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
331 const QModelIndex &index) const
333 QModelIndex parent = index.parent();
334 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
335 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
336 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
337 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
338 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
339 } else if (index.column() == ENF_VER_NAME_COLUMN) {
340 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
341 QString value = lineEdit->text();
342 if (entry.isEmpty() && !vertexExists(model, index, value))
343 model->setData(index, value, Qt::EditRole);
344 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
345 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
346 QString value = lineEdit->text();
347 if (! vertexExists(model, index, value))
348 model->setData(index, value, Qt::EditRole);
349 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
350 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
351 model->setData(index, lineEdit->text(), Qt::EditRole);
355 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
356 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
358 editor->setGeometry(option.rect);
361 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
362 const QModelIndex &index, QString value) const
365 QModelIndex parent = index.parent();
366 int row = index.row();
367 int col = index.column();
369 if (parent.isValid() && !value.isEmpty()) {
370 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
372 if (col == ENF_VER_X_COLUMN) {
373 x = value.toDouble();
374 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
375 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
377 if (col == ENF_VER_Y_COLUMN) {
378 y = value.toDouble();
379 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
380 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
382 if (col == ENF_VER_Z_COLUMN) {
383 z = value.toDouble();
384 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
385 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
387 int nbChildren = model->rowCount(parent);
388 for (int i = 0 ; i < nbChildren ; i++) {
390 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
391 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
392 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
393 if ((childX == x) && (childY == y) && (childZ == z)) {
400 // else if (col == ENF_VER_ENTRY_COLUMN) {
401 // // Compare entries if no coords (= selected geom)
402 // xString = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toString();
403 // if (xString.isEmpty) {
404 // int nbChildren = model->rowCount(parent);
405 // for (int i = 0 ; i < nbChildren ; i++) {
407 // QString childName = parent.child(i, ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
408 // if (childName == value) {
416 else if (col == ENF_VER_NAME_COLUMN) {
417 int nbChildren = model->rowCount(parent);
418 for (int i = 0 ; i < nbChildren ; i++) {
420 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
421 if (childName == value) {
434 // END EnforcedTreeWidgetDelegate
438 // BEGIN BLSURFPluginGUI_ObjectReferenceParamWdg
440 //================================================================================
442 // BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
443 // ( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection)
444 // : StdMeshersGUI_ObjectReferenceParamWdg(f, parent, multiSelection)
450 // BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
451 // ( MeshObjectType objType, QWidget* parent, bool multiSelection )
452 // : StdMeshersGUI_ObjectReferenceParamWdg( objType, parent, multiSelection )
457 // BLSURFPluginGUI_ObjectReferenceParamWdg::~BLSURFPluginGUI_ObjectReferenceParamWdg()
461 // mySelectionMgr->removeFilter( myFilter );
466 // void BLSURFPluginGUI_ObjectReferenceParamWdg::init()
468 // StdMeshersGUI_ObjectReferenceParamWdg::init();
469 // disconnect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection()));
470 // connect( mySelButton, SIGNAL(toggled(bool)), SLOT(setActivationStatus(bool)));
473 // void BLSURFPluginGUI_ObjectReferenceParamWdg::setActivationStatus(bool status)
476 // activateSelection();
478 // deactivateSelection();
481 // void BLSURFPluginGUI_ObjectReferenceParamWdg::activateSelectionOnly()
483 // if ( !mySelectionActivated && mySelectionMgr )
485 // mySelectionActivated = true;
486 // mySelectionMgr->clearFilters();
487 // if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
488 // aViewWindow->SetSelectionMode(ActorSelection);
490 // mySelectionMgr->installFilter( myFilter );
491 // connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
493 // emit selectionActivated();
496 // void BLSURFPluginGUI_ObjectReferenceParamWdg::deactivateSelectionOnly()
498 // mySelectionActivated = false;
499 // disconnect(mySelectionMgr, 0, this, 0 );
500 // mySelectionMgr->removeFilter( myFilter );
504 // END BLSURFPluginGUI_ObjectReferenceParamWdg
508 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
509 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
512 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
513 : SMESHGUI_GenericHypothesisCreator( theHypType )
515 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
516 this->mySMPMap.clear();
518 GeomToolSelected = NULL;
519 GeomToolSelected = getGeomSelectionTool();
521 aSel = GeomToolSelected->selectionMgr();
523 /* Initialize the Python interpreter */
524 if (! Py_IsInitialized())
525 throw ("Error: Python interpreter is not initialized");
526 PyGILState_STATE gstate;
527 gstate = PyGILState_Ensure();
530 main_mod = PyImport_AddModule("__main__");
533 main_dict = PyModule_GetDict(main_mod);
535 PyRun_SimpleString("from math import *");
536 PyGILState_Release(gstate);
540 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
545 * \brief {Get or create the geom selection tool for active study}
547 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool()
549 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
550 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
551 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
552 that->GeomToolSelected = new GeomSelectionTools(aStudy);
554 return that->GeomToolSelected;
557 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
559 return GeometryGUI::GetGeomGen();
563 bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
565 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
570 myOptionTable->setFocus();
571 QApplication::instance()->processEvents();
573 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
574 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
576 int row = 0, nbRows = myOptionTable->rowCount();
577 for ( ; row < nbRows; ++row )
579 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
580 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
581 if ( !value.isEmpty() ) {
583 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
585 catch ( const SALOME::SALOME_Exception& ex )
587 SUIT_MessageBox::critical( dlg(),
589 ex.details.text.in() );
594 h->SetOptionValues( myOptions ); // restore values
597 // SizeMap and attractors
600 mySizeMapTable->setFocus();
601 QApplication::instance()->processEvents();
603 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
604 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
606 // int row = 0, nbRows = mySizeMapTable->rowCount();
607 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
608 for ( ; row < nbRows; ++row )
610 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
611 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
612 if ( !sizeMap.isEmpty() ) {
613 if (that->sizeMapValidationFromRow(row))
616 const char* e = entry.toLatin1().constData();
617 const char* s = that->mySMPMap[entry].toLatin1().constData();
618 h->SetSizeMapEntry( e, s );
620 catch ( const SALOME::SALOME_Exception& ex )
622 SUIT_MessageBox::critical( dlg(),
624 ex.details.text.in() );
641 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
643 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
645 QFrame* fr = new QFrame( 0 );
646 // fr-> setMinimumSize(600,400);
647 QVBoxLayout* lay = new QVBoxLayout( fr );
648 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
650 lay->setSpacing( 0 );
653 QTabWidget* tab = new QTabWidget( fr );
654 tab->setTabShape( QTabWidget::Rounded );
655 tab->setTabPosition( QTabWidget::North );
656 lay->addWidget( tab );
659 myStdGroup = new QWidget();
660 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
661 aStdLayout->setSpacing( 6 );
662 aStdLayout->setMargin( 11 );
666 myName = new QLineEdit( myStdGroup );
668 myGradation = new SMESHGUI_SpinBox( myStdGroup );
669 myGradation->RangeStepAndValidator(1.1, 2.5, 0.1, "length_precision");
671 myPhysicalMesh = new QComboBox( myStdGroup );
672 QStringList physicalTypes;
673 physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ) << tr( "BLSURF_SIZE_MAP");
674 myPhysicalMesh->addItems( physicalTypes );
676 myPhySize = new SMESHGUI_SpinBox( myStdGroup );
677 myPhySize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
679 #ifdef WITH_SIZE_BOUNDARIES
680 myPhyMin = new SMESHGUI_SpinBox( myStdGroup );
681 myPhyMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
682 myPhyMin->setText("");
683 myPhyMax = new SMESHGUI_SpinBox( myStdGroup );
684 myPhyMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
685 myPhyMax->setText("");
688 myGeometricMesh = new QComboBox( myStdGroup );
690 types << tr( "BLSURF_DEFAULT_GEOM" ) << tr( "BLSURF_CUSTOM_GEOM" );
691 myGeometricMesh->addItems( types );
693 myAngleMeshS = new SMESHGUI_SpinBox( myStdGroup );
694 myAngleMeshS->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
696 myAngleMeshC = new SMESHGUI_SpinBox( myStdGroup );
697 myAngleMeshC->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
699 #ifdef WITH_SIZE_BOUNDARIES
700 myGeoMin = new SMESHGUI_SpinBox( myStdGroup );
701 myGeoMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
702 myGeoMin->setText("");
703 myGeoMax = new SMESHGUI_SpinBox( myStdGroup );
704 myGeoMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
705 myGeoMax->setText("");
707 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup );
708 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
710 // ADD WIDGETS (STANDARD TAB)
713 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
714 aStdLayout->addWidget( myName, row++, 1, 1, 1 );
716 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 );
717 aStdLayout->addWidget( myGradation, row++, 1, 1, 1 );
718 aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ), row, 0, 1, 1 );
719 aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 );
720 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 );
721 aStdLayout->addWidget( myPhySize, row++, 1, 1, 1 );
722 #ifdef WITH_SIZE_BOUNDARIES
723 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ), row, 0, 1, 1 );
724 aStdLayout->addWidget( myPhyMin, row++, 1, 1, 1 );
725 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ), row, 0, 1, 1 );
726 aStdLayout->addWidget( myPhyMax, row++, 1, 1, 1 );
728 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ), row, 0, 1, 1 );
729 aStdLayout->addWidget( myGeometricMesh, row++, 1, 1, 1 );
730 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 0, 1, 1 );
731 aStdLayout->addWidget( myAngleMeshS, row++, 1, 1, 1 );
732 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 0, 1, 1 );
733 aStdLayout->addWidget( myAngleMeshC, row++, 1, 1, 1 );
734 #ifdef WITH_SIZE_BOUNDARIES
735 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ), row, 0, 1, 1 );
736 aStdLayout->addWidget( myGeoMin, row++, 1, 1, 1 );
737 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ), row, 0, 1, 1 );
738 aStdLayout->addWidget( myGeoMax, row++, 1, 1, 1 );
740 aStdLayout->addWidget( myAllowQuadrangles, row++, 0, 1, 1 );
741 aStdLayout->addWidget( myDecimesh, row++, 0, 1, 1 );
743 // advanced parameters
744 myAdvGroup = new QWidget();
745 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
746 anAdvLayout->setSpacing( 6 );
747 anAdvLayout->setMargin( 11 );
748 anAdvLayout->setRowStretch( 4, 5 );
749 anAdvLayout->setColumnStretch( 1, 5 );
751 myTopology = new QComboBox( myAdvGroup );
752 QStringList topologyTypes;
753 topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) << tr( "BLSURF_TOPOLOGY_PROCESS" ) << tr( "BLSURF_TOPOLOGY_PROCESS2" );
754 myTopology->addItems( topologyTypes );
756 myVerbosity = new QSpinBox( myAdvGroup );
757 myVerbosity->setMinimum( 0 );
758 myVerbosity->setMaximum( 100 );
759 myVerbosity->setSingleStep( 5 );
761 myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup );
763 headers << tr( "OPTION_ID_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" );
764 myOptionTable->setHorizontalHeaderLabels( headers );
765 myOptionTable->horizontalHeader()->hideSection( OPTION_ID_COLUMN );
766 myOptionTable->horizontalHeader()->setStretchLastSection(true);
767 myOptionTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
768 //myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );//////
769 //myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE );/////
770 myOptionTable->verticalHeader()->hide();
771 //myOptionTable->setSelectionBehavior( QAbstractItemView::SelectRows );
773 QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup );
774 addBtn->setMenu( new QMenu() );
775 QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup );
778 // ADD WIDGETS (ADVANCED TAB)
779 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 );
780 anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 );
781 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 1, 0, 1, 1 );
782 anAdvLayout->addWidget( myVerbosity, 1, 1, 1, 1 );
783 anAdvLayout->addWidget( myOptionTable, 2, 0, 3, 2 );
784 anAdvLayout->addWidget( addBtn, 2, 2, 1, 1 );
785 anAdvLayout->addWidget( rmBtn, 3, 2, 1, 1 );
788 // Size Maps parameters
790 mySmpGroup = new QWidget();
791 // mySmpGroup->setMinimumWidth(500);
794 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
797 mySizeMapTable = new QTreeWidget( mySmpGroup );
798 mySizeMapTable ->setMinimumWidth(200);
799 QStringList sizeMapHeaders;
800 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
801 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
802 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
803 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
804 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
805 mySizeMapTable->setAlternatingRowColors(true);
808 smpTab = new QTabWidget( mySmpGroup );
809 smpTab->setTabShape( QTabWidget::Rounded );
810 smpTab->setTabPosition( QTabWidget::South );
811 lay->addWidget( smpTab );
813 // Filters of selection
814 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
816 SM_ShapeTypes.Add( TopAbs_VERTEX );
817 SM_ShapeTypes.Add( TopAbs_EDGE );
818 SM_ShapeTypes.Add( TopAbs_FACE );
820 ATT_ShapeTypes.Add( TopAbs_VERTEX );
821 ATT_ShapeTypes.Add( TopAbs_EDGE );
822 ATT_ShapeTypes.Add( TopAbs_WIRE );
823 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
825 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
826 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
827 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
829 // Standard size map tab
830 mySmpStdGroup = new QWidget();
831 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
832 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false);
833 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
834 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
835 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
836 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
839 myAttractorGroup = new QWidget();
840 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
841 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false,/*stretch=*/false);
842 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
843 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
844 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
845 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
846 QFrame* attLine = new QFrame(myAttractorGroup);
847 attLine->setFrameShape(QFrame::HLine);
848 attLine->setFrameShadow(QFrame::Sunken);
849 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false);
850 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
851 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
852 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
853 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
854 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
855 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
856 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
857 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
858 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
859 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
861 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
862 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
866 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
867 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
868 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
869 modifyMapButton->setEnabled(false);
872 myAttSelWdg->setEnabled(false);
873 myAttSizeSpin->setEnabled(false);
874 myAttSizeLabel->setEnabled(false);
875 myAttDistSpin->setEnabled(false);
876 myAttDistLabel->setEnabled(false);
877 myAttDistSpin2->setEnabled(false);
878 myAttDistLabel2->setEnabled(false);
879 myAttDistSpin->setValue(0.);
880 myAttDistSpin2->setValue(0.);
881 myAttSizeSpin->setValue(0.);
882 mySmpSizeSpin->setValue(0.);
885 // ADD WIDGETS (SIZEMAP TAB)
886 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
887 anSmpLayout->setColumnStretch(0, 1);
888 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
889 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
890 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
891 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
892 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
893 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
896 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
897 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
898 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
899 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
902 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
903 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
904 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
905 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
906 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
907 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
908 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
909 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
910 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
911 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
912 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
913 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
915 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
916 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
918 smpTab->setCurrentIndex( SMP_STD_TAB );
920 // Enforced vertices parameters
921 myEnfGroup = new QWidget();
922 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
924 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
925 // anEnfLayout->addWidget(myEnforcedVertexWidget);
926 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
927 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
929 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
930 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
931 myEnforcedTreeWidget->setSortingEnabled(true);
932 QStringList enforcedHeaders;
933 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
934 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
935 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
937 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
938 myEnforcedTreeWidget->setAlternatingRowColors(true);
939 myEnforcedTreeWidget->setUniformRowHeights(true);
940 myEnforcedTreeWidget->setAnimated(true);
941 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
942 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
943 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
944 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
945 myEnforcedTreeWidget->resizeColumnToContents(column);
947 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
948 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
949 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
951 // FACE AND VERTEX SELECTION
952 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
953 shapeTypes1.Add( TopAbs_FACE );
954 shapeTypes1.Add( TopAbs_COMPOUND );
955 shapeTypes2.Add( TopAbs_VERTEX );
956 shapeTypes2.Add( TopAbs_COMPOUND );
958 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
959 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true, /*stretch=*/false);
960 myEnfFaceWdg->SetDefaultText("Select Faces", "QLineEdit { color: grey }");
962 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
963 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
964 myEnfVertexWdg->SetDefaultText("Select Vertices", "QLineEdit { color: grey }");
966 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
968 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
969 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
970 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
972 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
973 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
974 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
976 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
977 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
978 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
980 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
981 myGroupName = new QLineEdit(myEnfGroup);
983 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
984 // QFrame *line = new QFrame(myEnfGroup);
985 // line->setFrameShape(QFrame::HLine);
986 // line->setFrameShadow(QFrame::Sunken);
987 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
989 // CheckBox for groups generation
990 makeGroupsCheck = new QGroupBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
991 makeGroupsCheck->setCheckable(true);
992 makeGroupsCheck->setChecked(false);
993 QGridLayout* aGroupLayout = new QGridLayout(makeGroupsCheck);
994 myGlobalGroupName = new QLineEdit(makeGroupsCheck);
995 aGroupLayout->addWidget(myGlobalGroupName);
997 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES+1, 1);
998 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
999 // FACE AND VERTEX SELECTION
1000 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
1001 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
1003 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
1004 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
1005 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
1006 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
1007 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
1008 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
1009 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
1010 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
1011 anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
1012 anEnfLayout2->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 0, 1, 2);
1013 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 0, 1, 2);
1014 // anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 0, 1, 2);
1015 anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
1016 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
1019 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1020 tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1021 tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) );
1022 tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1024 tab->setCurrentIndex( STD_TAB );
1027 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
1028 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
1029 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1030 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1031 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1033 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1034 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1035 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1036 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1037 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1038 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1039 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1040 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1041 // connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(deactivateSelection(QWidget*, QWidget*)));
1042 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
1043 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
1044 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1045 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1046 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1048 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1049 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1050 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1051 connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1052 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1053 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1054 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1055 connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1056 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1057 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1058 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1059 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onSmpTabChanged( int ) ) );
1061 // Enforced vertices
1062 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1063 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1064 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1065 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1066 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1067 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1072 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1073 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1075 void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1077 if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1078 || (now = myGroupName) || (now = makeGroupsCheck) || (now = myEnforcedTreeWidget)) {
1079 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1080 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1081 myEnfFaceWdg->deactivateSelection();
1082 myEnfVertexWdg->deactivateSelection();
1087 * This method resets the content of the X, Y, Z and GroupNAme widgets;
1089 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1091 myXCoord->setCleared(true);
1092 myYCoord->setCleared(true);
1093 myZCoord->setCleared(true);
1094 myXCoord->setText("");
1095 myYCoord->setText("");
1096 myZCoord->setText("");
1097 myGroupName->setText("");
1100 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1101 This method updates the tooltip of a modified item. The QLineEdit widgets content
1102 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1104 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1105 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1106 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1107 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1108 QVariant y = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1109 QVariant z = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1110 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1111 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1112 QTreeWidgetItem* parent = item->parent();
1114 clearEnforcedVertexWidgets();
1116 if (parent && (!x.isNull() || !entry.isNull())) {
1117 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1118 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1119 if (entry.isNull()) {
1120 toolTip += QString("(") + x.toString();
1121 toolTip += QString(", ") + y.toString();
1122 toolTip += QString(", ") + z.toString();
1123 toolTip += QString(")");
1126 if (!groupName.isEmpty())
1127 toolTip += QString(" [") + groupName + QString("]");
1129 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1132 myXCoord->SetValue(x.toDouble());
1133 myYCoord->SetValue(y.toDouble());
1134 myZCoord->SetValue(z.toDouble());
1137 if (!groupName.isEmpty())
1138 myGroupName->setText(groupName);
1142 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1143 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1144 clearEnforcedVertexWidgets();
1145 if (nbSelEnfVertex == 1)
1147 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1150 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1151 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1152 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1153 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1154 if (CORBA::is_nil(measureOp))
1157 CORBA::Double x,y,z;
1158 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1159 if ( measureOp->IsDone() )
1161 myXCoord->SetValue(x);
1162 myYCoord->SetValue(y);
1163 myZCoord->SetValue(z);
1169 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1170 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1171 of the enforced vertex clicked in the tree widget.
1173 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1174 clearEnforcedVertexWidgets();
1175 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1176 if (! items.isEmpty() && items.size() == 1) {
1177 QTreeWidgetItem *item = items[0];
1178 // for (int i=0 ; i < items.size() ; i++) {
1180 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1181 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1182 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1183 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1184 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1185 if (!x.isNull()/* && entry.isNull()*/) {
1186 myXCoord->SetValue(x.toDouble());
1187 myYCoord->SetValue(y.toDouble());
1188 myZCoord->SetValue(z.toDouble());
1191 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1192 myGroupName->setText(group.toString());
1197 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1198 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1200 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEntry, std::string theFaceName,
1201 double x, double y, double z, std::string vertexName, std::string geomEntry, std::string groupName) {
1202 // Find theFaceEntry item
1203 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1204 QTreeWidgetItem* theItem;
1205 if (theItemList.empty()) {
1206 theItem = new QTreeWidgetItem();
1207 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1208 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1209 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1210 myEnforcedTreeWidget->addTopLevelItem(theItem);
1213 theItem = theItemList[0];
1216 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1217 bool okToCreate = true;
1219 const int nbVert = theItem->childCount();
1220 // MESSAGE("Number of child rows: " << nbVert);
1222 double childValueX,childValueY,childValueZ;
1223 QString childEntry, childGroupName;
1224 QTreeWidgetItem* child;
1225 for (int row = 0;row<nbVert;row++) {
1226 child = theItem->child(row);
1227 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1228 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1229 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1230 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1231 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1232 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1233 // update group name
1234 if (childGroupName.toStdString() != groupName) {
1235 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1236 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1244 if (geomEntry.empty()) {
1245 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1248 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1253 if (geomEntry.empty()) {
1254 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1257 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1260 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1261 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1262 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1263 QSize iconSize = iconSelect.size()*0.7;
1265 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1266 QString myVertexName;
1268 while(indexRef != vertexIndex) {
1269 indexRef = vertexIndex;
1270 if (vertexName.empty())
1271 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1273 myVertexName = QString(vertexName.c_str());
1275 for (int row = 0;row<nbVert;row++) {
1276 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1277 if (myVertexName == name) {
1283 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1284 if (geomEntry.empty()) {
1285 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1286 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1287 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1290 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1291 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1293 if (groupName != "")
1294 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1296 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1297 if (geomEntry.empty()) {
1298 toolTip += QString(" (%1, ").arg(x);
1299 toolTip += QString("%1, ").arg(y);
1300 toolTip += QString("%1)").arg(z);
1302 if (groupName != "")
1303 toolTip += QString(" [%1]").arg(groupName.c_str());
1305 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1306 theItem->setExpanded(true);
1307 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1310 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1311 This method is called when a item is added into the enforced vertices tree widget
1313 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1314 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1316 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1318 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1319 myEnfFaceWdg->deactivateSelection();
1320 myEnfVertexWdg->deactivateSelection();
1322 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1323 myEnforcedTreeWidget->resizeColumnToContents(column);
1326 int selEnfFace = myEnfFaceWdg->NbObjects();
1327 int selEnfVertex = myEnfVertexWdg->NbObjects();
1328 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1330 if (selEnfFace == 0)
1333 if ((selEnfVertex == 0) && coordsEmpty)
1336 string entry, shapeName;
1338 for (int i = 0 ; i < selEnfFace ; i++) {
1339 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1340 entry = myEnfFace->GetStudyEntry();
1341 shapeName = myEnfFace->GetName();
1343 std::string groupName = myGroupName->text().toStdString();
1344 if (makeGroupsCheck->isChecked())
1345 groupName = myGlobalGroupName->text().toStdString();
1347 if (boost::trim_copy(groupName).empty())
1350 if (selEnfVertex <= 1)
1353 x = myXCoord->GetValue();
1354 y = myYCoord->GetValue();
1355 z = myZCoord->GetValue();
1356 if (selEnfVertex == 1) {
1357 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1358 addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1361 addEnforcedVertex(entry, shapeName, x, y, z, "", "", groupName);
1365 if ( CORBA::is_nil(getGeomEngine()))
1368 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1369 if (CORBA::is_nil(measureOp))
1372 CORBA::Double x,y,z;
1374 for (int j = 0 ; j < selEnfVertex ; j++)
1376 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1377 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1378 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1379 if ( measureOp->IsDone() )
1380 addEnforcedVertex(entry, shapeName, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1381 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1382 addEnforcedVertex(entry, shapeName, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1388 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1389 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1391 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1392 myEnforcedTreeWidget->resizeColumnToContents(column);
1394 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
1395 myPhysicalMesh->setCurrentIndex( SizeMap );
1396 onPhysicalMeshChanged();
1400 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1401 This method is called when a item is removed from the enforced vertices tree widget
1403 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1404 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1405 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1406 QList<QTreeWidgetItem *> selectedVertices;
1407 QSet<QTreeWidgetItem *> selectedEntries;
1408 QTreeWidgetItem* item;
1410 foreach( item, selectedItems ) {
1411 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1412 if (! value.isNull())
1413 selectedVertices.append(item);
1415 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1416 if (! value.isNull())
1417 selectedVertices.append(item);
1419 selectedEntries.insert(item);
1423 foreach(item,selectedVertices) {
1424 QTreeWidgetItem* parent = item->parent();
1425 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1426 parent->removeChild(item);
1428 if (parent->childCount() == 0) {
1429 if (selectedEntries.contains(parent))
1430 selectedEntries.remove(parent);
1435 foreach(item,selectedEntries) {
1436 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1440 myEnforcedTreeWidget->selectionModel()->clearSelection();
1443 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1444 This method updates the GUI widgets with the hypothesis data
1446 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1448 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1449 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1451 BlsurfHypothesisData data;
1452 that->readParamsFromHypo( data );
1455 myName->setText( data.myName );
1456 QFontMetrics metrics( myName->font() );
1457 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1459 myTopology->setCurrentIndex( data.myTopology );
1460 myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1461 myPhySize->SetValue( data.myPhySize );
1462 #ifdef WITH_SIZE_BOUNDARIES
1463 MESSAGE("data.myPhyMin: "<<data.myPhyMin)
1464 if (data.myPhyMin < 0)
1465 myPhyMin->setText("");
1467 myPhyMin->SetValue( data.myPhyMin );
1468 MESSAGE("data.myPhyMax: "<<data.myPhyMax)
1469 if (data.myPhyMax < 0)
1470 myPhyMax->setText("");
1472 myPhyMax->SetValue( data.myPhyMax );
1473 MESSAGE("data.myGeoMin: "<<data.myGeoMin)
1474 if (data.myGeoMin < 0)
1475 myGeoMin->setText("");
1477 myGeoMin->SetValue( data.myGeoMin );
1478 MESSAGE("data.myGeoMax: "<<data.myGeoMax)
1479 if (data.myGeoMax < 0)
1480 myGeoMax->setText("");
1482 myGeoMax->SetValue( data.myGeoMax );
1484 myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1485 // myAngleMeshS->setValue( data.myAngleMeshS );
1486 // myAngleMeshC->setValue( data.myAngleMeshC );
1487 // myGradation->setValue( data.myGradation );
1488 myAngleMeshS->SetValue( data.myAngleMeshS );
1489 myAngleMeshC->SetValue( data.myAngleMeshC );
1490 myGradation->SetValue( data.myGradation );
1491 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1492 myDecimesh->setChecked( data.myDecimesh );
1493 myVerbosity->setValue( data.myVerbosity );
1495 if ( myOptions.operator->() ) {
1496 // MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
1497 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1498 QString option = that->myOptions[i].in();
1499 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1500 if ( name_value.count() > 1 ) {
1501 QString idStr = QString("%1").arg( i );
1502 int row = myOptionTable->rowCount();
1503 myOptionTable->setRowCount( row+1 );
1504 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1505 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1506 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1507 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1508 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1509 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1510 Qt::ItemIsEditable |
1511 Qt::ItemIsEnabled );
1515 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1518 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1519 QMapIterator<QString, QString> i(that->mySMPMap);
1520 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1521 while (i.hasNext()) {
1523 const QString entry = i.key();
1524 const QString sizeMap = i.value();
1525 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1526 int row = mySizeMapTable->topLevelItemCount();
1527 QTreeWidgetItem* item = new QTreeWidgetItem();
1528 mySizeMapTable->addTopLevelItem( item );
1529 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1530 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1531 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1532 if (that->myATTMap.contains(entry)){
1533 const QString attEntry = that->myATTMap[entry];
1534 std::string attName = myGeomToolSelected->getNameFromEntry(attEntry.toStdString());
1535 QTreeWidgetItem* child = new QTreeWidgetItem();
1536 item->addChild( child );
1537 item->setExpanded(true);
1538 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1539 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attEntry ) );
1540 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString( attName ) ) );
1542 if (that->myAttDistMap[entry] > std::numeric_limits<double>::epsilon()){
1543 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Attractor" ) ) );
1546 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Constant Size" ) ) );
1551 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1554 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1555 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1556 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1558 // Enforced vertices
1559 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1560 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1561 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1562 TEntry entry = (*evmIt).first;
1563 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1564 MESSAGE("Face entry: " << entry);
1565 MESSAGE("Face name: " << shapeName);
1567 TEnfVertexList evs = (*evmIt).second;
1569 // evs = (*evmIt).second;
1572 // MESSAGE("evs = (*evmIt).second: FAIL");
1576 TEnfVertexList::const_iterator evsIt = evs.begin();
1577 TEnfVertex *enfVertex;
1578 for ( ; evsIt != evs.end() ; ++evsIt) {
1579 enfVertex = (*evsIt);
1580 MESSAGE("Name: " << enfVertex->name);
1582 if (enfVertex->coords.size()) {
1583 x = enfVertex->coords[0];
1584 y = enfVertex->coords[1];
1585 z = enfVertex->coords[2];
1587 that->addEnforcedVertex(entry, shapeName, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1591 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1592 myEnforcedTreeWidget->resizeColumnToContents(column);
1595 that->onPhysicalMeshChanged();
1596 that->onGeometricMeshChanged();
1599 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1600 This method updates the hypothesis data with the GUI widgets content.
1602 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1604 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1606 BlsurfHypothesisData data;
1607 QString guiHyp = that->readParamsFromWidgets( data );
1608 that->storeParamsToHypo( data );
1613 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1614 Updates the hypothesis data from hypothesis values.
1616 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
1618 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
1619 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1620 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1622 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1623 h_data.myName = isCreation() && data ? hypName() : "";
1625 h_data.myTopology = (int) h->GetTopology();
1626 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
1627 h_data.myPhySize = h->GetPhySize();
1628 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
1629 h_data.myAngleMeshS = h->GetAngleMeshS();
1630 h_data.myAngleMeshC = h->GetAngleMeshC();
1631 h_data.myGradation = h->GetGradation();
1632 h_data.myAllowQuadrangles = h->GetQuadAllowed();
1633 h_data.myDecimesh = h->GetDecimesh();
1634 h_data.myVerbosity = h->GetVerbosity();
1636 #ifdef WITH_SIZE_BOUNDARIES
1637 double PhyMin = h->GetPhyMin();
1638 double PhyMax = h->GetPhyMax();
1639 double GeoMin = h->GetGeoMin();
1640 double GeoMax = h->GetGeoMax();
1641 // if ( PhyMin > 0 )
1642 // h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString("");
1643 // h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString("");
1644 // h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString("");
1645 // h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString("");
1646 h_data.myPhyMin = PhyMin > 0 ? PhyMin : -1.0;
1647 h_data.myPhyMax = PhyMax > 0 ? PhyMax : -1.0;
1648 h_data.myGeoMin = GeoMin > 0 ? GeoMin : -1.0;
1649 h_data.myGeoMax = GeoMax > 0 ? GeoMax : -1.0;
1652 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1653 that->myOptions = h->GetOptionValues();
1655 that->mySMPMap.clear();
1656 that->myATTMap.clear();
1657 that->myAttDistMap.clear();
1658 that->myDistMap.clear();
1660 // classic size maps
1661 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
1662 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
1663 QString fullSizeMaps;
1664 QStringList fullSizeMapList;
1665 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1666 for ( int i = 0;i<mySizeMaps->length(); ++i ) {
1667 fullSizeMaps = mySizeMaps[i].in();
1668 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
1669 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
1670 if ( fullSizeMapList.count() > 1 ) {
1671 string fullSizeMap = fullSizeMapList[1].toStdString();
1672 int pos = fullSizeMap.find("return")+7;
1673 // MESSAGE("pos:" << pos);
1676 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
1681 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
1682 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
1683 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
1684 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
1690 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
1691 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
1693 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
1694 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
1695 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
1696 if ( fullCustomSizeMapList.count() > 1 ) {
1697 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
1698 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
1699 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
1700 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
1705 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
1706 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
1708 for ( int i = 0;i<allMyAttractors->length(); ++i ) {
1709 QString myAttractors = allMyAttractors[i].in();
1710 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
1711 if ( myAttractorList.count() > 1 ) {
1712 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
1713 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
1714 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
1715 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
1719 // attractor new version
1720 MESSAGE("retriveParams, Attractors")
1721 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
1722 for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
1723 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
1724 QString faceEntry = myAttractorParams.faceEntry.in();
1725 QString attEntry = myAttractorParams.attEntry.in();
1726 MESSAGE("attEntry = "<<attEntry.toStdString())
1727 double startSize = myAttractorParams.startSize;
1728 double endSize = myAttractorParams.endSize;
1729 double infDist = myAttractorParams.infDist;
1730 double constDist = myAttractorParams.constDist;
1731 that->mySMPMap[faceEntry] = QString::number( startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
1732 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
1733 that->myATTMap[faceEntry] = attEntry;
1734 that->myAttDistMap[faceEntry] = infDist;
1735 that->myDistMap[faceEntry] = constDist;
1738 // Enforced vertices
1739 h_data.enfVertexList.clear();
1740 h_data.faceEntryEnfVertexListMap.clear();
1742 h_data.groupNameEnfVertexListMap.clear();
1745 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
1746 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
1748 for ( int i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
1749 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
1750 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
1751 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
1752 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
1754 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
1756 for (int j=0 ; j<vertexList.length(); ++j) {
1757 TEnfVertex *enfVertex = new TEnfVertex();
1759 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
1760 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
1761 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
1762 for (int k=0 ; k< vertexList[j].coords.length();k++)
1763 enfVertex->coords.push_back(vertexList[j].coords[k]);
1765 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
1768 if (groupName != "") {
1769 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
1773 // h_data.enfVertMap[entry] = evs;
1774 // h_data.entryCoordsListMap[entry] = coordsList;
1776 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
1777 h_data.faceEntryEnfVertexListMap.erase(entry);
1784 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
1785 Saves the hypothesis data to hypothesis values.
1787 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
1789 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
1790 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1791 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
1797 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1799 if ( h->GetTopology() != h_data.myTopology ) // avoid duplication of DumpPython commands
1800 h->SetTopology( (int) h_data.myTopology );
1801 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh )
1802 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
1803 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
1804 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
1805 if ( h->GetGradation() != h_data.myGradation )
1806 h->SetGradation( h_data.myGradation );
1807 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
1808 h->SetQuadAllowed( h_data.myAllowQuadrangles );
1809 if ( h->GetDecimesh() != h_data.myDecimesh )
1810 h->SetDecimesh( h_data.myDecimesh );
1811 if ( h->GetVerbosity() != h_data.myVerbosity )
1812 h->SetVerbosity( h_data.myVerbosity );
1814 if( ((int) h_data.myPhysicalMesh == PhysicalUserDefined)||((int) h_data.myPhysicalMesh == SizeMap) ) {
1815 if ( h->GetPhySize() != h_data.myPhySize )
1816 h->SetPhySize( h_data.myPhySize );
1818 if( (int) h_data.myGeometricMesh == UserDefined ) {
1819 if ( h->GetAngleMeshS() != h_data.myAngleMeshS )
1820 h->SetAngleMeshS( h_data.myAngleMeshS );
1821 if ( h->GetAngleMeshC() != h_data.myAngleMeshC )
1822 h->SetAngleMeshC( h_data.myAngleMeshC );
1824 #ifdef WITH_SIZE_BOUNDARIES
1825 if (h_data.myPhyMin > 0)
1826 h->SetPhyMin( h_data.myPhyMin );
1827 if (h_data.myPhyMax > 0)
1828 h->SetPhyMax( h_data.myPhyMax );
1829 if (h_data.myGeoMin > 0)
1830 h->SetGeoMin( h_data.myGeoMin );
1831 if (h_data.myGeoMax > 0)
1832 h->SetGeoMax( h_data.myGeoMax );
1835 h->SetOptionValues( myOptions ); // is set in checkParams()
1837 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1838 QMapIterator<QString,QString> i(that->mySMPMap);
1839 while (i.hasNext()) {
1841 const QString entry = i.key();
1842 const QString sizeMap = i.value();
1844 if (sizeMap == "__TO_DELETE__") {
1845 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
1846 h->UnsetEntry(entry.toLatin1().constData());
1848 else if (sizeMap.startsWith("ATTRACTOR")) {
1849 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1850 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
1852 else if (sizeMap.startsWith("def")) {
1853 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1854 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
1857 if (!myATTMap[entry].isEmpty()){
1858 QString att_entry = myATTMap[entry];
1859 double infDist = myAttDistMap[entry];
1860 double constDist = myDistMap[entry];
1861 double phySize = h->GetPhySize();
1862 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1863 h->SetClassAttractorEntry( entry.toLatin1().constData(), att_entry.toLatin1().constData(), sizeMap.toDouble() , phySize, infDist, constDist );
1864 QApplication::restoreOverrideCursor();
1867 QString fullSizeMap;
1868 fullSizeMap = QString("");
1869 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
1870 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
1871 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
1872 fullSizeMap = QString("def f(t): return ") + sizeMap;
1873 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
1874 fullSizeMap = QString("def f(): return ") + sizeMap;
1875 // MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
1876 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
1881 // Enforced vertices
1885 std::string enfName;
1887 std::string groupName = "";
1890 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
1892 BLSURFPlugin::TFaceEntryEnfVertexListMap_var allEnforcedVerticesByFace = h->GetAllEnforcedVerticesByFace();
1893 hypNbVertex = allEnforcedVerticesByFace->length();
1896 // All enforced vertices were deleted
1897 if (evmIt == h_data.faceEntryEnfVertexListMap.end() && hypNbVertex!=0) {
1898 h->ClearAllEnforcedVertices();
1902 // All enforced vertices for a specific entry were deleted
1903 for (int i=0 ; i<hypNbVertex; i++) {
1904 BLSURFPlugin::TFaceEntryEnfVertexListMapElement el = allEnforcedVerticesByFace[i];
1905 TEnfName entry = el.faceEntry.in();
1906 if (h_data.faceEntryEnfVertexListMap.find(entry) == h_data.faceEntryEnfVertexListMap.end()) {
1907 MESSAGE("Remove all enforced vertices for entry " << entry);
1908 h->UnsetEnforcedVerticesEntry(entry.c_str());
1912 // One or several enforced vertices are added or removed for a specific entry
1913 TEnfVertexList enfVertexFromHyp;
1914 BLSURFPlugin::TEnfVertexList_var hypEnfVertexList;
1917 TEnfVertexList::const_iterator evsIt, enfVertexToRemove;
1918 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1919 faceEntry = evmIt->first;
1920 evs = evmIt->second;
1921 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
1922 evsIt = evs.begin();
1924 hypEnfVertexList = h->GetEnforcedVerticesEntry(faceEntry.c_str());
1925 hypNbVertex = hypEnfVertexList->length();
1926 MESSAGE("Number of enforced vertices from hypothesis: " << hypNbVertex);
1927 enfVertexFromHyp.clear();
1928 for (int i =0 ; i<hypNbVertex ; i++) {
1929 TEnfVertex *_enfVertex = new TEnfVertex();
1930 _enfVertex->name = string("");
1931 _enfVertex->name = CORBA::string_dup(hypEnfVertexList[i].name.in());
1932 _enfVertex->geomEntry = string("");
1933 _enfVertex->geomEntry = CORBA::string_dup(hypEnfVertexList[i].geomEntry.in());
1934 _enfVertex->grpName = string("");
1935 _enfVertex->grpName = CORBA::string_dup(hypEnfVertexList[i].grpName.in());
1936 for (int j=0 ; j< hypEnfVertexList[i].coords.length() ; j++)
1937 _enfVertex->coords.push_back(hypEnfVertexList[i].coords[j]);
1938 enfVertexFromHyp.insert(_enfVertex);
1939 MESSAGE("From hyp: enf vertex " << _enfVertex->name);
1940 // MESSAGE("From hyp: enf. vertex at " << _coords[0]<<", "<<_coords[1]<<", "<<_coords[2]);
1943 // TEnfVertex *enfVertex;
1944 for ( ; evsIt != evs.end() ; ++evsIt) {
1946 // enfVertex = (*evsIt);
1947 if ((*evsIt)->coords.size()) {
1948 x = (*evsIt)->coords[0];
1949 y = (*evsIt)->coords[1];
1950 z = (*evsIt)->coords[2];
1952 ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
1953 enfVertexFromHyp.erase((*evsIt));
1955 // for (enfVertexToRemove = enfVertexFromHyp.begin() ; enfVertexToRemove != enfVertexFromHyp.end() ; ++enfVertexToRemove) {
1956 // if (!TEnfVertexGUICmp(&enfVertex, &(*enfVertexToRemove))) {
1957 // MESSAGE("Enf vertex " << enfVertex.name << " must not be deleted")
1958 // enfVertexFromHyp.erase(enfVertexToRemove);
1963 // Remove old vertices
1964 enfVertexToRemove = enfVertexFromHyp.begin();
1965 for ( ; enfVertexToRemove!=enfVertexFromHyp.end() ; ++enfVertexToRemove) {
1966 // enfVertex = (*enfVertexToRemove);
1967 if (h_data.enfVertexList.find((*enfVertexToRemove)) != h_data.enfVertexList.end()) {
1969 // for ( evsIt=h_data.enfVertexList.begin();evsIt!=h_data.enfVertexList.end();evsIt++) {
1970 // if (TEnfVertexGUICmp(&(*evsIt),&enfVertex)) {
1971 MESSAGE("Remove enf vertex " << (*enfVertexToRemove)->name);
1972 if ((*enfVertexToRemove)->coords.size()) {
1973 x = (*enfVertexToRemove)->coords[0];
1974 y = (*enfVertexToRemove)->coords[1];
1975 z = (*enfVertexToRemove)->coords[2];
1977 ret = h->UnsetEnforcedVertexEntry(faceEntry.c_str(), x, y, z, (*enfVertexToRemove)->geomEntry.c_str());
1987 catch(const std::exception& ex) {
1988 std::cout << "Exception: " << ex.what() << std::endl;
1991 // catch(const SALOME::SALOME_Exception& ex)
1994 // // SalomeApp_Tools::QtCatchCorbaException(ex);
2000 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2001 Stores the widgets content to the hypothesis data.
2003 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2005 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
2006 h_data.myName = myName ? myName->text() : "";
2007 h_data.myTopology = myTopology->currentIndex();
2008 h_data.myPhysicalMesh = myPhysicalMesh->currentIndex();
2009 h_data.myPhySize = myPhySize->GetValue();
2010 #ifdef WITH_SIZE_BOUNDARIES
2011 h_data.myPhyMin = myPhyMin->GetValue();
2012 h_data.myPhyMax = myPhyMax->GetValue();
2013 h_data.myGeoMin = myGeoMin->GetValue();
2014 h_data.myGeoMax = myGeoMax->GetValue();
2016 h_data.myGeometricMesh = myGeometricMesh->currentIndex();
2017 h_data.myAngleMeshS = myAngleMeshS->GetValue();
2018 h_data.myAngleMeshC = myAngleMeshC->GetValue();
2019 h_data.myGradation = myGradation->GetValue();
2020 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
2021 h_data.myDecimesh = myDecimesh->isChecked();
2022 h_data.myVerbosity = myVerbosity->value();
2025 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2026 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2027 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2028 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2029 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; ";
2030 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2031 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2032 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; ";
2033 #ifdef WITH_SIZE_BOUNDARIES
2034 guiHyp += "hphymin = " + QString::number( h_data.myPhyMin ) + "; ";
2035 guiHyp += "hphymax = " + QString::number( h_data.myPhyMax ) + "; ";
2036 guiHyp += "hgeomin = " + QString::number( h_data.myGeoMin ) + "; ";
2037 guiHyp += "hgeomax = " + QString::number( h_data.myGeoMax ) + "; ";
2040 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2041 int row = 0, nbRows = myOptionTable->rowCount();
2042 for ( ; row < nbRows; ++row )
2044 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2045 if ( id >= 0 && id < myOptions->length() )
2047 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
2048 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
2049 if ( value.isNull() )
2051 that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
2053 guiHyp += name + " = " + value + "; ";
2058 row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2059 for ( ; row < nbRows; ++row )
2061 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2062 if ( that->mySMPMap.contains(entry) )
2063 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2066 // Enforced vertices
2067 h_data.enfVertexList.clear();
2068 h_data.faceEntryEnfVertexListMap.clear();
2070 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2071 int nbEnforcedVertices = 0;
2072 std::string groupName = "";
2073 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
2074 for (int i=0 ; i<nbEnforcedShapes ; i++) {
2075 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
2077 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2078 nbEnforcedVertices = shapeItem->childCount();
2079 if (nbEnforcedVertices >0) {
2080 double childValueX,childValueY,childValueZ;
2081 std::string childName, vertexEntry;
2082 QTreeWidgetItem* child;
2085 for (row = 0;row<nbEnforcedVertices;row++) {
2086 child = shapeItem->child(row);
2087 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2088 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2089 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2090 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2091 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2092 if (makeGroupsCheck->isChecked())
2093 groupName = myGlobalGroupName->text().toStdString();
2095 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2097 TEnfVertex *enfVertex = new TEnfVertex();
2098 enfVertex->name = childName;
2099 if (vertexEntry.empty()) {
2100 enfVertex->coords.push_back(childValueX);
2101 enfVertex->coords.push_back(childValueY);
2102 enfVertex->coords.push_back(childValueZ);
2105 enfVertex->geomEntry = vertexEntry;
2106 enfVertex->grpName = groupName;
2107 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2108 // if (it == h_data.enfVertexList.end())
2109 h_data.enfVertexList.insert(enfVertex);
2110 evs.insert(enfVertex);
2112 if (groupName != "")
2113 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2116 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2121 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2125 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
2126 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged");
2127 bool isPhysicalUserDefined = (myPhysicalMesh->currentIndex() == PhysicalUserDefined);
2128 bool isSizeMap = (myPhysicalMesh->currentIndex() == SizeMap);
2129 bool isCustom = (isPhysicalUserDefined || isSizeMap) ;
2130 bool geomIsCustom = (myGeometricMesh->currentIndex() == UserDefined);
2132 myGradation->setEnabled(!isPhysicalUserDefined || geomIsCustom);
2133 myPhySize->setEnabled(isCustom);
2134 myPhyMax->setEnabled(isCustom);
2135 myPhyMin->setEnabled(isCustom);
2137 if ( !myGradation->isEnabled())
2138 myGradation->SetValue( 1.1 );
2141 if ( myGeometricMesh->currentIndex() == DefaultGeom ) {
2142 myGeometricMesh->setCurrentIndex( UserDefined );
2143 onGeometricMeshChanged();
2148 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
2149 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged");
2150 bool isCustom = (myGeometricMesh->currentIndex() == UserDefined);
2151 bool phyIsSizemap = (myPhysicalMesh->currentIndex() == SizeMap);
2153 myAngleMeshS->setEnabled(isCustom);
2154 myAngleMeshC->setEnabled(isCustom);
2155 myGradation->setEnabled(isCustom || phyIsSizemap);
2156 myGeoMax->setEnabled(isCustom);
2157 myGeoMin->setEnabled(isCustom);
2159 if ( !myGradation->isEnabled())
2160 myGradation->SetValue( 1.1 );
2163 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
2164 if ( myPhysicalMesh->currentIndex() == DefaultSize ) {
2165 myPhysicalMesh->setCurrentIndex( PhysicalUserDefined );
2166 onPhysicalMeshChanged();
2171 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2173 QMenu* menu = (QMenu*)sender();
2174 // fill popup with option names
2176 if ( myOptions.operator->() ) {
2177 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
2178 QString name_value = myOptions[i].in();
2179 QString name = name_value.split( ":", QString::KeepEmptyParts )[0];
2180 menu->addAction( name );
2185 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
2187 myOptionTable->setFocus();
2188 QMenu* menu = (QMenu*)( a->parent() );
2190 int idx = menu->actions().indexOf( a );
2191 QString idStr = QString("%1").arg( idx );
2192 QString option = myOptions[idx].in();
2193 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
2195 // look for a row with optionName
2196 int row = 0, nbRows = myOptionTable->rowCount();
2197 for ( ; row < nbRows; ++row )
2198 if ( myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
2200 // add a row if not found
2201 if ( row == nbRows ) {
2202 myOptionTable->setRowCount( row+1 );
2203 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
2204 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
2205 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
2206 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
2207 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
2208 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
2209 Qt::ItemIsEditable |
2210 Qt::ItemIsEnabled );
2211 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2213 myOptionTable->clearSelection();
2214 myOptionTable->scrollToItem( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2215 //myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
2216 myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
2217 //myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2220 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
2222 // clear option values and remember selected row
2223 QList<int> selectedRows;
2224 QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
2225 QTableWidgetItem* item;
2226 foreach( item, selected ) {
2227 int row = item->row();
2228 if ( !selectedRows.contains( row ) ) {
2229 selectedRows.append( row );
2230 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2231 if ( id >= 0 && id < myOptions->length() )
2232 myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2235 qSort( selectedRows );
2236 QListIterator<int> it( selectedRows );
2238 while ( it.hasPrevious() )
2239 myOptionTable->removeRow( it.previous() );
2242 // **********************
2243 // *** BEGIN SIZE MAP ***
2244 // **********************
2246 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2248 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2250 if ( myGeomSelWdg2->IsObjectSelected() ){
2251 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2253 else if ( myGeomSelWdg1->IsObjectSelected() ){
2254 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2256 std::string entry = (string) mySMapObject->GetStudyEntry();
2257 QString qEntry = QString::fromStdString(entry);
2258 if (that->mySMPMap.contains(qEntry) && that->mySMPMap[qEntry] != "__TO_DELETE__" ) {
2259 addMapButton->setEnabled(false);
2260 modifyMapButton->setEnabled(true);
2263 addMapButton->setEnabled(true);
2264 modifyMapButton->setEnabled(false);
2269 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2271 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2272 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2273 if (col == SMP_SIZEMAP_COLUMN){
2274 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2275 if (!mySMPMap.contains(entry))
2277 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2278 CORBA::Object_var obj = entryToObject(entry);
2279 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){ // ADVANCED MAPS
2280 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2281 double phySize = that->mySMPMap[entry].toDouble(); // Retrieve values of the selected item in the current tab widgets
2282 double infDist = that->myAttDistMap[entry];
2283 double constDist = that->myDistMap[entry];
2284 QString attEntry = that->myATTMap[entry];
2285 CORBA::Object_var attObj = entryToObject(attEntry);
2286 myAttSizeSpin->setValue(phySize);
2287 if (sizeMap.startsWith("Attractor")){
2288 myAttDistSpin->setValue(infDist);
2289 myAttractorCheck->setChecked(true);
2292 myAttractorCheck->setChecked(false);
2294 if (sizeMap.startsWith("Constant") || constDist > std::numeric_limits<double>::epsilon()){
2295 myAttDistSpin2->setValue(constDist);
2296 myConstSizeCheck->setChecked(true);
2299 myConstSizeCheck->setChecked(false);
2301 myGeomSelWdg2->SetObject(obj);
2302 myAttSelWdg->SetObject(attObj);
2304 else { // CLASSIC MAPS
2305 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2306 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2307 if (!sizeMap.startsWith("def")){
2308 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2314 void BLSURFPluginGUI_HypothesisCreator::onSmpTabChanged(int tab)
2316 myAttDistSpin->setValue(0.); // Reinitialize widgets
2317 myAttSizeSpin->setValue(0.);
2318 myAttDistSpin2->setValue(0.);
2319 mySmpSizeSpin->setValue(0.);
2320 myGeomSelWdg1->deactivateSelection();
2321 myGeomSelWdg2->deactivateSelection();
2322 myAttSelWdg->deactivateSelection();
2323 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2324 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2325 myAttSelWdg->SetObject(CORBA::Object::_nil());
2326 myAttractorCheck->setChecked(false);
2327 myConstSizeCheck->setChecked(false);
2330 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2332 if (state == Qt::Checked){
2333 myAttSelWdg->setEnabled(true);
2334 myAttSizeSpin->setEnabled(true);
2335 myAttSizeLabel->setEnabled(true);
2336 myAttDistSpin->setEnabled(true);
2337 myAttDistLabel->setEnabled(true);
2338 if (!myAttSelWdg->IsObjectSelected()){
2339 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2342 if (state == Qt::Unchecked){
2343 myAttDistSpin->setEnabled(false);
2344 myAttDistLabel->setEnabled(false);
2345 myAttDistSpin->setValue(0.);
2346 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2347 myAttSelWdg->setEnabled(false);
2348 myAttSizeSpin->setEnabled(false);
2349 myAttSizeLabel->setEnabled(false);
2350 myAttDistSpin2->setEnabled(false);
2351 myAttDistLabel2->setEnabled(false);
2353 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2354 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2359 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2361 if (state == Qt::Checked){
2362 myAttSelWdg->setEnabled(true);
2363 myAttSizeSpin->setEnabled(true);
2364 myAttSizeLabel->setEnabled(true);
2365 myAttDistSpin2->setEnabled(true);
2366 myAttDistLabel2->setEnabled(true);
2367 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2368 !myAttSelWdg->IsObjectSelected()){
2369 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2372 if (state == Qt::Unchecked){
2373 myAttDistSpin2->setEnabled(false);
2374 myAttDistLabel2->setEnabled(false);
2375 myAttDistSpin2->setValue(0.);
2376 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2377 myAttSelWdg->setEnabled(false);
2378 myAttSizeSpin->setEnabled(false);
2379 myAttSizeLabel->setEnabled(false);
2380 myAttDistSpin->setEnabled(false);
2381 myAttDistLabel->setEnabled(false);
2383 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2384 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2389 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2391 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
2392 QList<int> selectedRows;
2393 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2394 QTreeWidgetItem* item;
2395 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2397 qSort( selectedRows );
2398 QListIterator<QTreeWidgetItem*> it( selected );
2400 while ( it.hasPrevious() ) {
2401 item = it.previous();
2402 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2403 if (that->mySMPMap.contains(entry))
2404 that->mySMPMap[entry] = "__TO_DELETE__";
2405 if (that->mySMPShapeTypeMap.contains(entry))
2406 that->mySMPShapeTypeMap.remove(entry);
2407 if (that->myATTMap.contains(entry))
2408 that->myATTMap.remove(entry);
2409 if (that->myDistMap.contains(entry))
2410 that->myDistMap.remove(entry);
2411 if (that->myAttDistMap.contains(entry))
2412 that->myAttDistMap.remove(entry);
2415 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2416 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2419 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2421 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
2422 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2423 if (col == SMP_SIZEMAP_COLUMN) {
2424 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2425 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2426 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2427 // MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
2428 if (! that->mySMPShapeTypeMap.contains(entry))
2430 if (that->mySMPMap.contains(entry))
2431 if (that->mySMPMap[entry] == sizeMap
2432 || sizeMap.startsWith("Attractor")
2433 || sizeMap.startsWith("Constant") ){
2436 if (! sizeMap.isEmpty()) {
2437 that->mySMPMap[entry] = sizeMap;
2438 sizeMapValidationFromEntry(entry);
2441 MESSAGE("Size map empty: reverse to precedent value" );
2442 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2444 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2448 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2450 if ( smpTab->currentIndex() == ATT_TAB ){
2451 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2452 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2453 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2454 insertAttractor(mySMapObject, myAttObject);
2457 if (smpTab->currentIndex() == SMP_STD_TAB ){
2458 if ( myGeomSelWdg1->IsObjectSelected() ){
2459 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2460 insertElement(mySMapObject);
2463 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2464 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2465 myAttDistSpin->setValue(0.);
2466 myAttSizeSpin->setValue(0.);
2467 myAttDistSpin2->setValue(0.);
2468 mySmpSizeSpin->setValue(0.);
2469 myConstSizeCheck->setChecked(false);
2470 myAttractorCheck->setChecked(false);
2471 myGeomSelWdg1->deactivateSelection();
2472 myGeomSelWdg2->deactivateSelection();
2473 myAttSelWdg->deactivateSelection();
2474 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2475 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2476 myAttSelWdg->SetObject(CORBA::Object::_nil());
2479 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
2481 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
2482 if ( smpTab->currentIndex() == ATT_TAB ){
2483 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2484 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2485 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2486 insertAttractor(mySMapObject, myAttObject, /*modify = */true);
2489 if (smpTab->currentIndex() == SMP_STD_TAB ){
2490 if ( myGeomSelWdg1->IsObjectSelected() ){
2491 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2492 insertElement(mySMapObject, /*modify = */true);
2495 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2496 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2497 myAttDistSpin->setValue(0.);
2498 myAttSizeSpin->setValue(0.);
2499 myAttDistSpin2->setValue(0.);
2500 mySmpSizeSpin->setValue(0.);
2501 myConstSizeCheck->setChecked(false);
2502 myAttractorCheck->setChecked(false);
2503 myGeomSelWdg1->deactivateSelection();
2504 myGeomSelWdg2->deactivateSelection();
2505 myAttSelWdg->deactivateSelection();
2506 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2507 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2508 myAttSelWdg->SetObject(CORBA::Object::_nil());
2511 void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
2513 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
2514 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2515 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2517 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2519 TopAbs_ShapeEnum shapeType;
2520 string entry, shapeName;
2521 entry = (string) anObject->GetStudyEntry();
2522 MESSAGE("entry = "<<entry);
2523 shapeName = anObject->GetName();
2524 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
2525 mySizeMapTable->setFocus();
2527 shapeEntry = QString::fromStdString(entry);
2528 double phySize = mySmpSizeSpin->value();
2529 std::ostringstream oss;
2532 sizeMap = QString::fromStdString(oss.str());
2533 QTreeWidgetItem* item = new QTreeWidgetItem();
2535 int rowToChange = findRowFromEntry(shapeEntry);
2536 item = mySizeMapTable->topLevelItem( rowToChange );
2539 if (that->mySMPMap.contains(shapeEntry)) {
2540 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2541 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2545 mySizeMapTable->addTopLevelItem(item);
2547 that->mySMPMap[shapeEntry] = sizeMap;
2548 that->myDistMap[shapeEntry] = 0. ;
2549 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
2550 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2551 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
2552 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
2553 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
2554 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
2555 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2556 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2557 mySizeMapTable->clearSelection();
2559 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2560 myPhysicalMesh->setCurrentIndex( SizeMap );
2561 onPhysicalMeshChanged();
2565 void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
2567 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
2568 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2569 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2571 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2573 TopAbs_ShapeEnum shapeType;
2574 string entry, attEntry, faceName, attName;
2575 entry = (string) aFace->GetStudyEntry();
2576 attEntry = (string) anAttractor->GetStudyEntry();
2577 faceName = aFace->GetName();
2578 attName = anAttractor->GetName();
2579 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
2580 mySizeMapTable->setFocus();
2581 QString shapeEntry = QString::fromStdString(entry);
2582 QString qAttEntry = QString::fromStdString(attEntry);
2584 double phySize = h->GetPhySize();
2585 double infDist = 0. ;
2586 double constDist = 0. ;
2587 phySize = myAttSizeSpin->value();
2588 if (myAttractorCheck->isChecked()){
2589 infDist = myAttDistSpin->value();
2591 if (myConstSizeCheck->isChecked()){
2592 constDist = myAttDistSpin2->value();
2594 std::ostringstream oss;
2595 std::ostringstream oss2;
2596 std::ostringstream oss3;
2600 QString sizeMap = QString::fromStdString(oss.str());
2601 QString infDistString = QString::fromStdString(oss2.str());
2602 QString constDistString = QString::fromStdString(oss3.str());
2604 QTreeWidgetItem* item;
2605 QTreeWidgetItem* child;
2607 int rowToChange = findRowFromEntry(shapeEntry);
2608 item = mySizeMapTable->topLevelItem( rowToChange );
2609 child = item->child( 0 );
2612 if (that->mySMPMap.contains(shapeEntry)) {
2613 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2614 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2618 item = new QTreeWidgetItem();
2619 child = new QTreeWidgetItem();
2620 mySizeMapTable->addTopLevelItem(item);
2621 item->addChild(child);
2623 that->mySMPMap.insert(shapeEntry,sizeMap);
2624 that->myATTMap.insert(shapeEntry,qAttEntry);
2625 that->myAttDistMap.insert(shapeEntry,infDist);
2626 that->myDistMap.insert(shapeEntry,constDist);
2627 that->mySMPShapeTypeMap.insert(shapeEntry,shapeType);
2628 item->setExpanded(true);
2629 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
2630 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
2631 if (infDist > std::numeric_limits<double>::epsilon()){
2632 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
2634 else if (constDist > std::numeric_limits<double>::epsilon()){
2635 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
2637 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2639 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
2640 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
2641 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
2643 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2644 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2645 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
2647 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2648 myPhysicalMesh->setCurrentIndex( SizeMap );
2649 onPhysicalMeshChanged();
2651 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2654 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
2656 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
2657 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2658 for ( ; row < nbRows; ++row )
2659 if (! sizeMapValidationFromRow(row))
2664 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
2666 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
2667 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2668 bool res = sizeMapValidationFromEntry(myEntry,displayError);
2669 mySizeMapTable->setFocus();
2673 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
2675 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
2677 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2679 if (! that->mySMPMap.contains(myEntry)) {
2680 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
2683 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
2684 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
2690 if (that->mySMPMap[myEntry].startsWith("def")) {
2691 // MESSAGE("custom function" );
2692 expr = that->mySMPMap[myEntry].toStdString();
2694 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
2695 // MESSAGE("Attractor" );
2696 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)) {
2699 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])" );
2705 // case size map is empty
2706 if (that->mySMPMap[myEntry].isEmpty()) {
2708 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
2712 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
2713 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
2714 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
2715 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
2716 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
2717 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
2720 //assert(Py_IsInitialized());
2721 if (! Py_IsInitialized())
2722 throw ("Erreur: Python interpreter is not initialized");
2723 PyGILState_STATE gstate;
2724 gstate = PyGILState_Ensure();
2726 PyObject * obj = NULL;
2727 PyObject* new_stderr = NULL;
2728 string err_description="";
2729 obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
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(),"Definition of Python Function : Error" ,err_description.c_str() );
2740 PyGILState_Release(gstate);
2745 PyObject * func = NULL;
2746 func = PyObject_GetAttrString(main_mod, "f");
2750 new_stderr=newPyStdOut(err_description);
2751 PySys_SetObject((char*)"stderr", new_stderr);
2753 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
2754 Py_DECREF(new_stderr);
2756 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
2757 PyGILState_Release(gstate);
2761 PyGILState_Release(gstate);
2763 // MESSAGE("SizeMap expression "<<expr<<" is valid");
2768 QString BLSURFPluginGUI_HypothesisCreator::caption() const
2770 return tr( "BLSURF_TITLE" );
2773 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
2775 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
2778 QString BLSURFPluginGUI_HypothesisCreator::type() const
2780 return tr( "BLSURF_HYPOTHESIS" );
2783 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
2785 return "blsurf_hypo_page.html";
2788 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
2791 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2793 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2798 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
2800 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
2801 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
2802 CORBA::Object_var obj;
2803 SALOMEDS::GenericAttribute_var anAttr;
2804 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
2805 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
2806 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2807 CORBA::String_var aVal = anIOR->Value();
2808 obj = myStudy->ConvertIORToObject(aVal);
2813 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
2814 QString entryForChecking;
2815 int endRow = mySizeMapTable->topLevelItemCount()-1;
2817 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2818 while (entry != entryForChecking && row <= endRow){
2820 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2822 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)