1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPluginGUI_HypothesisCreator.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPluginGUI_HypothesisCreator.h"
28 #include "BLSURFPluginGUI_Dlg.h"
29 #include "BLSURFPlugin_Hypothesis.hxx"
31 #include <GeometryGUI.h>
33 #include <SMESHGUI_Dialog.h>
34 #include <SMESHGUI_HypothesesUtils.h>
35 #include <SMESHGUI_IdValidator.h>
36 #include <SMESHGUI_SpinBox.h>
37 #include <SMESHGUI_Utils.h>
38 #include <SMESH_Gen_i.hxx>
39 #include <SMESH_NumberFilter.hxx>
40 #include <StdMeshersGUI_SubShapeSelectorWdg.h>
42 #include <LightApp_SelectionMgr.h>
43 #include <SALOME_ListIO.hxx>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
47 #include <SalomeApp_Application.h>
48 #include <SalomeApp_Tools.h>
50 #include <QApplication>
54 #include <QGridLayout>
56 #include <QHBoxLayout>
57 #include <QHeaderView>
61 #include <QModelIndexList>
63 #include <QPushButton>
64 #include <QRadioButton>
67 #include <QStandardItem>
68 #include <QStandardItemModel>
70 #include <QTableWidget>
71 #include <QTreeWidget>
72 #include <QTreeWidgetItem>
73 #include <QVBoxLayout>
75 #include <TopoDS_Shape.hxx>
76 #include <TopoDS_Iterator.hxx>
78 #include <structmember.h> // Python
96 TBL_MESHING = 0, TBL_PRECAD, TBL_CUSTOM,
98 // Enforced vertices array columns
99 ENF_VER_NAME_COLUMN = 0,
100 ENF_VER_FACE_ENTRY_COLUMN,
104 ENF_VER_ENTRY_COLUMN,
105 ENF_VER_GROUP_COLUMN,
108 PERIODICITY_OBJ_SOURCE_COLUMN = 0,
109 PERIODICITY_OBJ_TARGET_COLUMN,
110 PERIODICITY_P1_SOURCE_COLUMN,
111 PERIODICITY_P2_SOURCE_COLUMN,
112 PERIODICITY_P3_SOURCE_COLUMN,
113 PERIODICITY_P1_TARGET_COLUMN,
114 PERIODICITY_P2_TARGET_COLUMN,
115 PERIODICITY_P3_TARGET_COLUMN,
116 PERIODICITY_SHAPE_TYPE,
118 // PERIODICITY_OBJ_SOURCE_COLUMN = 0,
119 // PERIODICITY_ENTRY_SOURCE_COLUMN,
120 // PERIODICITY_OBJ_TARGET_COLUMN,
121 // PERIODICITY_ENTRY_TARGET_COLUMN,
122 // PERIODICITY_P1_SOURCE_COLUMN,
123 // PERIODICITY_P1_ENTRY_SOURCE_COLUMN,
124 // PERIODICITY_P2_SOURCE_COLUMN,
125 // PERIODICITY_P2_ENTRY_SOURCE_COLUMN,
126 // PERIODICITY_P3_SOURCE_COLUMN,
127 // PERIODICITY_P3_ENTRY_SOURCE_COLUMN,
128 // PERIODICITY_P1_TARGET_COLUMN,
129 // PERIODICITY_P1_ENTRY_TARGET_COLUMN,
130 // PERIODICITY_P2_TARGET_COLUMN,
131 // PERIODICITY_P2_ENTRY_TARGET_COLUMN,
132 // PERIODICITY_P3_TARGET_COLUMN,
133 // PERIODICITY_P3_ENTRY_TARGET_COLUMN,
135 PERIODICITY_NB_COLUMN
161 // Enforced vertices inputs
169 // ENF_VER_GROUP_CHECK,
173 ENF_VER_INTERNAL_ALL_FACES,
174 ENF_VER_INTERNAL_ALL_FACES_GROUP,
175 // ENF_VER_VERTEX_BTN,
176 // ENF_VER_REMOVE_BTN,
177 // ENF_VER_SEPARATOR,
182 /**************************************************
183 Begin initialization Python structures and objects
184 ***************************************************/
194 PyStdOut_dealloc(PyStdOut *self)
200 PyStdOut_write(PyStdOut *self, PyObject *args)
204 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
207 *(self->out)=*(self->out)+c;
213 static PyMethodDef PyStdOut_methods[] = {
214 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
215 PyDoc_STR("write(string) -> None")},
216 {NULL, NULL} /* sentinel */
219 static PyMemberDef PyStdOut_memberlist[] = {
220 {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
221 (char*)"flag indicating that a space needs to be printed; used by print"},
222 {NULL} /* Sentinel */
225 static PyTypeObject PyStdOut_Type = {
226 /* The ob_type field must be initialized in the module init function
227 * to be portable to Windows without using C++. */
228 PyVarObject_HEAD_INIT(NULL, 0)
230 sizeof(PyStdOut), /*tp_basicsize*/
233 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
240 0, /*tp_as_sequence*/
245 PyObject_GenericGetAttr, /*tp_getattro*/
246 /* softspace is writable: we must supply tp_setattro */
247 PyObject_GenericSetAttr, /* tp_setattro */
249 Py_TPFLAGS_DEFAULT, /*tp_flags*/
253 0, /*tp_richcompare*/
254 0, /*tp_weaklistoffset*/
257 PyStdOut_methods, /*tp_methods*/
258 PyStdOut_memberlist, /*tp_members*/
272 PyObject * newPyStdOut( std::string& out )
274 PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
279 return (PyObject*)self;
283 /*************************************************
284 End initialization Python structures and objects
285 **************************************************/
289 // BEGIN EnforcedTreeWidgetDelegate
292 EnforcedTreeWidgetDelegate::EnforcedTreeWidgetDelegate(QObject *parent)
293 : QItemDelegate(parent)
297 QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
298 const QStyleOptionViewItem & option ,
299 const QModelIndex & index ) const
301 QModelIndex father = index.parent();
302 QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
304 if (index.column() == ENF_VER_X_COLUMN || \
305 index.column() == ENF_VER_Y_COLUMN || \
306 index.column() == ENF_VER_Z_COLUMN)
308 SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
309 editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
310 editor->setReadOnly(!entry.isEmpty());
311 editor->setDisabled(!entry.isEmpty());
316 QLineEdit *editor = new QLineEdit(parent);
317 if (index.column() != ENF_VER_GROUP_COLUMN) {
318 editor->setReadOnly(!entry.isEmpty());
319 editor->setDisabled(!entry.isEmpty());
325 void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor,
326 const QModelIndex &index) const
328 QString value = index.model()->data(index, Qt::EditRole).toString();
330 if (index.column() == ENF_VER_X_COLUMN ||
331 index.column() == ENF_VER_Y_COLUMN ||
332 index.column() == ENF_VER_Z_COLUMN)
334 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
335 lineEdit->setText(value);
338 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
339 lineEdit->setText(value);
343 void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
344 const QModelIndex &index) const
346 QModelIndex parent = index.parent();
347 QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
348 if (index.column() == ENF_VER_X_COLUMN || index.column() == ENF_VER_Y_COLUMN || index.column() == ENF_VER_Z_COLUMN) {
349 SMESHGUI_SpinBox *lineEdit = static_cast<SMESHGUI_SpinBox*>(editor);
350 if (entry.isEmpty() && !vertexExists(model, index, lineEdit->GetString()))
351 model->setData(index, lineEdit->GetValue(), Qt::EditRole);
352 } else if (index.column() == ENF_VER_NAME_COLUMN) {
353 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
354 QString value = lineEdit->text();
355 if (entry.isEmpty() && !vertexExists(model, index, value))
356 model->setData(index, value, Qt::EditRole);
357 } else if (index.column() == ENF_VER_ENTRY_COLUMN) {
358 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
359 QString value = lineEdit->text();
360 if (!vertexExists(model, index, value))
361 model->setData(index, value, Qt::EditRole);
362 } else if (index.column() == ENF_VER_GROUP_COLUMN) {
363 QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
364 model->setData(index, lineEdit->text(), Qt::EditRole);
368 void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor,
369 const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
371 editor->setGeometry(option.rect);
374 bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model,
375 const QModelIndex &index, QString value) const
378 QModelIndex parent = index.parent();
379 int row = index.row();
380 int col = index.column();
382 if (parent.isValid() && !value.isEmpty()) {
383 if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
385 if (col == ENF_VER_X_COLUMN) {
386 x = value.toDouble();
387 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
388 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
390 if (col == ENF_VER_Y_COLUMN) {
391 y = value.toDouble();
392 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
393 z = parent.child(row, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
395 if (col == ENF_VER_Z_COLUMN) {
396 z = value.toDouble();
397 x = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
398 y = parent.child(row, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
400 int nbChildren = model->rowCount(parent);
401 for (int i = 0 ; i < nbChildren ; i++) {
403 double childX = parent.child(i, ENF_VER_X_COLUMN).data(Qt::EditRole).toDouble();
404 double childY = parent.child(i, ENF_VER_Y_COLUMN).data(Qt::EditRole).toDouble();
405 double childZ = parent.child(i, ENF_VER_Z_COLUMN).data(Qt::EditRole).toDouble();
406 if ((childX == x) && (childY == y) && (childZ == z)) {
413 else if (col == ENF_VER_NAME_COLUMN) {
414 int nbChildren = model->rowCount(parent);
415 for (int i = 0 ; i < nbChildren ; i++) {
417 QString childName = parent.child(i, ENF_VER_NAME_COLUMN).data(Qt::EditRole).toString();
418 if (childName == value) {
431 // END EnforcedTreeWidgetDelegate
436 * \brief {BLSURFPluginGUI_HypothesisCreator constructor}
437 * @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
440 BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType )
441 : SMESHGUI_GenericHypothesisCreator( theHypType )
443 this->mySMPMap.clear();
445 GeomToolSelected = NULL;
446 GeomToolSelected = getGeomSelectionTool();
448 aSel = GeomToolSelected->selectionMgr();
450 /* Initialize the Python interpreter */
451 if (! Py_IsInitialized())
452 throw ("Error: Python interpreter is not initialized");
453 PyGILState_STATE gstate;
454 gstate = PyGILState_Ensure();
457 main_mod = PyImport_AddModule("__main__");
460 main_dict = PyModule_GetDict(main_mod);
462 PyRun_SimpleString("from math import *");
463 PyGILState_Release(gstate);
467 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
472 * \brief {Get or create the geom selection tool for active study}
474 GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() const
476 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
477 if (that->GeomToolSelected == NULL) {
478 that->GeomToolSelected = new GeomSelectionTools();
480 return that->GeomToolSelected;
483 GEOM::GEOM_Gen_var BLSURFPluginGUI_HypothesisCreator::getGeomEngine()
485 return GeometryGUI::GetGeomGen();
488 void BLSURFPluginGUI_HypothesisCreator::avoidSimultaneousSelection(ListOfWidgets &selectionWidgets) const
490 StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0;
491 ListOfWidgets::const_iterator anIt = selectionWidgets.begin();
492 for ( ; anIt != selectionWidgets.end(); anIt++)
494 if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
496 StdMeshersGUI_ObjectReferenceParamWdg * w1 =
497 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
498 ListOfWidgets::const_iterator anIt2 = anIt;
499 for ( ++anIt2; anIt2 != selectionWidgets.end(); anIt2++)
500 if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg"))
502 StdMeshersGUI_ObjectReferenceParamWdg * w2 =
503 ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 );
504 w1->AvoidSimultaneousSelection( w2 );
506 if ( !widgetToActivate )
507 widgetToActivate = w1;
510 if ( widgetToActivate )
511 widgetToActivate->activateSelection();
514 bool BLSURFPluginGUI_HypothesisCreator::checkParams(QString& msg) const
518 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
519 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
523 myAdvWidget->myOptionTable->setFocus();
524 QApplication::instance()->processEvents();
528 int iTbl = 0, nbTbl = myAdvWidget->myOptionTable->topLevelItemCount();
529 for ( ; iTbl < nbTbl; ++iTbl )
531 QTreeWidgetItem* table = myAdvWidget->myOptionTable->topLevelItem( iTbl );
532 int nbRows = table->childCount();
533 for ( int iRow = 0; iRow < nbRows; ++iRow )
535 QTreeWidgetItem* row = table->child( iRow );
536 myAdvWidget->GetOptionAndValue( row, name, value, isDefault );
538 if ( name.simplified().isEmpty() )
539 continue; // invalid custom option
541 if ( isDefault ) // not selected option
548 h->SetOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
551 h->SetPreCADOptionValue( name.toLatin1().constData(), value.toLatin1().constData() );
554 h->AddOption( name.toLatin1().constData(), value.toLatin1().constData() );
558 catch ( const SALOME::SALOME_Exception& ex )
560 msg = ex.details.text.in();
568 // SizeMap and attractors
571 mySizeMapTable->setFocus();
572 QApplication::instance()->processEvents();
574 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
575 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
577 for ( ; row < nbRows; ++row )
579 QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
580 QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
581 if ( !sizeMap.isEmpty() ) {
582 if (that->sizeMapValidationFromRow(row))
585 e = entry.toStdString();
586 s = that->mySMPMap[entry].toStdString();
587 //h->SetSizeMapEntry( e.c_str(), s.c_str() );
589 catch ( const SALOME::SALOME_Exception& ex )
591 msg = ex.details.text.in();
602 // 22207: BLSURFPLUGIN: The user is allowed to enter 0 as a global or local size.
605 // In case if not STD_TAB is current tab, then text() of empty spinboxes returns "0" value.
606 // So STD_TAB must be current tab to get correct value of it's spinbox.
607 myTabWidget->setCurrentIndex( STD_TAB );
611 if ( !( ok = ( myStdWidget->myPhySize->text().isEmpty() ||
612 myStdWidget->myPhySize->text().toDouble() > 0.0 )))
613 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_HPHYDEF"));
617 if ( !( ok = ( myStdWidget->myMaxSize->text().isEmpty() ||
618 myStdWidget->myMaxSize->text().toDouble() > 0.0 )))
619 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_MAXSIZE"));
623 if ( !( ok = ( myStdWidget->myAngleMesh->text().isEmpty() ||
624 myStdWidget->myAngleMesh->text().toDouble() > 0.0 )))
625 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_ANGLE_MESH"));
629 if ( !( ok = ( myStdWidget->myChordalError->text().isEmpty() ||
630 myStdWidget->myChordalError->text().toDouble() > 0.0 )))
631 msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_CHORDAL_ERROR"));
634 // #16954 EDF 19466 - localsize
635 // Warn the user if local size is less than Min Size
637 !myStdWidget->myMinSizeRel->isChecked() &&
638 !myStdWidget->myMinSize->text().isEmpty() )
640 const double minSize = myStdWidget->myMinSize->GetValue();
642 for ( QMapIterator<QString,QString> i( mySMPMap ); i.hasNext() && ok ; )
645 double size = i.value().toDouble( &isValue );
646 ok = ( !isValue || size >= minSize );
648 for ( QMapIterator<QString, TAttractorVec > i( myATTMap ); i.hasNext() && ok ; i.next() )
650 const TAttractorVec& attVec = i.value();
651 for ( size_t i = 0; i < attVec.size(); ++i )
652 ok = ( attVec[i].IsToDelete() || attVec[i].startSize >= minSize );
655 msg = tr( "TOO_SMALL_LOCAL_SIZE" );
657 // Warn the user if local size is more than User Size
659 !myStdWidget->myPhySizeRel->isChecked() &&
660 !myStdWidget->myPhySize->text().isEmpty() )
662 const double userSize = myStdWidget->myPhySize->GetValue();
664 for ( QMapIterator<QString,QString> i( mySMPMap ); i.hasNext() && ok ; )
667 double size = i.value().toDouble( &isValue );
668 ok = ( !isValue || size <= userSize );
670 for ( QMapIterator<QString, TAttractorVec > i( myATTMap ); i.hasNext() && ok ; i.next() )
672 const TAttractorVec& attVec = i.value();
673 for ( size_t i = 0; i < attVec.size(); ++i )
674 ok = ( attVec[i].IsToDelete() || attVec[i].startSize <= userSize );
677 msg = tr( "TOO_LARGE_LOCAL_SIZE" );
685 h->SetOptionValues( myOptions ); // restore values
686 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
692 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
694 QFrame* fr = new QFrame( 0 );
695 QVBoxLayout* lay = new QVBoxLayout( fr );
697 lay->setSpacing( 0 );
699 // main TabWidget of the dialog
700 myTabWidget = new QTabWidget( fr );
701 myTabWidget->setTabShape( QTabWidget::Rounded );
702 myTabWidget->setTabPosition( QTabWidget::North );
703 lay->addWidget( myTabWidget );
708 myStdGroup = new QWidget();
709 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
710 aStdLayout->setSpacing( 6 );
711 aStdLayout->setMargin( 11 );
714 myName = new QLineEdit( myStdGroup );
715 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
717 myStdWidget->myPhysicalMesh->removeItem( PhysicalLocalSize );
722 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
723 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
725 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
730 aStdLayout->setRowStretch(row,1);
731 aStdLayout->setColumnStretch(1,1);
734 // advanced parameters
735 myAdvGroup = new QWidget();
736 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
737 anAdvLayout->setSpacing( 6 );
738 anAdvLayout->setMargin( 11 );
739 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
740 anAdvLayout->addWidget( myAdvWidget );
743 // Size Maps parameters
745 mySmpGroup = new QWidget( dlg() );
748 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
751 mySizeMapTable = new QTreeWidget( mySmpGroup );
752 mySizeMapTable ->setMinimumWidth(200);
753 QStringList sizeMapHeaders;
754 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
755 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
756 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
757 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
758 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
759 mySizeMapTable->setAlternatingRowColors(true);
762 smpTab = new QTabWidget( mySmpGroup );
763 smpTab->setTabShape( QTabWidget::Rounded );
764 smpTab->setTabPosition( QTabWidget::South );
765 lay->addWidget( smpTab );
767 // Filters of selection
768 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
770 SM_ShapeTypes.Add( TopAbs_VERTEX );
771 SM_ShapeTypes.Add( TopAbs_EDGE );
772 SM_ShapeTypes.Add( TopAbs_FACE );
773 SM_ShapeTypes.Add( TopAbs_COMPOUND );
775 ATT_ShapeTypes.Add( TopAbs_VERTEX );
776 ATT_ShapeTypes.Add( TopAbs_EDGE );
777 ATT_ShapeTypes.Add( TopAbs_WIRE );
778 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
780 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
781 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
782 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
784 // Standard size map tab
785 mySmpStdGroup = new QWidget();
786 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
787 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false);
788 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
789 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
790 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
791 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
794 myAttractorGroup = new QWidget();
795 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
796 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false);
797 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
798 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
799 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
800 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
801 QFrame* attLine = new QFrame(myAttractorGroup);
802 attLine->setFrameShape(QFrame::HLine);
803 attLine->setFrameShadow(QFrame::Sunken);
804 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false);
805 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
806 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
807 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
808 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
809 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
810 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
811 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
812 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
813 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
814 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
816 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
817 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
821 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
822 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
823 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
824 modifyMapButton->setEnabled(false);
827 myAttSelWdg->setEnabled(false);
828 myAttSizeSpin->setEnabled(false);
829 myAttSizeLabel->setEnabled(false);
830 myAttDistSpin->setEnabled(false);
831 myAttDistLabel->setEnabled(false);
832 myAttDistSpin2->setEnabled(false);
833 myAttDistLabel2->setEnabled(false);
834 myAttDistSpin->setValue(0.);
835 myAttDistSpin2->setValue(0.);
836 myAttSizeSpin->setValue(0.);
837 mySmpSizeSpin->setValue(0.);
840 // ADD WIDGETS (SIZEMAP TAB)
841 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
842 anSmpLayout->setColumnStretch(0, 1);
843 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
844 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
845 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
846 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
847 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
848 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
851 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
852 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
853 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
854 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
857 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
858 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
859 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
860 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
861 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
862 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
863 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
864 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
865 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
866 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
867 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
868 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
870 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
871 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
873 smpTab->setCurrentIndex( SMP_STD_TAB );
875 // Enforced vertices parameters
876 myEnfGroup = new QWidget( dlg() );
877 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
879 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
880 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
881 myEnforcedTreeWidget->setSortingEnabled(true);
882 QStringList enforcedHeaders;
883 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
884 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
885 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
887 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
888 myEnforcedTreeWidget->header()->setStretchLastSection(true);
889 myEnforcedTreeWidget->setAlternatingRowColors(true);
890 myEnforcedTreeWidget->setUniformRowHeights(true);
891 myEnforcedTreeWidget->setAnimated(true);
892 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
893 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
894 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
895 myEnforcedTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
896 myEnforcedTreeWidget->resizeColumnToContents(column);
898 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
899 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
900 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
902 // FACE AND VERTEX SELECTION
903 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
904 shapeTypes1.Add( TopAbs_FACE );
905 shapeTypes1.Add( TopAbs_COMPOUND );
906 shapeTypes2.Add( TopAbs_VERTEX );
907 shapeTypes2.Add( TopAbs_COMPOUND );
909 // SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
910 // myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true);
911 // myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
913 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
914 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
915 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
917 //myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
919 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
920 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
921 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
923 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
924 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
925 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
927 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
928 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
929 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
931 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
932 myGroupName = new QLineEdit(myEnfGroup);
934 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
935 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
937 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
939 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
940 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
942 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
943 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
944 // FACE AND VERTEX SELECTION
945 //anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
946 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
947 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
948 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
949 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
950 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
951 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
952 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
953 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
954 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
955 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
956 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
957 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
958 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
959 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
960 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
961 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
964 // Periodicity parameters
965 myPeriodicityGroup = new QWidget( dlg() );
966 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
968 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
969 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
970 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
972 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
974 QStringList myPeriodicityTreeHeaders;
975 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
976 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
977 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
978 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
979 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
980 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
981 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
982 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
983 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
984 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
986 // Hide the vertex name to make the widget more readable
987 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
988 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
989 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
990 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
991 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
992 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
993 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
996 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
997 myPeriodicityTreeWidget->setSortingEnabled(true);
999 myPeriodicityTreeWidget->setAlternatingRowColors(true);
1000 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
1001 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
1003 size_t periodicityVisibleColumns = 2;
1004 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
1005 myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
1006 myPeriodicityTreeWidget->resizeColumnToContents(column);
1008 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
1010 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
1012 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
1014 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
1015 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
1016 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
1018 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
1020 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
1021 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
1023 myPeriodicityOnFaceRadioButton->setChecked(true);
1025 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
1026 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
1029 // FACE, EDGE AND VERTEX SELECTION
1030 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
1031 shapeTypesFace.Add( TopAbs_FACE );
1032 shapeTypesFace.Add( TopAbs_EDGE );
1033 shapeTypesFace.Add( TopAbs_COMPOUND );
1034 shapeTypesEdge.Add( TopAbs_EDGE );
1035 shapeTypesEdge.Add( TopAbs_COMPOUND );
1037 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
1039 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1040 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1042 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1043 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false);
1044 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1045 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1047 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1048 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1049 // myPeriodicitySourceEdgeWdg->hide();
1050 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1052 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1053 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1055 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1056 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false);
1057 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1058 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1060 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1061 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1062 // myPeriodicityTargetEdgeWdg->hide();
1063 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1065 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1066 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1067 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1069 myPeriodicityGroupBox2->setCheckable(true);
1070 myPeriodicityGroupBox2->setChecked(false);
1072 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1073 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1075 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1076 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1079 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1080 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1083 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1084 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false);
1085 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1088 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1089 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1091 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1092 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false);
1093 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1096 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1097 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1099 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1100 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false);
1101 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1104 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1105 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1107 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1108 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false);
1109 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1112 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1113 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1115 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1116 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false);
1117 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1120 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1121 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1123 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1124 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false);
1125 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1127 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1128 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1131 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1132 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1134 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1135 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1137 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1139 myPeriodicitySelectionWidgets.clear();
1140 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1141 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1142 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1143 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1144 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1145 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1146 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1147 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1148 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1150 // HyperPatch parameters
1152 QWidget* hpGroup = new QWidget();
1153 QGridLayout* hpLayout = new QGridLayout(hpGroup);
1155 myHyPatchTable = new QTableWidget( hpGroup );
1156 myHyPatchTable->setColumnCount(1);
1157 myHyPatchTable->setHorizontalHeaderLabels( QStringList() << tr("BLSURF_HYPATCH_TBL_HEADER") );
1158 myHyPatchTable->setAlternatingRowColors(true);
1159 myHyPatchTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
1162 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1163 myHyPatchFaceSelBtn = new QPushButton( iconSelect, tr("BLSURF_HYPATCH_SEL_FACE"), hpGroup );
1164 myHyPatchGroupSelBtn = new QPushButton( iconSelect, tr("BLSURF_HYPATCH_SEL_GROUP"), hpGroup );
1165 myHyPatchFaceSelBtn->setCheckable( true );
1166 myHyPatchGroupSelBtn->setCheckable( true );
1168 myHyPatchFaceSelector = new StdMeshersGUI_SubShapeSelectorWdg( hpGroup, TopAbs_FACE, /*toShowList=*/false );
1170 QLabel* hpTagsLbl = new QLabel( tr("BLSURF_TAGS"), hpGroup );
1171 myHyPatchTagsLE = new QLineEdit( hpGroup );
1172 myHyPatchTagsLE->setValidator( new SMESHGUI_IdValidator( hpGroup ));
1174 QPushButton* hpAddBtn = new QPushButton( tr("BLSURF_SM_ADD"), hpGroup );
1175 QPushButton* hpRemBtn = new QPushButton( tr("BLSURF_SM_REMOVE"), hpGroup );
1177 hpLayout->addWidget( myHyPatchTable, 0, 0, 5, 1 );
1178 hpLayout->addWidget( myHyPatchFaceSelBtn, 0, 1, 1, 2 );
1179 hpLayout->addWidget( myHyPatchGroupSelBtn, 0, 3, 1, 2 );
1180 hpLayout->addWidget( hpTagsLbl, 1, 1, 1, 1 );
1181 hpLayout->addWidget( myHyPatchTagsLE, 1, 2, 1, 3 );
1182 hpLayout->addWidget( hpAddBtn, 2, 1, 1, 2 );
1183 hpLayout->addWidget( hpRemBtn, 2, 3, 1, 2 );
1184 hpLayout->addWidget( myHyPatchFaceSelector, 3, 1, 1, 4 );
1189 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1190 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1192 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1193 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1194 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1195 myTabWidget->insertTab( HYPERPATCH_TAB, hpGroup, tr( "BLSURF_HYPERPATCH_TAB" ));
1201 myPeriodicityGroup->hide();
1204 myTabWidget->setCurrentIndex( STD_TAB );
1206 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
1209 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1210 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1211 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1212 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1213 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1214 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1215 connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1216 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1217 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1218 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1219 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1220 connect( myTabWidget, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1222 // Enforced vertices
1223 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1224 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1225 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1226 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1227 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1228 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1229 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1232 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1233 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1234 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1235 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1237 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1238 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1240 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1241 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1246 connect( myHyPatchFaceSelBtn, SIGNAL( toggled(bool) ), SLOT( onHyPatchFaceSelection(bool) ));
1247 connect( myHyPatchGroupSelBtn, SIGNAL( toggled(bool) ), SLOT( onHyPatchGroupSelection(bool) ));
1248 connect( myHyPatchFaceSelector, SIGNAL( shapeSelected() ), SLOT( onHyPatchSelectionChanged()));
1249 connect( hpAddBtn, SIGNAL( clicked() ), SLOT( onHyPatchAdd()));
1250 connect( hpRemBtn, SIGNAL( clicked() ), SLOT( onHyPatchRemove()));
1255 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1256 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1258 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1260 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1261 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1262 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1263 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1264 // myEnfFaceWdg->deactivateSelection();
1265 // myEnfVertexWdg->deactivateSelection();
1269 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1271 myStdWidget->onPhysicalMeshChanged();
1275 * This method resets the content of the X, Y, Z widgets;
1277 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1279 myXCoord->setCleared(true);
1280 myYCoord->setCleared(true);
1281 myZCoord->setCleared(true);
1282 myXCoord->setText("");
1283 myYCoord->setText("");
1284 myZCoord->setText("");
1285 // myGroupName->setText("");
1288 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1289 This method updates the tooltip of a modified item. The QLineEdit widgets content
1290 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1292 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1293 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1294 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1295 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1296 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1297 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1298 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1299 QTreeWidgetItem* parent = item->parent();
1301 clearEnforcedVertexWidgets();
1303 if (parent && (!x.isNull() || !entry.isNull())) {
1304 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1305 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1306 if (entry.isNull()) {
1307 toolTip += QString("(") + x.toString();
1308 toolTip += QString(", ") + y.toString();
1309 toolTip += QString(", ") + z.toString();
1310 toolTip += QString(")");
1313 if (!groupName.isEmpty())
1314 toolTip += QString(" [") + groupName + QString("]");
1316 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1319 myXCoord->SetValue(x.toDouble());
1320 myYCoord->SetValue(y.toDouble());
1321 myZCoord->SetValue(z.toDouble());
1324 if (!groupName.isEmpty())
1325 myGroupName->setText(groupName);
1329 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1330 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1331 clearEnforcedVertexWidgets();
1332 if (nbSelEnfVertex == 1)
1334 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1337 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1338 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1339 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1340 if (CORBA::is_nil(measureOp))
1343 CORBA::Double x,y,z;
1344 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1345 if ( measureOp->IsDone() )
1347 myXCoord->SetValue(x);
1348 myYCoord->SetValue(y);
1349 myZCoord->SetValue(z);
1355 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1356 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1357 of the enforced vertex clicked in the tree widget.
1359 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1360 clearEnforcedVertexWidgets();
1361 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1362 if (! items.isEmpty() && items.size() == 1) {
1363 QTreeWidgetItem *item = items[0];
1364 // for (int i=0 ; i < items.size() ; i++) {
1366 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1367 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1368 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1369 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1370 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1371 if (!x.isNull()/* && entry.isNull()*/) {
1372 myXCoord->SetValue(x.toDouble());
1373 myYCoord->SetValue(y.toDouble());
1374 myZCoord->SetValue(z.toDouble());
1377 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1378 myGroupName->setText(group.toString());
1383 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1384 This method adds a face containing enforced vertices in the tree widget.
1386 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1387 // Find theFaceEntry item
1388 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1389 QTreeWidgetItem* theItem;
1390 if (theItemList.empty()) {
1391 theItem = new QTreeWidgetItem();
1392 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1393 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1394 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1395 myEnforcedTreeWidget->addTopLevelItem(theItem);
1398 theItem = theItemList[0];
1403 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1404 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1406 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z,
1407 std::string vertexName,
1408 std::string geomEntry,
1409 std::string groupName)
1411 bool okToCreate = true;
1413 const int nbVert = myEnforcedTreeWidget->topLevelItemCount();
1414 for (int row = 0; row < nbVert; row++ )
1416 QTreeWidgetItem* child = myEnforcedTreeWidget->topLevelItem( row );
1417 QString childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1418 QString childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1419 double childX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1420 double childY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1421 double childZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1422 if (((childEntry.isEmpty()) && (childX == x) && (childY == y) && (childZ == z)) ||
1423 ( !childEntry.isEmpty() && childEntry == geomEntry.c_str() ))
1425 // update group name
1426 if ( childGroupName != groupName.c_str() ) {
1427 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1437 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( myEnforcedTreeWidget );
1438 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1439 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1440 QSize iconSize = iconSelect.size()*0.7;
1442 int vertexIndex=nbVert;
1443 QString myVertexName;
1445 while(indexRef != vertexIndex) {
1446 indexRef = vertexIndex;
1447 if (vertexName.empty())
1448 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1450 myVertexName = QString(vertexName.c_str());
1452 for (int row = 0;row<nbVert;row++) {
1453 QString name = myEnforcedTreeWidget->topLevelItem(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1454 if (myVertexName == name) {
1460 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1461 if (geomEntry.empty()) {
1462 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1463 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1464 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1467 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1468 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1470 if (groupName != "")
1471 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1473 QString toolTip = myVertexName;
1474 if (geomEntry.empty()) {
1475 toolTip += QString(" (%1, %2, %3").arg(x).arg(y).arg(z);
1477 if (groupName != "")
1478 toolTip += QString(" [%1]").arg(groupName.c_str());
1480 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1481 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1484 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1485 This method is called when a item is added into the enforced vertices tree widget
1487 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1489 getGeomSelectionTool()->selectionMgr()->clearFilters();
1490 myEnfVertexWdg->deactivateSelection();
1492 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1493 myEnforcedTreeWidget->resizeColumnToContents(column);
1496 int selEnfVertex = myEnfVertexWdg->NbObjects();
1497 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1499 if ((selEnfVertex == 0) && coordsEmpty)
1502 string entry, shapeName;
1504 std::string groupName = myGroupName->text().simplified().toStdString();
1506 if (selEnfVertex <= 1)
1509 x = myXCoord->GetValue();
1510 y = myYCoord->GetValue();
1511 z = myZCoord->GetValue();
1512 if (selEnfVertex == 1) {
1513 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1514 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1517 addEnforcedVertex(x, y, z, "", "", groupName);
1521 if ( CORBA::is_nil(getGeomEngine()))
1524 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1525 if (CORBA::is_nil(measureOp))
1528 CORBA::Double x,y,z;
1530 for (int j = 0 ; j < selEnfVertex ; j++)
1532 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1533 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1534 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1535 if ( measureOp->IsDone() )
1536 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1537 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1538 addEnforcedVertex(0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1544 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1546 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1547 myEnforcedTreeWidget->resizeColumnToContents(column);
1549 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1550 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1551 myStdWidget->onPhysicalMeshChanged();
1555 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1556 This method is called when a item is removed from the enforced vertices tree widget
1558 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1559 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1560 QList<QTreeWidgetItem *> selectedVertices;
1561 QSet<QTreeWidgetItem *> selectedEntries;
1562 QTreeWidgetItem* item;
1564 foreach( item, selectedItems ) {
1565 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1566 if (! value.isNull())
1567 selectedVertices.append(item);
1569 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1570 if (! value.isNull())
1571 selectedVertices.append(item);
1573 selectedEntries.insert(item);
1577 foreach(item,selectedVertices) {
1578 QTreeWidgetItem* parent = item->parent();
1580 parent->removeChild(item);
1582 if ( parent && parent->childCount() == 0) {
1583 if (selectedEntries.contains(parent))
1584 selectedEntries.remove(parent);
1589 foreach(item,selectedEntries) {
1593 myEnforcedTreeWidget->selectionModel()->clearSelection();
1597 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1599 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1602 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1603 This method is called when a item is added into the periodicity table widget
1605 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1607 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1609 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1610 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1611 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1613 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1614 w1->deactivateSelection();
1618 // Source-Target selection
1619 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1620 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1622 if (selSource == 0 || selTarget == 0)
1625 // Vertices selection
1626 if (myPeriodicityGroupBox2->isChecked())
1628 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1629 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1630 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1631 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1632 //int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1633 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1635 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1637 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1638 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1643 // Add Source-Target in table
1644 string shapeEntry, sourceEntry, targetEntry;
1645 string shapeName, sourceName, targetName;
1646 GEOM::GEOM_Object_var shape;
1648 QTreeWidgetItem* item = new QTreeWidgetItem();
1649 myPeriodicityTreeWidget->addTopLevelItem(item);
1651 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1655 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1657 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1658 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1659 shapeName = shape->GetName();
1660 shapeEntry = shape->GetStudyEntry();
1661 item->setData(k, Qt::EditRole, shapeName.c_str() );
1662 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1663 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1667 // Add shape type in tree
1668 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1669 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1671 // Blank input fields
1672 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1674 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1675 w1->SetObject(GEOM::GEOM_Object::_nil());
1678 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1679 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1683 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1684 This method is called when a item is removed from the periodicity tree widget
1686 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1687 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1688 QTreeWidgetItem* item;
1690 foreach(item,selectedItems) {
1694 myEnforcedTreeWidget->selectionModel()->clearSelection();
1697 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1698 This method enable clears the field for periodicity by vertices
1700 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1704 for (int k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1706 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1707 w1->deactivateSelection();
1708 w1->SetObject(CORBA::Object::_nil());
1713 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1714 This method enable the proper shape selection widget to Face or Edge shapes
1716 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1718 // if (myPeriodicityOnFaceRadioButton->isChecked())
1720 // myPeriodicitySourceEdgeWdg->hide();
1721 // myPeriodicityTargetEdgeWdg->hide();
1722 // myPeriodicitySourceFaceWdg->show();
1723 // myPeriodicityTargetFaceWdg->show();
1727 // myPeriodicitySourceFaceWdg->hide();
1728 // myPeriodicityTargetFaceWdg->hide();
1729 // myPeriodicitySourceEdgeWdg->show();
1730 // myPeriodicityTargetEdgeWdg->show();
1734 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1736 QString shapeName, shapeEntry;
1737 CORBA::Object_var shape;
1739 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1740 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1742 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1744 shapeName = item->data(k, Qt::EditRole).toString();
1745 shapeEntry = item->data(k, Qt::UserRole).toString();
1746 if (! shapeEntry.isEmpty())
1748 shape = entryToObject(shapeEntry);
1749 w1->SetObject(shape);
1750 w1->deactivateSelection();
1752 myPeriodicityGroupBox2->setChecked(1);
1755 myPeriodicityGroupBox2->setChecked(0);
1758 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1759 myPeriodicityOnFaceRadioButton->setChecked(true);
1761 myPeriodicityOnEdgeRadioButton->setChecked(true);
1766 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1767 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1769 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1771 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1773 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1775 // find wich selection widget is activated
1776 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1778 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1779 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1781 // don't activate vertex selection if the group box is not checked
1782 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1784 // clear the selection, to avoid to put the same object in the other widget
1785 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1786 // activate the next widget
1787 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1788 w2->activateSelection();
1795 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1796 This method updates the GUI widgets with the hypothesis data
1798 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1800 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1802 BlsurfHypothesisData data;
1803 that->readParamsFromHypo( data );
1806 myName->setText( data.myName );
1807 QFontMetrics metrics( myName->font() );
1808 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1810 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1811 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1812 if (data.myPhySize <= 0)
1813 myStdWidget->myPhySize->setText("");
1815 myStdWidget->myPhySize->SetValue( data.myPhySize );
1816 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1817 if (data.myMinSize < 0)
1818 myStdWidget->myMinSize->setText("");
1820 myStdWidget->myMinSize->SetValue( data.myMinSize );
1821 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1822 if (data.myMaxSize < 0)
1823 myStdWidget->myMaxSize->setText("");
1825 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1826 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1827 myStdWidget->myUseGradation->setChecked( data.myUseGradation );
1828 if (data.myGradation <= 0 || !data.myUseGradation )
1829 myStdWidget->myGradation->setText("");
1831 myStdWidget->myGradation->SetValue( data.myGradation );
1832 myStdWidget->myUseVolumeGradation->setChecked( data.myUseVolumeGradation );
1833 if (data.myVolumeGradation <= 0 || !data.myUseVolumeGradation )
1834 myStdWidget->myVolumeGradation->setText("");
1836 myStdWidget->myVolumeGradation->SetValue( data.myVolumeGradation );
1838 foreach (QAbstractButton* button, myStdWidget->myButtonGroupElementType->buttons()) {
1839 if (myStdWidget->myButtonGroupElementType->id(button) == data.myElementType) {
1840 button->setChecked(true);
1845 myStdWidget->myUseSurfaceProximity->setChecked( data.myUseSurfaceProximity );
1846 myStdWidget->myNbSurfaceProximityLayers->setValue( data.myNbSurfaceProximityLayers );
1847 myStdWidget->mySurfaceProximityRatio->SetValue( data.mySurfaceProximityRatio );
1848 myStdWidget->myUseVolumeProximity->setChecked( data.myUseVolumeProximity );
1849 myStdWidget->myNbVolumeProximityLayers->setValue( data.myNbVolumeProximityLayers );
1850 myStdWidget->myVolumeProximityRatio->SetValue( data.myVolumeProximityRatio );
1851 if ( !data.myUseSurfaceProximity )
1853 //myStdWidget->myNbSurfaceProximityLayers->setText("");
1854 myStdWidget->mySurfaceProximityRatio->setText("");
1856 if ( !data.myUseVolumeProximity )
1858 //myStdWidget->myNbVolumeProximityLayers->setText("");
1859 myStdWidget->myVolumeProximityRatio->setText("");
1862 if (data.myAngleMesh < 0)
1863 myStdWidget->myAngleMesh->setText("");
1865 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1866 if (data.myChordalError <= 0)
1867 myStdWidget->myChordalError->setText("");
1869 myStdWidget->myChordalError->SetValue( data.myChordalError );
1870 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1871 if (data.myAnisotropicRatio <= 0)
1872 myStdWidget->myAnisotropicRatio->setText("");
1874 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1875 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1876 if (data.myTinyEdgeLength <= 0)
1877 myStdWidget->myTinyEdgeLength->setText("");
1879 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1880 myStdWidget->myOptimiseTinyEdges->setChecked( data.myOptimiseTinyEdges );
1881 if (data.myTinyEdgeOptimisLength <= 0)
1882 myStdWidget->myTinyEdgeOptimisLength->setText("");
1884 myStdWidget->myTinyEdgeOptimisLength->SetValue( data.myTinyEdgeOptimisLength );
1885 myStdWidget->myCorrectSurfaceIntersection->setChecked( data.myCorrectSurfaceIntersection );
1886 if (data.myCorrectSurfaceIntersectionMaxCost <= 0)
1887 myStdWidget->myCorrectSurfaceIntersectionMaxCost->setText("");
1889 myStdWidget->myCorrectSurfaceIntersectionMaxCost->SetValue( data.myCorrectSurfaceIntersectionMaxCost );
1890 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1891 if (data.myBadElementAspectRatio <= 0)
1892 myStdWidget->myBadElementAspectRatio->setText("");
1894 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1895 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1896 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1898 myStdWidget->resizeWidgets();
1900 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1902 if ( myOptions.operator->() ) {
1903 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1904 myAdvWidget->AddOption( TBL_MESHING, that->myOptions[i].in() );
1906 if ( myPreCADOptions.operator->() ) {
1907 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i )
1908 myAdvWidget->AddOption( TBL_PRECAD, that->myPreCADOptions[i].in() );
1910 if ( myCustomOptions.operator->() ) {
1911 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1912 myAdvWidget->AddOption( TBL_CUSTOM, that->myCustomOptions[i].in() );
1914 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1915 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1916 // myGMFFileMode->setChecked(data.myGMFFileMode);
1919 QMapIterator<QString, QString> i(that->mySMPMap);
1920 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1921 while (i.hasNext()) {
1923 const QString entry = i.key();
1924 const QString sizeMap = i.value();
1925 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1926 //int row = mySizeMapTable->topLevelItemCount();
1927 QTreeWidgetItem* item = new QTreeWidgetItem();
1928 mySizeMapTable->addTopLevelItem( item );
1929 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1930 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1931 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1932 if (that->myATTMap.contains(entry)) {
1933 TAttractorVec & attVec = that->myATTMap[entry];
1934 for ( size_t i = 0; i < attVec.size(); ++i )
1936 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
1937 QTreeWidgetItem* child = new QTreeWidgetItem();
1938 item->addChild( child );
1939 item->setExpanded(true);
1940 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
1941 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
1942 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
1944 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
1945 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
1948 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
1954 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1957 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1958 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1959 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1961 // Enforced vertices
1962 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1964 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1965 TEntry entry = (*evmIt).first;
1966 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1968 //QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1970 TEnfVertexList evs = (*evmIt).second;
1972 TEnfVertexList::const_iterator evsIt = evs.begin();
1973 TEnfVertex *enfVertex;
1974 for ( ; evsIt != evs.end() ; ++evsIt) {
1975 enfVertex = (*evsIt);
1976 double x = 0, y = 0, z = 0;
1977 if (enfVertex->coords.size()) {
1978 x = enfVertex->coords[0];
1979 y = enfVertex->coords[1];
1980 z = enfVertex->coords[2];
1982 that->addEnforcedVertex(x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1986 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1987 myEnforcedTreeWidget->resizeColumnToContents(column);
1989 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1990 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1991 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1995 // Add an item in the tree widget for each association
1996 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
1998 QTreeWidgetItem* item = new QTreeWidgetItem();
1999 myPeriodicityTreeWidget->addTopLevelItem(item);
2000 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
2001 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
2002 for (size_t k=0; k<periodicity_i.size(); k++)
2004 string shapeEntry = periodicity_i[k];
2005 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
2006 item->setData(k, Qt::EditRole, shapeName.c_str() );
2007 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
2012 for ( int i = 0; i < data.hyperpatches.size(); ++i )
2013 that->addHyPatchToTable( data.hyperpatches[i] );
2016 that->myStdWidget->onPhysicalMeshChanged();
2017 that->myStdWidget->onGeometricMeshChanged();
2018 that->onStateChange();
2021 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
2022 This method updates the hypothesis data with the GUI widgets content.
2024 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
2026 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2028 BlsurfHypothesisData data;
2029 QString guiHyp = that->readParamsFromWidgets( data );
2030 that->storeParamsToHypo( data );
2035 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
2036 Updates the hypothesis data from hypothesis values.
2038 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
2040 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2041 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2043 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
2044 h_data.myName = isCreation() && data ? hypName() : "";
2046 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
2047 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
2048 h_data.myPhySize = h->GetPhySize();
2049 h_data.myPhySizeRel = h->IsPhySizeRel();
2050 double minSize = h->GetMinSize();
2051 double maxSize = h->GetMaxSize();
2052 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2053 h_data.myMinSizeRel = h->IsMinSizeRel();
2054 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2055 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2056 h_data.myUseGradation = h->GetUseGradation();
2057 h_data.myGradation = h->GetGradation();
2058 h_data.myUseVolumeGradation = h->GetUseVolumeGradation();
2059 h_data.myVolumeGradation = h->GetVolumeGradation();
2060 h_data.myElementType = h->GetElementType();
2061 double angle = h->GetAngleMesh();
2062 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2063 double chordalError = h->GetChordalError();
2064 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2065 h_data.myAnisotropic = h->GetAnisotropic();
2066 double myAnisotropicRatio = h->GetAnisotropicRatio();
2067 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2068 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2069 double myTinyEdgeLength = h->GetTinyEdgeLength();
2070 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2071 h_data.myOptimiseTinyEdges = h->GetOptimiseTinyEdges();
2072 double myTinyEdgeOptimisLength = h->GetTinyEdgeOptimisationLength();
2073 h_data.myTinyEdgeOptimisLength = myTinyEdgeOptimisLength > 0 ? myTinyEdgeOptimisLength : -1.0;
2074 h_data.myCorrectSurfaceIntersection = h->GetCorrectSurfaceIntersection();
2075 double corrSurfaceIntersMaxCost = h->GetCorrectSurfaceIntersectionMaxCost();
2076 h_data.myCorrectSurfaceIntersectionMaxCost = corrSurfaceIntersMaxCost > 0 ? corrSurfaceIntersMaxCost : -1.0;
2077 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2078 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2079 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2080 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2081 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2082 h_data.myVerbosity = h->GetVerbosity();
2083 //h_data.myTopology = (int) h->GetTopology();
2084 //h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2085 // h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2086 // h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2087 h_data.myUseSurfaceProximity = h->GetUseSurfaceProximity ();
2088 h_data.myNbSurfaceProximityLayers = h->GetNbSurfaceProximityLayers();
2089 h_data.mySurfaceProximityRatio = h->GetSurfaceProximityRatio ();
2090 h_data.myUseVolumeProximity = h->GetUseVolumeProximity ();
2091 h_data.myNbVolumeProximityLayers = h->GetNbVolumeProximityLayers ();
2092 h_data.myVolumeProximityRatio = h->GetVolumeProximityRatio ();
2094 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2095 that->myOptions = h->GetOptionValues();
2096 that->myPreCADOptions = h->GetPreCADOptionValues();
2097 that->myCustomOptions = h->GetAdvancedOptionValues();
2099 h_data.myGMFFileName = h->GetGMFFile();
2100 // h_data.myGMFFileMode = h->GetGMFFileMode();
2102 that->mySMPMap.clear();
2103 that->myATTMap.clear();
2104 // that->myAttDistMap.clear();
2105 // that->myDistMap.clear();
2107 // classic size maps
2108 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2109 QString fullSizeMaps;
2110 QStringList fullSizeMapList;
2111 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2112 for ( CORBA::ULong i = 0;i<mySizeMaps->length(); ++i ) {
2113 fullSizeMaps = mySizeMaps[i].in();
2114 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2115 if ( fullSizeMapList.count() > 1 ) {
2116 string fullSizeMap = fullSizeMapList[1].toStdString();
2117 int pos = fullSizeMap.find("return")+7;
2120 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2125 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2126 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2132 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2134 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2135 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2136 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2137 if ( fullCustomSizeMapList.count() > 1 ) {
2138 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2139 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2144 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2146 for ( CORBA::ULong i = 0;i<allMyAttractors->length(); ++i ) {
2147 QString myAttractors = allMyAttractors[i].in();
2148 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2149 if ( myAttractorList.count() > 1 ) {
2150 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2151 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2155 // attractor new version
2156 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2157 for ( CORBA::ULong i = 0;i<allMyAttractorParams->length(); ++i ) {
2158 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2159 QString faceEntry = myAttractorParams.faceEntry.in();
2160 QString attEntry = myAttractorParams.attEntry.in();
2161 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2162 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2163 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2164 myAttractorParams.startSize,
2165 myAttractorParams.infDist,
2166 myAttractorParams.constDist ));
2169 // Enforced vertices
2170 h_data.enfVertexList.clear();
2171 h_data.faceEntryEnfVertexListMap.clear();
2173 h_data.groupNameEnfVertexListMap.clear();
2176 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2178 for ( CORBA::ULong i = 0;i<faceEntryEnfVertexListMap->length(); ++i )
2180 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2181 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2183 for (CORBA::ULong j=0 ; j<vertexList.length(); ++j)
2185 TEnfVertex *enfVertex = new TEnfVertex();
2186 enfVertex->name = vertexList[j].name.in();
2187 enfVertex->geomEntry = vertexList[j].geomEntry.in();
2188 enfVertex->grpName = vertexList[j].grpName.in();
2189 for (CORBA::ULong k=0 ; k< vertexList[j].coords.length();k++)
2190 enfVertex->coords.push_back(vertexList[j].coords[k]);
2192 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2195 if (groupName != "") {
2196 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2200 // h_data.enfVertMap[entry] = evs;
2201 // h_data.entryCoordsListMap[entry] = coordsList;
2203 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2204 h_data.faceEntryEnfVertexListMap.erase(entry);
2207 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2208 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2212 h_data.preCadPeriodicityVector.clear();
2214 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2215 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2217 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2218 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2222 h_data.hyperpatches.clear();
2223 BLSURFPlugin::THyperPatchList_var patchList = h->GetHyperPatches();
2224 for ( CORBA::ULong i = 0; i < patchList->length(); ++i )
2227 BLSURFPlugin::THyperPatch& patch = patchList[i];
2228 for ( CORBA::ULong j = 0; j < patch.length(); ++j )
2229 tags += QString::number( patch[j] ) + " ";
2230 if ( !tags.isEmpty() )
2231 h_data.hyperpatches.append( tags );
2237 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2238 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2241 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2243 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2244 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2245 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2247 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2248 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2250 if (sourceVertices.length()!=0)
2252 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2253 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2255 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2258 if (targetVertices.length()!=0)
2260 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2261 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2263 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2267 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2269 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2271 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2275 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2276 Saves the hypothesis data to hypothesis values.
2278 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2280 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2281 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2287 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2289 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2290 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2291 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2292 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2294 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2295 if ( h->GetPhySize() != h_data.myPhySize ||
2296 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2297 if ( h_data.myPhySizeRel )
2298 h->SetPhySizeRel( h_data.myPhySize );
2300 h->SetPhySize( h_data.myPhySize );
2303 if (h->GetMinSize() != h_data.myMinSize ||
2304 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2305 if ( h_data.myMinSizeRel )
2306 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2308 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2310 if (h->GetMaxSize() != h_data.myMaxSize ||
2311 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2312 if ( h_data.myMaxSizeRel )
2313 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2315 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2317 if ( h->GetUseGradation() != h_data.myUseGradation )
2318 h->SetUseGradation( h_data.myUseGradation );
2319 if ( h->GetGradation() != h_data.myGradation )
2320 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2321 if ( h->GetUseVolumeGradation() != h_data.myUseVolumeGradation )
2322 h->SetUseVolumeGradation( h_data.myUseVolumeGradation );
2323 if ( h->GetVolumeGradation() != h_data.myVolumeGradation )
2324 h->SetVolumeGradation( h_data.myVolumeGradation <= 0 ? -1 : h_data.myVolumeGradation );
2326 h->SetUseSurfaceProximity ( h_data.myUseSurfaceProximity );
2327 h->SetNbSurfaceProximityLayers( h_data.myNbSurfaceProximityLayers );
2328 h->SetSurfaceProximityRatio ( h_data.mySurfaceProximityRatio );
2329 h->SetUseVolumeProximity ( h_data.myUseVolumeProximity );
2330 h->SetNbVolumeProximityLayers ( h_data.myNbVolumeProximityLayers );
2331 h->SetVolumeProximityRatio ( h_data.myVolumeProximityRatio );
2333 if ( h->GetElementType() != h_data.myElementType )
2334 h->SetElementType( h_data.myElementType );
2336 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2337 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2338 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2339 if ( h->GetChordalError() != h_data.myChordalError )
2340 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2343 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2344 h->SetAnisotropic( h_data.myAnisotropic );
2345 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2346 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2348 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2349 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2350 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2351 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2353 if ( h->GetOptimiseTinyEdges() != h_data.myOptimiseTinyEdges )
2354 h->SetOptimiseTinyEdges( h_data.myOptimiseTinyEdges );
2355 if ( h_data.myOptimiseTinyEdges && ( h->GetTinyEdgeOptimisationLength() != h_data.myTinyEdgeOptimisLength ) )
2356 h->SetTinyEdgeOptimisationLength( h_data.myTinyEdgeOptimisLength <= 0 ? -1 :h_data.myTinyEdgeOptimisLength );
2357 if ( h->GetCorrectSurfaceIntersection() != h_data.myCorrectSurfaceIntersection )
2358 h->SetCorrectSurfaceIntersection( h_data.myCorrectSurfaceIntersection );
2359 if ( h_data.myCorrectSurfaceIntersection && ( h->GetCorrectSurfaceIntersectionMaxCost() != h_data.myCorrectSurfaceIntersectionMaxCost ) )
2360 h->SetCorrectSurfaceIntersectionMaxCost( h_data.myCorrectSurfaceIntersectionMaxCost <= 0 ? -1 :h_data.myCorrectSurfaceIntersectionMaxCost );
2362 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2363 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2364 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2365 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2367 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2368 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2370 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2371 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2373 if ( h->GetVerbosity() != h_data.myVerbosity )
2374 h->SetVerbosity( h_data.myVerbosity );
2375 // if ( h->GetTopology() != h_data.myTopology )
2376 // h->SetTopology( (int) h_data.myTopology );
2377 // if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2378 // h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2379 // if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2380 // h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2381 // if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2382 // h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2384 // options are set in checkParams()
2385 //h->SetOptionValues( myOptions ); // is set in readParamsFromWidgets()
2386 //h->SetPreCADOptionValues( myPreCADOptions ); // is set in readParamsFromWidgets()
2388 if ( h->GetGMFFile() != h_data.myGMFFileName )
2389 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2390 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2391 h->SetGMFFile( h_data.myGMFFileName.c_str());
2393 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2394 QMapIterator<QString,QString> i(that->mySMPMap);
2395 while (i.hasNext()) {
2397 const QString entry = i.key();
2398 const QString sizeMap = i.value();
2400 if (sizeMap == "__TO_DELETE__") {
2401 h->UnsetEntry(entry.toLatin1().constData());
2403 else if (sizeMap.startsWith("ATTRACTOR")) {
2404 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2406 else if (sizeMap.startsWith("def")) {
2407 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2410 if (!myATTMap[entry].empty()){
2411 const TAttractorVec& attVec = myATTMap[entry];
2412 for ( size_t i = 0; i < attVec.size(); ++i )
2414 if ( attVec[i].IsToDelete() )
2415 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2416 attVec[i].attEntry.c_str() );
2418 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2419 attVec[i].attEntry.c_str(),
2420 attVec[i].startSize,
2423 attVec[i].constDist );
2427 QString fullSizeMap;
2428 fullSizeMap = QString("");
2429 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2430 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2431 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2432 fullSizeMap = QString("def f(t): return ") + sizeMap;
2433 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2434 fullSizeMap = QString("def f(): return ") + sizeMap;
2435 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2440 // Enforced vertices
2443 std::string enfName;
2445 std::string groupName = "";
2448 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2449 // 1. Clear all enforced vertices in hypothesis
2450 // 2. Add new enforced vertex according to h_data
2452 if ( h->GetAllEnforcedVertices()->length() > 0 )
2453 h->ClearAllEnforcedVertices();
2456 TEnfVertexList::const_iterator evsIt;
2457 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2459 faceEntry = evmIt->first;
2460 evs = evmIt->second;
2461 evsIt = evs.begin();
2462 for ( ; evsIt != evs.end() ; ++evsIt)
2465 if ((*evsIt)->coords.size()) {
2466 x = (*evsIt)->coords[0];
2467 y = (*evsIt)->coords[1];
2468 z = (*evsIt)->coords[2];
2471 h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2475 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2476 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2477 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2478 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2481 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2482 h->ClearPreCadPeriodicityVectors();
2484 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2485 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2487 TPreCadPeriodicity periodicity_i = *pIt;
2488 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2489 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2490 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2491 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2492 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2493 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2494 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2495 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2496 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2498 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2499 if (! p1Source.empty())
2501 sourceVertices->length(3);
2502 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2503 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2504 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2508 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2509 if (! p1Target.empty())
2511 targetVertices->length(3);
2512 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2513 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2514 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2518 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2520 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2524 BLSURFPlugin::THyperPatchList_var hpl = new BLSURFPlugin::THyperPatchList();
2525 hpl->length( h_data.hyperpatches.size() );
2527 for ( int i = 0; i < h_data.hyperpatches.size(); ++i )
2529 QStringList tags = h_data.hyperpatches[i].split(" ", QString::SkipEmptyParts);
2530 BLSURFPlugin::THyperPatch& patch = hpl[ i ];
2531 patch.length( tags.size() );
2533 for ( int j = 0; j < tags.size(); ++j )
2534 patch[ j ] = tags[ j ].toDouble();
2536 h->SetHyperPatches( hpl );
2547 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2548 Stores the widgets content to the hypothesis data.
2550 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2552 h_data.myName = myName ? myName->text() : "";
2553 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2554 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2555 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2556 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2557 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2558 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2559 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2560 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2561 h_data.myUseGradation = myStdWidget->myUseGradation->isChecked() && !myStdWidget->myGradation->text().isEmpty();
2562 h_data.myGradation = h_data.myUseGradation ? myStdWidget->myGradation->GetValue() : -1.0;
2563 h_data.myUseVolumeGradation = myStdWidget->myUseVolumeGradation->isChecked() && !myStdWidget->myVolumeGradation->text().isEmpty();
2564 h_data.myVolumeGradation = h_data.myUseVolumeGradation ? myStdWidget->myVolumeGradation->GetValue() : -1. ;
2565 h_data.myElementType = myStdWidget->myButtonGroupElementType->checkedId();
2566 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2567 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2568 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2569 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2570 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2571 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2572 h_data.myOptimiseTinyEdges = myStdWidget->myOptimiseTinyEdges->isChecked();
2573 h_data.myTinyEdgeOptimisLength = myStdWidget->myTinyEdgeOptimisLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeOptimisLength->GetValue();
2574 h_data.myCorrectSurfaceIntersection = myStdWidget->myCorrectSurfaceIntersection->isChecked();
2575 h_data.myCorrectSurfaceIntersectionMaxCost = myStdWidget->myCorrectSurfaceIntersectionMaxCost->text().isEmpty() ? -1.0 : myStdWidget->myCorrectSurfaceIntersectionMaxCost->GetValue();
2576 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2577 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2578 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2579 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2580 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2581 //h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2582 //h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2583 //h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2584 //h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2585 h_data.myUseSurfaceProximity = myStdWidget->myUseSurfaceProximity ->isChecked();
2586 h_data.myNbSurfaceProximityLayers = myStdWidget->myNbSurfaceProximityLayers->value();
2587 h_data.mySurfaceProximityRatio = myStdWidget->mySurfaceProximityRatio ->value();
2588 h_data.myUseVolumeProximity = myStdWidget->myUseVolumeProximity ->isChecked();
2589 h_data.myNbVolumeProximityLayers = myStdWidget->myNbVolumeProximityLayers ->value();
2590 h_data.myVolumeProximityRatio = myStdWidget->myVolumeProximityRatio ->value();
2593 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2594 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2595 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2596 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2597 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2598 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2599 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2600 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2601 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2602 guiHyp += tr("BLSURF_ELEMENT_TYPE") + " = " + QString::number(h_data.myElementType) + "; ";
2603 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2604 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2605 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2606 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2609 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2610 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2611 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2612 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2613 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2614 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2617 // guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2618 // guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2619 // guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2620 // guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2622 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2623 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2626 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2627 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2628 for ( ; row < nbRows; ++row )
2630 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2631 if ( that->mySMPMap.contains(entry) )
2632 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2635 // Enforced vertices
2636 h_data.enfVertexList.clear();
2637 h_data.faceEntryEnfVertexListMap.clear();
2639 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2640 std::string groupName = "", faceEntry = "";
2641 for (int i=0 ; i<nbEnforcedShapes ; i++)
2643 double childValueX,childValueY,childValueZ;
2644 std::string childName, vertexEntry;
2645 QTreeWidgetItem* child;
2647 child = myEnforcedTreeWidget->topLevelItem(i);
2648 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2649 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2650 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2651 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2652 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2653 // if (myGlobalGroupName->isChecked())
2654 // groupName = myGlobalGroupName->text().toStdString();
2656 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2658 TEnfVertex *enfVertex = new TEnfVertex();
2659 enfVertex->name = childName;
2660 if (vertexEntry.empty()) {
2661 enfVertex->coords.push_back(childValueX);
2662 enfVertex->coords.push_back(childValueY);
2663 enfVertex->coords.push_back(childValueZ);
2666 enfVertex->geomEntry = vertexEntry;
2667 enfVertex->grpName = groupName;
2668 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2669 // if (it == h_data.enfVertexList.end())
2670 h_data.enfVertexList.insert(enfVertex);
2672 if (groupName != "")
2673 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2675 h_data.faceEntryEnfVertexListMap[faceEntry].insert( enfVertex );
2678 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2679 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2682 h_data.preCadPeriodicityVector.clear();
2683 // For each tree item, store each value. Shapes are stored as entries.
2684 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2685 for (int i=0 ; i<nbPeriodicityDescriptions ; i++) {
2686 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2687 TPreCadPeriodicity periodicity_i;
2689 for (int k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2691 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2692 periodicity_i.push_back(entry);
2694 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2696 guiHyp += "PERIODICITY = yes; ";
2700 h_data.hyperpatches.clear();
2701 for ( int row = 0; row < myHyPatchTable->rowCount(); ++row )
2702 h_data.hyperpatches.append( myHyPatchTable->item( row, 0 )->text() );
2707 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2709 myAdvWidget->AddOption( TBL_CUSTOM, NULL );
2712 void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int row, int column )
2714 // if ( column != OPTION_NAME_COLUMN )
2716 // myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2719 // **********************
2720 // *** BEGIN SIZE MAP ***
2721 // **********************
2723 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2725 if ( myGeomSelWdg2->IsObjectSelected() ){
2726 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2728 else if ( myGeomSelWdg1->IsObjectSelected() ){
2729 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2732 mySMapObject = GEOM::GEOM_Object::_nil();
2734 bool dataAvailable = !mySMapObject->_is_nil();
2736 if ( dataAvailable )
2737 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2739 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2740 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2741 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2742 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2743 ( myATTMap.contains( qEntry )))
2746 QString attEntry = myAttSelWdg->GetValue();
2747 const TAttractorVec& attVec = myATTMap[ qEntry ];
2748 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2749 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2752 addMapButton->setEnabled( !mapExists && dataAvailable );
2753 modifyMapButton->setEnabled( mapExists && dataAvailable );
2756 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2758 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2759 if (col == SMP_SIZEMAP_COLUMN) {
2760 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2762 if (!mySMPMap.contains(entry))
2764 if ( QTreeWidgetItem* parent = item->parent() )
2768 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2770 if (!mySMPMap.contains(entry))
2773 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2774 CORBA::Object_var obj = entryToObject(entry);
2775 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2776 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2777 // Retrieve values of the selected item in the current tab widgets
2778 const TAttractorVec& attVec = myATTMap[entry];
2779 if ( !attVec.empty() )
2782 if ( !childEntry.isEmpty() )
2783 for ( size_t i = 0; i < attVec.size(); ++i )
2784 if ( childEntry == attVec[i].attEntry.c_str() )
2789 double phySize = attVec[iAtt].startSize;
2790 double infDist = attVec[iAtt].infDist;
2791 double constDist = attVec[iAtt].constDist;
2792 QString attEntry = attVec[iAtt].attEntry.c_str();
2793 CORBA::Object_var attObj = entryToObject(attEntry);
2794 myAttSizeSpin->setValue(phySize);
2795 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2796 myAttDistSpin->setValue(infDist);
2797 myAttractorCheck->setChecked(true);
2800 myAttractorCheck->setChecked(false);
2802 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2803 myAttDistSpin2->setValue(constDist);
2804 myConstSizeCheck->setChecked(true);
2807 myConstSizeCheck->setChecked(false);
2809 myGeomSelWdg2->SetObject(obj);
2810 myAttSelWdg->SetObject(attObj);
2813 else { // CLASSIC MAPS
2814 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2815 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2816 if (!sizeMap.startsWith("def")){
2817 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2823 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2825 getGeomSelectionTool()->selectionMgr()->clearFilters();
2826 if ( sender() == myTabWidget )
2828 myGeomSelWdg1 ->deactivateSelection();
2829 myGeomSelWdg2 ->deactivateSelection();
2830 myAttSelWdg ->deactivateSelection();
2831 myEnfVertexWdg ->deactivateSelection();
2832 myPeriodicitySourceFaceWdg->deactivateSelection();
2833 myPeriodicityTargetFaceWdg->deactivateSelection();
2834 myPeriodicityP1SourceWdg ->deactivateSelection();
2835 myPeriodicityP2SourceWdg ->deactivateSelection();
2836 myPeriodicityP3SourceWdg ->deactivateSelection();
2837 myPeriodicityP1TargetWdg ->deactivateSelection();
2838 myPeriodicityP2TargetWdg ->deactivateSelection();
2839 myPeriodicityP3TargetWdg ->deactivateSelection();
2840 if ( myHyPatchFaceSelBtn->isChecked() )
2841 myHyPatchFaceSelBtn->toggle();
2842 if ( myHyPatchGroupSelBtn->isChecked() )
2843 myHyPatchGroupSelBtn->toggle();
2845 else if ( sender() == smpTab )
2847 myAttDistSpin->setValue(0.); // Reinitialize widgets
2848 myAttSizeSpin->setValue(0.);
2849 myAttDistSpin2->setValue(0.);
2850 mySmpSizeSpin->setValue(0.);
2851 myGeomSelWdg1->deactivateSelection();
2852 myGeomSelWdg2->deactivateSelection();
2853 myAttSelWdg->deactivateSelection();
2854 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2855 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2856 myAttSelWdg->SetObject(CORBA::Object::_nil());
2857 myAttractorCheck->setChecked(false);
2858 myConstSizeCheck->setChecked(false);
2861 if ( tab == SMP_TAB ) // [#16954] limit local size by Min and User Size
2863 double minSize = 0, maxSize = COORD_MAX;
2865 if ( !myStdWidget->myMinSizeRel->isChecked() &&
2866 !myStdWidget->myMinSize->text().isEmpty() )
2867 minSize = myStdWidget->myMinSize->GetValue();
2869 if ( !myStdWidget->myPhySizeRel->isChecked() &&
2870 !myStdWidget->myPhySize->text().isEmpty() )
2871 maxSize = myStdWidget->myPhySize->GetValue();
2873 mySmpSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
2874 myAttSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
2878 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2880 if (state == Qt::Checked){
2881 myAttSelWdg->setEnabled(true);
2882 myAttSizeSpin->setEnabled(true);
2883 myAttSizeLabel->setEnabled(true);
2884 myAttDistSpin->setEnabled(true);
2885 myAttDistLabel->setEnabled(true);
2886 if (!myAttSelWdg->IsObjectSelected()){
2887 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2890 if (state == Qt::Unchecked){
2891 myAttDistSpin->setEnabled(false);
2892 myAttDistLabel->setEnabled(false);
2893 myAttDistSpin->setValue(0.);
2894 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2895 myAttSelWdg->setEnabled(false);
2896 myAttSizeSpin->setEnabled(false);
2897 myAttSizeLabel->setEnabled(false);
2898 myAttDistSpin2->setEnabled(false);
2899 myAttDistLabel2->setEnabled(false);
2901 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2902 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2905 onMapGeomContentModified();
2908 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2910 if (state == Qt::Checked){
2911 myAttSelWdg->setEnabled(true);
2912 myAttSizeSpin->setEnabled(true);
2913 myAttSizeLabel->setEnabled(true);
2914 myAttDistSpin2->setEnabled(true);
2915 myAttDistLabel2->setEnabled(true);
2916 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2917 !myAttSelWdg->IsObjectSelected()){
2918 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2921 if (state == Qt::Unchecked){
2922 myAttDistSpin2->setEnabled(false);
2923 myAttDistLabel2->setEnabled(false);
2924 myAttDistSpin2->setValue(0.);
2925 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2926 myAttSelWdg->setEnabled(false);
2927 myAttSizeSpin->setEnabled(false);
2928 myAttSizeLabel->setEnabled(false);
2929 myAttDistSpin->setEnabled(false);
2930 myAttDistLabel->setEnabled(false);
2932 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2933 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2936 onMapGeomContentModified();
2939 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2941 QList<int> selectedRows;
2942 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2943 QTreeWidgetItem* item;
2944 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2946 qSort( selectedRows );
2947 QListIterator<QTreeWidgetItem*> it( selected );
2949 while ( it.hasPrevious() ) {
2950 item = it.previous();
2951 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2952 QString parentEntry;
2953 if ( QTreeWidgetItem* parent = item->parent() )
2954 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2955 if (that->mySMPMap.contains(entry))
2957 that->mySMPMap[entry] = "__TO_DELETE__";
2958 if ( myATTMap.contains( entry ))
2960 TAttractorVec& attVec = myATTMap[entry];
2961 for ( size_t i = 0; i < attVec.size(); ++i )
2962 attVec[i].SetToDelete();
2965 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
2967 TAttractorVec& attVec = myATTMap[parentEntry];
2968 for ( size_t i = 0; i < attVec.size(); ++i )
2970 if ( entry == attVec[i].attEntry.c_str() )
2971 attVec[i].SetToDelete();
2974 if (that->mySMPShapeTypeMap.contains(entry))
2975 that->mySMPShapeTypeMap.remove(entry);
2976 // if (that->myDistMap.contains(entry))
2977 // that->myDistMap.remove(entry);
2978 // if (that->myAttDistMap.contains(entry))
2979 // that->myAttDistMap.remove(entry);
2982 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2983 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2986 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2988 if (col == SMP_SIZEMAP_COLUMN) {
2989 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2990 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2991 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2992 if (! that->mySMPShapeTypeMap.contains(entry))
2994 if (that->mySMPMap.contains(entry))
2995 if (that->mySMPMap[entry] == sizeMap
2996 || sizeMap.startsWith("Attractor")
2997 || sizeMap.startsWith("Constant") ){
3000 if (! sizeMap.isEmpty()) {
3001 that->mySMPMap[entry] = sizeMap;
3002 sizeMapValidationFromEntry(entry);
3005 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
3007 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
3011 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
3014 if ( smpTab->currentIndex() == ATT_TAB ){
3015 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3016 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3017 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3018 res = insertAttractor(mySMapObject, myAttObject);
3021 if (smpTab->currentIndex() == SMP_STD_TAB ){
3022 if ( myGeomSelWdg1->IsObjectSelected() ){
3023 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3024 res = insertElement(mySMapObject);
3028 // Local size should be more than 0
3029 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3030 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3033 getGeomSelectionTool()->selectionMgr()->clearFilters();
3034 myAttDistSpin->setValue(0.);
3035 myAttSizeSpin->setValue(0.);
3036 myAttDistSpin2->setValue(0.);
3037 mySmpSizeSpin->setValue(0.);
3038 myConstSizeCheck->setChecked(false);
3039 myAttractorCheck->setChecked(false);
3040 myGeomSelWdg1->deactivateSelection();
3041 myGeomSelWdg2->deactivateSelection();
3042 myAttSelWdg->deactivateSelection();
3043 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3044 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3045 myAttSelWdg->SetObject(CORBA::Object::_nil());
3048 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
3051 if ( smpTab->currentIndex() == ATT_TAB ){
3052 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3053 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3054 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3055 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
3058 if (smpTab->currentIndex() == SMP_STD_TAB ){
3059 if ( myGeomSelWdg1->IsObjectSelected() ){
3060 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3061 res = insertElement(mySMapObject, /*modify = */true);
3065 // Local size should be more than 0
3066 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3067 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3070 getGeomSelectionTool()->selectionMgr()->clearFilters();
3071 myAttDistSpin->setValue(0.);
3072 myAttSizeSpin->setValue(0.);
3073 myAttDistSpin2->setValue(0.);
3074 mySmpSizeSpin->setValue(0.);
3075 myConstSizeCheck->setChecked(false);
3076 myAttractorCheck->setChecked(false);
3077 myGeomSelWdg1->deactivateSelection();
3078 myGeomSelWdg2->deactivateSelection();
3079 myAttSelWdg->deactivateSelection();
3080 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3081 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3082 myAttSelWdg->SetObject(CORBA::Object::_nil());
3085 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3087 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3088 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3090 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3092 TopAbs_ShapeEnum shapeType;
3093 string entry, shapeName;
3094 entry = (string) anObject->GetStudyEntry();
3095 shapeName = anObject->GetName();
3096 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3097 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3098 // in order to write the size map with the right syntax in StoreParamsToHypo
3099 // (f(t) for edges, f(u,v) for faces ...)
3100 if (shapeType == TopAbs_COMPOUND){
3101 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3102 TopoDS_Shape childShape;
3103 TopoDS_Iterator anIt(theShape);
3104 for(;anIt.More();anIt.Next()){
3105 childShape = anIt.Value();
3106 shapeType = childShape.ShapeType();
3107 if(!childShape.IsNull()){
3112 mySizeMapTable->setFocus();
3114 shapeEntry = QString::fromStdString(entry);
3115 double phySize = mySmpSizeSpin->value();
3118 return false; // Local size should be more than 0
3120 std::ostringstream oss;
3123 sizeMap = QString::fromStdString(oss.str());
3124 QTreeWidgetItem* item = new QTreeWidgetItem();
3126 int rowToChange = findRowFromEntry(shapeEntry);
3127 item = mySizeMapTable->topLevelItem( rowToChange );
3130 if (that->mySMPMap.contains(shapeEntry)) {
3131 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3135 mySizeMapTable->addTopLevelItem(item);
3137 that->mySMPMap[shapeEntry] = sizeMap;
3138 //that->myDistMap[shapeEntry] = 0. ;
3139 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3140 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3141 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3142 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3143 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3144 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3145 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3146 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3147 mySizeMapTable->clearSelection();
3149 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3150 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3151 myStdWidget->onPhysicalMeshChanged();
3156 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3158 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3159 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3161 TopAbs_ShapeEnum shapeType;
3162 string entry, attEntry, faceName, attName;
3163 entry = (string) aFace->GetStudyEntry();
3164 attEntry = (string) anAttractor->GetStudyEntry();
3165 faceName = aFace->GetName();
3166 attName = anAttractor->GetName();
3167 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3168 mySizeMapTable->setFocus();
3169 QString shapeEntry = QString::fromStdString(entry);
3170 QString qAttEntry = QString::fromStdString(attEntry);
3172 double phySize = h->GetPhySize();
3173 double infDist = 0. ;
3174 double constDist = 0. ;
3175 phySize = myAttSizeSpin->value();
3178 return false; // Local size should be more than 0
3180 if (myAttractorCheck->isChecked()){
3181 infDist = myAttDistSpin->value();
3183 if (myConstSizeCheck->isChecked()){
3184 constDist = myAttDistSpin2->value();
3186 std::ostringstream oss;
3187 std::ostringstream oss2;
3188 std::ostringstream oss3;
3192 QString sizeMap = QString::fromStdString(oss.str());
3193 QString infDistString = QString::fromStdString(oss2.str());
3194 QString constDistString = QString::fromStdString(oss3.str());
3196 QTreeWidgetItem* item;
3197 QTreeWidgetItem* child = 0;
3198 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3200 int rowToChange = findRowFromEntry(shapeEntry);
3201 item = mySizeMapTable->topLevelItem( rowToChange );
3203 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3204 if (( child = item->child( i )))
3205 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3207 TAttractorVec & attVec = myATTMap[shapeEntry];
3208 for ( size_t i = 0; i < attVec.size(); ++i )
3209 if ( attVec[i].attEntry == attEntry )
3211 attVec[i] = attParams;
3216 // if (that->mySMPMap.contains(shapeEntry)) {
3217 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3221 int rowToChange = findRowFromEntry(shapeEntry);
3222 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3224 item = mySizeMapTable->topLevelItem( rowToChange );
3227 item = new QTreeWidgetItem();
3228 mySizeMapTable->addTopLevelItem(item);
3230 child = new QTreeWidgetItem();
3231 item->addChild(child);
3232 bool exists = false;
3233 TAttractorVec & attVec = myATTMap[shapeEntry];
3234 for ( size_t i = 0; i < attVec.size(); ++i )
3235 if ( attVec[i].attEntry == attEntry )
3237 attVec[i] = attParams;
3242 myATTMap[shapeEntry].push_back( attParams );
3244 mySMPMap.insert(shapeEntry,sizeMap);
3245 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3246 item->setExpanded(true);
3247 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3248 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3249 if (infDist > std::numeric_limits<double>::epsilon()){
3250 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3252 else if (constDist > std::numeric_limits<double>::epsilon()){
3253 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3255 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3257 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3258 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3259 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3261 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3262 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3263 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3265 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3266 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3267 myStdWidget->onPhysicalMeshChanged();
3272 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3274 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3275 for ( ; row < nbRows; ++row )
3276 if (! sizeMapValidationFromRow(row))
3281 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3283 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3284 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3285 mySizeMapTable->setFocus();
3289 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3292 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3294 if (! that->mySMPMap.contains(myEntry)) {
3297 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3303 if (that->mySMPMap[myEntry].startsWith("def")) {
3304 expr = that->mySMPMap[myEntry].toStdString();
3306 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3307 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)) {
3310 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])" );
3316 // case size map is empty
3317 if (that->mySMPMap[myEntry].isEmpty()) {
3319 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3323 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3324 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3325 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3326 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3327 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3328 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3331 //assert(Py_IsInitialized());
3332 if (! Py_IsInitialized())
3333 throw ("Erreur: Python interpreter is not initialized");
3334 PyGILState_STATE gstate;
3335 gstate = PyGILState_Ensure();
3337 string err_description="";
3338 PyObject* obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3342 PyObject* new_stderr = newPyStdOut(err_description);
3343 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3344 Py_INCREF(old_stderr);
3345 PySys_SetObject((char*)"stderr", new_stderr);
3347 PySys_SetObject((char*)"stderr", old_stderr);
3348 Py_DECREF(new_stderr);
3350 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3351 PyGILState_Release(gstate);
3356 PyObject* func = PyObject_GetAttrString(main_mod, "f");
3360 PyObject* new_stderr = newPyStdOut(err_description);
3361 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3362 Py_INCREF(old_stderr);
3363 PySys_SetObject((char*)"stderr", new_stderr);
3365 PySys_SetObject((char*)"stderr", old_stderr);
3366 Py_DECREF(new_stderr);
3368 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3369 PyGILState_Release(gstate);
3373 PyGILState_Release(gstate);
3379 //================================================================================
3381 * \brief SLOT: Activate selection of faces in the Viewer
3383 //================================================================================
3385 void BLSURFPluginGUI_HypothesisCreator::onHyPatchFaceSelection(bool on)
3387 if ( on && myHyPatchFaceSelector->GetMainShape().IsNull() )
3389 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
3390 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
3391 myHyPatchFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
3393 myHyPatchFaceSelector->setVisible( on ); // show its buttons
3394 myHyPatchFaceSelector->ShowPreview( on ); // show faces in the Viewer
3395 // treat selection or not
3396 myHyPatchFaceSelector->ActivateSelection( on || myHyPatchGroupSelBtn->isChecked() );
3399 myHyPatchGroupSelBtn->setChecked( false );
3402 //================================================================================
3404 * \brief SLOT: Deactivate selection of faces in the Viewer
3406 //================================================================================
3408 void BLSURFPluginGUI_HypothesisCreator::onHyPatchGroupSelection(bool on)
3410 if ( on && myHyPatchFaceSelector->GetMainShape().IsNull() )
3412 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
3413 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
3414 myHyPatchFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
3416 if ( !myHyPatchFaceSelBtn->isChecked() )
3418 myHyPatchFaceSelector->setVisible( false ); // show its buttons
3419 myHyPatchFaceSelector->ShowPreview( false ); // show faces in the Viewer
3421 // treat selection or not
3422 myHyPatchFaceSelector->ActivateSelection( on || myHyPatchFaceSelBtn->isChecked() );
3425 myHyPatchFaceSelBtn->setChecked( false );
3428 //================================================================================
3430 * \brief SLOT: show IDs of selected faces in Tags LineEdit
3432 //================================================================================
3434 void BLSURFPluginGUI_HypothesisCreator::onHyPatchSelectionChanged()
3437 const QList<int>& tags = myHyPatchFaceSelector->GetSelectedIDs();
3438 for ( int i = 0; i < tags.size(); ++i )
3439 tagString += QString::number( tags[i] ) + " ";
3441 myHyPatchTagsLE->setText( tagString );
3444 //================================================================================
3446 * \brief SLOT: Add the Tags to the HyperPatch table
3448 //================================================================================
3450 void BLSURFPluginGUI_HypothesisCreator::onHyPatchAdd()
3452 QStringList tagList = myHyPatchTagsLE->text().split(" ", QString::SkipEmptyParts);
3453 if ( tagList.size() > 1 )
3455 addHyPatchToTable( myHyPatchTagsLE->text() );
3456 myHyPatchTagsLE->setText("");
3460 //================================================================================
3462 * \brief Add a row to myHyPatchTable
3464 //================================================================================
3466 void BLSURFPluginGUI_HypothesisCreator::addHyPatchToTable(const QString& tags)
3468 if ( tags.isEmpty() ) return;
3470 QTableWidgetItem* cell = new QTableWidgetItem( tags );
3471 cell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
3473 int row = myHyPatchTable->rowCount();
3474 myHyPatchTable->insertRow( row );
3475 myHyPatchTable->setItem( row, 0, cell );
3478 //================================================================================
3480 * \brief SLOT: remove selected rows from the HyperPatch table
3482 //================================================================================
3484 void BLSURFPluginGUI_HypothesisCreator::onHyPatchRemove()
3486 QList<QTableWidgetItem *> items = myHyPatchTable->selectedItems();
3487 while ( !items.isEmpty() )
3489 myHyPatchTable->removeRow( items[0]->row() );
3490 items = myHyPatchTable->selectedItems();
3494 bool BLSURFPluginGUI_HypothesisCreator::hasGeom() const
3496 return hypType() == BLSURFPlugin_Hypothesis::GetHypType(true);
3499 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3501 return tr( "BLSURF_TITLE" );
3504 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3506 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3509 QString BLSURFPluginGUI_HypothesisCreator::type() const
3511 return tr( "BLSURF_HYPOTHESIS" );
3514 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3516 return "blsurf_hypo_page.html";
3519 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3522 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3524 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3529 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3531 CORBA::Object_var obj;
3532 SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.toStdString().c_str() );
3533 if (!aSObj->_is_nil()) {
3534 obj = aSObj->GetObject();
3535 aSObj->UnRegister();
3540 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3541 int endRow = mySizeMapTable->topLevelItemCount()-1;
3543 for ( ; row <= endRow; ++row )
3545 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3546 if (entry == entryForChecking )