1 // Copyright (C) 2007-2020 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 ; )
651 const TAttractorVec& attVec = i.value();
652 for ( size_t i = 0; i < attVec.size(); ++i )
653 ok = ( attVec[i].IsToDelete() || attVec[i].startSize >= minSize );
656 msg = tr( "TOO_SMALL_LOCAL_SIZE" );
658 // Warn the user if local size is more than User Size
660 !myStdWidget->myPhySizeRel->isChecked() &&
661 !myStdWidget->myPhySize->text().isEmpty() )
663 const double userSize = myStdWidget->myPhySize->GetValue();
665 for ( QMapIterator<QString,QString> i( mySMPMap ); i.hasNext() && ok ; )
668 double size = i.value().toDouble( &isValue );
669 ok = ( !isValue || size <= userSize );
671 for ( QMapIterator<QString, TAttractorVec > i( myATTMap ); i.hasNext() && ok ; )
674 const TAttractorVec& attVec = i.value();
675 for ( size_t i = 0; i < attVec.size(); ++i )
676 ok = ( attVec[i].IsToDelete() || attVec[i].startSize <= userSize );
679 msg = tr( "TOO_LARGE_LOCAL_SIZE" );
687 h->SetOptionValues( myOptions ); // restore values
688 h->SetPreCADOptionValues( myPreCADOptions ); // restore values
694 QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
696 QFrame* fr = new QFrame( 0 );
697 QVBoxLayout* lay = new QVBoxLayout( fr );
699 lay->setSpacing( 0 );
701 // main TabWidget of the dialog
702 myTabWidget = new QTabWidget( fr );
703 myTabWidget->setTabShape( QTabWidget::Rounded );
704 myTabWidget->setTabPosition( QTabWidget::North );
705 lay->addWidget( myTabWidget );
710 myStdGroup = new QWidget();
711 QGridLayout* aStdLayout = new QGridLayout( myStdGroup );
712 aStdLayout->setSpacing( 6 );
713 aStdLayout->setMargin( 11 );
716 myName = new QLineEdit( myStdGroup );
717 myStdWidget = new BLSURFPluginGUI_StdWidget(myStdGroup);
719 myStdWidget->myPhysicalMesh->removeItem( PhysicalLocalSize );
724 aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), 0, 0, 1, 1 );
725 aStdLayout->addWidget( myName, row++, 1, 1, 3 );
727 aStdLayout->addWidget( myStdWidget, row++, 0, 1, 4 );
732 aStdLayout->setRowStretch(row,1);
733 aStdLayout->setColumnStretch(1,1);
736 // advanced parameters
737 myAdvGroup = new QWidget();
738 QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup );
739 anAdvLayout->setSpacing( 6 );
740 anAdvLayout->setMargin( 11 );
741 myAdvWidget = new BLSURFPluginGUI_AdvWidget(myAdvGroup);
742 anAdvLayout->addWidget( myAdvWidget );
745 // Size Maps parameters
747 mySmpGroup = new QWidget( dlg() );
750 QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
753 mySizeMapTable = new QTreeWidget( mySmpGroup );
754 mySizeMapTable ->setMinimumWidth(200);
755 QStringList sizeMapHeaders;
756 sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" );
757 mySizeMapTable->setHeaderLabels(sizeMapHeaders);
758 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
759 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
760 mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN);
761 mySizeMapTable->setAlternatingRowColors(true);
764 smpTab = new QTabWidget( mySmpGroup );
765 smpTab->setTabShape( QTabWidget::Rounded );
766 smpTab->setTabPosition( QTabWidget::South );
767 lay->addWidget( smpTab );
769 // Filters of selection
770 TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes;
772 SM_ShapeTypes.Add( TopAbs_VERTEX );
773 SM_ShapeTypes.Add( TopAbs_EDGE );
774 SM_ShapeTypes.Add( TopAbs_FACE );
775 SM_ShapeTypes.Add( TopAbs_COMPOUND );
777 ATT_ShapeTypes.Add( TopAbs_VERTEX );
778 ATT_ShapeTypes.Add( TopAbs_EDGE );
779 ATT_ShapeTypes.Add( TopAbs_WIRE );
780 ATT_ShapeTypes.Add( TopAbs_COMPOUND );
782 SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes);
783 SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes);
784 SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE);
786 // Standard size map tab
787 mySmpStdGroup = new QWidget();
788 QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup);
789 myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false);
790 myGeomSelWdg1->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
791 mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup);
792 mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
793 QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup);
796 myAttractorGroup = new QWidget();
797 QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup);
798 myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false);
799 myGeomSelWdg2->SetDefaultText(tr("BLS_SEL_FACE"), "QLineEdit { color: grey }");
800 myGeomSelWdg2->AvoidSimultaneousSelection(myGeomSelWdg1);
801 myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup);
802 myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup);
803 QFrame* attLine = new QFrame(myAttractorGroup);
804 attLine->setFrameShape(QFrame::HLine);
805 attLine->setFrameShadow(QFrame::Sunken);
806 myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false);
807 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
808 myAttSizeSpin = new SMESHGUI_SpinBox(myAttractorGroup);
809 myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
810 myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myAttractorGroup);
811 myAttDistSpin = new SMESHGUI_SpinBox(myAttractorGroup);
812 myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision");
813 myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup);
814 myAttDistSpin2 = new SMESHGUI_SpinBox(myAttractorGroup);
815 myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision");
816 myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myAttractorGroup);
818 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1);
819 myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2);
823 addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
824 removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
825 modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
826 modifyMapButton->setEnabled(false);
829 myAttSelWdg->setEnabled(false);
830 myAttSizeSpin->setEnabled(false);
831 myAttSizeLabel->setEnabled(false);
832 myAttDistSpin->setEnabled(false);
833 myAttDistLabel->setEnabled(false);
834 myAttDistSpin2->setEnabled(false);
835 myAttDistLabel2->setEnabled(false);
836 myAttDistSpin->setValue(0.);
837 myAttDistSpin2->setValue(0.);
838 myAttSizeSpin->setValue(0.);
839 mySmpSizeSpin->setValue(0.);
842 // ADD WIDGETS (SIZEMAP TAB)
843 anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1);
844 anSmpLayout->setColumnStretch(0, 1);
845 // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2);
846 anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3);
847 anSmpLayout->setRowStretch(SMP_TAB_WDG, 1);
848 anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1);
849 anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1);
850 anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1);
853 anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2);
854 anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1);
855 anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1);
856 anSmpStdLayout->setRowStretch(SMP_SPACE2, 1);
859 anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2, 1, 1, 2);
860 anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2);
861 anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK,1, 1, 2);
862 anAttLayout->addWidget(attLine, SMP_SPACE, 1, 1, 2);
863 anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2);
864 anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1);
865 anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1);
866 anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1);
867 anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1);
868 anAttLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1);
869 anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1);
870 anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1);
872 smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) );
873 smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) );
875 smpTab->setCurrentIndex( SMP_STD_TAB );
877 // Enforced vertices parameters
878 myEnfGroup = new QWidget( dlg() );
879 QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
881 myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
882 myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
883 myEnforcedTreeWidget->setSortingEnabled(true);
884 QStringList enforcedHeaders;
885 enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_FACE_ENTRY_COLUMN")
886 << tr("BLSURF_ENF_VER_X_COLUMN")<< tr("BLSURF_ENF_VER_Y_COLUMN") << tr("BLSURF_ENF_VER_Z_COLUMN")
887 << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_GROUP_COLUMN" );
889 myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
890 myEnforcedTreeWidget->header()->setStretchLastSection(true);
891 myEnforcedTreeWidget->setAlternatingRowColors(true);
892 myEnforcedTreeWidget->setUniformRowHeights(true);
893 myEnforcedTreeWidget->setAnimated(true);
894 myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
895 myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
896 for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
897 myEnforcedTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
898 myEnforcedTreeWidget->resizeColumnToContents(column);
900 myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
901 myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
902 myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
904 // FACE AND VERTEX SELECTION
905 TColStd_MapOfInteger shapeTypes1, shapeTypes2;
906 shapeTypes1.Add( TopAbs_FACE );
907 shapeTypes1.Add( TopAbs_COMPOUND );
908 shapeTypes2.Add( TopAbs_VERTEX );
909 shapeTypes2.Add( TopAbs_COMPOUND );
911 // SMESH_NumberFilter* faceFilter = new SMESH_NumberFilter("GEOM", TopAbs_FACE, 0, shapeTypes1);
912 // myEnfFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( faceFilter, 0, /*multiSel=*/true);
913 // myEnfFaceWdg->SetDefaultText(tr("BLS_SEL_FACES"), "QLineEdit { color: grey }");
915 SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes2);
916 myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true);
917 myEnfVertexWdg->SetDefaultText(tr("BLS_SEL_VERTICES"), "QLineEdit { color: grey }");
919 //myEnfVertexWdg->AvoidSimultaneousSelection(myEnfFaceWdg);
921 QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
922 myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
923 myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
925 QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
926 myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
927 myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
929 QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
930 myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
931 myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
933 QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
934 myGroupName = new QLineEdit(myEnfGroup);
936 addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
937 removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
939 myInternalEnforcedVerticesAllFaces = new QCheckBox(tr("BLSURF_ENF_VER_INTERNAL_VERTICES"),myEnfGroup);
941 QLabel* myInternalEnforcedVerticesAllFacesGroupLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup );
942 myInternalEnforcedVerticesAllFacesGroup = new QLineEdit(myEnfGroup);
944 anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES, 1);
945 QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
946 // FACE AND VERTEX SELECTION
947 //anEnfLayout2->addWidget(myEnfFaceWdg, ENF_VER_FACE, 0, 1, 2);
948 anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
949 anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
950 anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
951 anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
952 anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
953 anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
954 anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
955 anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
956 anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
957 anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
958 anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
959 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFaces, ENF_VER_INTERNAL_ALL_FACES, 0, 1, 2);
960 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroupLabel, ENF_VER_INTERNAL_ALL_FACES_GROUP, 0, 1, 1);
961 anEnfLayout2->addWidget(myInternalEnforcedVerticesAllFacesGroup, ENF_VER_INTERNAL_ALL_FACES_GROUP, 1, 1, 1);
962 anEnfLayout2->setRowStretch(ENF_VER_NB_LINES+1, 1);
963 anEnfLayout->addLayout(anEnfLayout2, 0,1,ENF_VER_NB_LINES+1,2);
966 // Periodicity parameters
967 myPeriodicityGroup = new QWidget( dlg() );
968 aPeriodicityLayout1 = new QGridLayout(myPeriodicityGroup);
970 myPeriodicitySplitter = new QSplitter(myPeriodicityGroup);
971 myPeriodicitySplitter->setOrientation(Qt::Horizontal);
972 aPeriodicityLayout1->addWidget(myPeriodicitySplitter, 0, 0, 1, 1);
974 myPeriodicityTreeWidget = new QTreeWidget(myPeriodicitySplitter);
976 QStringList myPeriodicityTreeHeaders;
977 myPeriodicityTreeHeaders << tr("BLSURF_PERIODICITY_OBJ_SOURCE_COLUMN")
978 << tr("BLSURF_PERIODICITY_OBJ_TARGET_COLUMN")
979 << tr("BLSURF_PERIODICITY_P1_SOURCE_COLUMN")
980 << tr("BLSURF_PERIODICITY_P2_SOURCE_COLUMN")
981 << tr("BLSURF_PERIODICITY_P3_SOURCE_COLUMN")
982 << tr("BLSURF_PERIODICITY_P1_TARGET_COLUMN")
983 << tr("BLSURF_PERIODICITY_P2_TARGET_COLUMN")
984 << tr("BLSURF_PERIODICITY_P3_TARGET_COLUMN")
985 << tr("BLSURF_PERIODICITY_SHAPE_TYPE");
986 myPeriodicityTreeWidget->setHeaderLabels(myPeriodicityTreeHeaders);
988 // Hide the vertex name to make the widget more readable
989 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_SOURCE_COLUMN);
990 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_SOURCE_COLUMN);
991 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_SOURCE_COLUMN);
992 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P1_TARGET_COLUMN);
993 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P2_TARGET_COLUMN);
994 myPeriodicityTreeWidget->hideColumn(PERIODICITY_P3_TARGET_COLUMN);
995 myPeriodicityTreeWidget->hideColumn(PERIODICITY_SHAPE_TYPE);
998 myPeriodicityTreeWidget->setColumnCount(PERIODICITY_NB_COLUMN);
999 myPeriodicityTreeWidget->setSortingEnabled(true);
1001 myPeriodicityTreeWidget->setAlternatingRowColors(true);
1002 myPeriodicityTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
1003 myPeriodicityTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
1005 size_t periodicityVisibleColumns = 2;
1006 for (size_t column = 0; column < periodicityVisibleColumns; ++column) {
1007 myPeriodicityTreeWidget->header()->setSectionResizeMode(column,QHeaderView::Interactive);
1008 myPeriodicityTreeWidget->resizeColumnToContents(column);
1010 myPeriodicityTreeWidget->header()->setStretchLastSection(true);
1012 myPeriodicitySplitter->addWidget(myPeriodicityTreeWidget);
1014 myPeriodicityRightWidget = new QWidget(myPeriodicitySplitter);
1016 myPeriodicityRightGridLayout = new QGridLayout(myPeriodicityRightWidget);
1017 myPeriodicityGroupBox1 = new QGroupBox(tr("BLSURF_PRECAD_PERIODICITY"), myPeriodicityRightWidget);
1018 myPeriodicityGroupBox1Layout = new QGridLayout(myPeriodicityGroupBox1);
1020 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox1, 0, 0, 1, 2);
1022 myPeriodicityOnFaceRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_FACE"), myPeriodicityGroupBox1);
1023 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnFaceRadioButton, 0, 0, 1, 2);
1025 myPeriodicityOnFaceRadioButton->setChecked(true);
1027 myPeriodicityOnEdgeRadioButton = new QRadioButton(tr("BLSURF_PERIODICITY_ON_EDGE"), myPeriodicityGroupBox1);
1028 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityOnEdgeRadioButton, 0, 2, 1, 2);
1031 // FACE, EDGE AND VERTEX SELECTION
1032 TColStd_MapOfInteger shapeTypesFace, shapeTypesEdge;
1033 shapeTypesFace.Add( TopAbs_FACE );
1034 shapeTypesFace.Add( TopAbs_EDGE );
1035 shapeTypesFace.Add( TopAbs_COMPOUND );
1036 shapeTypesEdge.Add( TopAbs_EDGE );
1037 shapeTypesEdge.Add( TopAbs_COMPOUND );
1039 // myPeriodicityEdgeFilter = new SMESH_NumberFilter("GEOM", TopAbs_EDGE, 0, shapeTypesEdge);
1041 myPeriodicityMainSourceLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_SOURCE"), myPeriodicityGroupBox1);
1042 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainSourceLabel, 1, 0, 1, 1);
1044 SMESH_NumberFilter* myPeriodicitySourceFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1045 myPeriodicitySourceFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicitySourceFaceFilter, 0, /*multiSel=*/false);
1046 // myPeriodicitySourceFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1047 myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceFaceWdg, 1, 1, 1, 1);
1049 // myPeriodicitySourceEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1050 // myPeriodicitySourceEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1051 // myPeriodicitySourceEdgeWdg->hide();
1052 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicitySourceEdgeWdg, 1, 1, 1, 1);
1054 myPeriodicityMainTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_MAIN_TARGET"), myPeriodicityGroupBox1);
1055 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityMainTargetLabel, 1, 2, 1, 1);
1057 SMESH_NumberFilter* myPeriodicityTargetFaceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, shapeTypesFace);
1058 myPeriodicityTargetFaceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityTargetFaceFilter, 0, /*multiSel=*/false);
1059 // myPeriodicityTargetFaceWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_FACE"), "QLineEdit { color: grey }");
1060 myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetFaceWdg, 1, 3, 1, 1);
1062 // myPeriodicityTargetEdgeWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityEdgeFilter, 0, /*multiSel=*/false);
1063 // myPeriodicityTargetEdgeWdg->SetDefaultText(tr("BLSURF_PERIODICITY_SELECT_EDGE"), "QLineEdit { color: grey }");
1064 // myPeriodicityTargetEdgeWdg->hide();
1065 // myPeriodicityGroupBox1Layout->addWidget(myPeriodicityTargetEdgeWdg, 1, 3, 1, 1);
1067 myPeriodicityGroupBox2 = new QGroupBox(tr("BLSURF_PERIODICITY_WITH_VERTICES"), myPeriodicityRightWidget);
1068 myPeriodicityGroupBox2Layout = new QGridLayout(myPeriodicityGroupBox2);
1069 myPeriodicityRightGridLayout->addWidget(myPeriodicityGroupBox2, 1, 0, 1, 2);
1071 myPeriodicityGroupBox2->setCheckable(true);
1072 myPeriodicityGroupBox2->setChecked(false);
1074 myPeriodicitySourceLabel = new QLabel(tr("BLSURF_PERIODICITY_SOURCE"), myPeriodicityGroupBox2);
1075 myPeriodicityGroupBox2Layout->addWidget(myPeriodicitySourceLabel, 0, 0, 1, 2);
1077 myPeriodicityTargetLabel = new QLabel(tr("BLSURF_PERIODICITY_TARGET"), myPeriodicityGroupBox2);
1078 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityTargetLabel, 0, 2, 1, 2);
1081 myPeriodicityP1SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_SOURCE"), myPeriodicityGroupBox2);
1082 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceLabel, 1, 0, 1, 1);
1085 SMESH_NumberFilter* myPeriodicityP1SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1086 myPeriodicityP1SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1SourceFilter, 0, /*multiSel=*/false);
1087 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1SourceWdg, 1, 1, 1, 1);
1090 myPeriodicityP2SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_SOURCE"), myPeriodicityGroupBox2);
1091 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceLabel, 2, 0, 1, 1);
1093 SMESH_NumberFilter* myPeriodicityP2SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1094 myPeriodicityP2SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2SourceFilter, 0, /*multiSel=*/false);
1095 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2SourceWdg, 2, 1, 1, 1);
1098 myPeriodicityP3SourceLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_SOURCE"), myPeriodicityGroupBox2);
1099 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceLabel, 3, 0, 1, 1);
1101 SMESH_NumberFilter* myPeriodicityP3SourceFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1102 myPeriodicityP3SourceWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3SourceFilter, 0, /*multiSel=*/false);
1103 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3SourceWdg, 3, 1, 1, 1);
1106 myPeriodicityP1TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P1_TARGET"), myPeriodicityGroupBox2);
1107 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetLabel, 1, 2, 1, 1);
1109 SMESH_NumberFilter* myPeriodicityP1TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1110 myPeriodicityP1TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP1TargetFilter, 0, /*multiSel=*/false);
1111 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP1TargetWdg, 1, 3, 1, 1);
1114 myPeriodicityP2TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P2_TARGET"), myPeriodicityGroupBox2);
1115 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetLabel, 2, 2, 1, 1);
1117 SMESH_NumberFilter* myPeriodicityP2TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1118 myPeriodicityP2TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP2TargetFilter, 0, /*multiSel=*/false);
1119 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP2TargetWdg, 2, 3, 1, 1);
1122 myPeriodicityP3TargetLabel = new QLabel(tr("BLSURF_PERIODICITY_P3_TARGET"), myPeriodicityGroupBox2);
1123 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetLabel, 3, 2, 1, 1);
1125 SMESH_NumberFilter* myPeriodicityP3TargetFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX);
1126 myPeriodicityP3TargetWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myPeriodicityP3TargetFilter, 0, /*multiSel=*/false);
1127 myPeriodicityGroupBox2Layout->addWidget(myPeriodicityP3TargetWdg, 3, 3, 1, 1);
1129 myPeriodicityVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
1130 myPeriodicityGroupBox2Layout->addItem(myPeriodicityVerticalSpacer, 7, 1, 1, 1);
1133 myPeriodicityAddButton = new QPushButton(tr("BLSURF_PERIODICITY_ADD"),myPeriodicityRightWidget);
1134 myPeriodicityRightGridLayout->addWidget(myPeriodicityAddButton, 2, 0, 1, 1);
1136 myPeriodicityRemoveButton = new QPushButton(tr("BLSURF_PERIODICITY_REMOVE"),myPeriodicityRightWidget);
1137 myPeriodicityRightGridLayout->addWidget(myPeriodicityRemoveButton, 2, 1, 1, 1);
1139 myPeriodicitySplitter->addWidget(myPeriodicityRightWidget);
1141 myPeriodicitySelectionWidgets.clear();
1142 myPeriodicitySelectionWidgets.append(myPeriodicitySourceFaceWdg);
1143 myPeriodicitySelectionWidgets.append(myPeriodicityTargetFaceWdg);
1144 myPeriodicitySelectionWidgets.append(myPeriodicityP1SourceWdg);
1145 myPeriodicitySelectionWidgets.append(myPeriodicityP2SourceWdg);
1146 myPeriodicitySelectionWidgets.append(myPeriodicityP3SourceWdg);
1147 myPeriodicitySelectionWidgets.append(myPeriodicityP1TargetWdg);
1148 myPeriodicitySelectionWidgets.append(myPeriodicityP2TargetWdg);
1149 myPeriodicitySelectionWidgets.append(myPeriodicityP3TargetWdg);
1150 avoidSimultaneousSelection(myPeriodicitySelectionWidgets);
1152 // HyperPatch parameters
1154 QWidget* hpGroup = new QWidget();
1155 QGridLayout* hpLayout = new QGridLayout(hpGroup);
1157 myHyPatchTable = new QTableWidget( hpGroup );
1158 myHyPatchTable->setColumnCount(1);
1159 myHyPatchTable->setHorizontalHeaderLabels( QStringList() << tr("BLSURF_HYPATCH_TBL_HEADER") );
1160 myHyPatchTable->setAlternatingRowColors(true);
1161 myHyPatchTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
1164 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1165 myHyPatchFaceSelBtn = new QPushButton( iconSelect, tr("BLSURF_HYPATCH_SEL_FACE"), hpGroup );
1166 myHyPatchGroupSelBtn = new QPushButton( iconSelect, tr("BLSURF_HYPATCH_SEL_GROUP"), hpGroup );
1167 myHyPatchFaceSelBtn->setCheckable( true );
1168 myHyPatchGroupSelBtn->setCheckable( true );
1170 myHyPatchFaceSelector = new StdMeshersGUI_SubShapeSelectorWdg( hpGroup, TopAbs_FACE, /*toShowList=*/false );
1172 QLabel* hpTagsLbl = new QLabel( tr("BLSURF_TAGS"), hpGroup );
1173 myHyPatchTagsLE = new QLineEdit( hpGroup );
1174 myHyPatchTagsLE->setValidator( new SMESHGUI_IdValidator( hpGroup ));
1176 QPushButton* hpAddBtn = new QPushButton( tr("BLSURF_SM_ADD"), hpGroup );
1177 QPushButton* hpRemBtn = new QPushButton( tr("BLSURF_SM_REMOVE"), hpGroup );
1179 hpLayout->addWidget( myHyPatchTable, 0, 0, 5, 1 );
1180 hpLayout->addWidget( myHyPatchFaceSelBtn, 0, 1, 1, 2 );
1181 hpLayout->addWidget( myHyPatchGroupSelBtn, 0, 3, 1, 2 );
1182 hpLayout->addWidget( hpTagsLbl, 1, 1, 1, 1 );
1183 hpLayout->addWidget( myHyPatchTagsLE, 1, 2, 1, 3 );
1184 hpLayout->addWidget( hpAddBtn, 2, 1, 1, 2 );
1185 hpLayout->addWidget( hpRemBtn, 2, 3, 1, 2 );
1186 hpLayout->addWidget( myHyPatchFaceSelector, 3, 1, 1, 4 );
1191 myTabWidget->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
1192 myTabWidget->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
1194 myTabWidget->insertTab( SMP_TAB, mySmpGroup, tr( "LOCAL_SIZE" ) );
1195 myTabWidget->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
1196 myTabWidget->insertTab( PERIODICITY_TAB, myPeriodicityGroup, tr( "BLSURF_PERIODICITY" ) );
1197 myTabWidget->insertTab( HYPERPATCH_TAB, hpGroup, tr( "BLSURF_HYPERPATCH_TAB" ));
1203 myPeriodicityGroup->hide();
1206 myTabWidget->setCurrentIndex( STD_TAB );
1208 connect( myAdvWidget->addBtn, SIGNAL( clicked() ), this, SLOT( onAddOption() ) );
1211 connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) );
1212 connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
1213 connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) );
1214 connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this, SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
1215 connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1216 connect( myGeomSelWdg1, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1217 connect( myAttSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) );
1218 connect( mySizeMapTable, SIGNAL( itemChanged (QTreeWidgetItem *, int)),this, SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
1219 connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) );
1220 connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) );
1221 connect( smpTab, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1222 connect( myTabWidget, SIGNAL( currentChanged ( int )), this, SLOT( onTabChanged( int ) ) );
1224 // Enforced vertices
1225 connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) );
1226 connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) );
1227 connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
1228 connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) );
1229 connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
1230 connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
1231 connect( myInternalEnforcedVerticesAllFaces, SIGNAL( stateChanged ( int )), this, SLOT( onInternalVerticesClicked( int ) ) );
1234 connect( myPeriodicityAddButton, SIGNAL( clicked()), this, SLOT( onAddPeriodicity() ) );
1235 connect( myPeriodicityRemoveButton, SIGNAL( clicked()), this, SLOT( onRemovePeriodicity() ) );
1236 connect( myPeriodicityTreeWidget, SIGNAL( itemClicked(QTreeWidgetItem*, int)), this, SLOT( onPeriodicityTreeClicked(QTreeWidgetItem *, int) ) );
1237 connect( myPeriodicityGroupBox2, SIGNAL(toggled(bool)), this, SLOT(onPeriodicityByVerticesChecked(bool)));
1239 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1240 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1242 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1243 connect( w1, SIGNAL(contentModified ()), this, SLOT(onPeriodicityContentModified()));
1248 connect( myHyPatchFaceSelBtn, SIGNAL( toggled(bool) ), SLOT( onHyPatchFaceSelection(bool) ));
1249 connect( myHyPatchGroupSelBtn, SIGNAL( toggled(bool) ), SLOT( onHyPatchGroupSelection(bool) ));
1250 connect( myHyPatchFaceSelector, SIGNAL( shapeSelected() ), SLOT( onHyPatchSelectionChanged()));
1251 connect( hpAddBtn, SIGNAL( clicked() ), SLOT( onHyPatchAdd()));
1252 connect( hpRemBtn, SIGNAL( clicked() ), SLOT( onHyPatchRemove()));
1257 /** BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget*, QWidget*)
1258 This method stop the selection of the widgets StdMeshersGUI_ObjectReferenceParamWdg
1260 // void BLSURFPluginGUI_HypothesisCreator::deactivateSelection(QWidget* old, QWidget* now)
1262 // if ((now == myXCoord) || (now == myYCoord) || (now == myZCoord)
1263 // || (now = myGroupName) || (now = myGlobalGroupName) || (now = myEnforcedTreeWidget)) {
1264 // BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1265 // that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1266 // myEnfFaceWdg->deactivateSelection();
1267 // myEnfVertexWdg->deactivateSelection();
1271 void BLSURFPluginGUI_HypothesisCreator::onStateChange()
1273 myStdWidget->onPhysicalMeshChanged();
1277 * This method resets the content of the X, Y, Z widgets;
1279 void BLSURFPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
1281 myXCoord->setCleared(true);
1282 myYCoord->setCleared(true);
1283 myZCoord->setCleared(true);
1284 myXCoord->setText("");
1285 myYCoord->setText("");
1286 myZCoord->setText("");
1287 // myGroupName->setText("");
1290 /** BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item, column)
1291 This method updates the tooltip of a modified item. The QLineEdit widgets content
1292 is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
1294 void BLSURFPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTreeWidgetItem* item, int column) {
1295 QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
1296 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1297 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1298 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1299 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1300 QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString();
1301 QTreeWidgetItem* parent = item->parent();
1303 clearEnforcedVertexWidgets();
1305 if (parent && (!x.isNull() || !entry.isNull())) {
1306 QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
1307 QString toolTip = shapeName + QString(": ") + vertexName.toString();
1308 if (entry.isNull()) {
1309 toolTip += QString("(") + x.toString();
1310 toolTip += QString(", ") + y.toString();
1311 toolTip += QString(", ") + z.toString();
1312 toolTip += QString(")");
1315 if (!groupName.isEmpty())
1316 toolTip += QString(" [") + groupName + QString("]");
1318 item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1321 myXCoord->SetValue(x.toDouble());
1322 myYCoord->SetValue(y.toDouble());
1323 myZCoord->SetValue(z.toDouble());
1326 if (!groupName.isEmpty())
1327 myGroupName->setText(groupName);
1331 void BLSURFPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
1332 int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
1333 clearEnforcedVertexWidgets();
1334 if (nbSelEnfVertex == 1)
1336 if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
1339 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
1340 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1341 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1342 if (CORBA::is_nil(measureOp))
1345 CORBA::Double x,y,z;
1346 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1347 if ( measureOp->IsDone() )
1349 myXCoord->SetValue(x);
1350 myYCoord->SetValue(y);
1351 myZCoord->SetValue(z);
1357 /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords()
1358 This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
1359 of the enforced vertex clicked in the tree widget.
1361 void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() {
1362 clearEnforcedVertexWidgets();
1363 QList<QTreeWidgetItem *> items = myEnforcedTreeWidget->selectedItems();
1364 if (! items.isEmpty() && items.size() == 1) {
1365 QTreeWidgetItem *item = items[0];
1366 // for (int i=0 ; i < items.size() ; i++) {
1368 QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1369 QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
1370 QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
1371 QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1372 QVariant group = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole);
1373 if (!x.isNull()/* && entry.isNull()*/) {
1374 myXCoord->SetValue(x.toDouble());
1375 myYCoord->SetValue(y.toDouble());
1376 myZCoord->SetValue(z.toDouble());
1379 if (!group.isNull() && (!x.isNull() || !entry.isNull()))
1380 myGroupName->setText(group.toString());
1385 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(entry, shapeName, useInternalVertices)
1386 This method adds a face containing enforced vertices in the tree widget.
1388 QTreeWidgetItem* BLSURFPluginGUI_HypothesisCreator::addEnforcedFace(std::string theFaceEntry, std::string theFaceName) {
1389 // Find theFaceEntry item
1390 QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(theFaceEntry.c_str()),Qt::MatchExactly,ENF_VER_FACE_ENTRY_COLUMN);
1391 QTreeWidgetItem* theItem;
1392 if (theItemList.empty()) {
1393 theItem = new QTreeWidgetItem();
1394 theItem->setData(ENF_VER_FACE_ENTRY_COLUMN, Qt::EditRole, QVariant(theFaceEntry.c_str()));
1395 theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(theFaceName.c_str()));
1396 theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(theFaceEntry.c_str()));
1397 myEnforcedTreeWidget->addTopLevelItem(theItem);
1400 theItem = theItemList[0];
1405 /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
1406 This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
1408 void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z,
1409 std::string vertexName,
1410 std::string geomEntry,
1411 std::string groupName)
1413 bool okToCreate = true;
1415 const int nbVert = myEnforcedTreeWidget->topLevelItemCount();
1416 for (int row = 0; row < nbVert; row++ )
1418 QTreeWidgetItem* child = myEnforcedTreeWidget->topLevelItem( row );
1419 QString childGroupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString();
1420 QString childEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString();
1421 double childX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
1422 double childY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
1423 double childZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
1424 if (((childEntry.isEmpty()) && (childX == x) && (childY == y) && (childZ == z)) ||
1425 ( !childEntry.isEmpty() && childEntry == geomEntry.c_str() ))
1427 // update group name
1428 if ( childGroupName != groupName.c_str() ) {
1429 child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1439 QTreeWidgetItem *vertexItem = new QTreeWidgetItem( myEnforcedTreeWidget );
1440 vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1441 QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
1442 QSize iconSize = iconSelect.size()*0.7;
1444 int vertexIndex=nbVert;
1445 QString myVertexName;
1447 while(indexRef != vertexIndex) {
1448 indexRef = vertexIndex;
1449 if (vertexName.empty())
1450 myVertexName = QString("Vertex #%1").arg(vertexIndex);
1452 myVertexName = QString(vertexName.c_str());
1454 for (int row = 0;row<nbVert;row++) {
1455 QString name = myEnforcedTreeWidget->topLevelItem(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
1456 if (myVertexName == name) {
1462 vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
1463 if (geomEntry.empty()) {
1464 vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
1465 vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
1466 vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
1469 vertexItem->setIcon(ENF_VER_NAME_COLUMN, QIcon(iconSelect.scaled(iconSize,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
1470 vertexItem->setData( ENF_VER_ENTRY_COLUMN, Qt::EditRole, QString(geomEntry.c_str()) );
1472 if (groupName != "")
1473 vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
1475 QString toolTip = myVertexName;
1476 if (geomEntry.empty()) {
1477 toolTip += QString(" (%1, %2, %3").arg(x).arg(y).arg(z);
1479 if (groupName != "")
1480 toolTip += QString(" [%1]").arg(groupName.c_str());
1482 vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
1483 myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
1486 /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1487 This method is called when a item is added into the enforced vertices tree widget
1489 void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices()
1491 getGeomSelectionTool()->selectionMgr()->clearFilters();
1492 myEnfVertexWdg->deactivateSelection();
1494 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1495 myEnforcedTreeWidget->resizeColumnToContents(column);
1498 int selEnfVertex = myEnfVertexWdg->NbObjects();
1499 bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
1501 if ((selEnfVertex == 0) && coordsEmpty)
1504 string entry, shapeName;
1506 std::string groupName = myGroupName->text().simplified().toStdString();
1508 if (selEnfVertex <= 1)
1511 x = myXCoord->GetValue();
1512 y = myYCoord->GetValue();
1513 z = myZCoord->GetValue();
1514 if (selEnfVertex == 1) {
1515 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
1516 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1519 addEnforcedVertex(x, y, z, "", "", groupName);
1523 if ( CORBA::is_nil(getGeomEngine()))
1526 GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
1527 if (CORBA::is_nil(measureOp))
1530 CORBA::Double x,y,z;
1532 for (int j = 0 ; j < selEnfVertex ; j++)
1534 myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
1535 if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
1536 measureOp->PointCoordinates (myEnfVertex, x, y, z);
1537 if ( measureOp->IsDone() )
1538 addEnforcedVertex(x, y, z, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1539 } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
1540 addEnforcedVertex(0, 0, 0, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
1546 myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
1548 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1549 myEnforcedTreeWidget->resizeColumnToContents(column);
1551 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
1552 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
1553 myStdWidget->onPhysicalMeshChanged();
1557 /** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
1558 This method is called when a item is removed from the enforced vertices tree widget
1560 void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
1561 QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
1562 QList<QTreeWidgetItem *> selectedVertices;
1563 QSet<QTreeWidgetItem *> selectedEntries;
1564 QTreeWidgetItem* item;
1566 foreach( item, selectedItems ) {
1567 QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
1568 if (! value.isNull())
1569 selectedVertices.append(item);
1571 value = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole);
1572 if (! value.isNull())
1573 selectedVertices.append(item);
1575 selectedEntries.insert(item);
1579 foreach(item,selectedVertices) {
1580 QTreeWidgetItem* parent = item->parent();
1582 parent->removeChild(item);
1584 if ( parent && parent->childCount() == 0) {
1585 if (selectedEntries.contains(parent))
1586 selectedEntries.remove(parent);
1591 foreach(item,selectedEntries) {
1595 myEnforcedTreeWidget->selectionModel()->clearSelection();
1599 void BLSURFPluginGUI_HypothesisCreator::onInternalVerticesClicked(int state)
1601 myInternalEnforcedVerticesAllFacesGroup->setEnabled(state == Qt::Checked);
1604 /** BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity()
1605 This method is called when a item is added into the periodicity table widget
1607 void BLSURFPluginGUI_HypothesisCreator::onAddPeriodicity() {
1609 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1611 that->getGeomSelectionTool()->selectionMgr()->clearFilters();
1612 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1613 for ( ; anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1615 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1616 w1->deactivateSelection();
1620 // Source-Target selection
1621 int selSource = myPeriodicitySourceFaceWdg->NbObjects();
1622 int selTarget = myPeriodicityTargetFaceWdg->NbObjects();
1624 if (selSource == 0 || selTarget == 0)
1627 // Vertices selection
1628 if (myPeriodicityGroupBox2->isChecked())
1630 int P1Ssel = myPeriodicityP1SourceWdg->NbObjects();
1631 int P2Ssel = myPeriodicityP2SourceWdg->NbObjects();
1632 int P3Ssel = myPeriodicityP3SourceWdg->NbObjects();
1633 int P1Tsel = myPeriodicityP1TargetWdg->NbObjects();
1634 //int P2Tsel = myPeriodicityP2TargetWdg->NbObjects();
1635 int P3Tsel = myPeriodicityP3TargetWdg->NbObjects();
1637 if (P1Ssel!=1 || P2Ssel!=1 || P3Ssel!=1 || P1Tsel!=1 || P3Tsel!=1 || P3Tsel!=1)
1639 QString msg = tr("BLSURF_PERIODICITY_WRONG_NUMBER_OF_VERTICES");
1640 SUIT_MessageBox::critical( dlg(),"Error" , msg );
1645 // Add Source-Target in table
1646 string shapeEntry, sourceEntry, targetEntry;
1647 string shapeName, sourceName, targetName;
1648 GEOM::GEOM_Object_var shape;
1650 QTreeWidgetItem* item = new QTreeWidgetItem();
1651 myPeriodicityTreeWidget->addTopLevelItem(item);
1653 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
1657 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1659 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1660 shape = w1->GetObject< GEOM::GEOM_Object >(0);
1661 shapeName = shape->GetName();
1662 shapeEntry = shape->GetStudyEntry();
1663 item->setData(k, Qt::EditRole, shapeName.c_str() );
1664 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
1665 if (! myPeriodicityGroupBox2->isChecked() && k==1)
1669 // Add shape type in tree
1670 string onFace = (myPeriodicityOnFaceRadioButton->isChecked()) ? "1" : "0";
1671 item->setData(PERIODICITY_SHAPE_TYPE, Qt::UserRole, onFace.c_str());
1673 // Blank input fields
1674 for (anIt = myPeriodicitySelectionWidgets.begin(); anIt != myPeriodicitySelectionWidgets.end(); anIt++)
1676 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1677 w1->SetObject(GEOM::GEOM_Object::_nil());
1680 // for (int column = 0; column < myPeriodicityTreeWidget->columnCount(); ++column)
1681 // myPeriodicityTreeWidget->resizeColumnToContents(column);
1685 /** BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity()
1686 This method is called when a item is removed from the periodicity tree widget
1688 void BLSURFPluginGUI_HypothesisCreator::onRemovePeriodicity() {
1689 QList<QTreeWidgetItem *> selectedItems = myPeriodicityTreeWidget->selectedItems();
1690 QTreeWidgetItem* item;
1692 foreach(item,selectedItems) {
1696 myEnforcedTreeWidget->selectionModel()->clearSelection();
1699 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked()
1700 This method enable clears the field for periodicity by vertices
1702 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityByVerticesChecked(bool checked)
1706 for (int k=2; k<myPeriodicitySelectionWidgets.size(); k++)
1708 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k] );
1709 w1->deactivateSelection();
1710 w1->SetObject(CORBA::Object::_nil());
1715 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1716 This method enable the proper shape selection widget to Face or Edge shapes
1718 //void BLSURFPluginGUI_HypothesisCreator::onPeriodicityRadioButtonChanged()
1720 // if (myPeriodicityOnFaceRadioButton->isChecked())
1722 // myPeriodicitySourceEdgeWdg->hide();
1723 // myPeriodicityTargetEdgeWdg->hide();
1724 // myPeriodicitySourceFaceWdg->show();
1725 // myPeriodicityTargetFaceWdg->show();
1729 // myPeriodicitySourceFaceWdg->hide();
1730 // myPeriodicityTargetFaceWdg->hide();
1731 // myPeriodicitySourceEdgeWdg->show();
1732 // myPeriodicityTargetEdgeWdg->show();
1736 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityTreeClicked(QTreeWidgetItem* item, int row)
1738 QString shapeName, shapeEntry;
1739 CORBA::Object_var shape;
1741 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1742 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1744 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1746 shapeName = item->data(k, Qt::EditRole).toString();
1747 shapeEntry = item->data(k, Qt::UserRole).toString();
1748 if (! shapeEntry.isEmpty())
1750 shape = entryToObject(shapeEntry);
1751 w1->SetObject(shape);
1752 w1->deactivateSelection();
1754 myPeriodicityGroupBox2->setChecked(1);
1757 myPeriodicityGroupBox2->setChecked(0);
1760 if (item->data(PERIODICITY_SHAPE_TYPE, Qt::UserRole) == "1")
1761 myPeriodicityOnFaceRadioButton->setChecked(true);
1763 myPeriodicityOnEdgeRadioButton->setChecked(true);
1768 /** BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1769 This method gives the focus to the next selection widget when a content is modified in a selection widget.
1771 void BLSURFPluginGUI_HypothesisCreator::onPeriodicityContentModified()
1773 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1775 ListOfWidgets::const_iterator anIt = myPeriodicitySelectionWidgets.begin();
1777 // find wich selection widget is activated
1778 for (; anIt != myPeriodicitySelectionWidgets.end(); anIt++, k++)
1780 StdMeshersGUI_ObjectReferenceParamWdg * w1 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt );
1781 if (w1->IsSelectionActivated() && k<(myPeriodicitySelectionWidgets.size()-1))
1783 // don't activate vertex selection if the group box is not checked
1784 if (k==1 && !myPeriodicityGroupBox2->isChecked())
1786 // clear the selection, to avoid to put the same object in the other widget
1787 that->getGeomSelectionTool()->selectionMgr()->clearSelected();
1788 // activate the next widget
1789 StdMeshersGUI_ObjectReferenceParamWdg * w2 = ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( myPeriodicitySelectionWidgets[k+1] );
1790 w2->activateSelection();
1797 /** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
1798 This method updates the GUI widgets with the hypothesis data
1800 void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
1802 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
1804 BlsurfHypothesisData data;
1805 that->readParamsFromHypo( data );
1808 myName->setText( data.myName );
1809 QFontMetrics metrics( myName->font() );
1810 myName->setMinimumWidth( metrics.width( data.myName )+5 );
1812 myStdWidget->myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh );
1813 myStdWidget->myGeometricMesh->setCurrentIndex( data.myGeometricMesh );
1814 if (data.myPhySize <= 0)
1815 myStdWidget->myPhySize->setText("");
1817 myStdWidget->myPhySize->SetValue( data.myPhySize );
1818 myStdWidget->myPhySizeRel->setChecked( data.myPhySizeRel );
1819 if (data.myMinSize < 0)
1820 myStdWidget->myMinSize->setText("");
1822 myStdWidget->myMinSize->SetValue( data.myMinSize );
1823 myStdWidget->myMinSizeRel->setChecked( data.myMinSizeRel );
1824 if (data.myMaxSize < 0)
1825 myStdWidget->myMaxSize->setText("");
1827 myStdWidget->myMaxSize->SetValue( data.myMaxSize );
1828 myStdWidget->myMaxSizeRel->setChecked( data.myMaxSizeRel );
1829 myStdWidget->myUseGradation->setChecked( data.myUseGradation );
1830 if (data.myGradation <= 0 || !data.myUseGradation )
1831 myStdWidget->myGradation->setText("");
1833 myStdWidget->myGradation->SetValue( data.myGradation );
1834 myStdWidget->myUseVolumeGradation->setChecked( data.myUseVolumeGradation );
1835 if (data.myVolumeGradation <= 0 || !data.myUseVolumeGradation )
1836 myStdWidget->myVolumeGradation->setText("");
1838 myStdWidget->myVolumeGradation->SetValue( data.myVolumeGradation );
1840 foreach (QAbstractButton* button, myStdWidget->myButtonGroupElementType->buttons()) {
1841 if (myStdWidget->myButtonGroupElementType->id(button) == data.myElementType) {
1842 button->setChecked(true);
1847 myStdWidget->myUseSurfaceProximity->setChecked( data.myUseSurfaceProximity );
1848 myStdWidget->myNbSurfaceProximityLayers->setValue( data.myNbSurfaceProximityLayers );
1849 myStdWidget->mySurfaceProximityRatio->SetValue( data.mySurfaceProximityRatio );
1850 myStdWidget->myUseVolumeProximity->setChecked( data.myUseVolumeProximity );
1851 myStdWidget->myNbVolumeProximityLayers->setValue( data.myNbVolumeProximityLayers );
1852 myStdWidget->myVolumeProximityRatio->SetValue( data.myVolumeProximityRatio );
1853 if ( !data.myUseSurfaceProximity )
1855 //myStdWidget->myNbSurfaceProximityLayers->setText("");
1856 myStdWidget->mySurfaceProximityRatio->setText("");
1858 if ( !data.myUseVolumeProximity )
1860 //myStdWidget->myNbVolumeProximityLayers->setText("");
1861 myStdWidget->myVolumeProximityRatio->setText("");
1864 if (data.myAngleMesh < 0)
1865 myStdWidget->myAngleMesh->setText("");
1867 myStdWidget->myAngleMesh->SetValue( data.myAngleMesh );
1868 if (data.myChordalError <= 0)
1869 myStdWidget->myChordalError->setText("");
1871 myStdWidget->myChordalError->SetValue( data.myChordalError );
1872 myStdWidget->myAnisotropic->setChecked( data.myAnisotropic );
1873 if (data.myAnisotropicRatio <= 0)
1874 myStdWidget->myAnisotropicRatio->setText("");
1876 myStdWidget->myAnisotropicRatio->SetValue( data.myAnisotropicRatio );
1877 myStdWidget->myRemoveTinyEdges->setChecked( data.myRemoveTinyEdges );
1878 if (data.myTinyEdgeLength <= 0)
1879 myStdWidget->myTinyEdgeLength->setText("");
1881 myStdWidget->myTinyEdgeLength->SetValue( data.myTinyEdgeLength );
1882 myStdWidget->myOptimiseTinyEdges->setChecked( data.myOptimiseTinyEdges );
1883 if (data.myTinyEdgeOptimisLength <= 0)
1884 myStdWidget->myTinyEdgeOptimisLength->setText("");
1886 myStdWidget->myTinyEdgeOptimisLength->SetValue( data.myTinyEdgeOptimisLength );
1887 myStdWidget->myCorrectSurfaceIntersection->setChecked( data.myCorrectSurfaceIntersection );
1888 if (data.myCorrectSurfaceIntersectionMaxCost <= 0)
1889 myStdWidget->myCorrectSurfaceIntersectionMaxCost->setText("");
1891 myStdWidget->myCorrectSurfaceIntersectionMaxCost->SetValue( data.myCorrectSurfaceIntersectionMaxCost );
1892 myStdWidget->myForceBadElementRemoval->setChecked( data.myForceBadElementRemoval );
1893 if (data.myBadElementAspectRatio <= 0)
1894 myStdWidget->myBadElementAspectRatio->setText("");
1896 myStdWidget->myBadElementAspectRatio->SetValue( data.myBadElementAspectRatio );
1897 myStdWidget->myOptimizeMesh->setChecked( data.myOptimizeMesh );
1898 myStdWidget->myQuadraticMesh->setChecked( data.myQuadraticMesh );
1900 myStdWidget->resizeWidgets();
1902 myAdvWidget->myVerbosity->setValue( data.myVerbosity );
1904 if ( myOptions.operator->() ) {
1905 for ( int i = 0, nb = myOptions->length(); i < nb; ++i )
1906 myAdvWidget->AddOption( TBL_MESHING, that->myOptions[i].in() );
1908 if ( myPreCADOptions.operator->() ) {
1909 for ( int i = 0, nb = myPreCADOptions->length(); i < nb; ++i )
1910 myAdvWidget->AddOption( TBL_PRECAD, that->myPreCADOptions[i].in() );
1912 if ( myCustomOptions.operator->() ) {
1913 for ( int i = 0, nb = myCustomOptions->length(); i < nb; ++i )
1914 myAdvWidget->AddOption( TBL_CUSTOM, that->myCustomOptions[i].in() );
1916 myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
1917 myAdvWidget->myGMFFileName->setText(QString(data.myGMFFileName.c_str()));
1918 // myGMFFileMode->setChecked(data.myGMFFileMode);
1921 QMapIterator<QString, QString> i(that->mySMPMap);
1922 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
1923 while (i.hasNext()) {
1925 const QString entry = i.key();
1926 const QString sizeMap = i.value();
1927 string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString());
1928 //int row = mySizeMapTable->topLevelItemCount();
1929 QTreeWidgetItem* item = new QTreeWidgetItem();
1930 mySizeMapTable->addTopLevelItem( item );
1931 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled );
1932 item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) );
1933 item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) );
1934 if (that->myATTMap.contains(entry)) {
1935 TAttractorVec & attVec = that->myATTMap[entry];
1936 for ( size_t i = 0; i < attVec.size(); ++i )
1938 std::string attName = myGeomToolSelected->getNameFromEntry( attVec[i].attEntry );
1939 QTreeWidgetItem* child = new QTreeWidgetItem();
1940 item->addChild( child );
1941 item->setExpanded(true);
1942 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( attVec[i].startSize ));
1943 child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attVec[i].attEntry.c_str() ));
1944 child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( attName.c_str() ));
1946 if ( attVec[i].infDist > std::numeric_limits<double>::epsilon()){
1947 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Attractor" ));
1950 item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( "Constant Size" ));
1956 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) );
1959 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
1960 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
1961 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
1963 // Enforced vertices
1964 TFaceEntryEnfVertexListMap::const_iterator evmIt = data.faceEntryEnfVertexListMap.begin();
1966 for ( ; evmIt != data.faceEntryEnfVertexListMap.end() ; ++evmIt) {
1967 TEntry entry = (*evmIt).first;
1968 std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
1970 //QTreeWidgetItem* faceItem = that->addEnforcedFace(entry, shapeName);
1972 TEnfVertexList evs = (*evmIt).second;
1974 TEnfVertexList::const_iterator evsIt = evs.begin();
1975 TEnfVertex *enfVertex;
1976 for ( ; evsIt != evs.end() ; ++evsIt) {
1977 enfVertex = (*evsIt);
1978 double x = 0, y = 0, z = 0;
1979 if (enfVertex->coords.size()) {
1980 x = enfVertex->coords[0];
1981 y = enfVertex->coords[1];
1982 z = enfVertex->coords[2];
1984 that->addEnforcedVertex(x, y, z, enfVertex->name, enfVertex->geomEntry, enfVertex->grpName);
1988 for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
1989 myEnforcedTreeWidget->resizeColumnToContents(column);
1991 myInternalEnforcedVerticesAllFaces->setChecked(data.myInternalEnforcedVerticesAllFaces);
1992 myInternalEnforcedVerticesAllFacesGroup->setText(QString(data.myInternalEnforcedVerticesAllFacesGroup.c_str()));
1993 myInternalEnforcedVerticesAllFacesGroup->setEnabled(data.myInternalEnforcedVerticesAllFaces);
1997 // Add an item in the tree widget for each association
1998 for (size_t i=0 ; i<data.preCadPeriodicityVector.size() ; i++)
2000 QTreeWidgetItem* item = new QTreeWidgetItem();
2001 myPeriodicityTreeWidget->addTopLevelItem(item);
2002 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled );
2003 TPreCadPeriodicity periodicity_i = data.preCadPeriodicityVector[i];
2004 for (size_t k=0; k<periodicity_i.size(); k++)
2006 string shapeEntry = periodicity_i[k];
2007 string shapeName = myGeomToolSelected->getNameFromEntry(shapeEntry);
2008 item->setData(k, Qt::EditRole, shapeName.c_str() );
2009 item->setData(k, Qt::UserRole, shapeEntry.c_str() );
2014 for ( int i = 0; i < data.hyperpatches.size(); ++i )
2015 that->addHyPatchToTable( data.hyperpatches[i] );
2018 that->myStdWidget->onPhysicalMeshChanged();
2019 that->myStdWidget->onGeometricMeshChanged();
2020 that->onStateChange();
2023 /** BLSURFPluginGUI_HypothesisCreator::storeParams()
2024 This method updates the hypothesis data with the GUI widgets content.
2026 QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
2028 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2030 BlsurfHypothesisData data;
2031 QString guiHyp = that->readParamsFromWidgets( data );
2032 that->storeParamsToHypo( data );
2037 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
2038 Updates the hypothesis data from hypothesis values.
2040 bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
2042 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2043 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() );
2045 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
2046 h_data.myName = isCreation() && data ? hypName() : "";
2048 h_data.myPhysicalMesh = (int) h->GetPhysicalMesh();
2049 h_data.myGeometricMesh = (int) h->GetGeometricMesh();
2050 h_data.myPhySize = h->GetPhySize();
2051 h_data.myPhySizeRel = h->IsPhySizeRel();
2052 double minSize = h->GetMinSize();
2053 double maxSize = h->GetMaxSize();
2054 h_data.myMinSize = minSize > 0 ? minSize : -1.0;
2055 h_data.myMinSizeRel = h->IsMinSizeRel();
2056 h_data.myMaxSize = maxSize > 0 ? maxSize : -1.0;
2057 h_data.myMaxSizeRel = h->IsMaxSizeRel();
2058 h_data.myUseGradation = h->GetUseGradation();
2059 h_data.myGradation = h->GetGradation();
2060 h_data.myUseVolumeGradation = h->GetUseVolumeGradation();
2061 h_data.myVolumeGradation = h->GetVolumeGradation();
2062 h_data.myElementType = h->GetElementType();
2063 double angle = h->GetAngleMesh();
2064 h_data.myAngleMesh = angle > 0 ? angle : -1.0;
2065 double chordalError = h->GetChordalError();
2066 h_data.myChordalError = chordalError > 0 ? chordalError : -1.0;
2067 h_data.myAnisotropic = h->GetAnisotropic();
2068 double myAnisotropicRatio = h->GetAnisotropicRatio();
2069 h_data.myAnisotropicRatio = myAnisotropicRatio > 0 ? myAnisotropicRatio : -1.0;
2070 h_data.myRemoveTinyEdges = h->GetRemoveTinyEdges();
2071 double myTinyEdgeLength = h->GetTinyEdgeLength();
2072 h_data.myTinyEdgeLength = myTinyEdgeLength > 0 ? myTinyEdgeLength : -1.0;
2073 h_data.myOptimiseTinyEdges = h->GetOptimiseTinyEdges();
2074 double myTinyEdgeOptimisLength = h->GetTinyEdgeOptimisationLength();
2075 h_data.myTinyEdgeOptimisLength = myTinyEdgeOptimisLength > 0 ? myTinyEdgeOptimisLength : -1.0;
2076 h_data.myCorrectSurfaceIntersection = h->GetCorrectSurfaceIntersection();
2077 double corrSurfaceIntersMaxCost = h->GetCorrectSurfaceIntersectionMaxCost();
2078 h_data.myCorrectSurfaceIntersectionMaxCost = corrSurfaceIntersMaxCost > 0 ? corrSurfaceIntersMaxCost : -1.0;
2079 h_data.myForceBadElementRemoval = h->GetBadElementRemoval();
2080 double myBadElementAspectRatio = h->GetBadElementAspectRatio();
2081 h_data.myBadElementAspectRatio = myBadElementAspectRatio > 0 ? myBadElementAspectRatio : -1.0;
2082 h_data.myOptimizeMesh = h->GetOptimizeMesh();
2083 h_data.myQuadraticMesh = h->GetQuadraticMesh();
2084 h_data.myVerbosity = h->GetVerbosity();
2085 //h_data.myTopology = (int) h->GetTopology();
2086 //h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges();
2087 // h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology();
2088 // h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput();
2089 h_data.myUseSurfaceProximity = h->GetSurfaceProximity ();
2090 h_data.myNbSurfaceProximityLayers = h->GetNbSurfaceProximityLayers();
2091 h_data.mySurfaceProximityRatio = h->GetSurfaceProximityRatio ();
2092 h_data.myUseVolumeProximity = h->GetVolumeProximity ();
2093 h_data.myNbVolumeProximityLayers = h->GetNbVolumeProximityLayers ();
2094 h_data.myVolumeProximityRatio = h->GetVolumeProximityRatio ();
2096 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2097 that->myOptions = h->GetOptionValues();
2098 that->myPreCADOptions = h->GetPreCADOptionValues();
2099 that->myCustomOptions = h->GetAdvancedOptionValues();
2101 h_data.myGMFFileName = h->GetGMFFile();
2102 // h_data.myGMFFileMode = h->GetGMFFileMode();
2104 that->mySMPMap.clear();
2105 that->myATTMap.clear();
2106 // that->myAttDistMap.clear();
2107 // that->myDistMap.clear();
2109 // classic size maps
2110 BLSURFPlugin::string_array_var mySizeMaps = h->GetSizeMapEntries();
2111 QString fullSizeMaps;
2112 QStringList fullSizeMapList;
2113 GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
2114 for ( CORBA::ULong i = 0;i<mySizeMaps->length(); ++i ) {
2115 fullSizeMaps = mySizeMaps[i].in();
2116 fullSizeMapList = fullSizeMaps.split( "|", QString::KeepEmptyParts );
2117 if ( fullSizeMapList.count() > 1 ) {
2118 string fullSizeMap = fullSizeMapList[1].toStdString();
2119 int pos = fullSizeMap.find("return")+7;
2122 sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
2127 that->mySMPMap[fullSizeMapList[0]] = sizeMap;
2128 that->mySMPShapeTypeMap[fullSizeMapList[0]] = myGeomToolSelected->entryToShapeType(fullSizeMapList[0].toStdString());
2134 BLSURFPlugin::string_array_var myCustomSizeMaps = h->GetCustomSizeMapEntries();
2136 for ( int i = 0;i<myCustomSizeMaps->length(); ++i ) {
2137 QString fullCustomSizeMaps = myCustomSizeMaps[i].in();
2138 QStringList fullCustomSizeMapList = fullCustomSizeMaps.split( "|", QString::KeepEmptyParts );
2139 if ( fullCustomSizeMapList.count() > 1 ) {
2140 that->mySMPMap[fullCustomSizeMapList[0]] = fullCustomSizeMapList[1];
2141 that->mySMPShapeTypeMap[fullCustomSizeMapList[0]] = GeomToolSelected->entryToShapeType(fullCustomSizeMapList[0].toStdString());
2146 BLSURFPlugin::string_array_var allMyAttractors = h->GetAttractorEntries();
2148 for ( CORBA::ULong i = 0;i<allMyAttractors->length(); ++i ) {
2149 QString myAttractors = allMyAttractors[i].in();
2150 QStringList myAttractorList = myAttractors.split( "|", QString::KeepEmptyParts );
2151 if ( myAttractorList.count() > 1 ) {
2152 that->mySMPMap[myAttractorList[0]] = myAttractorList[1];
2153 that->mySMPShapeTypeMap[myAttractorList[0]] = myGeomToolSelected->entryToShapeType(myAttractorList[0].toStdString());
2157 // attractor new version
2158 BLSURFPlugin::TAttParamsMap_var allMyAttractorParams = h->GetAttractorParams();
2159 for ( CORBA::ULong i = 0;i<allMyAttractorParams->length(); ++i ) {
2160 BLSURFPlugin::TAttractorParams myAttractorParams = allMyAttractorParams[i];
2161 QString faceEntry = myAttractorParams.faceEntry.in();
2162 QString attEntry = myAttractorParams.attEntry.in();
2163 that->mySMPMap[faceEntry] = QString::number( myAttractorParams.startSize, 'g', 6 ); // TODO utiliser les préférences ici (cf. sketcher)
2164 that->mySMPShapeTypeMap[faceEntry] = myGeomToolSelected->entryToShapeType(faceEntry.toStdString());
2165 that->myATTMap[faceEntry].push_back( TAttractor( myAttractorParams.attEntry.in(),
2166 myAttractorParams.startSize,
2167 myAttractorParams.infDist,
2168 myAttractorParams.constDist ));
2171 // Enforced vertices
2172 h_data.enfVertexList.clear();
2173 h_data.faceEntryEnfVertexListMap.clear();
2175 h_data.groupNameEnfVertexListMap.clear();
2178 BLSURFPlugin::TFaceEntryEnfVertexListMap_var faceEntryEnfVertexListMap = h->GetAllEnforcedVerticesByFace();
2180 for ( CORBA::ULong i = 0;i<faceEntryEnfVertexListMap->length(); ++i )
2182 std::string entry = faceEntryEnfVertexListMap[i].faceEntry.in();
2183 BLSURFPlugin::TEnfVertexList vertexList = faceEntryEnfVertexListMap[i].enfVertexList;
2185 for (CORBA::ULong j=0 ; j<vertexList.length(); ++j)
2187 TEnfVertex *enfVertex = new TEnfVertex();
2188 enfVertex->name = vertexList[j].name.in();
2189 enfVertex->geomEntry = vertexList[j].geomEntry.in();
2190 enfVertex->grpName = vertexList[j].grpName.in();
2191 for (CORBA::ULong k=0 ; k< vertexList[j].coords.length();k++)
2192 enfVertex->coords.push_back(vertexList[j].coords[k]);
2194 h_data.faceEntryEnfVertexListMap[entry].insert(enfVertex);
2197 if (groupName != "") {
2198 h_data.groupNameEnfVertexListMap[groupName].insert(ev);
2202 // h_data.enfVertMap[entry] = evs;
2203 // h_data.entryCoordsListMap[entry] = coordsList;
2205 if (h_data.faceEntryEnfVertexListMap[entry].size() == 0) {
2206 h_data.faceEntryEnfVertexListMap.erase(entry);
2209 h_data.myInternalEnforcedVerticesAllFaces = h->GetInternalEnforcedVertexAllFaces();
2210 h_data.myInternalEnforcedVerticesAllFacesGroup = h->GetInternalEnforcedVertexAllFacesGroup();
2214 h_data.preCadPeriodicityVector.clear();
2216 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector = h->GetPreCadFacesPeriodicityVector();
2217 AddPreCadSequenceToVector(h_data, preCadFacePeriodicityVector, true);
2219 BLSURFPlugin::TPeriodicityList_var preCadEdgePeriodicityVector = h->GetPreCadEdgesPeriodicityVector();
2220 AddPreCadSequenceToVector(h_data, preCadEdgePeriodicityVector, false);
2224 h_data.hyperpatches.clear();
2225 BLSURFPlugin::THyperPatchList_var patchList = h->GetHyperPatches();
2226 for ( CORBA::ULong i = 0; i < patchList->length(); ++i )
2229 BLSURFPlugin::THyperPatch& patch = patchList[i];
2230 for ( CORBA::ULong j = 0; j < patch.length(); ++j )
2231 tags += QString::number( patch[j] ) + " ";
2232 if ( !tags.isEmpty() )
2233 h_data.hyperpatches.append( tags );
2239 void BLSURFPluginGUI_HypothesisCreator::AddPreCadSequenceToVector(BlsurfHypothesisData& h_data,
2240 BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const
2243 for (size_t i=0; i<preCadFacePeriodicityVector->length(); i++ )
2245 TPreCadPeriodicity periodicity_i(PERIODICITY_NB_COLUMN);
2246 periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN] = preCadFacePeriodicityVector[i].shape1Entry.in();
2247 periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN] = preCadFacePeriodicityVector[i].shape2Entry.in();
2249 BLSURFPlugin::TEntryList sourceVertices = preCadFacePeriodicityVector[i].theSourceVerticesEntries;
2250 BLSURFPlugin::TEntryList targetVertices = preCadFacePeriodicityVector[i].theTargetVerticesEntries;
2252 if (sourceVertices.length()!=0)
2254 periodicity_i[PERIODICITY_P1_SOURCE_COLUMN] = sourceVertices[0].in();
2255 periodicity_i[PERIODICITY_P2_SOURCE_COLUMN] = sourceVertices[1].in();
2257 periodicity_i[PERIODICITY_P3_SOURCE_COLUMN] = sourceVertices[2].in();
2260 if (targetVertices.length()!=0)
2262 periodicity_i[PERIODICITY_P1_TARGET_COLUMN] = targetVertices[0].in();
2263 periodicity_i[PERIODICITY_P2_TARGET_COLUMN] = targetVertices[1].in();
2265 periodicity_i[PERIODICITY_P3_TARGET_COLUMN] = targetVertices[2].in();
2269 periodicity_i[PERIODICITY_SHAPE_TYPE] = "1";
2271 periodicity_i[PERIODICITY_SHAPE_TYPE] = "0";
2273 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2277 /** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
2278 Saves the hypothesis data to hypothesis values.
2280 bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
2282 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
2283 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() );
2289 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
2291 if ( h->GetPhysicalMesh() != h_data.myPhysicalMesh ) // avoid duplication of DumpPython commands
2292 h->SetPhysicalMesh( (int) h_data.myPhysicalMesh );
2293 if ( h->GetGeometricMesh() != (int) h_data.myGeometricMesh )
2294 h->SetGeometricMesh( (int) h_data.myGeometricMesh );
2296 if ( ((int) h_data.myPhysicalMesh == PhysicalGlobalSize)||((int) h_data.myPhysicalMesh == PhysicalLocalSize) ) {
2297 if ( h->GetPhySize() != h_data.myPhySize ||
2298 h->IsPhySizeRel() != h_data.myPhySizeRel ) {
2299 if ( h_data.myPhySizeRel )
2300 h->SetPhySizeRel( h_data.myPhySize );
2302 h->SetPhySize( h_data.myPhySize );
2305 if (h->GetMinSize() != h_data.myMinSize ||
2306 h->IsMinSizeRel() != h_data.myMinSizeRel ) {
2307 if ( h_data.myMinSizeRel )
2308 h->SetMinSizeRel( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2310 h->SetMinSize( h_data.myMinSize <= 0 ? -1 : h_data.myMinSize );
2312 if (h->GetMaxSize() != h_data.myMaxSize ||
2313 h->IsMaxSizeRel() != h_data.myMaxSizeRel ) {
2314 if ( h_data.myMaxSizeRel )
2315 h->SetMaxSizeRel( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2317 h->SetMaxSize( h_data.myMaxSize <= 0 ? -1 : h_data.myMaxSize );
2319 if ( h->GetUseGradation() != h_data.myUseGradation )
2320 h->SetUseGradation( h_data.myUseGradation );
2321 if ( h->GetGradation() != h_data.myGradation )
2322 h->SetGradation( h_data.myGradation <= 0 ? -1 : h_data.myGradation );
2323 if ( h->GetUseVolumeGradation() != h_data.myUseVolumeGradation )
2324 h->SetUseVolumeGradation( h_data.myUseVolumeGradation );
2325 if ( h->GetVolumeGradation() != h_data.myVolumeGradation )
2326 h->SetVolumeGradation( h_data.myVolumeGradation <= 0 ? -1 : h_data.myVolumeGradation );
2328 h->SetSurfaceProximity ( h_data.myUseSurfaceProximity );
2329 h->SetNbSurfaceProximityLayers( h_data.myNbSurfaceProximityLayers );
2330 h->SetSurfaceProximityRatio ( h_data.mySurfaceProximityRatio );
2331 h->SetVolumeProximity ( h_data.myUseVolumeProximity );
2332 h->SetNbVolumeProximityLayers ( h_data.myNbVolumeProximityLayers );
2333 h->SetVolumeProximityRatio ( h_data.myVolumeProximityRatio );
2335 if ( h->GetElementType() != h_data.myElementType )
2336 h->SetElementType( h_data.myElementType );
2338 if ( (int) h_data.myGeometricMesh != DefaultGeom ) {
2339 if ( h->GetAngleMesh() != h_data.myAngleMesh )
2340 h->SetAngleMesh( h_data.myAngleMesh <= 0 ? -1 :h_data.myAngleMesh );
2341 if ( h->GetChordalError() != h_data.myChordalError )
2342 h->SetChordalError( h_data.myChordalError <= 0 ? -1 :h_data.myChordalError );
2345 if ( h->GetAnisotropic() != h_data.myAnisotropic )
2346 h->SetAnisotropic( h_data.myAnisotropic );
2347 if ( h_data.myAnisotropic && ( h->GetAnisotropicRatio() != h_data.myAnisotropicRatio ) )
2348 h->SetAnisotropicRatio( h_data.myAnisotropicRatio <= 0 ? -1 :h_data.myAnisotropicRatio );
2350 if ( h->GetRemoveTinyEdges() != h_data.myRemoveTinyEdges )
2351 h->SetRemoveTinyEdges( h_data.myRemoveTinyEdges );
2352 if ( h_data.myRemoveTinyEdges && ( h->GetTinyEdgeLength() != h_data.myTinyEdgeLength ) )
2353 h->SetTinyEdgeLength( h_data.myTinyEdgeLength <= 0 ? -1 :h_data.myTinyEdgeLength );
2355 if ( h->GetOptimiseTinyEdges() != h_data.myOptimiseTinyEdges )
2356 h->SetOptimiseTinyEdges( h_data.myOptimiseTinyEdges );
2357 if ( h_data.myOptimiseTinyEdges && ( h->GetTinyEdgeOptimisationLength() != h_data.myTinyEdgeOptimisLength ) )
2358 h->SetTinyEdgeOptimisationLength( h_data.myTinyEdgeOptimisLength <= 0 ? -1 :h_data.myTinyEdgeOptimisLength );
2359 if ( h->GetCorrectSurfaceIntersection() != h_data.myCorrectSurfaceIntersection )
2360 h->SetCorrectSurfaceIntersection( h_data.myCorrectSurfaceIntersection );
2361 if ( h_data.myCorrectSurfaceIntersection && ( h->GetCorrectSurfaceIntersectionMaxCost() != h_data.myCorrectSurfaceIntersectionMaxCost ) )
2362 h->SetCorrectSurfaceIntersectionMaxCost( h_data.myCorrectSurfaceIntersectionMaxCost <= 0 ? -1 :h_data.myCorrectSurfaceIntersectionMaxCost );
2364 if ( h->GetBadElementRemoval() != h_data.myForceBadElementRemoval )
2365 h->SetBadElementRemoval( h_data.myForceBadElementRemoval );
2366 if ( h_data.myForceBadElementRemoval && ( h->GetBadElementAspectRatio() != h_data.myBadElementAspectRatio ) )
2367 h->SetBadElementAspectRatio( h_data.myBadElementAspectRatio <= 0 ? -1 :h_data.myBadElementAspectRatio );
2369 if ( h->GetOptimizeMesh() != h_data.myOptimizeMesh )
2370 h->SetOptimizeMesh( h_data.myOptimizeMesh );
2372 if ( h->GetQuadraticMesh() != h_data.myQuadraticMesh )
2373 h->SetQuadraticMesh( h_data.myQuadraticMesh );
2375 if ( h->GetVerbosity() != h_data.myVerbosity )
2376 h->SetVerbosity( h_data.myVerbosity );
2377 // if ( h->GetTopology() != h_data.myTopology )
2378 // h->SetTopology( (int) h_data.myTopology );
2379 // if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges )
2380 // h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges );
2381 // if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology )
2382 // h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology );
2383 // if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput )
2384 // h->SetPreCADDiscardInput( h_data.myPreCADDiscardInput );
2386 // options are set in checkParams()
2387 //h->SetOptionValues( myOptions ); // is set in readParamsFromWidgets()
2388 //h->SetPreCADOptionValues( myPreCADOptions ); // is set in readParamsFromWidgets()
2390 if ( h->GetGMFFile() != h_data.myGMFFileName )
2391 // || ( h->GetGMFFileMode() != h_data.myGMFFileMode ) )
2392 // h->SetGMFFile( h_data.myGMFFileName.c_str(), h_data.myGMFFileMode );
2393 h->SetGMFFile( h_data.myGMFFileName.c_str());
2395 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2396 QMapIterator<QString,QString> i(that->mySMPMap);
2397 while (i.hasNext()) {
2399 const QString entry = i.key();
2400 const QString sizeMap = i.value();
2402 if (sizeMap == "__TO_DELETE__") {
2403 h->UnsetEntry(entry.toLatin1().constData());
2405 else if (sizeMap.startsWith("ATTRACTOR")) {
2406 h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData());
2408 else if (sizeMap.startsWith("def")) {
2409 // h->SetCustomSizeMapEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() );
2412 if (!myATTMap[entry].empty()){
2413 const TAttractorVec& attVec = myATTMap[entry];
2414 for ( size_t i = 0; i < attVec.size(); ++i )
2416 if ( attVec[i].IsToDelete() )
2417 h->UnsetAttractorEntry( entry.toLatin1().constData(),
2418 attVec[i].attEntry.c_str() );
2420 h->SetClassAttractorEntry( entry.toLatin1().constData(),
2421 attVec[i].attEntry.c_str(),
2422 attVec[i].startSize,
2425 attVec[i].constDist );
2429 QString fullSizeMap;
2430 fullSizeMap = QString("");
2431 if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE)
2432 fullSizeMap = QString("def f(u,v): return ") + sizeMap;
2433 else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE)
2434 fullSizeMap = QString("def f(t): return ") + sizeMap;
2435 else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX)
2436 fullSizeMap = QString("def f(): return ") + sizeMap;
2437 h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
2442 // Enforced vertices
2445 std::string enfName;
2447 std::string groupName = "";
2450 TFaceEntryEnfVertexListMap::const_iterator evmIt = h_data.faceEntryEnfVertexListMap.begin();
2451 // 1. Clear all enforced vertices in hypothesis
2452 // 2. Add new enforced vertex according to h_data
2454 if ( h->GetAllEnforcedVertices()->length() > 0 )
2455 h->ClearAllEnforcedVertices();
2458 TEnfVertexList::const_iterator evsIt;
2459 for ( ; evmIt != h_data.faceEntryEnfVertexListMap.end() ; ++evmIt)
2461 faceEntry = evmIt->first;
2462 evs = evmIt->second;
2463 evsIt = evs.begin();
2464 for ( ; evsIt != evs.end() ; ++evsIt)
2467 if ((*evsIt)->coords.size()) {
2468 x = (*evsIt)->coords[0];
2469 y = (*evsIt)->coords[1];
2470 z = (*evsIt)->coords[2];
2473 h->SetEnforcedVertexEntry( faceEntry.c_str(), x, y, z, (*evsIt)->name.c_str(), (*evsIt)->geomEntry.c_str(), (*evsIt)->grpName.c_str());
2477 if ( h->GetInternalEnforcedVertexAllFaces() != h_data.myInternalEnforcedVerticesAllFaces )
2478 h->SetInternalEnforcedVertexAllFaces( h_data.myInternalEnforcedVerticesAllFaces );
2479 if ( h->GetInternalEnforcedVertexAllFacesGroup() != h_data.myInternalEnforcedVerticesAllFacesGroup )
2480 h->SetInternalEnforcedVertexAllFacesGroup( h_data.myInternalEnforcedVerticesAllFacesGroup.c_str() );
2483 if ( h->GetPreCadFacesPeriodicityVector()->length() > 0 || h->GetPreCadEdgesPeriodicityVector()->length() > 0 )
2484 h->ClearPreCadPeriodicityVectors();
2486 TPreCadPeriodicityVector::const_iterator pIt = h_data.preCadPeriodicityVector.begin();
2487 for ( ; pIt != h_data.preCadPeriodicityVector.end() ; ++pIt)
2489 TPreCadPeriodicity periodicity_i = *pIt;
2490 TEntry source = periodicity_i[PERIODICITY_OBJ_SOURCE_COLUMN];
2491 TEntry target = periodicity_i[PERIODICITY_OBJ_TARGET_COLUMN];
2492 TEntry p1Source = periodicity_i[PERIODICITY_P1_SOURCE_COLUMN];
2493 TEntry p2Source = periodicity_i[PERIODICITY_P2_SOURCE_COLUMN];
2494 TEntry p3Source = periodicity_i[PERIODICITY_P3_SOURCE_COLUMN];
2495 TEntry p1Target = periodicity_i[PERIODICITY_P1_TARGET_COLUMN];
2496 TEntry p2Target = periodicity_i[PERIODICITY_P2_TARGET_COLUMN];
2497 TEntry p3Target = periodicity_i[PERIODICITY_P3_TARGET_COLUMN];
2498 bool onFace = (periodicity_i[PERIODICITY_SHAPE_TYPE]=="1") ? true : false;
2500 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
2501 if (! p1Source.empty())
2503 sourceVertices->length(3);
2504 sourceVertices[0]=CORBA::string_dup(p1Source.c_str());
2505 sourceVertices[1]=CORBA::string_dup(p2Source.c_str());
2506 sourceVertices[2]=CORBA::string_dup(p3Source.c_str());
2510 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
2511 if (! p1Target.empty())
2513 targetVertices->length(3);
2514 targetVertices[0]=CORBA::string_dup(p1Target.c_str());
2515 targetVertices[1]=CORBA::string_dup(p2Target.c_str());
2516 targetVertices[2]=CORBA::string_dup(p3Target.c_str());
2520 h->AddPreCadFacesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2522 h->AddPreCadEdgesPeriodicityEntry(source.c_str(), target.c_str(), sourceVertices, targetVertices);
2526 BLSURFPlugin::THyperPatchList_var hpl = new BLSURFPlugin::THyperPatchList();
2527 hpl->length( h_data.hyperpatches.size() );
2529 for ( int i = 0; i < h_data.hyperpatches.size(); ++i )
2531 QStringList tags = h_data.hyperpatches[i].split(" ", QString::SkipEmptyParts);
2532 BLSURFPlugin::THyperPatch& patch = hpl[ i ];
2533 patch.length( tags.size() );
2535 for ( int j = 0; j < tags.size(); ++j )
2536 patch[ j ] = tags[ j ].toDouble();
2538 h->SetHyperPatches( hpl );
2549 /** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
2550 Stores the widgets content to the hypothesis data.
2552 QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
2554 h_data.myName = myName ? myName->text() : "";
2555 h_data.myPhysicalMesh = myStdWidget->myPhysicalMesh->currentIndex();
2556 h_data.myGeometricMesh = myStdWidget->myGeometricMesh->currentIndex();
2557 h_data.myPhySize = myStdWidget->myPhySize->text().isEmpty() ? -1.0 : myStdWidget->myPhySize->GetValue();
2558 h_data.myPhySizeRel = myStdWidget->myPhySizeRel->isChecked();
2559 h_data.myMinSize = myStdWidget->myMinSize->text().isEmpty() ? -1.0 : myStdWidget->myMinSize->GetValue();
2560 h_data.myMinSizeRel = myStdWidget->myMinSizeRel->isChecked();
2561 h_data.myMaxSize = myStdWidget->myMaxSize->text().isEmpty() ? -1.0 : myStdWidget->myMaxSize->GetValue();
2562 h_data.myMaxSizeRel = myStdWidget->myMaxSizeRel->isChecked();
2563 h_data.myUseGradation = myStdWidget->myUseGradation->isChecked() && !myStdWidget->myGradation->text().isEmpty();
2564 h_data.myGradation = h_data.myUseGradation ? myStdWidget->myGradation->GetValue() : -1.0;
2565 h_data.myUseVolumeGradation = myStdWidget->myUseVolumeGradation->isChecked() && !myStdWidget->myVolumeGradation->text().isEmpty();
2566 h_data.myVolumeGradation = h_data.myUseVolumeGradation ? myStdWidget->myVolumeGradation->GetValue() : -1. ;
2567 h_data.myElementType = myStdWidget->myButtonGroupElementType->checkedId();
2568 h_data.myAngleMesh = myStdWidget->myAngleMesh->text().isEmpty() ? -1.0 : myStdWidget->myAngleMesh->GetValue();
2569 h_data.myChordalError = myStdWidget->myChordalError->text().isEmpty() ? -1.0 : myStdWidget->myChordalError->GetValue();
2570 h_data.myAnisotropic = myStdWidget->myAnisotropic->isChecked();
2571 h_data.myAnisotropicRatio = myStdWidget->myAnisotropicRatio->text().isEmpty() ? -1.0 : myStdWidget->myAnisotropicRatio->GetValue();
2572 h_data.myRemoveTinyEdges = myStdWidget->myRemoveTinyEdges->isChecked();
2573 h_data.myTinyEdgeLength = myStdWidget->myTinyEdgeLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeLength->GetValue();
2574 h_data.myOptimiseTinyEdges = myStdWidget->myOptimiseTinyEdges->isChecked();
2575 h_data.myTinyEdgeOptimisLength = myStdWidget->myTinyEdgeOptimisLength->text().isEmpty() ? -1.0 : myStdWidget->myTinyEdgeOptimisLength->GetValue();
2576 h_data.myCorrectSurfaceIntersection = myStdWidget->myCorrectSurfaceIntersection->isChecked();
2577 h_data.myCorrectSurfaceIntersectionMaxCost = myStdWidget->myCorrectSurfaceIntersectionMaxCost->text().isEmpty() ? -1.0 : myStdWidget->myCorrectSurfaceIntersectionMaxCost->GetValue();
2578 h_data.myForceBadElementRemoval= myStdWidget->myForceBadElementRemoval->isChecked();
2579 h_data.myBadElementAspectRatio = myStdWidget->myBadElementAspectRatio->text().isEmpty() ? -1.0 : myStdWidget->myBadElementAspectRatio->GetValue();
2580 h_data.myOptimizeMesh = myStdWidget->myOptimizeMesh->isChecked();
2581 h_data.myQuadraticMesh = myStdWidget->myQuadraticMesh->isChecked();
2582 h_data.myVerbosity = myAdvWidget->myVerbosity->value();
2583 //h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD;
2584 //h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked();
2585 //h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked();
2586 //h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked();
2587 h_data.myUseSurfaceProximity = myStdWidget->myUseSurfaceProximity ->isChecked();
2588 h_data.myNbSurfaceProximityLayers = myStdWidget->myNbSurfaceProximityLayers->value();
2589 h_data.mySurfaceProximityRatio = myStdWidget->mySurfaceProximityRatio ->value();
2590 h_data.myUseVolumeProximity = myStdWidget->myUseVolumeProximity ->isChecked();
2591 h_data.myNbVolumeProximityLayers = myStdWidget->myNbVolumeProximityLayers ->value();
2592 h_data.myVolumeProximityRatio = myStdWidget->myVolumeProximityRatio ->value();
2595 guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; ";
2596 guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; ";
2597 guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; ";
2598 guiHyp += tr("BLSURF_HPHYDEF") + " " + tr("BLSURF_SIZE_REL") +" = " + QString(h_data.myPhySizeRel ? "yes" : "no") + "; ";
2599 guiHyp += tr("BLSURF_MINSIZE") + " = "+ QString::number( h_data.myMinSize ) + "; ";
2600 guiHyp += tr("BLSURF_MINSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMinSizeRel ? "yes" : "no") + "; ";
2601 guiHyp += tr("BLSURF_MAXSIZE") + " = "+ QString::number( h_data.myMaxSize ) + "; ";
2602 guiHyp += tr("BLSURF_MAXSIZE") + " " + tr("BLSURF_SIZE_REL") + " = " + QString(h_data.myMaxSizeRel ? "yes" : "no") + "; ";
2603 guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; ";
2604 guiHyp += tr("BLSURF_ELEMENT_TYPE") + " = " + QString::number(h_data.myElementType) + "; ";
2605 guiHyp += tr("BLSURF_ANGLE_MESH") + " = " + QString::number( h_data.myAngleMesh ) + "; ";
2606 guiHyp += tr("BLSURF_CHORDAL_ERROR") + " = " + QString::number( h_data.myChordalError ) + "; ";
2607 guiHyp += tr("BLSURF_ANISOTROPIC") + " = " + QString(h_data.myAnisotropic ? "yes" : "no") + "; ";
2608 guiHyp += tr("BLSURF_ANISOTROPIC_RATIO") + " = " + QString::number( h_data.myAnisotropicRatio ) + "; ";
2611 guiHyp += tr("BLSURF_REMOVE_TINY_EDGES") + " = " + QString(h_data.myRemoveTinyEdges ? "yes" : "no") + "; ";
2612 guiHyp += tr("BLSURF_TINY_EDGES_LENGTH") + " = " + QString::number( h_data.myTinyEdgeLength ) + "; ";
2613 guiHyp += tr("BLSURF_REMOVE_SLIVERS") + " = " + QString(h_data.myForceBadElementRemoval ? "yes" : "no") + "; ";
2614 guiHyp += tr("BLSURF_BAD_SURFACE_ELEMENT_ASPECT_RATIO") + " = " + QString::number( h_data.myBadElementAspectRatio ) + "; ";
2615 guiHyp += tr("BLSURF_OPTIMISATION") + " = " + QString(h_data.myOptimizeMesh ? "yes" : "no") + "; ";
2616 guiHyp += tr("BLSURF_ELEMENT_ORDER") + " = " + QString(h_data.myQuadraticMesh ? "yes" : "no") + "; ";
2619 // guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; ";
2620 // guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; ";
2621 // guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; ";
2622 // guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; ";
2624 h_data.myGMFFileName = myAdvWidget->myGMFFileName->text().toStdString();
2625 // h_data.myGMFFileMode = myGMFFileMode->isChecked();
2628 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2629 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
2630 for ( ; row < nbRows; ++row )
2632 QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString();
2633 if ( that->mySMPMap.contains(entry) )
2634 guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
2637 // Enforced vertices
2638 h_data.enfVertexList.clear();
2639 h_data.faceEntryEnfVertexListMap.clear();
2641 int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
2642 std::string groupName = "", faceEntry = "";
2643 for (int i=0 ; i<nbEnforcedShapes ; i++)
2645 double childValueX,childValueY,childValueZ;
2646 std::string childName, vertexEntry;
2647 QTreeWidgetItem* child;
2649 child = myEnforcedTreeWidget->topLevelItem(i);
2650 childName = child->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString().toStdString();
2651 childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
2652 childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
2653 childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
2654 vertexEntry = child->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
2655 // if (myGlobalGroupName->isChecked())
2656 // groupName = myGlobalGroupName->text().toStdString();
2658 groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString();
2660 TEnfVertex *enfVertex = new TEnfVertex();
2661 enfVertex->name = childName;
2662 if (vertexEntry.empty()) {
2663 enfVertex->coords.push_back(childValueX);
2664 enfVertex->coords.push_back(childValueY);
2665 enfVertex->coords.push_back(childValueZ);
2668 enfVertex->geomEntry = vertexEntry;
2669 enfVertex->grpName = groupName;
2670 // TEnfVertexList::iterator it = h_data.enfVertexList.find(enfVertex);
2671 // if (it == h_data.enfVertexList.end())
2672 h_data.enfVertexList.insert(enfVertex);
2674 if (groupName != "")
2675 h_data.groupNameEnfVertexListMap[groupName].insert(vertex);
2677 h_data.faceEntryEnfVertexListMap[faceEntry].insert( enfVertex );
2680 h_data.myInternalEnforcedVerticesAllFaces = myInternalEnforcedVerticesAllFaces->isChecked();
2681 h_data.myInternalEnforcedVerticesAllFacesGroup = myInternalEnforcedVerticesAllFacesGroup->text().toStdString();
2684 h_data.preCadPeriodicityVector.clear();
2685 // For each tree item, store each value. Shapes are stored as entries.
2686 int nbPeriodicityDescriptions = myPeriodicityTreeWidget->topLevelItemCount();
2687 for (int i=0 ; i<nbPeriodicityDescriptions ; i++) {
2688 QTreeWidgetItem* item = myPeriodicityTreeWidget->topLevelItem(i);
2689 TPreCadPeriodicity periodicity_i;
2691 for (int k=0; k<myPeriodicityTreeWidget->columnCount(); ++k)
2693 std::string entry = item->data(k, Qt::UserRole).toString().toStdString();
2694 periodicity_i.push_back(entry);
2696 h_data.preCadPeriodicityVector.push_back(periodicity_i);
2698 guiHyp += "PERIODICITY = yes; ";
2702 h_data.hyperpatches.clear();
2703 for ( int row = 0; row < myHyPatchTable->rowCount(); ++row )
2704 h_data.hyperpatches.append( myHyPatchTable->item( row, 0 )->text() );
2709 void BLSURFPluginGUI_HypothesisCreator::onAddOption()
2711 myAdvWidget->AddOption( TBL_CUSTOM, NULL );
2714 void BLSURFPluginGUI_HypothesisCreator::onChangeOptionName( int row, int column )
2716 // if ( column != OPTION_NAME_COLUMN )
2718 // myAdvWidget->myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
2721 // **********************
2722 // *** BEGIN SIZE MAP ***
2723 // **********************
2725 void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified()
2727 if ( myGeomSelWdg2->IsObjectSelected() ){
2728 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
2730 else if ( myGeomSelWdg1->IsObjectSelected() ){
2731 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
2734 mySMapObject = GEOM::GEOM_Object::_nil();
2736 bool dataAvailable = !mySMapObject->_is_nil();
2738 if ( dataAvailable )
2739 qEntry = SMESH::toQStr( mySMapObject->GetStudyEntry() );
2741 bool mapExists = ( mySMPMap.contains(qEntry) && mySMPMap[qEntry] != "__TO_DELETE__" );
2742 if (( mapExists && myGeomSelWdg2->IsObjectSelected() ) &&
2743 ( dataAvailable = myAttSelWdg->isEnabled() ) &&
2744 ( dataAvailable = myAttSelWdg->IsObjectSelected() ) &&
2745 ( myATTMap.contains( qEntry )))
2748 QString attEntry = myAttSelWdg->GetValue();
2749 const TAttractorVec& attVec = myATTMap[ qEntry ];
2750 for ( size_t i = 0; i < attVec.size() && !mapExists; ++i )
2751 mapExists = ( attEntry == attVec[i].attEntry.c_str() );
2754 addMapButton->setEnabled( !mapExists && dataAvailable );
2755 modifyMapButton->setEnabled( mapExists && dataAvailable );
2758 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
2760 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2761 if (col == SMP_SIZEMAP_COLUMN) {
2762 QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2764 if (!mySMPMap.contains(entry))
2766 if ( QTreeWidgetItem* parent = item->parent() )
2770 entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
2772 if (!mySMPMap.contains(entry))
2775 QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString();
2776 CORBA::Object_var obj = entryToObject(entry);
2777 if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")) { // ADVANCED MAPS
2778 smpTab->setCurrentIndex(ATT_TAB); // Change Tab
2779 // Retrieve values of the selected item in the current tab widgets
2780 const TAttractorVec& attVec = myATTMap[entry];
2781 if ( !attVec.empty() )
2784 if ( !childEntry.isEmpty() )
2785 for ( size_t i = 0; i < attVec.size(); ++i )
2786 if ( childEntry == attVec[i].attEntry.c_str() )
2791 double phySize = attVec[iAtt].startSize;
2792 double infDist = attVec[iAtt].infDist;
2793 double constDist = attVec[iAtt].constDist;
2794 QString attEntry = attVec[iAtt].attEntry.c_str();
2795 CORBA::Object_var attObj = entryToObject(attEntry);
2796 myAttSizeSpin->setValue(phySize);
2797 if ( infDist > std::numeric_limits<double>::epsilon() /*sizeMap.startsWith("Attractor")*/){
2798 myAttDistSpin->setValue(infDist);
2799 myAttractorCheck->setChecked(true);
2802 myAttractorCheck->setChecked(false);
2804 if (/*sizeMap.startsWith("Constant") || */constDist > std::numeric_limits<double>::epsilon()){
2805 myAttDistSpin2->setValue(constDist);
2806 myConstSizeCheck->setChecked(true);
2809 myConstSizeCheck->setChecked(false);
2811 myGeomSelWdg2->SetObject(obj);
2812 myAttSelWdg->SetObject(attObj);
2815 else { // CLASSIC MAPS
2816 smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab
2817 myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets
2818 if (!sizeMap.startsWith("def")){
2819 mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble());
2825 void BLSURFPluginGUI_HypothesisCreator::onTabChanged(int tab)
2827 getGeomSelectionTool()->selectionMgr()->clearFilters();
2828 if ( sender() == myTabWidget )
2830 myGeomSelWdg1 ->deactivateSelection();
2831 myGeomSelWdg2 ->deactivateSelection();
2832 myAttSelWdg ->deactivateSelection();
2833 myEnfVertexWdg ->deactivateSelection();
2834 myPeriodicitySourceFaceWdg->deactivateSelection();
2835 myPeriodicityTargetFaceWdg->deactivateSelection();
2836 myPeriodicityP1SourceWdg ->deactivateSelection();
2837 myPeriodicityP2SourceWdg ->deactivateSelection();
2838 myPeriodicityP3SourceWdg ->deactivateSelection();
2839 myPeriodicityP1TargetWdg ->deactivateSelection();
2840 myPeriodicityP2TargetWdg ->deactivateSelection();
2841 myPeriodicityP3TargetWdg ->deactivateSelection();
2842 if ( myHyPatchFaceSelBtn->isChecked() )
2843 myHyPatchFaceSelBtn->toggle();
2844 if ( myHyPatchGroupSelBtn->isChecked() )
2845 myHyPatchGroupSelBtn->toggle();
2847 else if ( sender() == smpTab )
2849 myAttDistSpin->setValue(0.); // Reinitialize widgets
2850 myAttSizeSpin->setValue(0.);
2851 myAttDistSpin2->setValue(0.);
2852 mySmpSizeSpin->setValue(0.);
2853 myGeomSelWdg1->deactivateSelection();
2854 myGeomSelWdg2->deactivateSelection();
2855 myAttSelWdg->deactivateSelection();
2856 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
2857 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
2858 myAttSelWdg->SetObject(CORBA::Object::_nil());
2859 myAttractorCheck->setChecked(false);
2860 myConstSizeCheck->setChecked(false);
2863 if ( tab == SMP_TAB ) // [#16954] limit local size by Min and User Size
2865 double minSize = 0, maxSize = COORD_MAX;
2867 if ( !myStdWidget->myMinSizeRel->isChecked() &&
2868 !myStdWidget->myMinSize->text().isEmpty() )
2869 minSize = myStdWidget->myMinSize->GetValue();
2871 if ( !myStdWidget->myPhySizeRel->isChecked() &&
2872 !myStdWidget->myPhySize->text().isEmpty() )
2873 maxSize = myStdWidget->myPhySize->GetValue();
2875 mySmpSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
2876 myAttSizeSpin->RangeStepAndValidator(minSize, maxSize, 1.0, "length_precision");
2880 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
2882 if (state == Qt::Checked){
2883 myAttSelWdg->setEnabled(true);
2884 myAttSizeSpin->setEnabled(true);
2885 myAttSizeLabel->setEnabled(true);
2886 myAttDistSpin->setEnabled(true);
2887 myAttDistLabel->setEnabled(true);
2888 if (!myAttSelWdg->IsObjectSelected()){
2889 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2892 if (state == Qt::Unchecked){
2893 myAttDistSpin->setEnabled(false);
2894 myAttDistLabel->setEnabled(false);
2895 myAttDistSpin->setValue(0.);
2896 if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2897 myAttSelWdg->setEnabled(false);
2898 myAttSizeSpin->setEnabled(false);
2899 myAttSizeLabel->setEnabled(false);
2900 myAttDistSpin2->setEnabled(false);
2901 myAttDistLabel2->setEnabled(false);
2903 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2904 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2907 onMapGeomContentModified();
2910 void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state)
2912 if (state == Qt::Checked){
2913 myAttSelWdg->setEnabled(true);
2914 myAttSizeSpin->setEnabled(true);
2915 myAttSizeLabel->setEnabled(true);
2916 myAttDistSpin2->setEnabled(true);
2917 myAttDistLabel2->setEnabled(true);
2918 if (myAttractorCheck->checkState() == Qt::Unchecked &&
2919 !myAttSelWdg->IsObjectSelected()){
2920 myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }");
2923 if (state == Qt::Unchecked){
2924 myAttDistSpin2->setEnabled(false);
2925 myAttDistLabel2->setEnabled(false);
2926 myAttDistSpin2->setValue(0.);
2927 if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected
2928 myAttSelWdg->setEnabled(false);
2929 myAttSizeSpin->setEnabled(false);
2930 myAttSizeLabel->setEnabled(false);
2931 myAttDistSpin->setEnabled(false);
2932 myAttDistLabel->setEnabled(false);
2934 else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected
2935 myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }");
2938 onMapGeomContentModified();
2941 void BLSURFPluginGUI_HypothesisCreator::onRemoveMap()
2943 QList<int> selectedRows;
2944 QList<QTreeWidgetItem*> selected = mySizeMapTable->selectedItems();
2945 QTreeWidgetItem* item;
2946 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2948 qSort( selectedRows );
2949 QListIterator<QTreeWidgetItem*> it( selected );
2951 while ( it.hasPrevious() ) {
2952 item = it.previous();
2953 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2954 QString parentEntry;
2955 if ( QTreeWidgetItem* parent = item->parent() )
2956 parentEntry = parent->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2957 if (that->mySMPMap.contains(entry))
2959 that->mySMPMap[entry] = "__TO_DELETE__";
2960 if ( myATTMap.contains( entry ))
2962 TAttractorVec& attVec = myATTMap[entry];
2963 for ( size_t i = 0; i < attVec.size(); ++i )
2964 attVec[i].SetToDelete();
2967 else if ( mySMPMap.contains( parentEntry ) && myATTMap.contains( parentEntry ))
2969 TAttractorVec& attVec = myATTMap[parentEntry];
2970 for ( size_t i = 0; i < attVec.size(); ++i )
2972 if ( entry == attVec[i].attEntry.c_str() )
2973 attVec[i].SetToDelete();
2976 if (that->mySMPShapeTypeMap.contains(entry))
2977 that->mySMPShapeTypeMap.remove(entry);
2978 // if (that->myDistMap.contains(entry))
2979 // that->myDistMap.remove(entry);
2980 // if (that->myAttDistMap.contains(entry))
2981 // that->myAttDistMap.remove(entry);
2984 mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
2985 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
2988 void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col)
2990 if (col == SMP_SIZEMAP_COLUMN) {
2991 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
2992 QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString();
2993 QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString();
2994 if (! that->mySMPShapeTypeMap.contains(entry))
2996 if (that->mySMPMap.contains(entry))
2997 if (that->mySMPMap[entry] == sizeMap
2998 || sizeMap.startsWith("Attractor")
2999 || sizeMap.startsWith("Constant") ){
3002 if (! sizeMap.isEmpty()) {
3003 that->mySMPMap[entry] = sizeMap;
3004 sizeMapValidationFromEntry(entry);
3007 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
3009 mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
3013 void BLSURFPluginGUI_HypothesisCreator::onAddMap()
3016 if ( smpTab->currentIndex() == ATT_TAB ){
3017 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3018 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3019 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3020 res = insertAttractor(mySMapObject, myAttObject);
3023 if (smpTab->currentIndex() == SMP_STD_TAB ){
3024 if ( myGeomSelWdg1->IsObjectSelected() ){
3025 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3026 res = insertElement(mySMapObject);
3030 // Local size should be more than 0
3031 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3032 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3035 getGeomSelectionTool()->selectionMgr()->clearFilters();
3036 myAttDistSpin->setValue(0.);
3037 myAttSizeSpin->setValue(0.);
3038 myAttDistSpin2->setValue(0.);
3039 mySmpSizeSpin->setValue(0.);
3040 myConstSizeCheck->setChecked(false);
3041 myAttractorCheck->setChecked(false);
3042 myGeomSelWdg1->deactivateSelection();
3043 myGeomSelWdg2->deactivateSelection();
3044 myAttSelWdg->deactivateSelection();
3045 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3046 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3047 myAttSelWdg->SetObject(CORBA::Object::_nil());
3050 void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
3053 if ( smpTab->currentIndex() == ATT_TAB ){
3054 if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){
3055 mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
3056 myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0);
3057 res = insertAttractor(mySMapObject, myAttObject, /*modify = */true);
3060 if (smpTab->currentIndex() == SMP_STD_TAB ){
3061 if ( myGeomSelWdg1->IsObjectSelected() ){
3062 mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
3063 res = insertElement(mySMapObject, /*modify = */true);
3067 // Local size should be more than 0
3068 QString msg = tr("ZERO_VALUE_OF").arg( tr("BLSURF_SM_SIZE"));
3069 SUIT_MessageBox::critical( dlg(),"Error" , msg );
3072 getGeomSelectionTool()->selectionMgr()->clearFilters();
3073 myAttDistSpin->setValue(0.);
3074 myAttSizeSpin->setValue(0.);
3075 myAttDistSpin2->setValue(0.);
3076 mySmpSizeSpin->setValue(0.);
3077 myConstSizeCheck->setChecked(false);
3078 myAttractorCheck->setChecked(false);
3079 myGeomSelWdg1->deactivateSelection();
3080 myGeomSelWdg2->deactivateSelection();
3081 myAttSelWdg->deactivateSelection();
3082 myGeomSelWdg1->SetObject(CORBA::Object::_nil());
3083 myGeomSelWdg2->SetObject(CORBA::Object::_nil());
3084 myAttSelWdg->SetObject(CORBA::Object::_nil());
3087 bool BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
3089 // BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3090 // BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3092 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3094 TopAbs_ShapeEnum shapeType;
3095 string entry, shapeName;
3096 entry = (string) anObject->GetStudyEntry();
3097 shapeName = anObject->GetName();
3098 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject ).ShapeType();
3099 // Group management : the type of entities in the group is stored in the SMPShapeTypeMap
3100 // in order to write the size map with the right syntax in StoreParamsToHypo
3101 // (f(t) for edges, f(u,v) for faces ...)
3102 if (shapeType == TopAbs_COMPOUND){
3103 TopoDS_Shape theShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( anObject );
3104 TopoDS_Shape childShape;
3105 TopoDS_Iterator anIt(theShape);
3106 for(;anIt.More();anIt.Next()){
3107 childShape = anIt.Value();
3108 shapeType = childShape.ShapeType();
3109 if(!childShape.IsNull()){
3114 mySizeMapTable->setFocus();
3116 shapeEntry = QString::fromStdString(entry);
3117 double phySize = mySmpSizeSpin->value();
3120 return false; // Local size should be more than 0
3122 std::ostringstream oss;
3125 sizeMap = QString::fromStdString(oss.str());
3126 QTreeWidgetItem* item = new QTreeWidgetItem();
3128 int rowToChange = findRowFromEntry(shapeEntry);
3129 item = mySizeMapTable->topLevelItem( rowToChange );
3132 if (that->mySMPMap.contains(shapeEntry)) {
3133 if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3137 mySizeMapTable->addTopLevelItem(item);
3139 that->mySMPMap[shapeEntry] = sizeMap;
3140 //that->myDistMap[shapeEntry] = 0. ;
3141 that->mySMPShapeTypeMap[shapeEntry] = shapeType;
3142 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3143 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3144 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) );
3145 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3146 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3147 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3148 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3149 mySizeMapTable->clearSelection();
3151 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3152 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3153 myStdWidget->onPhysicalMeshChanged();
3158 bool BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify)
3160 BLSURFPlugin::BLSURFPlugin_Hypothesis_var h =
3161 BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis());
3163 TopAbs_ShapeEnum shapeType;
3164 string entry, attEntry, faceName, attName;
3165 entry = (string) aFace->GetStudyEntry();
3166 attEntry = (string) anAttractor->GetStudyEntry();
3167 faceName = aFace->GetName();
3168 attName = anAttractor->GetName();
3169 shapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aFace ).ShapeType();
3170 mySizeMapTable->setFocus();
3171 QString shapeEntry = QString::fromStdString(entry);
3172 QString qAttEntry = QString::fromStdString(attEntry);
3174 double phySize = h->GetPhySize();
3175 double infDist = 0. ;
3176 double constDist = 0. ;
3177 phySize = myAttSizeSpin->value();
3180 return false; // Local size should be more than 0
3182 if (myAttractorCheck->isChecked()){
3183 infDist = myAttDistSpin->value();
3185 if (myConstSizeCheck->isChecked()){
3186 constDist = myAttDistSpin2->value();
3188 std::ostringstream oss;
3189 std::ostringstream oss2;
3190 std::ostringstream oss3;
3194 QString sizeMap = QString::fromStdString(oss.str());
3195 QString infDistString = QString::fromStdString(oss2.str());
3196 QString constDistString = QString::fromStdString(oss3.str());
3198 QTreeWidgetItem* item;
3199 QTreeWidgetItem* child = 0;
3200 TAttractor attParams( attEntry.c_str(), phySize, infDist, constDist );
3202 int rowToChange = findRowFromEntry(shapeEntry);
3203 item = mySizeMapTable->topLevelItem( rowToChange );
3205 for ( int i = 0, nb = item->childCount(); i < nb; ++i )
3206 if (( child = item->child( i )))
3207 if ( qAttEntry == child->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString() )
3209 TAttractorVec & attVec = myATTMap[shapeEntry];
3210 for ( size_t i = 0; i < attVec.size(); ++i )
3211 if ( attVec[i].attEntry == attEntry )
3213 attVec[i] = attParams;
3218 // if (that->mySMPMap.contains(shapeEntry)) {
3219 // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") {
3223 int rowToChange = findRowFromEntry(shapeEntry);
3224 if ( rowToChange < mySizeMapTable->topLevelItemCount() )
3226 item = mySizeMapTable->topLevelItem( rowToChange );
3229 item = new QTreeWidgetItem();
3230 mySizeMapTable->addTopLevelItem(item);
3232 child = new QTreeWidgetItem();
3233 item->addChild(child);
3234 bool exists = false;
3235 TAttractorVec & attVec = myATTMap[shapeEntry];
3236 for ( size_t i = 0; i < attVec.size(); ++i )
3237 if ( attVec[i].attEntry == attEntry )
3239 attVec[i] = attParams;
3244 myATTMap[shapeEntry].push_back( attParams );
3246 mySMPMap.insert(shapeEntry,sizeMap);
3247 mySMPShapeTypeMap.insert(shapeEntry,shapeType);
3248 item->setExpanded(true);
3249 item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) );
3250 item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) );
3251 if (infDist > std::numeric_limits<double>::epsilon()){
3252 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) );
3254 else if (constDist > std::numeric_limits<double>::epsilon()){
3255 item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) );
3257 item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled );
3259 child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) );
3260 child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) );
3261 child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) );
3263 mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
3264 mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
3265 mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN );
3267 if ( myStdWidget->myPhysicalMesh->currentIndex() != PhysicalLocalSize ) {
3268 myStdWidget->myPhysicalMesh->setCurrentIndex( PhysicalLocalSize );
3269 myStdWidget->onPhysicalMeshChanged();
3274 bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()
3276 int row = 0, nbRows = mySizeMapTable->topLevelItemCount();
3277 for ( ; row < nbRows; ++row )
3278 if (! sizeMapValidationFromRow(row))
3283 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError)
3285 QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3286 bool res = sizeMapValidationFromEntry(myEntry,displayError);
3287 mySizeMapTable->setFocus();
3291 bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry, bool displayError)
3294 BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
3296 if (! that->mySMPMap.contains(myEntry)) {
3299 if (! that->mySMPShapeTypeMap.contains(myEntry)) {
3305 if (that->mySMPMap[myEntry].startsWith("def")) {
3306 expr = that->mySMPMap[myEntry].toStdString();
3308 else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
3309 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)) {
3312 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])" );
3318 // case size map is empty
3319 if (that->mySMPMap[myEntry].isEmpty()) {
3321 SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
3325 if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
3326 expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
3327 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
3328 expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
3329 else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
3330 expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
3333 //assert(Py_IsInitialized());
3334 if (! Py_IsInitialized())
3335 throw ("Erreur: Python interpreter is not initialized");
3336 PyGILState_STATE gstate;
3337 gstate = PyGILState_Ensure();
3339 string err_description="";
3340 PyObject* obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL);
3344 PyObject* new_stderr = newPyStdOut(err_description);
3345 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3346 Py_INCREF(old_stderr);
3347 PySys_SetObject((char*)"stderr", new_stderr);
3349 PySys_SetObject((char*)"stderr", old_stderr);
3350 Py_DECREF(new_stderr);
3352 SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() );
3353 PyGILState_Release(gstate);
3358 PyObject* func = PyObject_GetAttrString(main_mod, "f");
3362 PyObject* new_stderr = newPyStdOut(err_description);
3363 PyObject* old_stderr = PySys_GetObject((char*)"stderr");
3364 Py_INCREF(old_stderr);
3365 PySys_SetObject((char*)"stderr", new_stderr);
3367 PySys_SetObject((char*)"stderr", old_stderr);
3368 Py_DECREF(new_stderr);
3370 SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() );
3371 PyGILState_Release(gstate);
3375 PyGILState_Release(gstate);
3381 //================================================================================
3383 * \brief SLOT: Activate selection of faces in the Viewer
3385 //================================================================================
3387 void BLSURFPluginGUI_HypothesisCreator::onHyPatchFaceSelection(bool on)
3389 if ( on && myHyPatchFaceSelector->GetMainShape().IsNull() )
3391 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
3392 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
3393 myHyPatchFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
3395 myHyPatchFaceSelector->setVisible( on ); // show its buttons
3396 myHyPatchFaceSelector->ShowPreview( on ); // show faces in the Viewer
3397 // treat selection or not
3398 myHyPatchFaceSelector->ActivateSelection( on || myHyPatchGroupSelBtn->isChecked() );
3401 myHyPatchGroupSelBtn->setChecked( false );
3404 //================================================================================
3406 * \brief SLOT: Deactivate selection of faces in the Viewer
3408 //================================================================================
3410 void BLSURFPluginGUI_HypothesisCreator::onHyPatchGroupSelection(bool on)
3412 if ( on && myHyPatchFaceSelector->GetMainShape().IsNull() )
3414 QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry();
3415 QString aSubEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry();
3416 myHyPatchFaceSelector->SetGeomShapeEntry( aSubEntry, aMainEntry );
3418 if ( !myHyPatchFaceSelBtn->isChecked() )
3420 myHyPatchFaceSelector->setVisible( false ); // show its buttons
3421 myHyPatchFaceSelector->ShowPreview( false ); // show faces in the Viewer
3423 // treat selection or not
3424 myHyPatchFaceSelector->ActivateSelection( on || myHyPatchFaceSelBtn->isChecked() );
3427 myHyPatchFaceSelBtn->setChecked( false );
3430 //================================================================================
3432 * \brief SLOT: show IDs of selected faces in Tags LineEdit
3434 //================================================================================
3436 void BLSURFPluginGUI_HypothesisCreator::onHyPatchSelectionChanged()
3439 const QList<int>& tags = myHyPatchFaceSelector->GetSelectedIDs();
3440 for ( int i = 0; i < tags.size(); ++i )
3441 tagString += QString::number( tags[i] ) + " ";
3443 myHyPatchTagsLE->setText( tagString );
3446 //================================================================================
3448 * \brief SLOT: Add the Tags to the HyperPatch table
3450 //================================================================================
3452 void BLSURFPluginGUI_HypothesisCreator::onHyPatchAdd()
3454 QStringList tagList = myHyPatchTagsLE->text().split(" ", QString::SkipEmptyParts);
3455 if ( tagList.size() > 1 )
3457 addHyPatchToTable( myHyPatchTagsLE->text() );
3458 myHyPatchTagsLE->setText("");
3462 //================================================================================
3464 * \brief Add a row to myHyPatchTable
3466 //================================================================================
3468 void BLSURFPluginGUI_HypothesisCreator::addHyPatchToTable(const QString& tags)
3470 if ( tags.isEmpty() ) return;
3472 QTableWidgetItem* cell = new QTableWidgetItem( tags );
3473 cell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
3475 int row = myHyPatchTable->rowCount();
3476 myHyPatchTable->insertRow( row );
3477 myHyPatchTable->setItem( row, 0, cell );
3480 //================================================================================
3482 * \brief SLOT: remove selected rows from the HyperPatch table
3484 //================================================================================
3486 void BLSURFPluginGUI_HypothesisCreator::onHyPatchRemove()
3488 QList<QTableWidgetItem *> items = myHyPatchTable->selectedItems();
3489 while ( !items.isEmpty() )
3491 myHyPatchTable->removeRow( items[0]->row() );
3492 items = myHyPatchTable->selectedItems();
3496 bool BLSURFPluginGUI_HypothesisCreator::hasGeom() const
3498 return hypType() == BLSURFPlugin_Hypothesis::GetHypType(true);
3501 QString BLSURFPluginGUI_HypothesisCreator::caption() const
3503 return tr( "BLSURF_TITLE" );
3506 QPixmap BLSURFPluginGUI_HypothesisCreator::icon() const
3508 return SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "ICON_DLG_BLSURF_PARAMETERS") );
3511 QString BLSURFPluginGUI_HypothesisCreator::type() const
3513 return tr( "BLSURF_HYPOTHESIS" );
3516 QString BLSURFPluginGUI_HypothesisCreator::helpPage() const
3518 return "blsurf_hypo_page.html";
3521 LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr()
3524 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
3526 return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
3531 CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
3533 CORBA::Object_var obj;
3534 SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.toStdString().c_str() );
3535 if (!aSObj->_is_nil()) {
3536 obj = aSObj->GetObject();
3537 aSObj->UnRegister();
3542 int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){
3543 int endRow = mySizeMapTable->topLevelItemCount()-1;
3545 for ( ; row <= endRow; ++row )
3547 QString entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
3548 if (entry == entryForChecking )