1 // Copyright (C) 2007-2012 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>
61 #include <QFileDialog>
63 #include <QStandardItemModel>
64 #include <QStandardItem>
65 #include <QTreeWidget>
66 #include <QTreeWidgetItem>
67 #include <QModelIndexList>
69 #include <LightApp_SelectionMgr.h>
70 #include <SalomeApp_Application.h>
71 #include <SALOME_ListIO.hxx>
72 #include <SALOME_ListIteratorOfListIO.hxx>
73 #include "SALOME_LifeCycleCORBA.hxx"
75 #include <TopoDS_Shape.hxx>
76 #include <TopoDS_Iterator.hxx>
77 #include <SMESH_Gen_i.hxx>
78 #include <boost/shared_ptr.hpp>
79 #include <boost/algorithm/string.hpp>
80 #include <structmember.h>
84 #define WITH_SIZE_BOUNDARIES
111 OPTION_ID_COLUMN = 0,
121 // Enforced vertices array columns
122 ENF_VER_NAME_COLUMN = 0,
123 ENF_VER_FACE_ENTRY_COLUMN,
127 ENF_VER_ENTRY_COLUMN,
128 ENF_VER_GROUP_COLUMN,
155 // Enforced vertices inputs
163 // ENF_VER_GROUP_CHECK,
167 ENF_VER_INTERNAL_ALL_FACES,
168 ENF_VER_INTERNAL_ALL_FACES_GROUP,
169 // ENF_VER_VERTEX_BTN,
170 // ENF_VER_REMOVE_BTN,
171 // ENF_VER_SEPARATOR,
176 /**************************************************
177 Begin initialization Python structures and objects
178 ***************************************************/
187 PyStdOut_dealloc(PyStdOut *self)
193 PyStdOut_write(PyStdOut *self, PyObject *args)
197 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
201 *(self->out)=*(self->out)+c;
207 static PyMethodDef PyStdOut_methods[] = {
208 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
209 PyDoc_STR("write(string) -> None")},
210 {NULL, NULL} /* sentinel */
213 static PyMemberDef PyStdOut_memberlist[] = {
214 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
215 (char*)"flag indicating that a space needs to be printed; used by print"},
216 {NULL} /* Sentinel */
219 static PyTypeObject PyStdOut_Type = {
220 /* The ob_type field must be initialized in the module init function
221 * to be portable to Windows without using C++. */
222 PyObject_HEAD_INIT(NULL)
225 sizeof(PyStdOut), /*tp_basicsize*/
228 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
235 0, /*tp_as_sequence*/
240 PyObject_GenericGetAttr, /*tp_getattro*/
241 /* softspace is writable: we must supply tp_setattro */
242 PyObject_GenericSetAttr, /* tp_setattro */
244 Py_TPFLAGS_DEFAULT, /*tp_flags*/
248 0, /*tp_richcompare*/
249 0, /*tp_weaklistoffset*/
252 PyStdOut_methods, /*tp_methods*/
253 PyStdOut_memberlist, /*tp_members*/
267 PyObject * newPyStdOut( std::string& out )
270 self = PyObject_New(PyStdOut, &PyStdOut_Type);
275 return (PyObject*)self;
278 /*************************************************
279 End initialization Python structures and objects
280 **************************************************/
284 // BEGIN EnforcedTreeWidgetDelegate
287 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
288 : QItemDelegate(parent)
292 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
293 const QStyleOptionViewItem & option ,
294 const QModelIndex & index ) const
296 QModelIndex father = index.parent();
297 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
299 if (index.column() == ENF_VER_X_COLUMN || \
300 index.column() == ENF_VER_Y_COLUMN || \
301 index.column() == ENF_VER_Z_COLUMN)
303 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
304 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
305 editor->setReadOnly(!entry.isEmpty());
306 editor->setDisabled(!entry.isEmpty());
311 QLineEdit *editor = new QLineEdit(parent);
312 if (index.column() != ENF_VER_GROUP_COLUMN) {
313 editor->setReadOnly(!entry.isEmpty());
314 editor->setDisabled(!entry.isEmpty());
320 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
321 const QModelIndex &index) const
323 QString value = index.model()->data(index, Qt::EditRole).toString();
325 if (index.column() == ENF_VER_X_COLUMN ||
326 index.column() == ENF_VER_Y_COLUMN ||
327 index.column() == ENF_VER_Z_COLUMN)
329 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
330 lineEdit->setText(value);
333 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
334 lineEdit->setText(value);
338 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
339 const QModelIndex &index) const
341 QModelIndex parent = index.parent();
342 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
343 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
344 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
345 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
346 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
347 } else if (index.column() == ENF_VER_NAME_COLUMN) {
348 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
349 QString value = lineEdit->text();
350 if (entry.isEmpty() && !vertexExists(model, index, value))
351 model->setData(index, value, Qt::EditRole);
352 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
353 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
354 QString value = lineEdit->text();
355 if (! vertexExists(model, index, value))
356 model->setData(index, value, Qt::EditRole);
357 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
358 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
359 model->setData(index, lineEdit->text(), Qt::EditRole);
363 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
364 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
366 editor->setGeometry(option.rect);
369 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
370 const QModelIndex &index, QString value) const
373 QModelIndex parent = index.parent();
374 int row = index.row();
375 int col = index.column();
377 if (parent.isValid() && !value.isEmpty()) {
378 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
380 if (col == ENF_VER_X_COLUMN) {
381 x = value.toDouble();
382 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
383 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
385 if (col == ENF_VER_Y_COLUMN) {
386 y = value.toDouble();
387 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
388 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
390 if (col == ENF_VER_Z_COLUMN) {
391 z = value.toDouble();
392 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
393 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
395 int nbChildren = model->rowCount(parent);
396 for (int i = 0 ; i < nbChildren ; i++) {
398 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
399 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
400 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
401 if ((childX == x) && (childY == y) && (childZ == z)) {
408 else if (col == ENF_VER_NAME_COLUMN) {
409 int nbChildren = model->rowCount(parent);
410 for (int i = 0 ; i < nbChildren ; i++) {
412 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
413 if (childName == value) {
426 // END EnforcedTreeWidgetDelegate
430 // BEGIN BLSURFPluginGUI_ObjectReferenceParamWdg
432 //================================================================================
434 // BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
435 // ( SUIT_SelectionFilter* f, QWidget* parent, bool multiSelection)
436 // : StdMeshersGUI_ObjectReferenceParamWdg(f, parent, multiSelection)
442 // BLSURFPluginGUI_ObjectReferenceParamWdg::BLSURFPluginGUI_ObjectReferenceParamWdg
443 // ( MeshObjectType objType, QWidget* parent, bool multiSelection )
444 // : StdMeshersGUI_ObjectReferenceParamWdg( objType, parent, multiSelection )
449 // BLSURFPluginGUI_ObjectReferenceParamWdg::~BLSURFPluginGUI_ObjectReferenceParamWdg()
453 // mySelectionMgr->removeFilter( myFilter );
458 // void BLSURFPluginGUI_ObjectReferenceParamWdg::init()
460 // StdMeshersGUI_ObjectReferenceParamWdg::init();
461 // disconnect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection()));
462 // connect( mySelButton, SIGNAL(toggled(bool)), SLOT(setActivationStatus(bool)));
465 // void BLSURFPluginGUI_ObjectReferenceParamWdg::setActivationStatus(bool status)
468 // activateSelection();
470 // deactivateSelection();
473 // void BLSURFPluginGUI_ObjectReferenceParamWdg::activateSelectionOnly()
475 // if ( !mySelectionActivated && mySelectionMgr )
477 // mySelectionActivated = true;
478 // mySelectionMgr->clearFilters();
479 // if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
480 // aViewWindow->SetSelectionMode(ActorSelection);
482 // mySelectionMgr->installFilter( myFilter );
483 // connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
485 // emit selectionActivated();
488 // void BLSURFPluginGUI_ObjectReferenceParamWdg::deactivateSelectionOnly()
490 // mySelectionActivated = false;
491 // disconnect(mySelectionMgr, 0, this, 0 );
492 // mySelectionMgr->removeFilter( myFilter );
496 // END BLSURFPluginGUI_ObjectReferenceParamWdg
500 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
501 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
504 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
505 : SMESHGUI_GenericHypothesisCreator( theHypType )
507 MESSAGE("BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator");
508 this->mySMPMap.clear();
510 GeomToolSelected = NULL;
511 GeomToolSelected = getGeomSelectionTool();
513 aSel = GeomToolSelected->selectionMgr();
515 /* Initialize the Python interpreter */
516 if (! Py_IsInitialized())
517 throw ("Error: Python interpreter is not initialized");
518 PyGILState_STATE gstate;
519 gstate = PyGILState_Ensure();
522 main_mod = PyImport_AddModule("__main__");
525 main_dict = PyModule_GetDict(main_mod);
527 PyRun_SimpleString("from math import *");
528 PyGILState_Release(gstate);
532 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
537 * \brief {Get or create the geom selection tool for active study}
539 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool()
541 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
542 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
543 if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
544 that->GeomToolSelected = new GeomSelectionTools(aStudy);
546 return that->GeomToolSelected;
549 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
551 return GeometryGUI::GetGeomGen();
555 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
557 MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams");
560 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
561 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
565 myOptionTable->setFocus();
566 QApplication::instance()->processEvents();
568 int row = 0, nbRows = myOptionTable->rowCount();
569 for ( ; row < nbRows; ++row )
571 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
572 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
573 if ( !value.isEmpty() ) {
575 QString optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().trimmed();
576 if (optionType == "PRECAD")
577 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
578 else if (optionType == "BLSURF")
579 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
581 catch ( const SALOME::SALOME_Exception& ex )
583 msg = ex.details.text.in();
591 h->SetOptionValues( myOptions ); // restore values
592 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
595 // SizeMap and attractors
598 mySizeMapTable->setFocus();
599 QApplication::instance()->processEvents();
601 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
602 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
604 for ( ; row < nbRows; ++row )
606 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
607 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
608 MESSAGE("entry ="<<entry.toStdString())
609 if ( !sizeMap.isEmpty() ) {
610 if (that->sizeMapValidationFromRow(row))
613 MESSAGE("entry ="<<entry.toStdString())
614 MESSAGE("sizeMap ="<<sizeMap.toStdString())
616 e = entry.toStdString();
617 s = that->mySMPMap[entry].toStdString();
618 MESSAGE("row = "<<row)
621 h->SetSizeMapEntry( e.c_str(), s.c_str() );
623 catch ( const SALOME::SALOME_Exception& ex )
625 msg = ex.details.text.in();
642 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
644 MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame");
646 QFrame* fr = new QFrame( 0 );
647 // fr-> setMinimumSize(600,400);
648 QVBoxLayout* lay = new QVBoxLayout( fr );
649 // lay->setSizeConstraint(QLayout::SetDefaultConstraint);
651 lay->setSpacing( 0 );
654 QTabWidget* tab = new QTabWidget( fr );
655 tab->setTabShape( QTabWidget::Rounded );
656 tab->setTabPosition( QTabWidget::North );
657 lay->addWidget( tab );
660 myStdGroup = new QWidget();
661 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
662 aStdLayout->setSpacing( 6 );
663 aStdLayout->setMargin( 11 );
667 myName = new QLineEdit( myStdGroup );
669 myGradation = new SMESHGUI_SpinBox( myStdGroup );
670 myGradation->RangeStepAndValidator(1.1, 2.5, 0.1, "length_precision");
672 myPhysicalMesh = new QComboBox( myStdGroup );
673 QStringList physicalTypes;
674 physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ) << tr( "BLSURF_SIZE_MAP");
675 myPhysicalMesh->addItems( physicalTypes );
677 myPhySize = new SMESHGUI_SpinBox( myStdGroup );
678 myPhySize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
680 #ifdef WITH_SIZE_BOUNDARIES
681 myPhyMin = new SMESHGUI_SpinBox( myStdGroup );
682 myPhyMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
683 myPhyMin->setText("");
684 myPhyMax = new SMESHGUI_SpinBox( myStdGroup );
685 myPhyMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
686 myPhyMax->setText("");
689 myGeometricMesh = new QComboBox( myStdGroup );
691 types << tr( "BLSURF_DEFAULT_GEOM" ) << tr( "BLSURF_CUSTOM_GEOM" );
692 myGeometricMesh->addItems( types );
694 myAngleMeshS = new SMESHGUI_SpinBox( myStdGroup );
695 myAngleMeshS->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
697 myAngleMeshC = new SMESHGUI_SpinBox( myStdGroup );
698 myAngleMeshC->RangeStepAndValidator(0, 16, 0.5, "angular_precision");
700 #ifdef WITH_SIZE_BOUNDARIES
701 myGeoMin = new SMESHGUI_SpinBox( myStdGroup );
702 myGeoMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
703 myGeoMin->setText("");
704 myGeoMax = new SMESHGUI_SpinBox( myStdGroup );
705 myGeoMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
706 myGeoMax->setText("");
708 myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup );
709 myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup );
711 // ADD WIDGETS (STANDARD TAB)
714 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 );
715 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
717 aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ), row, 0, 1, 1 );
718 aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 );
719 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 );
720 aStdLayout->addWidget( myPhySize, row++, 1, 1, 1 );
721 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 );
722 aStdLayout->addWidget( myGradation, row++, 1, 1, 1 );
723 #ifdef WITH_SIZE_BOUNDARIES
724 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ), row, 0, 1, 1 );
725 aStdLayout->addWidget( myPhyMin, row++, 1, 1, 1 );
726 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ), row, 0, 1, 1 );
727 aStdLayout->addWidget( myPhyMax, row++, 1, 1, 1 );
734 aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ), row, 2, 1, 1 );
735 aStdLayout->addWidget( myGeometricMesh, row++, 3, 1, 1 );
736 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 2, 1, 1 );
737 aStdLayout->addWidget( myAngleMeshS, row++, 3, 1, 1 );
738 aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 2, 1, 1 );
739 aStdLayout->addWidget( myAngleMeshC, row++, 3, 1, 1 );
740 #ifdef WITH_SIZE_BOUNDARIES
741 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ), row, 2, 1, 1 );
742 aStdLayout->addWidget( myGeoMin, row++, 3, 1, 1 );
743 aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ), row, 2, 1, 1 );
744 aStdLayout->addWidget( myGeoMax, row++, 3, 1, 1 );
746 row = max(row,maxrow)+1;
747 aStdLayout->addWidget( myAllowQuadrangles, row, 0, 1, 2 );
748 aStdLayout->addWidget( myDecimesh, row++, 2, 1, 2 );
749 aStdLayout->setRowStretch(row,1);
752 // advanced parameters
753 myAdvGroup = new QWidget();
754 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
755 anAdvLayout->setSpacing( 6 );
756 anAdvLayout->setMargin( 11 );
757 anAdvLayout->setRowStretch( 4, 5 );
758 anAdvLayout->setColumnStretch( 1, 5 );
760 myTopology = new QComboBox( myAdvGroup );
761 QStringList topologyTypes;
762 topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" )
763 << tr( "BLSURF_TOPOLOGY_PROCESS" )
764 << tr( "BLSURF_TOPOLOGY_PROCESS2" )
765 << tr( "BLSURF_TOPOLOGY_PRECAD" );
766 myTopology->addItems( topologyTypes );
768 myVerbosity = new QSpinBox( myAdvGroup );
769 myVerbosity->setMinimum( 0 );
770 myVerbosity->setMaximum( 100 );
771 myVerbosity->setSingleStep( 5 );
773 myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup );
775 headers << tr( "OPTION_ID_COLUMN" )<< tr( "OPTION_TYPE_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" );
776 myOptionTable->setHorizontalHeaderLabels( headers );
777 myOptionTable->horizontalHeader()->hideSection( OPTION_ID_COLUMN );
778 // myOptionTable->horizontalHeader()->hideSection( OPTION_TYPE_COLUMN );
779 myOptionTable->horizontalHeader()->setStretchLastSection(true);
780 myOptionTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
781 //myOptionTable->setColumnReadOnly( OPTION_NAME_COLUMN, TRUE );//////
782 //myOptionTable->setColumnReadOnly( OPTION_VALUE_COLUMN, FALSE );/////
783 myOptionTable->verticalHeader()->hide();
784 //myOptionTable->setSelectionBehavior( QAbstractItemView::SelectRows );
786 QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup );
787 addBtn->setMenu( new QMenu() );
788 QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup );
790 myPreCADGroupBox = new QGroupBox(tr("BLSURF_PRECAD_GROUP"), myAdvGroup );
791 myPreCADGroupBox->setEnabled(false);
792 QGridLayout* aPreCADGroupLayout = new QGridLayout(myPreCADGroupBox);
793 myPreCADMergeEdges = new QCheckBox(tr("BLSURF_PRECAD_MERGE_EDGES"),myPreCADGroupBox);
794 aPreCADGroupLayout->addWidget(myPreCADMergeEdges,0,0,1,2);
795 myPreCADRemoveNanoEdges = new QCheckBox(tr("BLSURF_PRECAD_REMOVE_NANO_EDGES"),myPreCADGroupBox);
796 aPreCADGroupLayout->addWidget(myPreCADRemoveNanoEdges,1,0,1,2);
797 myPreCADEpsNano = new SMESHGUI_SpinBox(myPreCADGroupBox);
798 myPreCADEpsNano->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
799 myPreCADEpsNano->setText("");
800 aPreCADGroupLayout->addWidget( new QLabel( tr( "BLSURF_PRECAD_EPS_NANO" ), myPreCADGroupBox ), 2, 0, 1, 1 );
801 aPreCADGroupLayout->addWidget(myPreCADEpsNano, 2, 1, 1, 1 );
802 myPreCADDiscardInput = new QCheckBox(tr("BLSURF_PRECAD_DISCARD_INPUT"),myPreCADGroupBox);
803 aPreCADGroupLayout->addWidget(myPreCADDiscardInput, 3, 0, 1, 2);
805 QPushButton* chooseGMFBtn = new QPushButton( tr( "BLSURF_GMF_FILE" ), myAdvGroup );
806 myGMFFileName = new QLineEdit(myAdvGroup);
807 // myGMFFileMode = new QCheckBox(tr("BLSURF_GMF_MODE"),myAdvGroup);
809 // ADD WIDGETS (ADVANCED TAB)
810 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 0, 0, 1, 1 );
811 anAdvLayout->addWidget( myVerbosity, 0, 1, 1, 1 );
812 anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 1, 0, 1, 1 );
813 anAdvLayout->addWidget( myTopology, 1, 1, 1, 1 );
814 anAdvLayout->addWidget( myPreCADGroupBox , 2, 0, 1, 2 );
815 anAdvLayout->addWidget( addBtn, 0, 2, 1, 1 );
816 anAdvLayout->addWidget( rmBtn, 0, 3, 1, 1 );
817 anAdvLayout->addWidget( myOptionTable, 1, 2, 3, 2 );
818 anAdvLayout->addWidget( chooseGMFBtn, 3, 0, 1, 1 );
819 anAdvLayout->addWidget( myGMFFileName, 3, 1, 1, 1 );
820 // anAdvLayout->addWidget( myGMFFileMode, 4, 0, 1, 2 );
821 anAdvLayout->setRowStretch(4,1);
824 // Size Maps parameters
826 mySmpGroup = new QWidget();
827 // mySmpGroup->setMinimumWidth(500);
830 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
833 mySizeMapTable = new QTreeWidget( mySmpGroup );
834 mySizeMapTable ->setMinimumWidth(200);
835 QStringList sizeMapHeaders;
836 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
837 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
838 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
839 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
840 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
841 mySizeMapTable->setAlternatingRowColors(true);
844 smpTab = new QTabWidget( mySmpGroup );
845 smpTab->setTabShape( QTabWidget::Rounded );
846 smpTab->setTabPosition( QTabWidget::South );
847 lay->addWidget( smpTab );
849 // Filters of selection
850 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
852 SM_ShapeTypes.Add( TopAbs_VERTEX );
853 SM_ShapeTypes.Add( TopAbs_EDGE );
854 SM_ShapeTypes.Add( TopAbs_FACE );
855 SM_ShapeTypes.Add( TopAbs_COMPOUND );
857 ATT_ShapeTypes.Add( TopAbs_VERTEX );
858 ATT_ShapeTypes.Add( TopAbs_EDGE );
859 ATT_ShapeTypes.Add( TopAbs_WIRE );
860 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
862 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
863 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
864 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
866 // Standard size map tab
867 mySmpStdGroup = new QWidget();
868 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
869 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false);
870 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
871 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
872 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
873 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
876 myAttractorGroup = new QWidget();
877 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
878 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false,/*stretch=*/false);
879 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
880 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
881 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
882 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
883 QFrame* attLine = new QFrame(myAttractorGroup);
884 attLine->setFrameShape(QFrame::HLine);
885 attLine->setFrameShadow(QFrame::Sunken);
886 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false);
887 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
888 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
889 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
890 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
891 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
892 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
893 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
894 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
895 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
896 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
898 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
899 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
903 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
904 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
905 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
906 modifyMapButton->setEnabled(false);
909 myAttSelWdg->setEnabled(false);
910 myAttSizeSpin->setEnabled(false);
911 myAttSizeLabel->setEnabled(false);
912 myAttDistSpin->setEnabled(false);
913 myAttDistLabel->setEnabled(false);
914 myAttDistSpin2->setEnabled(false);
915 myAttDistLabel2->setEnabled(false);
916 myAttDistSpin->setValue(0.);
917 myAttDistSpin2->setValue(0.);
918 myAttSizeSpin->setValue(0.);
919 mySmpSizeSpin->setValue(0.);
922 // ADD WIDGETS (SIZEMAP TAB)
923 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
924 anSmpLayout->setColumnStretch(0, 1);
925 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
926 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
927 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
928 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
929 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
930 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
933 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
934 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
935 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
936 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
939 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
940 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
941 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
942 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
943 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
944 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
945 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
946 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
947 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
948 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
949 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
950 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
952 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
953 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
955 smpTab->setCurrentIndex( SMP_STD_TAB );
957 // Enforced vertices parameters
958 myEnfGroup = new QWidget();
959 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
961 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup);
962 // anEnfLayout->addWidget(myEnforcedVertexWidget);
963 // MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance");
964 // myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced();
966 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
967 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
968 myEnforcedTreeWidget->setSortingEnabled(true);
969 QStringList enforcedHeaders;
970 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
971 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
972 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
974 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
975 myEnforcedTreeWidget->header()->setStretchLastSection(true);
976 myEnforcedTreeWidget->setAlternatingRowColors(true);
977 myEnforcedTreeWidget->setUniformRowHeights(true);
978 myEnforcedTreeWidget->setAnimated(true);
979 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
980 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
981 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
982 myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
983 myEnforcedTreeWidget->resizeColumnToContents(column);
985 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
986 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
987 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
989 // FACE AND VERTEX SELECTION
990 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
991 shapeTypes1.Add( TopAbs_FACE );
992 shapeTypes1.Add( TopAbs_COMPOUND );
993 shapeTypes2.Add( TopAbs_VERTEX );
994 shapeTypes2.Add( TopAbs_COMPOUND );
996 SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
997 myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true, /*stretch=*/false);
998 myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
1000 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
1001 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
1002 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
1004 myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
1006 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
1007 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
1008 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
1010 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
1011 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
1012 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
1014 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
1015 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
1016 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
1018 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
1019 myGroupName = new QLineEdit(myEnfGroup);
1021 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
1022 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
1024 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
1026 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
1027 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
1029 // myGlobalGroupName = new QCheckBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup);
1030 // myGlobalGroupName->setChecked(false);
1032 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
1033 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
1034 // FACE AND VERTEX SELECTION
1035 anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
1036 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
1037 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
1038 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
1039 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
1040 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
1041 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
1042 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
1043 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
1044 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
1045 // anEnfLayout2->addWidget(myGlobalGroupName, ENF_VER_GROUP_CHECK, 0, 1, 2);
1046 // anEnfLayout2->setRowStretch( ENF_VER_SPACE, 1);
1047 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
1048 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
1049 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
1050 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
1051 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
1052 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
1053 // anEnfLayout2->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 0, 1, 2);
1054 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
1055 // anEnfLayout->setRowStretch(1, 1);
1058 tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1059 tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1060 tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) );
1061 tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1063 tab->setCurrentIndex( STD_TAB );
1066 connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
1067 connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
1068 connect( myTopology, SIGNAL( activated( int ) ), this, SLOT( onTopologyChanged( int ) ) );
1069 connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
1070 connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
1071 connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
1072 connect( chooseGMFBtn, SIGNAL( clicked()), this, SLOT( onChooseGMFFile() ) );
1075 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1076 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1077 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1078 // connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
1079 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1080 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1081 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1082 // connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) );
1083 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1084 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1085 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1086 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onSmpTabChanged( int ) ) );
1088 // Enforced vertices
1089 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1090 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1091 // connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
1092 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1093 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1094 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1095 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1096 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1097 // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) );
1098 // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) );
1103 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1104 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1106 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1108 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1109 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1110 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1111 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1112 // myEnfFaceWdg->deactivateSelection();
1113 // myEnfVertexWdg->deactivateSelection();
1118 * This method resets the content of the X, Y, Z widgets;
1120 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1122 myXCoord->setCleared(true);
1123 myYCoord->setCleared(true);
1124 myZCoord->setCleared(true);
1125 myXCoord->setText("");
1126 myYCoord->setText("");
1127 myZCoord->setText("");
1128 // myGroupName->setText("");
1131 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1132 This method updates the tooltip of a modified item. The QLineEdit widgets content
1133 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1135 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1136 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
1137 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1138 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1139 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1140 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1141 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1142 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1143 QTreeWidgetItem* parent = item->parent();
1145 clearEnforcedVertexWidgets();
1147 if (parent && (!x.isNull() || !entry.isNull())) {
1148 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1149 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1150 if (entry.isNull()) {
1151 toolTip += QString("(") + x.toString();
1152 toolTip += QString(", ") + y.toString();
1153 toolTip += QString(", ") + z.toString();
1154 toolTip += QString(")");
1157 if (!groupName.isEmpty())
1158 toolTip += QString(" [") + groupName + QString("]");
1160 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1163 myXCoord->SetValue(x.toDouble());
1164 myYCoord->SetValue(y.toDouble());
1165 myZCoord->SetValue(z.toDouble());
1168 if (!groupName.isEmpty())
1169 myGroupName->setText(groupName);
1173 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1174 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1175 clearEnforcedVertexWidgets();
1176 if (nbSelEnfVertex == 1)
1178 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1181 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1182 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1183 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1184 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1185 if (CORBA::is_nil(measureOp))
1188 CORBA::Double x,y,z;
1189 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1190 if ( measureOp->IsDone() )
1192 myXCoord->SetValue(x);
1193 myYCoord->SetValue(y);
1194 myZCoord->SetValue(z);
1200 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1201 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1202 of the enforced vertex clicked in the tree widget.
1204 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1205 clearEnforcedVertexWidgets();
1206 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1207 if (! items.isEmpty() && items.size() == 1) {
1208 QTreeWidgetItem *item = items[0];
1209 // for (int i=0 ; i < items.size() ; i++) {
1211 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1212 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1213 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1214 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1215 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1216 if (!x.isNull()/* && entry.isNull()*/) {
1217 myXCoord->SetValue(x.toDouble());
1218 myYCoord->SetValue(y.toDouble());
1219 myZCoord->SetValue(z.toDouble());
1222 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1223 myGroupName->setText(group.toString());
1228 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1229 This method adds a face containing enforced vertices in the tree widget.
1231 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1232 // Find theFaceEntry item
1233 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1234 QTreeWidgetItem* theItem;
1235 if (theItemList.empty()) {
1236 theItem = new QTreeWidgetItem();
1237 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1238 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1239 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1240 myEnforcedTreeWidget->addTopLevelItem(theItem);
1243 theItem = theItemList[0];
1248 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1249 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1251 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(QTreeWidgetItem* theItem, double x, double y, double z,
1252 std::string vertexName, std::string geomEntry, std::string groupName) {
1254 std::string theFaceName = theItem->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
1255 // MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
1256 bool okToCreate = true;
1258 const int nbVert = theItem->childCount();
1259 // MESSAGE("Number of child rows: " << nbVert);
1261 double childValueX,childValueY,childValueZ;
1262 QString childEntry, childGroupName;
1263 QTreeWidgetItem* child;
1264 for (int row = 0;row<nbVert;row++) {
1265 child = theItem->child(row);
1266 childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1267 childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1268 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1269 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1270 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1271 if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
1272 // update group name
1273 if (childGroupName.toStdString() != groupName) {
1274 MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
1275 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1283 if (geomEntry.empty()) {
1284 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
1287 MESSAGE("In " << theFaceName << " vertex with entry " << geomEntry << " already exist: dont create again");
1292 if (geomEntry.empty()) {
1293 MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
1296 MESSAGE("In " << theFaceName << " vertex with geom entry " << geomEntry << " is created");
1299 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
1300 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1301 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1302 QSize iconSize = iconSelect.size()*0.7;
1304 int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
1305 QString myVertexName;
1307 while(indexRef != vertexIndex) {
1308 indexRef = vertexIndex;
1309 if (vertexName.empty())
1310 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1312 myVertexName = QString(vertexName.c_str());
1314 for (int row = 0;row<nbVert;row++) {
1315 QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1316 if (myVertexName == name) {
1322 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1323 if (geomEntry.empty()) {
1324 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1325 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1326 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1329 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1330 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1332 if (groupName != "")
1333 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1335 QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
1336 if (geomEntry.empty()) {
1337 toolTip += QString(" (%1, ").arg(x);
1338 toolTip += QString("%1, ").arg(y);
1339 toolTip += QString("%1)").arg(z);
1341 if (groupName != "")
1342 toolTip += QString(" [%1]").arg(groupName.c_str());
1344 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1345 theItem->setExpanded(true);
1346 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1349 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1350 This method is called when a item is added into the enforced vertices tree widget
1352 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
1353 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices");
1355 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1357 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1358 myEnfFaceWdg->deactivateSelection();
1359 myEnfVertexWdg->deactivateSelection();
1361 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1362 myEnforcedTreeWidget->resizeColumnToContents(column);
1365 int selEnfFace = myEnfFaceWdg->NbObjects();
1366 int selEnfVertex = myEnfVertexWdg->NbObjects();
1367 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1369 if (selEnfFace == 0)
1372 if ((selEnfVertex == 0) && coordsEmpty)
1375 string entry, shapeName;
1377 for (int i = 0 ; i < selEnfFace ; i++) {
1378 myEnfFace = myEnfFaceWdg->GetObject< GEOM::GEOM_Object >(i);
1379 entry = myEnfFace->GetStudyEntry();
1380 shapeName = myEnfFace->GetName();
1382 QTreeWidgetItem * faceItem = addEnforcedFace(entry, shapeName);
1384 std::string groupName = myGroupName->text().toStdString();
1386 if (boost::trim_copy(groupName).empty())
1389 if (selEnfVertex == 1)
1392 x = myXCoord->GetValue();
1393 y = myYCoord->GetValue();
1394 z = myZCoord->GetValue();
1395 if (selEnfVertex == 1) {
1396 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1397 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1400 addEnforcedVertex(faceItem, x, y, z, "", "", groupName);
1404 if ( CORBA::is_nil(getGeomEngine()))
1407 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
1408 if (CORBA::is_nil(measureOp))
1411 CORBA::Double x,y,z;
1413 for (int j = 0 ; j < selEnfVertex ; j++)
1415 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1416 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1417 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1418 if ( measureOp->IsDone() )
1419 addEnforcedVertex(faceItem, x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1420 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1421 addEnforcedVertex(faceItem, 0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1427 myEnfFaceWdg->SetObject(GEOM::GEOM_Object::_nil());
1428 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1430 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1431 myEnforcedTreeWidget->resizeColumnToContents(column);
1433 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
1434 myPhysicalMesh->setCurrentIndex( SizeMap );
1435 onPhysicalMeshChanged();
1439 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1440 This method is called when a item is removed from the enforced vertices tree widget
1442 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1443 // MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
1444 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1445 QList<QTreeWidgetItem *> selectedVertices;
1446 QSet<QTreeWidgetItem *> selectedEntries;
1447 QTreeWidgetItem* item;
1449 foreach( item, selectedItems ) {
1450 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1451 if (! value.isNull())
1452 selectedVertices.append(item);
1454 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1455 if (! value.isNull())
1456 selectedVertices.append(item);
1458 selectedEntries.insert(item);
1462 foreach(item,selectedVertices) {
1463 QTreeWidgetItem* parent = item->parent();
1464 // MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1465 parent->removeChild(item);
1467 if (parent->childCount() == 0) {
1468 if (selectedEntries.contains(parent))
1469 selectedEntries.remove(parent);
1474 foreach(item,selectedEntries) {
1475 // MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
1479 myEnforcedTreeWidget->selectionModel()->clearSelection();
1483 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1485 if (state == Qt::Checked) {
1486 myInternalEnforcedVerticesAllFacesGroup->setEnabled(true);
1488 if (state == Qt::Unchecked) {
1489 myInternalEnforcedVerticesAllFacesGroup->setEnabled(false);
1493 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1494 This method updates the GUI widgets with the hypothesis data
1496 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1498 MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
1499 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1501 BlsurfHypothesisData data;
1502 that->readParamsFromHypo( data );
1505 myName->setText( data.myName );
1506 QFontMetrics metrics( myName->font() );
1507 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1509 myTopology->setCurrentIndex( data.myTopology );
1510 myPreCADGroupBox->setEnabled(data.myTopology == PreCAD);
1511 myPreCADMergeEdges->setChecked( data.myPreCADMergeEdges );
1512 myPreCADRemoveNanoEdges->setChecked( data.myPreCADRemoveNanoEdges );
1513 myPreCADDiscardInput->setChecked( data.myPreCADDiscardInput );
1514 MESSAGE("data.myPreCADEpsNano: "<<data.myPreCADEpsNano)
1515 if (data.myPreCADEpsNano < 0)
1516 myPreCADEpsNano->setText("");
1518 myPreCADEpsNano->SetValue( data.myPreCADEpsNano );
1519 myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1520 myPhySize->SetValue( data.myPhySize );
1521 #ifdef WITH_SIZE_BOUNDARIES
1522 MESSAGE("data.myPhyMin: "<<data.myPhyMin)
1523 if (data.myPhyMin < 0)
1524 myPhyMin->setText("");
1526 myPhyMin->SetValue( data.myPhyMin );
1527 MESSAGE("data.myPhyMax: "<<data.myPhyMax)
1528 if (data.myPhyMax < 0)
1529 myPhyMax->setText("");
1531 myPhyMax->SetValue( data.myPhyMax );
1532 MESSAGE("data.myGeoMin: "<<data.myGeoMin)
1533 if (data.myGeoMin < 0)
1534 myGeoMin->setText("");
1536 myGeoMin->SetValue( data.myGeoMin );
1537 MESSAGE("data.myGeoMax: "<<data.myGeoMax)
1538 if (data.myGeoMax < 0)
1539 myGeoMax->setText("");
1541 myGeoMax->SetValue( data.myGeoMax );
1543 myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1544 myAngleMeshS->SetValue( data.myAngleMeshS );
1545 myAngleMeshC->SetValue( data.myAngleMeshC );
1546 myGradation->SetValue( data.myGradation );
1547 myAllowQuadrangles->setChecked( data.myAllowQuadrangles );
1548 myDecimesh->setChecked( data.myDecimesh );
1549 myVerbosity->setValue( data.myVerbosity );
1551 if ( myOptions.operator->() ) {
1552 // MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
1553 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
1554 QString option = that->myOptions[i].in();
1555 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1556 if ( name_value.count() > 1 ) {
1557 QString idStr = QString("%1").arg( i );
1558 int row = myOptionTable->rowCount();
1559 myOptionTable->setRowCount( row+1 );
1560 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1561 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1562 myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "BLSURF" ) );
1563 myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
1564 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1565 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1566 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1567 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1568 Qt::ItemIsEditable |
1569 Qt::ItemIsEnabled );
1573 if ( myPreCADOptions.operator->() ) {
1574 // MESSAGE("retrieveParams():myPreCADOptions->length() = " << myPreCADOptions->length());
1575 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
1576 QString option = that->myPreCADOptions[i].in();
1577 QStringList name_value = option.split( ":", QString::KeepEmptyParts );
1578 if ( name_value.count() > 1 ) {
1579 QString idStr = QString("%1").arg( i );
1580 int row = myOptionTable->rowCount();
1581 myOptionTable->setRowCount( row+1 );
1582 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
1583 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
1584 myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( "PRECAD" ) );
1585 myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
1586 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
1587 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
1588 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
1589 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
1590 Qt::ItemIsEditable |
1591 Qt::ItemIsEnabled );
1595 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1596 myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1597 // myGMFFileMode->setChecked(data.myGMFFileMode);
1600 MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
1601 QMapIterator<QString, QString> i(that->mySMPMap);
1602 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1603 while (i.hasNext()) {
1605 const QString entry = i.key();
1606 const QString sizeMap = i.value();
1607 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1608 int row = mySizeMapTable->topLevelItemCount();
1609 QTreeWidgetItem* item = new QTreeWidgetItem();
1610 mySizeMapTable->addTopLevelItem( item );
1611 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1612 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1613 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1614 if (that->myATTMap.contains(entry)){
1615 const QString attEntry = that->myATTMap[entry];
1616 std::string attName = myGeomToolSelected->getNameFromEntry(attEntry.toStdString());
1617 QTreeWidgetItem* child = new QTreeWidgetItem();
1618 item->addChild( child );
1619 item->setExpanded(true);
1620 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1621 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attEntry ) );
1622 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString( attName ) ) );
1624 if (that->myAttDistMap[entry] > std::numeric_limits<double>::epsilon()){
1625 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Attractor" ) ) );
1628 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Constant Size" ) ) );
1633 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1636 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1637 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1638 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1640 // Enforced vertices
1641 MESSAGE("retrieveParams(): data.entryCoordsListMap.size() = " << data.faceEntryEnfVertexListMap.size());
1642 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1644 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1645 TEntry entry = (*evmIt).first;
1646 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1647 MESSAGE("Face entry: " << entry);
1648 MESSAGE("Face name: " << shapeName);
1650 QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1652 TEnfVertexList evs = (*evmIt).second;
1654 TEnfVertexList::const_iterator evsIt = evs.begin();
1655 TEnfVertex *enfVertex;
1656 for ( ; evsIt != evs.end() ; ++evsIt) {
1657 enfVertex = (*evsIt);
1658 MESSAGE("Name: " << enfVertex->name);
1660 if (enfVertex->coords.size()) {
1661 x = enfVertex->coords[0];
1662 y = enfVertex->coords[1];
1663 z = enfVertex->coords[2];
1665 that->addEnforcedVertex(faceItem, x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1669 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1670 myEnforcedTreeWidget->resizeColumnToContents(column);
1672 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1673 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1674 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1677 that->onPhysicalMeshChanged();
1678 that->onGeometricMeshChanged();
1681 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
1682 This method updates the hypothesis data with the GUI widgets content.
1684 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
1686 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1688 BlsurfHypothesisData data;
1689 QString guiHyp = that->readParamsFromWidgets( data );
1690 that->storeParamsToHypo( data );
1695 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
1696 Updates the hypothesis data from hypothesis values.
1698 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
1700 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
1701 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1702 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
1704 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
1705 h_data.myName = isCreation() && data ? hypName() : "";
1707 h_data.myTopology = (int) h->GetTopology();
1708 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
1709 h_data.myPhySize = h->GetPhySize();
1710 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
1711 h_data.myAngleMeshS = h->GetAngleMeshS();
1712 h_data.myAngleMeshC = h->GetAngleMeshC();
1713 h_data.myGradation = h->GetGradation();
1714 h_data.myAllowQuadrangles = h->GetQuadAllowed();
1715 h_data.myDecimesh = h->GetDecimesh();
1716 h_data.myVerbosity = h->GetVerbosity();
1717 h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
1718 h_data.myPreCADRemoveNanoEdges = h->GetPreCADRemoveNanoEdges();
1719 h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
1720 double EpsNano = h->GetPreCADEpsNano();
1721 h_data.myPreCADEpsNano = EpsNano > 0 ? EpsNano : -1.0;
1723 #ifdef WITH_SIZE_BOUNDARIES
1724 double PhyMin = h->GetPhyMin();
1725 double PhyMax = h->GetPhyMax();
1726 double GeoMin = h->GetGeoMin();
1727 double GeoMax = h->GetGeoMax();
1728 // if ( PhyMin > 0 )
1729 // h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString("");
1730 // h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString("");
1731 // h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString("");
1732 // h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString("");
1733 h_data.myPhyMin = PhyMin > 0 ? PhyMin : -1.0;
1734 h_data.myPhyMax = PhyMax > 0 ? PhyMax : -1.0;
1735 h_data.myGeoMin = GeoMin > 0 ? GeoMin : -1.0;
1736 h_data.myGeoMax = GeoMax > 0 ? GeoMax : -1.0;
1739 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1740 that->myOptions = h->GetOptionValues();
1741 that->myPreCADOptions = h->GetPreCADOptionValues();
1743 h_data.myGMFFileName = h->GetGMFFile();
1744 // h_data.myGMFFileMode = h->GetGMFFileMode();
1746 that->mySMPMap.clear();
1747 that->myATTMap.clear();
1748 that->myAttDistMap.clear();
1749 that->myDistMap.clear();
1751 // classic size maps
1752 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
1753 // MESSAGE("mySizeMaps->length() = " << mySizeMaps->length());
1754 QString fullSizeMaps;
1755 QStringList fullSizeMapList;
1756 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1757 for ( int i = 0;i<mySizeMaps->length(); ++i ) {
1758 fullSizeMaps = mySizeMaps[i].in();
1759 // MESSAGE("fullSizeMaps: " << fullSizeMaps.toStdString());
1760 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
1761 if ( fullSizeMapList.count() > 1 ) {
1762 string fullSizeMap = fullSizeMapList[1].toStdString();
1763 int pos = fullSizeMap.find("return")+7;
1764 // MESSAGE("pos:" << pos);
1767 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
1772 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
1773 // MESSAGE("mySMPMap[" << fullSizeMapList[0].toStdString() << "] = " << sizeMap.toStdString());
1774 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
1775 // MESSAGE("mySMPShapeTypeMap[" << fullSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullSizeMapList[0]]);
1781 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
1782 MESSAGE("myCustomSizeMaps->length() = " << myCustomSizeMaps->length());
1784 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
1785 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
1786 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
1787 if ( fullCustomSizeMapList.count() > 1 ) {
1788 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
1789 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
1790 MESSAGE("mySMPMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << fullCustomSizeMapList[1].toStdString());
1791 MESSAGE("mySMPShapeTypeMap[" << fullCustomSizeMapList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[fullCustomSizeMapList[0]]);
1796 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
1797 // MESSAGE("myAttractors->length() = " << allMyAttractors->length());
1799 for ( int i = 0;i<allMyAttractors->length(); ++i ) {
1800 QString myAttractors = allMyAttractors[i].in();
1801 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
1802 if ( myAttractorList.count() > 1 ) {
1803 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
1804 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
1805 // MESSAGE("mySMPMap[" << myAttractorList[0].toStdString() << "] = " << myAttractorList[1].toStdString());
1806 // MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
1810 // attractor new version
1811 MESSAGE("retrieveParams, Attractors")
1812 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
1813 for ( int i = 0;i<allMyAttractorParams->length(); ++i ) {
1814 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
1815 QString faceEntry = myAttractorParams.faceEntry.in();
1816 QString attEntry = myAttractorParams.attEntry.in();
1817 MESSAGE("attEntry = "<<attEntry.toStdString())
1818 double startSize = myAttractorParams.startSize;
1819 double endSize = myAttractorParams.endSize;
1820 double infDist = myAttractorParams.infDist;
1821 double constDist = myAttractorParams.constDist;
1822 that->mySMPMap[faceEntry] = QString::number( startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
1823 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
1824 that->myATTMap[faceEntry] = attEntry;
1825 that->myAttDistMap[faceEntry] = infDist;
1826 that->myDistMap[faceEntry] = constDist;
1829 // Enforced vertices
1830 h_data.enfVertexList.clear();
1831 h_data.faceEntryEnfVertexListMap.clear();
1833 h_data.groupNameEnfVertexListMap.clear();
1836 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
1837 MESSAGE("faceEntryEnfVertexListMap->length() = " << faceEntryEnfVertexListMap->length());
1839 for ( int i = 0;i<faceEntryEnfVertexListMap->length(); ++i ) {
1840 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
1841 // BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList.in();
1842 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
1843 // BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str());
1845 // TEnfVertexList& enfVertexList = h_data.faceEntryEnfVertexListMap[entry];
1847 for (int j=0 ; j<vertexList.length(); ++j) {
1848 TEnfVertex *enfVertex = new TEnfVertex();
1850 enfVertex->name = CORBA::string_dup(vertexList[j].name.in());
1851 enfVertex->geomEntry = CORBA::string_dup(vertexList[j].geomEntry.in());
1852 enfVertex->grpName = CORBA::string_dup(vertexList[j].grpName.in());
1853 for (int k=0 ; k< vertexList[j].coords.length();k++)
1854 enfVertex->coords.push_back(vertexList[j].coords[k]);
1856 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
1859 if (groupName != "") {
1860 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
1864 // h_data.enfVertMap[entry] = evs;
1865 // h_data.entryCoordsListMap[entry] = coordsList;
1867 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
1868 h_data.faceEntryEnfVertexListMap.erase(entry);
1871 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
1872 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
1877 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
1878 Saves the hypothesis data to hypothesis values.
1880 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
1882 MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
1883 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
1884 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
1890 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
1892 if ( h->GetTopology() != h_data.myTopology ) // avoid duplication of DumpPython commands
1893 h->SetTopology( (int) h_data.myTopology );
1894 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh )
1895 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
1896 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
1897 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
1898 if ( h->GetGradation() != h_data.myGradation )
1899 h->SetGradation( h_data.myGradation );
1900 if ( h->GetQuadAllowed() != h_data.myAllowQuadrangles )
1901 h->SetQuadAllowed( h_data.myAllowQuadrangles );
1902 if ( h->GetDecimesh() != h_data.myDecimesh )
1903 h->SetDecimesh( h_data.myDecimesh );
1904 if ( h->GetVerbosity() != h_data.myVerbosity )
1905 h->SetVerbosity( h_data.myVerbosity );
1906 if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
1907 h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
1908 if ( h->GetPreCADRemoveNanoEdges() != h_data.myPreCADRemoveNanoEdges )
1909 h->SetPreCADRemoveNanoEdges( h_data.myPreCADRemoveNanoEdges );
1910 if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
1911 h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
1912 if ( h->GetPreCADEpsNano() != h_data.myPreCADEpsNano && h_data.myPreCADEpsNano > 0)
1913 h->SetPreCADEpsNano( h_data.myPreCADEpsNano );
1915 if( ((int) h_data.myPhysicalMesh == PhysicalUserDefined)||((int) h_data.myPhysicalMesh == SizeMap) ) {
1916 if ( h->GetPhySize() != h_data.myPhySize )
1917 h->SetPhySize( h_data.myPhySize );
1919 if( (int) h_data.myGeometricMesh == UserDefined ) {
1920 if ( h->GetAngleMeshS() != h_data.myAngleMeshS )
1921 h->SetAngleMeshS( h_data.myAngleMeshS );
1922 if ( h->GetAngleMeshC() != h_data.myAngleMeshC )
1923 h->SetAngleMeshC( h_data.myAngleMeshC );
1925 #ifdef WITH_SIZE_BOUNDARIES
1926 if (h->GetPhyMin() != h_data.myPhyMin && h_data.myPhyMin > 0)
1927 h->SetPhyMin( h_data.myPhyMin );
1928 if (h->GetPhyMax() != h_data.myPhyMax && h_data.myPhyMax > 0)
1929 h->SetPhyMax( h_data.myPhyMax );
1930 if (h->GetGeoMin() != h_data.myGeoMin && h_data.myGeoMin > 0)
1931 h->SetGeoMin( h_data.myGeoMin );
1932 if (h->GetGeoMax() != h_data.myGeoMax && h_data.myGeoMax > 0)
1933 h->SetGeoMax( h_data.myGeoMax );
1936 h->SetOptionValues( myOptions ); // is set in checkParams()
1937 h->SetPreCADOptionValues( myPreCADOptions ); // is set in checkParams()
1939 if ( h->GetGMFFile() != h_data.myGMFFileName )
1940 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
1941 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
1942 h->SetGMFFile( h_data.myGMFFileName.c_str());
1944 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1945 QMapIterator<QString,QString> i(that->mySMPMap);
1946 while (i.hasNext()) {
1948 const QString entry = i.key();
1949 const QString sizeMap = i.value();
1951 if (sizeMap == "__TO_DELETE__") {
1952 MESSAGE("Delete entry " << entry.toStdString() << " from engine");
1953 h->UnsetEntry(entry.toLatin1().constData());
1955 else if (sizeMap.startsWith("ATTRACTOR")) {
1956 // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1957 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
1959 else if (sizeMap.startsWith("def")) {
1960 // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString());
1961 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
1964 if (!myATTMap[entry].isEmpty()){
1965 QString att_entry = myATTMap[entry];
1966 double infDist = myAttDistMap[entry];
1967 double constDist = myDistMap[entry];
1968 double phySize = h->GetPhySize();
1969 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1970 h->SetClassAttractorEntry( entry.toLatin1().constData(), att_entry.toLatin1().constData(), sizeMap.toDouble() , phySize, infDist, constDist );
1971 QApplication::restoreOverrideCursor();
1974 QString fullSizeMap;
1975 fullSizeMap = QString("");
1976 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
1977 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
1978 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
1979 fullSizeMap = QString("def f(t): return ") + sizeMap;
1980 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
1981 fullSizeMap = QString("def f(): return ") + sizeMap;
1982 MESSAGE("SetSizeMapEntry("<<entry.toStdString()<<") = " <<fullSizeMap.toStdString());
1983 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
1988 // Enforced vertices
1991 std::string enfName;
1993 std::string groupName = "";
1996 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
1997 // 1. Clear all enforced vertices in hypothesis
1998 // 2. Add new enforced vertex according to h_data
2000 if ( h->GetAllEnforcedVertices()->length() > 0 )
2001 h->ClearAllEnforcedVertices();
2004 TEnfVertexList::const_iterator evsIt;
2005 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2007 faceEntry = evmIt->first;
2008 evs = evmIt->second;
2009 MESSAGE("Number of enforced vertices for face entry " << faceEntry << ": " << evs.size());
2010 evsIt = evs.begin();
2011 for ( ; evsIt != evs.end() ; ++evsIt)
2014 if ((*evsIt)->coords.size()) {
2015 x = (*evsIt)->coords[0];
2016 y = (*evsIt)->coords[1];
2017 z = (*evsIt)->coords[2];
2019 ret = h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2023 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2024 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2025 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2026 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2029 catch(const std::exception& ex) {
2030 std::cout << "Exception: " << ex.what() << std::endl;
2033 // catch(const SALOME::SALOME_Exception& ex)
2036 // // SalomeApp_Tools::QtCatchCorbaException(ex);
2042 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2043 Stores the widgets content to the hypothesis data.
2045 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2047 MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
2048 h_data.myName = myName ? myName->text() : "";
2049 h_data.myTopology = myTopology->currentIndex();
2050 h_data.myPhysicalMesh = myPhysicalMesh->currentIndex();
2051 h_data.myPhySize = myPhySize->GetValue();
2052 #ifdef WITH_SIZE_BOUNDARIES
2053 h_data.myPhyMin = myPhyMin->GetValue();
2054 h_data.myPhyMax = myPhyMax->GetValue();
2055 h_data.myGeoMin = myGeoMin->GetValue();
2056 h_data.myGeoMax = myGeoMax->GetValue();
2058 h_data.myGeometricMesh = myGeometricMesh->currentIndex();
2059 h_data.myAngleMeshS = myAngleMeshS->GetValue();
2060 h_data.myAngleMeshC = myAngleMeshC->GetValue();
2061 h_data.myGradation = myGradation->GetValue();
2062 h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked();
2063 h_data.myDecimesh = myDecimesh->isChecked();
2064 h_data.myVerbosity = myVerbosity->value();
2065 h_data.myPreCADMergeEdges = myPreCADMergeEdges->isChecked();
2066 h_data.myPreCADRemoveNanoEdges = myPreCADRemoveNanoEdges->isChecked();
2067 h_data.myPreCADDiscardInput = myPreCADDiscardInput->isChecked();
2068 h_data.myPreCADEpsNano = myPreCADEpsNano->GetValue();
2071 guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2072 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2073 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2074 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2075 guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; ";
2076 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2077 guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; ";
2078 guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; ";
2079 #ifdef WITH_SIZE_BOUNDARIES
2080 guiHyp += "hphymin = " + QString::number( h_data.myPhyMin ) + "; ";
2081 guiHyp += "hphymax = " + QString::number( h_data.myPhyMax ) + "; ";
2082 guiHyp += "hgeomin = " + QString::number( h_data.myGeoMin ) + "; ";
2083 guiHyp += "hgeomax = " + QString::number( h_data.myGeoMax ) + "; ";
2085 guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2086 guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADRemoveNanoEdges ? "yes" : "no") + "; ";
2087 guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2088 guiHyp += tr("BLSURF_PRECAD_EPS_NANO") + " = " + QString::number( h_data.myPreCADEpsNano ) + "; ";
2090 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2091 int row = 0, nbRows = myOptionTable->rowCount();
2092 for ( ; row < nbRows; ++row )
2094 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2095 std::string optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
2096 if ( id >= 0 && ( ( optionType == "BLSURF" && id < myOptions->length() ) || ( optionType == "PRECAD" && id < myPreCADOptions->length() ) ) )
2098 QString name = myOptionTable->item( row, OPTION_NAME_COLUMN )->text();
2099 QString value = myOptionTable->item( row, OPTION_VALUE_COLUMN )->text().trimmed();
2100 if ( value.isNull() )
2102 if (optionType == "PRECAD")
2103 that->myPreCADOptions[ id ] = ( name + ":" + value).toLatin1().constData();
2105 that->myOptions[ id ] = ( name + ":" + value).toLatin1().constData();
2107 if ( value != "" ) {
2108 if (optionType == "PRECAD")
2109 guiHyp += "PRECAD_";
2110 guiHyp += name + " = " + value + "; ";
2115 h_data.myGMFFileName = myGMFFileName->text().toStdString();
2116 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2119 row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2120 for ( ; row < nbRows; ++row )
2122 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2123 if ( that->mySMPMap.contains(entry) )
2124 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2127 // Enforced vertices
2128 h_data.enfVertexList.clear();
2129 h_data.faceEntryEnfVertexListMap.clear();
2131 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2132 int nbEnforcedVertices = 0;
2133 std::string groupName = "";
2134 // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
2135 for (int i=0 ; i<nbEnforcedShapes ; i++) {
2136 QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
2138 std::string faceEntry = shapeItem->data(ENF_VER_FACE_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2139 nbEnforcedVertices = shapeItem->childCount();
2140 if (nbEnforcedVertices >0) {
2141 double childValueX,childValueY,childValueZ;
2142 std::string childName, vertexEntry;
2143 QTreeWidgetItem* child;
2146 for (row = 0;row<nbEnforcedVertices;row++) {
2147 child = shapeItem->child(row);
2148 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2149 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2150 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2151 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2152 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2153 // if (myGlobalGroupName->isChecked())
2154 // groupName = myGlobalGroupName->text().toStdString();
2156 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2158 TEnfVertex *enfVertex = new TEnfVertex();
2159 enfVertex->name = childName;
2160 if (vertexEntry.empty()) {
2161 enfVertex->coords.push_back(childValueX);
2162 enfVertex->coords.push_back(childValueY);
2163 enfVertex->coords.push_back(childValueZ);
2166 enfVertex->geomEntry = vertexEntry;
2167 enfVertex->grpName = groupName;
2168 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2169 // if (it == h_data.enfVertexList.end())
2170 h_data.enfVertexList.insert(enfVertex);
2171 evs.insert(enfVertex);
2173 if (groupName != "")
2174 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2177 h_data.faceEntryEnfVertexListMap[faceEntry] = evs;
2182 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2183 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2185 MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
2190 void BLSURFPluginGUI_HypothesisCreator::onTopologyChanged(int index) {
2191 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onTopologyChanged");
2192 myPreCADGroupBox->setEnabled(index == PreCAD);
2195 void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() {
2196 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged");
2197 bool isPhysicalUserDefined = (myPhysicalMesh->currentIndex() == PhysicalUserDefined);
2198 bool isSizeMap = (myPhysicalMesh->currentIndex() == SizeMap);
2199 bool isCustom = (isPhysicalUserDefined || isSizeMap) ;
2200 bool geomIsCustom = (myGeometricMesh->currentIndex() == UserDefined);
2202 myGradation->setEnabled(!isPhysicalUserDefined || geomIsCustom);
2203 myPhySize->setEnabled(isCustom);
2204 myPhyMax->setEnabled(isCustom);
2205 myPhyMin->setEnabled(isCustom);
2207 if ( !myGradation->isEnabled())
2208 myGradation->SetValue( 1.1 );
2211 if ( myGeometricMesh->currentIndex() == DefaultGeom ) {
2212 myGeometricMesh->setCurrentIndex( UserDefined );
2213 onGeometricMeshChanged();
2218 void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() {
2219 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged");
2220 bool isCustom = (myGeometricMesh->currentIndex() == UserDefined);
2221 bool phyIsSizemap = (myPhysicalMesh->currentIndex() == SizeMap);
2223 myAngleMeshS->setEnabled(isCustom);
2224 myAngleMeshC->setEnabled(isCustom);
2225 myGradation->setEnabled(isCustom || phyIsSizemap);
2226 myGeoMax->setEnabled(isCustom);
2227 myGeoMin->setEnabled(isCustom);
2229 if ( !myGradation->isEnabled())
2230 myGradation->SetValue( 1.1 );
2233 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
2234 if ( myPhysicalMesh->currentIndex() == DefaultSize ) {
2235 myPhysicalMesh->setCurrentIndex( PhysicalUserDefined );
2236 onPhysicalMeshChanged();
2241 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2243 QMenu* menu = (QMenu*)sender();
2244 // fill popup with option names
2246 QString name_value, name;
2247 if ( myOptions.operator->() ) {
2248 QMenu* blsurfMenu = menu->addMenu(tr("OPTION_MENU_BLSURF"));
2249 for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
2250 name_value = myOptions[i].in();
2251 name = name_value.split( ":", QString::KeepEmptyParts )[0];
2252 blsurfMenu->addAction( name );
2255 if ( myPreCADOptions.operator->() ) {
2256 QMenu* preCADmenu = menu->addMenu(tr("OPTION_MENU_PRECAD"));
2257 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i ) {
2258 name_value = myPreCADOptions[i].in();
2259 name = name_value.split( ":", QString::KeepEmptyParts )[0];
2260 preCADmenu->addAction( name );
2265 void BLSURFPluginGUI_HypothesisCreator::onOptionChosenInPopup( QAction* a )
2267 myOptionTable->setFocus();
2268 QMenu* menu = (QMenu*)( a->parent() );
2270 int idx = menu->actions().indexOf( a );
2271 QString idStr = QString("%1").arg( idx );
2272 QString option, optionType;
2273 if (menu->title() == tr("OPTION_MENU_BLSURF")) {
2274 option = myOptions[idx].in();
2275 optionType = "BLSURF";
2277 else if (menu->title() == tr("OPTION_MENU_PRECAD")) {
2278 option = myPreCADOptions[idx].in();
2279 optionType = "PRECAD";
2281 QString optionName = option.split( ":", QString::KeepEmptyParts )[0];
2283 // look for a row with optionName
2284 int row = 0, nbRows = myOptionTable->rowCount();
2285 for ( ; row < nbRows; ++row )
2286 if ( myOptionTable->item( row, OPTION_ID_COLUMN )->text() == idStr )
2287 if ( myOptionTable->item( row, OPTION_TYPE_COLUMN )->text() == optionType )
2289 // add a row if not found
2290 if ( row == nbRows ) {
2291 myOptionTable->setRowCount( row+1 );
2292 myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
2293 myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
2294 myOptionTable->setItem( row, OPTION_TYPE_COLUMN, new QTableWidgetItem( optionType ) );
2295 myOptionTable->item( row, OPTION_TYPE_COLUMN )->setFlags( 0 );
2296 myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( optionName ) );
2297 myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
2298 myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( "" ) );
2299 myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
2300 Qt::ItemIsEditable |
2301 Qt::ItemIsEnabled );
2302 myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2304 myOptionTable->clearSelection();
2305 myOptionTable->scrollToItem( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2306 //myOptionTable->item( row, OPTION_VALUE_COLUMN )->setSelected( true );
2307 myOptionTable->setCurrentCell( row, OPTION_VALUE_COLUMN );
2308 //myOptionTable->openPersistentEditor( myOptionTable->item( row, OPTION_VALUE_COLUMN ) );
2311 void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
2313 // clear option values and remember selected row
2314 QList<int> selectedRows;
2315 QList<QTableWidgetItem*> selected = myOptionTable->selectedItems();
2316 QTableWidgetItem* item;
2317 foreach( item, selected ) {
2318 int row = item->row();
2319 if ( !selectedRows.contains( row ) ) {
2320 selectedRows.append( row );
2321 int id = myOptionTable->item( row, OPTION_ID_COLUMN )->text().toInt();
2322 std::string optionType = myOptionTable->item( row, OPTION_TYPE_COLUMN )->text().toStdString();
2324 if (optionType == "BLSURF" && id < myOptions->length() )
2325 myOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2326 else if (optionType == "PRECAD" && id < myPreCADOptions->length() )
2327 myPreCADOptions[ id ] = myOptionTable->item( row, OPTION_NAME_COLUMN )->text().toLatin1().constData();
2330 qSort( selectedRows );
2331 QListIterator<int> it( selectedRows );
2333 while ( it.hasPrevious() )
2334 myOptionTable->removeRow( it.previous() );
2337 void BLSURFPluginGUI_HypothesisCreator::onChooseGMFFile()
2339 // QFileDialog dlg(0);
2340 // dlg.selectFile(myGMFFileName->text());
2341 // dlg.setNameFilter(tr("BLSURF_GMF_FILE_FORMAT"));
2342 // dlg.setDefaultSuffix(QString("mesh"));
2343 myGMFFileName->setText(QFileDialog::getSaveFileName(0, tr("BLSURF_GMF_FILE_DIALOG"), myGMFFileName->text(), tr("BLSURF_GMF_FILE_FORMAT")));
2347 // **********************
2348 // *** BEGIN SIZE MAP ***
2349 // **********************
2351 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2353 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2355 if ( myGeomSelWdg2->IsObjectSelected() ){
2356 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2358 else if ( myGeomSelWdg1->IsObjectSelected() ){
2359 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2361 std::string entry = (string) mySMapObject->GetStudyEntry();
2362 QString qEntry = QString::fromStdString(entry);
2363 if (that->mySMPMap.contains(qEntry) && that->mySMPMap[qEntry] != "__TO_DELETE__" ) {
2364 addMapButton->setEnabled(false);
2365 modifyMapButton->setEnabled(true);
2368 addMapButton->setEnabled(true);
2369 modifyMapButton->setEnabled(false);
2374 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2376 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
2377 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2378 if (col == SMP_SIZEMAP_COLUMN){
2379 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2380 if (!mySMPMap.contains(entry))
2382 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2383 CORBA::Object_var obj = entryToObject(entry);
2384 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){ // ADVANCED MAPS
2385 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2386 double phySize = that->mySMPMap[entry].toDouble(); // Retrieve values of the selected item in the current tab widgets
2387 double infDist = that->myAttDistMap[entry];
2388 double constDist = that->myDistMap[entry];
2389 QString attEntry = that->myATTMap[entry];
2390 CORBA::Object_var attObj = entryToObject(attEntry);
2391 myAttSizeSpin->setValue(phySize);
2392 if (sizeMap.startsWith("Attractor")){
2393 myAttDistSpin->setValue(infDist);
2394 myAttractorCheck->setChecked(true);
2397 myAttractorCheck->setChecked(false);
2399 if (sizeMap.startsWith("Constant") || constDist > std::numeric_limits<double>::epsilon()){
2400 myAttDistSpin2->setValue(constDist);
2401 myConstSizeCheck->setChecked(true);
2404 myConstSizeCheck->setChecked(false);
2406 myGeomSelWdg2->SetObject(obj);
2407 myAttSelWdg->SetObject(attObj);
2409 else { // CLASSIC MAPS
2410 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2411 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2412 if (!sizeMap.startsWith("def")){
2413 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2419 void BLSURFPluginGUI_HypothesisCreator::onSmpTabChanged(int tab)
2421 myAttDistSpin->setValue(0.); // Reinitialize widgets
2422 myAttSizeSpin->setValue(0.);
2423 myAttDistSpin2->setValue(0.);
2424 mySmpSizeSpin->setValue(0.);
2425 myGeomSelWdg1->deactivateSelection();
2426 myGeomSelWdg2->deactivateSelection();
2427 myAttSelWdg->deactivateSelection();
2428 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2429 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2430 myAttSelWdg->SetObject(CORBA::Object::_nil());
2431 myAttractorCheck->setChecked(false);
2432 myConstSizeCheck->setChecked(false);
2435 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2437 if (state == Qt::Checked){
2438 myAttSelWdg->setEnabled(true);
2439 myAttSizeSpin->setEnabled(true);
2440 myAttSizeLabel->setEnabled(true);
2441 myAttDistSpin->setEnabled(true);
2442 myAttDistLabel->setEnabled(true);
2443 if (!myAttSelWdg->IsObjectSelected()){
2444 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2447 if (state == Qt::Unchecked){
2448 myAttDistSpin->setEnabled(false);
2449 myAttDistLabel->setEnabled(false);
2450 myAttDistSpin->setValue(0.);
2451 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2452 myAttSelWdg->setEnabled(false);
2453 myAttSizeSpin->setEnabled(false);
2454 myAttSizeLabel->setEnabled(false);
2455 myAttDistSpin2->setEnabled(false);
2456 myAttDistLabel2->setEnabled(false);
2458 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2459 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2464 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2466 if (state == Qt::Checked){
2467 myAttSelWdg->setEnabled(true);
2468 myAttSizeSpin->setEnabled(true);
2469 myAttSizeLabel->setEnabled(true);
2470 myAttDistSpin2->setEnabled(true);
2471 myAttDistLabel2->setEnabled(true);
2472 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2473 !myAttSelWdg->IsObjectSelected()){
2474 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2477 if (state == Qt::Unchecked){
2478 myAttDistSpin2->setEnabled(false);
2479 myAttDistLabel2->setEnabled(false);
2480 myAttDistSpin2->setValue(0.);
2481 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2482 myAttSelWdg->setEnabled(false);
2483 myAttSizeSpin->setEnabled(false);
2484 myAttSizeLabel->setEnabled(false);
2485 myAttDistSpin->setEnabled(false);
2486 myAttDistLabel->setEnabled(false);
2488 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2489 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2494 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2496 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()");
2497 QList<int> selectedRows;
2498 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2499 QTreeWidgetItem* item;
2500 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2502 qSort( selectedRows );
2503 QListIterator<QTreeWidgetItem*> it( selected );
2505 while ( it.hasPrevious() ) {
2506 item = it.previous();
2507 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2508 if (that->mySMPMap.contains(entry))
2509 that->mySMPMap[entry] = "__TO_DELETE__";
2510 if (that->mySMPShapeTypeMap.contains(entry))
2511 that->mySMPShapeTypeMap.remove(entry);
2512 if (that->myATTMap.contains(entry))
2513 that->myATTMap.remove(entry);
2514 if (that->myDistMap.contains(entry))
2515 that->myDistMap.remove(entry);
2516 if (that->myAttDistMap.contains(entry))
2517 that->myAttDistMap.remove(entry);
2520 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2521 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2524 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2526 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")");
2527 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2528 if (col == SMP_SIZEMAP_COLUMN) {
2529 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2530 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2531 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2532 MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString());
2533 if (! that->mySMPShapeTypeMap.contains(entry))
2534 MESSAGE("no such entry in mySMPShapeTypeMap")
2536 if (that->mySMPMap.contains(entry))
2537 if (that->mySMPMap[entry] == sizeMap
2538 || sizeMap.startsWith("Attractor")
2539 || sizeMap.startsWith("Constant") ){
2542 if (! sizeMap.isEmpty()) {
2543 that->mySMPMap[entry] = sizeMap;
2544 sizeMapValidationFromEntry(entry);
2547 MESSAGE("Size map empty: reverse to precedent value" );
2548 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
2550 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2554 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
2556 if ( smpTab->currentIndex() == ATT_TAB ){
2557 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2558 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2559 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2560 insertAttractor(mySMapObject, myAttObject);
2563 if (smpTab->currentIndex() == SMP_STD_TAB ){
2564 if ( myGeomSelWdg1->IsObjectSelected() ){
2565 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2566 insertElement(mySMapObject);
2569 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2570 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2571 myAttDistSpin->setValue(0.);
2572 myAttSizeSpin->setValue(0.);
2573 myAttDistSpin2->setValue(0.);
2574 mySmpSizeSpin->setValue(0.);
2575 myConstSizeCheck->setChecked(false);
2576 myAttractorCheck->setChecked(false);
2577 myGeomSelWdg1->deactivateSelection();
2578 myGeomSelWdg2->deactivateSelection();
2579 myAttSelWdg->deactivateSelection();
2580 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2581 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2582 myAttSelWdg->SetObject(CORBA::Object::_nil());
2585 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
2587 MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()");
2588 if ( smpTab->currentIndex() == ATT_TAB ){
2589 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
2590 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2591 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
2592 insertAttractor(mySMapObject, myAttObject, /*modify = */true);
2595 if (smpTab->currentIndex() == SMP_STD_TAB ){
2596 if ( myGeomSelWdg1->IsObjectSelected() ){
2597 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2598 insertElement(mySMapObject, /*modify = */true);
2601 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2602 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
2603 myAttDistSpin->setValue(0.);
2604 myAttSizeSpin->setValue(0.);
2605 myAttDistSpin2->setValue(0.);
2606 mySmpSizeSpin->setValue(0.);
2607 myConstSizeCheck->setChecked(false);
2608 myAttractorCheck->setChecked(false);
2609 myGeomSelWdg1->deactivateSelection();
2610 myGeomSelWdg2->deactivateSelection();
2611 myAttSelWdg->deactivateSelection();
2612 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2613 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2614 myAttSelWdg->SetObject(CORBA::Object::_nil());
2617 void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
2619 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()");
2620 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2621 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2623 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2625 TopAbs_ShapeEnum shapeType;
2626 string entry, shapeName;
2627 entry = (string) anObject->GetStudyEntry();
2628 MESSAGE("entry = "<<entry);
2629 shapeName = anObject->GetName();
2630 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
2631 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
2632 // in order to write the size map with the right syntax in StoreParamsToHypo
2633 // (f(t) for edges, f(u,v) for faces ...)
2634 if (shapeType == TopAbs_COMPOUND){
2635 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
2636 TopoDS_Shape childShape;
2637 TopoDS_Iterator anIt(theShape);
2638 for(;anIt.More();anIt.Next()){
2639 childShape = anIt.Value();
2640 shapeType = childShape.ShapeType();
2641 if(!childShape.IsNull()){
2646 mySizeMapTable->setFocus();
2648 shapeEntry = QString::fromStdString(entry);
2649 double phySize = mySmpSizeSpin->value();
2650 std::ostringstream oss;
2653 sizeMap = QString::fromStdString(oss.str());
2654 QTreeWidgetItem* item = new QTreeWidgetItem();
2656 int rowToChange = findRowFromEntry(shapeEntry);
2657 item = mySizeMapTable->topLevelItem( rowToChange );
2660 if (that->mySMPMap.contains(shapeEntry)) {
2661 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2662 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2666 mySizeMapTable->addTopLevelItem(item);
2668 that->mySMPMap[shapeEntry] = sizeMap;
2669 that->myDistMap[shapeEntry] = 0. ;
2670 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
2671 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2672 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
2673 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
2674 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
2675 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
2676 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2677 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2678 mySizeMapTable->clearSelection();
2680 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2681 myPhysicalMesh->setCurrentIndex( SizeMap );
2682 onPhysicalMeshChanged();
2686 void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
2688 MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()");
2689 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2690 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
2692 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2694 TopAbs_ShapeEnum shapeType;
2695 string entry, attEntry, faceName, attName;
2696 entry = (string) aFace->GetStudyEntry();
2697 attEntry = (string) anAttractor->GetStudyEntry();
2698 faceName = aFace->GetName();
2699 attName = anAttractor->GetName();
2700 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
2701 mySizeMapTable->setFocus();
2702 QString shapeEntry = QString::fromStdString(entry);
2703 QString qAttEntry = QString::fromStdString(attEntry);
2705 double phySize = h->GetPhySize();
2706 double infDist = 0. ;
2707 double constDist = 0. ;
2708 phySize = myAttSizeSpin->value();
2709 if (myAttractorCheck->isChecked()){
2710 infDist = myAttDistSpin->value();
2712 if (myConstSizeCheck->isChecked()){
2713 constDist = myAttDistSpin2->value();
2715 std::ostringstream oss;
2716 std::ostringstream oss2;
2717 std::ostringstream oss3;
2721 QString sizeMap = QString::fromStdString(oss.str());
2722 QString infDistString = QString::fromStdString(oss2.str());
2723 QString constDistString = QString::fromStdString(oss3.str());
2725 QTreeWidgetItem* item;
2726 QTreeWidgetItem* child;
2728 int rowToChange = findRowFromEntry(shapeEntry);
2729 item = mySizeMapTable->topLevelItem( rowToChange );
2730 child = item->child( 0 );
2733 if (that->mySMPMap.contains(shapeEntry)) {
2734 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
2735 // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")");
2739 item = new QTreeWidgetItem();
2740 child = new QTreeWidgetItem();
2741 mySizeMapTable->addTopLevelItem(item);
2742 item->addChild(child);
2744 that->mySMPMap.insert(shapeEntry,sizeMap);
2745 that->myATTMap.insert(shapeEntry,qAttEntry);
2746 that->myAttDistMap.insert(shapeEntry,infDist);
2747 that->myDistMap.insert(shapeEntry,constDist);
2748 that->mySMPShapeTypeMap.insert(shapeEntry,shapeType);
2749 item->setExpanded(true);
2750 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
2751 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
2752 if (infDist > std::numeric_limits<double>::epsilon()){
2753 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
2755 else if (constDist > std::numeric_limits<double>::epsilon()){
2756 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
2758 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
2760 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
2761 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
2762 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
2764 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
2765 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
2766 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
2768 if ( myPhysicalMesh->currentIndex() != SizeMap ) {
2769 myPhysicalMesh->setCurrentIndex( SizeMap );
2770 onPhysicalMeshChanged();
2772 MESSAGE("mySMPMap.size() = "<<mySMPMap.size());
2775 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
2777 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()");
2778 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2779 for ( ; row < nbRows; ++row )
2780 if (! sizeMapValidationFromRow(row))
2785 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
2787 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<<myRow);
2788 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2789 bool res = sizeMapValidationFromEntry(myEntry,displayError);
2790 mySizeMapTable->setFocus();
2794 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
2796 MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()");
2797 MESSAGE("myEntry = "<<myEntry.toStdString())
2799 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2801 if (! that->mySMPMap.contains(myEntry)) {
2802 // MESSAGE("Geometry with entry "<<myEntry.toStdString()<<" was not found.");
2805 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
2806 // MESSAGE("Shape type with entry "<<myEntry.toStdString()<<" was not found.");
2812 if (that->mySMPMap[myEntry].startsWith("def")) {
2813 // MESSAGE("custom function" );
2814 expr = that->mySMPMap[myEntry].toStdString();
2816 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
2817 // MESSAGE("Attractor" );
2818 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)) {
2821 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])" );
2827 // case size map is empty
2828 if (that->mySMPMap[myEntry].isEmpty()) {
2830 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
2834 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
2835 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
2836 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
2837 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
2838 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
2839 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
2842 //assert(Py_IsInitialized());
2843 if (! Py_IsInitialized())
2844 throw ("Erreur: Python interpreter is not initialized");
2845 PyGILState_STATE gstate;
2846 gstate = PyGILState_Ensure();
2848 PyObject * obj = NULL;
2849 PyObject* new_stderr = NULL;
2850 string err_description="";
2851 obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
2855 new_stderr=newPyStdOut(err_description);
2856 PySys_SetObject((char*)"stderr", new_stderr);
2858 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
2859 Py_DECREF(new_stderr);
2861 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
2862 PyGILState_Release(gstate);
2867 PyObject * func = NULL;
2868 func = PyObject_GetAttrString(main_mod, "f");
2872 new_stderr=newPyStdOut(err_description);
2873 PySys_SetObject((char*)"stderr", new_stderr);
2875 PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
2876 Py_DECREF(new_stderr);
2878 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
2879 PyGILState_Release(gstate);
2883 PyGILState_Release(gstate);
2885 // MESSAGE("SizeMap expression "<<expr<<" is valid");
2890 QString BLSURFPluginGUI_HypothesisCreator::caption() const
2892 return tr( "BLSURF_TITLE" );
2895 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
2897 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
2900 QString BLSURFPluginGUI_HypothesisCreator::type() const
2902 return tr( "BLSURF_HYPOTHESIS" );
2905 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
2907 return "blsurf_hypo_page.html";
2910 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
2913 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
2915 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
2920 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
2922 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
2923 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
2924 CORBA::Object_var obj;
2925 SALOMEDS::GenericAttribute_var anAttr;
2926 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
2927 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
2928 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2929 CORBA::String_var aVal = anIOR->Value();
2930 obj = myStudy->ConvertIORToObject(aVal);
2935 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
2936 QString entryForChecking;
2937 int endRow = mySizeMapTable->topLevelItemCount()-1;
2939 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2940 while (entry != entryForChecking && row <= endRow){
2942 entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2944 MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<<row<<" , endRow ="<<endRow)