1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_AddMeshElementDlg.cxx
25 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
28 #include "SMESHGUI_AddQuadraticElementDlg.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_GroupUtils.h"
35 #include "SMESHGUI_IdValidator.h"
37 #include <SMESH_Actor.h>
38 #include <SMESH_ActorUtils.h>
39 #include <SMESH_FaceOrientationFilter.h>
40 #include <SMDS_Mesh.hxx>
42 // SALOME GUI includes
43 #include <SUIT_Desktop.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_ResourceMgr.h>
47 #include <SUIT_ViewManager.h>
49 #include <LightApp_SelectionMgr.h>
51 #include <SVTK_ViewModel.h>
52 #include <SVTK_ViewWindow.h>
54 #include <SALOME_ListIO.hxx>
56 #include <SalomeApp_Application.h>
61 #include <SALOMEconfig.h>
62 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
65 #include <TColStd_MapOfInteger.hxx>
68 #include <vtkIdList.h>
69 #include <vtkUnstructuredGrid.h>
70 #include <vtkDataSetMapper.h>
71 #include <vtkPolyDataMapper.h>
72 #include <vtkProperty.h>
73 #include <vtkCellType.h>
80 #include <QPushButton>
81 #include <QRadioButton>
82 #include <QVBoxLayout>
83 #include <QHBoxLayout>
84 #include <QGridLayout>
86 #include <QTableWidget>
88 #include <QButtonGroup>
99 // Define the sequences of ids
100 static int FirstEdgeIds[] = {0};
101 static int LastEdgeIds[] = {1};
103 static int FirstTriangleIds[] = {0,1,2};
104 static int LastTriangleIds[] = {1,2,0};
106 static int FirstQuadrangleIds[] = {0,1,2,3};
107 static int LastQuadrangleIds[] = {1,2,3,0};
109 static int FirstTetrahedronIds[] = {0,1,2,3,3,3};
110 static int LastTetrahedronIds[] = {1,2,0,0,1,2};
112 static int FirstPyramidIds[] = {0,1,2,3,4,4,4,4};
113 static int LastPyramidIds[] = {1,2,3,0,0,1,2,3};
115 static int FirstPentahedronIds[] = {0,1,2,3,4,5,0,1,2};
116 static int LastPentahedronIds[] = {1,2,0,4,5,3,3,4,5};
118 static int FirstHexahedronIds[] = {0,1,2,3,4,5,6,7,0,1,2,3};
119 static int LastHexahedronIds[] = {1,2,3,0,5,6,7,4,4,5,6,7};
121 static std::vector<int> FirstPolygonIds;
122 static std::vector<int> LastPolygonIds;
124 void ReverseConnectivity( std::vector<vtkIdType> & ids, SMDSAbs_EntityType type,
125 bool toReverse, // inverse element
126 bool toVtkOrder ) // smds connectivity to vtk one
128 if ( toReverse ) // first reverse smds order
130 const std::vector<int>& index = SMDS_MeshCell::reverseSmdsOrder(type, ids.size());
131 SMDS_MeshCell::applyInterlace( index, ids );
133 if ( toVtkOrder ) // from smds to vtk connectivity
135 const std::vector<int>& index = SMDS_MeshCell::toVtkOrder(type);
136 SMDS_MeshCell::applyInterlace( index, ids );
142 class TElementSimulationQuad
144 SalomeApp_Application* myApplication;
145 SUIT_ViewWindow* myViewWindow;
146 SVTK_ViewWindow* myVTKViewWindow;
148 SALOME_Actor* myPreviewActor;
149 vtkDataSetMapper* myMapper;
150 vtkUnstructuredGrid* myGrid;
151 //vtkProperty* myBackProp, *myProp;
153 //double myRGB[3], myBackRGB[3];
155 SALOME_Actor* myFaceOrientation;
156 vtkPolyDataMapper* myFaceOrientationDataMapper;
157 SMESH_FaceOrientationFilter* myFaceOrientationFilter;
160 TElementSimulationQuad (SalomeApp_Application* theApplication)
162 myApplication = theApplication;
163 SUIT_ViewManager* mgr = theApplication->activeViewManager();
165 myViewWindow = mgr->getActiveView();
166 myVTKViewWindow = GetVtkViewWindow(myViewWindow);
168 myGrid = vtkUnstructuredGrid::New();
170 // Create and display actor
171 myMapper = vtkDataSetMapper::New();
172 myMapper->SetInputData(myGrid);
174 myPreviewActor = SALOME_Actor::New();
175 myPreviewActor->PickableOff();
176 myPreviewActor->VisibilityOff();
177 myPreviewActor->SetMapper(myMapper);
181 vtkProperty* myProp = vtkProperty::New();
182 SMESH::GetColor( "SMESH", "preview_color", ffc, delta, "0, 255, 0|-100" ) ;
184 myProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
185 myPreviewActor->SetProperty( myProp );
188 vtkProperty* myBackProp = vtkProperty::New();
189 bfc = Qtx::mainColorToSecondary(ffc, delta);
190 myBackProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
191 myPreviewActor->SetBackfaceProperty( myBackProp );
192 myBackProp->Delete();
194 myVTKViewWindow->AddActor(myPreviewActor);
196 // Orientation of faces
197 myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
198 myFaceOrientationFilter->SetInputData(myGrid);
200 myFaceOrientationDataMapper = vtkPolyDataMapper::New();
201 myFaceOrientationDataMapper->SetInputConnection(myFaceOrientationFilter->GetOutputPort());
203 myFaceOrientation = SALOME_Actor::New();
204 myFaceOrientation->PickableOff();
205 myFaceOrientation->VisibilityOff();
206 myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
208 vtkProperty* anOrientationProp = vtkProperty::New();
210 GetColor( "SMESH", "orientation_color", aRGB[0], aRGB[1], aRGB[2], QColor( 255, 255, 255 ) );
211 anOrientationProp->SetColor( aRGB[0], aRGB[1], aRGB[2] );
212 myFaceOrientation->SetProperty( anOrientationProp );
213 anOrientationProp->Delete();
215 myVTKViewWindow->AddActor(myFaceOrientation);
218 typedef std::vector<vtkIdType> TVTKIds;
219 void SetPosition (SMESH_Actor* theActor,
220 SMDSAbs_EntityType theType,
223 const bool theReverse)
225 vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
226 myGrid->SetPoints(aGrid->GetPoints());
230 ReverseConnectivity( theIds, theType, theReverse, /*toVtkOrder=*/true);
233 vtkIdList *anIds = vtkIdList::New();
235 for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) {
236 anIds->InsertId(i,theIds[i]);
237 //std::cout << i<< ": " << theIds[i] << std::endl;
240 vtkIdType aType = SMDS_MeshCell::toVtkType(theType);
241 myGrid->InsertNextCell(aType,anIds);
246 myPreviewActor->GetMapper()->Update();
247 myPreviewActor->SetRepresentation( theMode );
248 SetVisibility(true, theActor->GetFacesOriented());
252 void SetVisibility (bool theVisibility, bool theShowOrientation = false)
254 myPreviewActor->SetVisibility(theVisibility);
255 myFaceOrientation->SetVisibility(theShowOrientation);
256 RepaintCurrentView();
260 ~TElementSimulationQuad()
262 if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
263 myVTKViewWindow->RemoveActor(myPreviewActor);
264 myVTKViewWindow->RemoveActor(myFaceOrientation);
266 myPreviewActor->Delete();
267 myFaceOrientation->Delete();
269 myMapper->RemoveAllInputs();
272 myFaceOrientationFilter->Delete();
274 myFaceOrientationDataMapper->RemoveAllInputs();
275 myFaceOrientationDataMapper->Delete();
280 // myBackProp->Delete();
287 \brief Simple 'busy state' flag locker.
293 //! Constructor. Sets passed boolean flag to \c true.
294 BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
295 //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
296 ~BusyLocker() { myBusy = false; }
298 bool& myBusy; //! External 'busy state' boolean flag
303 \brief Simple editable table item.
306 class IdEditItem: public QTableWidgetItem
309 IdEditItem(const QString& text );
312 QWidget* createEditor() const;
315 IdEditItem::IdEditItem(const QString& text )
316 : QTableWidgetItem(text, QTableWidgetItem::UserType+100)
320 IdEditItem::~IdEditItem()
324 QWidget* IdEditItem::createEditor() const
326 QLineEdit *aLineEdit = new QLineEdit(text(), tableWidget());
327 aLineEdit->setValidator( new SMESHGUI_IdValidator(tableWidget(), 1) );
331 //=================================================================================
332 // function : SMESHGUI_AddQuadraticElementDlg()
333 // purpose : constructor
334 //=================================================================================
336 SMESHGUI_AddQuadraticElementDlg::SMESHGUI_AddQuadraticElementDlg( SMESHGUI* theModule,
337 const SMDSAbs_EntityType theType )
338 : QDialog( SMESH::GetDesktop( theModule ) ),
339 mySMESHGUI( theModule ),
340 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
342 myGeomType( theType )
345 setAttribute( Qt::WA_DeleteOnClose, true );
347 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
348 (SUIT_Session::session()->activeApplication());
350 mySimulation = new SMESH::TElementSimulationQuad (anApp);
351 mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
353 QString anElementName;
355 switch ( myGeomType ) {
356 case SMDSEntity_Quad_Edge:
357 anElementName = QString("QUADRATIC_EDGE");
359 case SMDSEntity_Quad_Triangle:
360 anElementName = QString("QUADRATIC_TRIANGLE");
362 case SMDSEntity_Quad_Quadrangle:
363 anElementName = QString("QUADRATIC_QUADRANGLE");
365 case SMDSEntity_Quad_Polygon:
366 anElementName = QString("QUADRATIC_POLYGON");
368 case SMDSEntity_BiQuad_Quadrangle:
369 anElementName = QString("BIQUADRATIC_QUADRANGLE");
371 case SMDSEntity_BiQuad_Triangle:
372 anElementName = QString("BIQUADRATIC_TRIANGLE");
374 case SMDSEntity_Quad_Tetra:
375 anElementName = QString("QUADRATIC_TETRAHEDRON");
377 case SMDSEntity_Quad_Pyramid:
378 anElementName = QString("QUADRATIC_PYRAMID");
380 case SMDSEntity_Quad_Penta:
381 anElementName = QString("QUADRATIC_PENTAHEDRON");
383 case SMDSEntity_BiQuad_Penta:
384 anElementName = QString("BIQUADRATIC_PENTAHEDRON");
386 case SMDSEntity_Quad_Hexa:
387 anElementName = QString("QUADRATIC_HEXAHEDRON");
389 case SMDSEntity_TriQuad_Hexa:
390 anElementName = QString("TRIQUADRATIC_HEXAHEDRON");
393 myGeomType = SMDSEntity_Quad_Edge;
394 anElementName = QString("QUADRATIC_EDGE");
397 QString iconName = tr(QString("ICON_DLG_%1").arg(anElementName).toLatin1().data());
398 QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(anElementName).toLatin1().data());
399 QString argumentsGrTitle = tr(QString("SMESH_ADD_%1").arg(anElementName).toLatin1().data());
400 QString constructorGrTitle = tr(QString("SMESH_%1").arg(anElementName).toLatin1().data());
402 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName));
403 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
405 setWindowTitle(caption);
407 setSizeGripEnabled(true);
409 QVBoxLayout* aDialogLayout = new QVBoxLayout(this);
410 aDialogLayout->setSpacing(SPACING);
411 aDialogLayout->setMargin(MARGIN);
413 /***************************************************************/
414 GroupConstructors = new QGroupBox(constructorGrTitle, this);
415 QButtonGroup* ButtonGroup = new QButtonGroup(this);
416 QHBoxLayout* aGroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
417 aGroupConstructorsLayout->setSpacing(SPACING);
418 aGroupConstructorsLayout->setMargin(MARGIN);
420 myRadioButton1 = new QRadioButton(GroupConstructors);
421 myRadioButton1->setIcon(image0);
422 aGroupConstructorsLayout->addWidget(myRadioButton1);
423 ButtonGroup->addButton(myRadioButton1, 0);
425 /***************************************************************/
426 GroupArguments = new QGroupBox(argumentsGrTitle, this);
427 QGridLayout* aGroupArgumentsLayout = new QGridLayout(GroupArguments);
428 aGroupArgumentsLayout->setSpacing(SPACING);
429 aGroupArgumentsLayout->setMargin(MARGIN);
432 QLabel* aCornerNodesLabel = new QLabel(tr("SMESH_CORNER_NODES"), GroupArguments);
433 myCornerSelectButton = new QPushButton(GroupArguments);
434 myCornerSelectButton->setIcon(image1);
435 myCornerNodes = new QLineEdit(GroupArguments);
438 myTable = new QTableWidget(GroupArguments);
441 myMidFaceLabel = new QLabel(tr("SMESH_MIDFACE_NODES"), GroupArguments);
442 myMidFaceSelectButton = new QPushButton(GroupArguments);
443 myMidFaceSelectButton->setIcon(image1);
444 myMidFaceNodes = new QLineEdit(GroupArguments);
445 myMidFaceNodes->setValidator(new SMESHGUI_IdValidator(this, 6));
448 myCenterLabel = new QLabel(tr("SMESH_CENTER_NODE"), GroupArguments);
449 myCenterSelectButton = new QPushButton(GroupArguments);
450 myCenterSelectButton->setIcon(image1);
451 myCenterNode = new QLineEdit(GroupArguments);
452 myCenterNode->setValidator(new SMESHGUI_IdValidator(this, 1));
454 myReverseCB = new QCheckBox(tr("SMESH_REVERSE"), GroupArguments);
456 aGroupArgumentsLayout->addWidget(aCornerNodesLabel, 0, 0);
457 aGroupArgumentsLayout->addWidget(myCornerSelectButton, 0, 1);
458 aGroupArgumentsLayout->addWidget(myCornerNodes, 0, 2);
459 aGroupArgumentsLayout->addWidget(myTable, 1, 0, 1, 3);
460 aGroupArgumentsLayout->addWidget(myMidFaceLabel, 2, 0);
461 aGroupArgumentsLayout->addWidget(myMidFaceSelectButton, 2, 1);
462 aGroupArgumentsLayout->addWidget(myMidFaceNodes, 2, 2);
463 aGroupArgumentsLayout->addWidget(myCenterLabel, 3, 0);
464 aGroupArgumentsLayout->addWidget(myCenterSelectButton, 3, 1);
465 aGroupArgumentsLayout->addWidget(myCenterNode, 3, 2);
466 aGroupArgumentsLayout->addWidget(myReverseCB, 4, 0, 1, 3);
468 /***************************************************************/
469 GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this );
470 GroupGroups->setCheckable( true );
471 QHBoxLayout* GroupGroupsLayout = new QHBoxLayout(GroupGroups);
472 GroupGroupsLayout->setSpacing(SPACING);
473 GroupGroupsLayout->setMargin(MARGIN);
475 TextLabel_GroupName = new QLabel( tr( "SMESH_GROUP" ), GroupGroups );
476 ComboBox_GroupName = new QComboBox( GroupGroups );
477 ComboBox_GroupName->setEditable( true );
478 ComboBox_GroupName->setInsertPolicy( QComboBox::NoInsert );
480 GroupGroupsLayout->addWidget( TextLabel_GroupName );
481 GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 );
483 /***************************************************************/
484 GroupButtons = new QGroupBox(this);
485 QHBoxLayout* aGroupButtonsLayout = new QHBoxLayout(GroupButtons);
486 aGroupButtonsLayout->setSpacing(SPACING);
487 aGroupButtonsLayout->setMargin(MARGIN);
489 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
490 buttonOk->setAutoDefault(true);
491 buttonOk->setDefault(true);
492 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
493 buttonApply->setAutoDefault(true);
494 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
495 buttonCancel->setAutoDefault(true);
496 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
497 buttonHelp->setAutoDefault(true);
499 aGroupButtonsLayout->addWidget(buttonOk);
500 aGroupButtonsLayout->addSpacing(10);
501 aGroupButtonsLayout->addWidget(buttonApply);
502 aGroupButtonsLayout->addSpacing(10);
503 aGroupButtonsLayout->addStretch();
504 aGroupButtonsLayout->addWidget(buttonCancel);
505 aGroupButtonsLayout->addWidget(buttonHelp);
507 /***************************************************************/
508 aDialogLayout->addWidget(GroupConstructors);
509 aDialogLayout->addWidget(GroupArguments);
510 aDialogLayout->addWidget(GroupGroups);
511 aDialogLayout->addWidget(GroupButtons);
513 Init(); /* Initialisations */
516 //=================================================================================
517 // function : ~SMESHGUI_AddQuadraticElementDlg()
518 // purpose : Destroys the object and frees any allocated resources
519 //=================================================================================
521 SMESHGUI_AddQuadraticElementDlg::~SMESHGUI_AddQuadraticElementDlg()
526 //=================================================================================
529 //=================================================================================
531 void SMESHGUI_AddQuadraticElementDlg::Init()
533 myRadioButton1->setChecked(true);
534 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
536 /* reset "Add to group" control */
537 GroupGroups->setChecked( false );
540 myNbMidFaceNodes = 0;
545 switch (myGeomType) {
546 case SMDSEntity_Quad_Edge:
549 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_edges
551 case SMDSEntity_Quad_Triangle:
554 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_triangles
556 case SMDSEntity_BiQuad_Triangle:
560 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_triangles
562 case SMDSEntity_Quad_Quadrangle:
565 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_quadrangles
567 case SMDSEntity_BiQuad_Quadrangle:
571 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_quadrangles
573 case SMDSEntity_Quad_Polygon:
575 myNbCorners = 0; // no limit
576 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_polygons
578 case SMDSEntity_Quad_Tetra:
581 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_tetrahedrons
583 case SMDSEntity_Quad_Pyramid:
586 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_pyramids
588 case SMDSEntity_Quad_Penta:
591 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_pentahedrons
593 case SMDSEntity_BiQuad_Penta:
596 myNbMidFaceNodes = 3;
597 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_pentahedrons
599 case SMDSEntity_Quad_Hexa:
602 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_hexahedrons
604 case SMDSEntity_TriQuad_Hexa:
607 myNbMidFaceNodes = 6;
609 myHelpFileName = "adding_quadratic_elements.html#?"; //Adding_hexahedrons
614 myMidFaceLabel ->setVisible( myNbMidFaceNodes );
615 myMidFaceSelectButton->setVisible( myNbMidFaceNodes );
616 myMidFaceNodes ->setVisible( myNbMidFaceNodes );
617 myCenterLabel ->setVisible( myNbCenterNodes );
618 myCenterSelectButton ->setVisible( myNbCenterNodes );
619 myCenterNode ->setVisible( myNbCenterNodes );
621 myCornerNodes->setValidator(new SMESHGUI_IdValidator(this, myNbCorners));
623 /* initialize table */
624 myTable->setColumnCount(3);
625 myTable->setRowCount(aNumRows);
627 QStringList aColLabels;
628 aColLabels.append(tr("SMESH_FIRST"));
629 aColLabels.append(tr("SMESH_MIDDLE"));
630 aColLabels.append(tr("SMESH_LAST"));
631 myTable->setHorizontalHeaderLabels(aColLabels);
633 for ( int col = 0; col < myTable->columnCount(); col++ )
634 myTable->setColumnWidth(col, 80);
636 //myTable->setColumnReadOnly(0, true); // VSR: TODO
637 //myTable->setColumnReadOnly(2, true); // VSR: TODO
639 myTable->setEnabled( false );
641 for ( int row = 0; row < myTable->rowCount(); row++ )
643 myTable->setItem( row, 0, new QTableWidgetItem( "" ) );
644 myTable->item( row, 0 )->setFlags(0);
646 IdEditItem* anEditItem = new IdEditItem( "" );
647 anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
648 myTable->setItem(row, 1, anEditItem);
650 myTable->setItem( row, 2, new QTableWidgetItem( "" ) );
651 myTable->item( row, 2 )->setFlags(0);
654 /* signals and slots connections */
655 connect(myCornerSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
656 connect(myMidFaceSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
657 connect(myCenterSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
658 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
659 connect(myTable, SIGNAL(cellDoubleClicked(int, int)), SLOT(onCellDoubleClicked(int, int)));
660 connect(myTable, SIGNAL(cellChanged (int, int)), SLOT(onCellTextChange(int, int)));
661 connect(myCornerNodes, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
662 connect(myMidFaceNodes, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
663 connect(myCenterNode, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
664 connect(myReverseCB, SIGNAL(stateChanged(int)), SLOT(onReverse(int)));
666 connect(buttonOk, SIGNAL(clicked()), SLOT(ClickOnOk()));
667 connect(buttonCancel, SIGNAL(clicked()), SLOT(reject()));
668 connect(buttonApply, SIGNAL(clicked()), SLOT(ClickOnApply()));
669 connect(buttonHelp, SIGNAL(clicked()), SLOT(ClickOnHelp()));
671 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
672 connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(reject()));
673 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), SLOT(reject()));
674 connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), SLOT(onOpenView()));
675 connect(mySMESHGUI, SIGNAL (SignalCloseView()), SLOT(onCloseView()));
677 myCurrentLineEdit = myCornerNodes;
679 // set selection mode
680 SMESH::SetPointRepresentation(true);
682 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
683 aViewWindow->SetSelectionMode( NodeSelection );
685 SelectionIntoArgument();
688 //=================================================================================
689 // function : ClickOnApply()
691 //=================================================================================
693 bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply()
698 if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() )
701 BusyLocker lock( myBusy );
703 std::vector<vtkIdType> anIds;
705 switch (myGeomType) {
706 case SMDSEntity_Quad_Edge:
707 anIds.push_back(myTable->item(0, 0)->text().toInt());
708 anIds.push_back(myTable->item(0, 2)->text().toInt());
709 anIds.push_back(myTable->item(0, 1)->text().toInt());
711 case SMDSEntity_Quad_Triangle:
712 case SMDSEntity_Quad_Quadrangle:
713 case SMDSEntity_Quad_Polygon:
714 case SMDSEntity_BiQuad_Triangle:
715 case SMDSEntity_BiQuad_Quadrangle:
716 case SMDSEntity_Quad_Tetra:
717 case SMDSEntity_Quad_Pyramid:
718 case SMDSEntity_Quad_Penta:
719 case SMDSEntity_BiQuad_Penta:
720 case SMDSEntity_Quad_Hexa:
721 case SMDSEntity_TriQuad_Hexa:
722 for ( int row = 0; row < myNbCorners; row++ )
723 anIds.push_back(myTable->item(row, 0)->text().toInt());
724 for ( int row = 0; row < myTable->rowCount(); row++ )
725 anIds.push_back(myTable->item(row, 1)->text().toInt());
726 if ( myNbMidFaceNodes )
728 QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
729 for (int i = 0; i < aListId.count(); i++)
730 anIds.push_back( aListId[ i ].toInt() );
732 if ( myNbCenterNodes )
734 QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts);
735 anIds.push_back( aListId[ 0 ].toInt() );
740 if ( myReverseCB->isChecked())
741 ReverseConnectivity( anIds, myGeomType, /*toReverse=*/true, /*toVtkOrder=*/false );
743 int aNumberOfIds = anIds.size();
744 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
745 anArrayOfIdeces->length( aNumberOfIds );
747 for (int i = 0; i < aNumberOfIds; i++)
748 anArrayOfIdeces[i] = anIds[ i ];
750 bool addToGroup = GroupGroups->isChecked();
753 SMESH::SMESH_GroupBase_var aGroup;
756 aGroupName = ComboBox_GroupName->currentText();
757 for ( int i = 1; i <= ComboBox_GroupName->count(); i++ ) {
758 QString aName = ComboBox_GroupName->itemText( i );
759 if ( aGroupName == aName && ( i == ComboBox_GroupName->currentIndex() || idx == 0 ) )
762 if ( idx > 0 && idx <= myGroups.count() ) {
763 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] );
764 if ( !aGeomGroup->_is_nil() ) {
765 int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
766 tr( "MESH_GEOM_GRP_CHOSEN" ).arg( aGroupName ),
767 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
768 if ( res == 1 ) return false;
770 SMESH::SMESH_GroupOnFilter_var aFilterGroup = SMESH::SMESH_GroupOnFilter::_narrow( myGroups[idx-1] );
771 if ( !aFilterGroup->_is_nil() ) {
772 int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
773 tr( "MESH_FILTER_GRP_CHOSEN" ).arg( aGroupName ),
774 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
775 if ( res == 1 ) return false;
777 aGroup = myGroups[idx-1];
781 SMESH::ElementType anElementType = SMESH::ALL;
782 long anElemId = -1, nbElemsBefore = 0;
783 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
784 switch (myGeomType) {
785 case SMDSEntity_Quad_Edge:
786 anElementType = SMESH::EDGE;
787 nbElemsBefore = myMesh->NbEdges();
788 anElemId = aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
789 case SMDSEntity_Quad_Triangle:
790 case SMDSEntity_Quad_Quadrangle:
791 case SMDSEntity_BiQuad_Triangle:
792 case SMDSEntity_BiQuad_Quadrangle:
793 anElementType = SMESH::FACE;
794 nbElemsBefore = myMesh->NbFaces();
795 anElemId = aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
796 case SMDSEntity_Quad_Polygon:
797 anElementType = SMESH::FACE;
798 nbElemsBefore = myMesh->NbFaces();
799 anElemId = aMeshEditor->AddQuadPolygonalFace(anArrayOfIdeces.inout()); break;
800 case SMDSEntity_Quad_Tetra:
801 case SMDSEntity_Quad_Pyramid:
802 case SMDSEntity_Quad_Penta:
803 case SMDSEntity_BiQuad_Penta:
804 case SMDSEntity_Quad_Hexa:
805 case SMDSEntity_TriQuad_Hexa:
806 anElementType = SMESH::VOLUME;
807 nbElemsBefore = myMesh->NbVolumes();
808 anElemId = aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
812 if ( anElemId != -1 && addToGroup && !aGroupName.isEmpty() ) {
813 SMESH::SMESH_Group_var aGroupUsed;
814 if ( aGroup->_is_nil() ) {
816 aGroupUsed = SMESH::AddGroup( myMesh, anElementType, aGroupName );
817 if ( !aGroupUsed->_is_nil() ) {
818 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroupUsed));
819 ComboBox_GroupName->addItem( aGroupName );
823 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup );
824 SMESH::SMESH_GroupOnFilter_var aFilterGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGroup );
825 if ( !aGeomGroup->_is_nil() ) {
826 aGroupUsed = myMesh->ConvertToStandalone( aGeomGroup );
827 if ( !aGroupUsed->_is_nil() && idx > 0 ) {
828 myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
829 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
832 else if ( !aFilterGroup->_is_nil() ) {
833 aGroupUsed = myMesh->ConvertToStandalone( aFilterGroup );
834 if ( !aGroupUsed->_is_nil() && idx > 0 ) {
835 myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
836 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
840 aGroupUsed = SMESH::SMESH_Group::_narrow( aGroup );
843 if ( !aGroupUsed->_is_nil() ) {
844 SMESH::long_array_var anIdList = new SMESH::long_array;
845 anIdList->length( 1 );
846 anIdList[0] = anElemId;
847 aGroupUsed->Add( anIdList.inout() );
851 if ( nbElemsBefore == 0 )
853 // 1st element of the type has been added, update actor to show this entity
854 unsigned int aMode = myActor->GetEntityMode();
855 switch ( anElementType ) {
857 myActor->SetRepresentation(SMESH_Actor::eEdge);
858 myActor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break;
860 myActor->SetRepresentation(SMESH_Actor::eSurface);
861 myActor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break;
863 myActor->SetRepresentation(SMESH_Actor::eSurface);
864 myActor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break;
869 SALOME_ListIO aList; aList.Append( myActor->getIO() );
870 mySelector->ClearIndex();
871 mySelectionMgr->setSelectedObjects( aList, false );
873 mySimulation->SetVisibility(false);
877 SetCurrentSelection();
881 SMESHGUI::Modified();
886 //=================================================================================
887 // function : ClickOnOk()
889 //=================================================================================
891 void SMESHGUI_AddQuadraticElementDlg::ClickOnOk()
893 if ( ClickOnApply() )
897 //=================================================================================
898 // function : reject()
900 //=================================================================================
902 void SMESHGUI_AddQuadraticElementDlg::reject()
904 mySelectionMgr->clearSelected();
905 mySimulation->SetVisibility(false);
906 SMESH::SetPointRepresentation(false);
907 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
908 aViewWindow->SetSelectionMode( ActorSelection );
909 disconnect(mySelectionMgr, 0, this, 0);
910 mySMESHGUI->ResetState();
914 //=================================================================================
915 // function : onOpenView()
917 //=================================================================================
918 void SMESHGUI_AddQuadraticElementDlg::onOpenView()
920 if ( mySelector && mySimulation ) {
921 mySimulation->SetVisibility(false);
922 SMESH::SetPointRepresentation(false);
925 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
926 mySimulation = new SMESH::TElementSimulationQuad(
927 dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
928 ActivateThisDialog();
932 //=================================================================================
933 // function : onCloseView()
935 //=================================================================================
936 void SMESHGUI_AddQuadraticElementDlg::onCloseView()
938 DeactivateActiveDialog();
943 //=================================================================================
944 // function : ClickOnHelp()
946 //=================================================================================
948 void SMESHGUI_AddQuadraticElementDlg::ClickOnHelp()
950 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
952 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
956 platform = "winapplication";
958 platform = "application";
960 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
961 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
962 arg(app->resourceMgr()->stringValue("ExternalBrowser",
964 arg(myHelpFileName));
968 //=================================================================================
969 // function : onTextChange()
971 //=================================================================================
973 void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText)
976 BusyLocker lock( myBusy );
978 mySimulation->SetVisibility(false);
980 // highlight entered nodes
981 SMDS_Mesh* aMesh = 0;
983 aMesh = myActor->GetObject()->GetMesh();
985 QLineEdit* send = (QLineEdit*)sender();
986 if (send == myCornerNodes ||
987 send == myMidFaceNodes ||
988 send == myCenterNode)
989 myCurrentLineEdit = send;
992 TColStd_MapOfInteger newIndices;
994 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
996 for (int i = 0; i < aListId.count(); i++) {
997 if ( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
999 newIndices.Add( n->GetID() );
1008 mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
1009 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1010 aViewWindow->highlight( myActor->getIO(), true, true );
1012 if ( myCurrentLineEdit == myCornerNodes )
1013 UpdateTable( allOk );
1017 displaySimulation();
1020 //=================================================================================
1021 // function : SelectionIntoArgument()
1022 // purpose : Called when selection has changed
1023 //=================================================================================
1025 void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument()
1028 BusyLocker lock( myBusy );
1030 QString aCurrentEntry = myEntry;
1032 if ( myCurrentLineEdit )
1037 myCurrentLineEdit->setText("");
1039 if (!GroupButtons->isEnabled()) // inactive
1042 mySimulation->SetVisibility(false);
1044 // get selected mesh
1045 SALOME_ListIO aList;
1046 mySelectionMgr->selectedObjects(aList);
1048 if (aList.Extent() != 1)
1055 Handle(SALOME_InteractiveObject) anIO = aList.First();
1056 myEntry = anIO->getEntry();
1057 myMesh = SMESH::GetMeshByIO(anIO);
1058 if (myMesh->_is_nil()) {
1063 myActor = SMESH::FindActorByEntry(anIO->getEntry());
1068 if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
1069 SMESH::ElementType anElementType = SMESH::ALL;
1070 switch ( myGeomType ) {
1071 case SMDSEntity_Quad_Edge:
1072 anElementType = SMESH::EDGE; break;
1073 case SMDSEntity_Quad_Triangle:
1074 case SMDSEntity_Quad_Quadrangle:
1075 case SMDSEntity_Quad_Polygon:
1076 case SMDSEntity_BiQuad_Triangle:
1077 case SMDSEntity_BiQuad_Quadrangle:
1078 anElementType = SMESH::FACE; break;
1079 case SMDSEntity_Quad_Tetra:
1080 case SMDSEntity_Quad_Pyramid:
1081 case SMDSEntity_Quad_Penta:
1082 case SMDSEntity_BiQuad_Penta:
1083 case SMDSEntity_Quad_Hexa:
1084 case SMDSEntity_TriQuad_Hexa:
1085 anElementType = SMESH::VOLUME; break;
1089 ComboBox_GroupName->clear();
1090 ComboBox_GroupName->addItem( QString() );
1091 SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
1092 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
1093 SMESH::SMESH_GroupBase_var aGroup = aListOfGroups[i];
1094 if ( !aGroup->_is_nil() && aGroup->GetType() == anElementType ) {
1095 QString aGroupName( aGroup->GetName() );
1096 if ( !aGroupName.isEmpty() ) {
1097 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
1098 ComboBox_GroupName->addItem( aGroupName );
1109 // get selected nodes
1110 QString aString = "";
1111 int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString);
1113 if ( myCurrentLineEdit )
1115 if ( myCurrentLineEdit != myCenterNode || nbNodes == 1 )
1116 myCurrentLineEdit->setText(aString);
1118 if ( myCurrentLineEdit == myCornerNodes )
1121 else if ( myTable->isEnabled() && nbNodes == 1 )
1123 int theRow = myTable->currentRow(), theCol = myTable->currentColumn();
1125 myTable->item(theRow, 1)->setText(aString);
1129 displaySimulation();
1132 //=================================================================================
1133 // function : displaySimulation()
1135 //=================================================================================
1137 void SMESHGUI_AddQuadraticElementDlg::displaySimulation()
1141 SMESH::TElementSimulationQuad::TVTKIds anIds;
1143 // Collect ids from the dialog
1146 int aDisplayMode = VTK_SURFACE;
1148 if ( myGeomType == SMDSEntity_Quad_Edge )
1150 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) );
1151 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 2)->text().toInt() ) );
1152 anID = myTable->item(0, 1)->text().toInt(&ok);
1153 if (!ok) anID = myTable->item(0, 0)->text().toInt();
1154 anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
1155 aDisplayMode = VTK_WIREFRAME;
1159 for ( int row = 0; row < myNbCorners; row++ )
1160 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(row, 0)->text().toInt() ) );
1162 for ( int row = 0; row < myTable->rowCount(); row++ )
1164 anID = myTable->item(row, 1)->text().toInt(&ok);
1166 anID = myTable->item(row, 0)->text().toInt();
1167 aDisplayMode = VTK_WIREFRAME;
1169 anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
1171 if ( myNbMidFaceNodes )
1173 QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
1174 for (int i = 0; i < aListId.count(); i++)
1175 anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() ));
1177 if ( myNbCenterNodes )
1179 QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts);
1180 anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ 0 ].toInt() ));
1184 mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked());
1188 mySimulation->SetVisibility(false);
1190 SMESH::UpdateView();
1193 //=================================================================================
1194 // function : SetCurrentSelection()
1196 //=================================================================================
1198 void SMESHGUI_AddQuadraticElementDlg::SetCurrentSelection()
1200 QPushButton* send = (QPushButton*)sender();
1201 myCurrentLineEdit = 0;
1203 if (send == myCornerSelectButton)
1204 myCurrentLineEdit = myCornerNodes;
1205 else if ( send == myMidFaceSelectButton )
1206 myCurrentLineEdit = myMidFaceNodes;
1207 else if ( send == myCenterSelectButton )
1208 myCurrentLineEdit = myCenterNode;
1210 if ( myCurrentLineEdit )
1212 myCurrentLineEdit->setFocus();
1213 SelectionIntoArgument();
1217 //=================================================================================
1218 // function : DeactivateActiveDialog()
1220 //=================================================================================
1222 void SMESHGUI_AddQuadraticElementDlg::DeactivateActiveDialog()
1224 if (GroupConstructors->isEnabled()) {
1225 GroupConstructors->setEnabled(false);
1226 GroupArguments->setEnabled(false);
1227 GroupButtons->setEnabled(false);
1228 mySimulation->SetVisibility(false);
1229 mySMESHGUI->ResetState();
1230 mySMESHGUI->SetActiveDialogBox(0);
1234 //=================================================================================
1235 // function : ActivateThisDialog()
1237 //=================================================================================
1239 void SMESHGUI_AddQuadraticElementDlg::ActivateThisDialog()
1241 /* Emit a signal to deactivate the active dialog */
1242 mySMESHGUI->EmitSignalDeactivateDialog();
1244 GroupConstructors->setEnabled(true);
1245 GroupArguments->setEnabled(true);
1246 GroupButtons->setEnabled(true);
1248 SMESH::SetPointRepresentation(true);
1250 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1251 aViewWindow->SetSelectionMode( NodeSelection );
1252 SelectionIntoArgument();
1255 //=================================================================================
1256 // function : enterEvent()
1258 //=================================================================================
1259 void SMESHGUI_AddQuadraticElementDlg::enterEvent (QEvent*)
1261 if ( !GroupConstructors->isEnabled() ) {
1262 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
1263 if ( aViewWindow && !mySelector && !mySimulation) {
1264 mySelector = aViewWindow->GetSelector();
1265 mySimulation = new SMESH::TElementSimulationQuad(
1266 dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
1268 ActivateThisDialog();
1272 //=================================================================================
1273 // function : onReverse()
1275 //=================================================================================
1277 void SMESHGUI_AddQuadraticElementDlg::onReverse (int state)
1279 mySimulation->SetVisibility(false);
1280 displaySimulation();
1284 //=================================================================================
1285 // function : IsValid()
1287 //=================================================================================
1289 bool SMESHGUI_AddQuadraticElementDlg::IsValid()
1291 SMDS_Mesh* aMesh = 0;
1293 aMesh = myActor->GetObject()->GetMesh();
1298 std::set< int > okIDs;
1299 for ( int row = 0; row < myTable->rowCount(); row++ )
1301 int anID = myTable->item(row, 1)->text().toInt(&ok);
1305 const SMDS_MeshNode * aNode = aMesh->FindNode(anID);
1308 okIDs.insert( anID );
1311 QStringList aListId;
1312 if ( myNbMidFaceNodes )
1313 aListId += myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
1314 if ( myNbCenterNodes )
1315 aListId += myCenterNode->text().split(" ", QString::SkipEmptyParts);
1317 for (int i = 0; i < aListId.count(); i++)
1319 int anID = aListId[ i ].toInt(&ok);
1323 if ( !aMesh->FindNode(anID) )
1325 okIDs.insert( anID );
1328 return (int) okIDs.size() == myTable->rowCount() + myNbMidFaceNodes + myNbCenterNodes;
1331 //=================================================================================
1332 // function : UpdateTable()
1334 //=================================================================================
1336 void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity )
1338 QStringList aListCorners = myCornerNodes->text().split(" ", QString::SkipEmptyParts);
1340 if ( myGeomType == SMDSEntity_Quad_Polygon ) // POLYGON
1342 if ( aListCorners.count() < 3 )
1343 theConersValidity = false;
1345 if ( aListCorners.count() != myTable->rowCount() && theConersValidity )
1347 // adjust nb of rows for the polygon
1348 int oldNbRows = myTable->rowCount();
1349 myTable->setRowCount( aListCorners.count() );
1350 for ( int row = oldNbRows; row < myTable->rowCount(); row++ )
1352 myTable->setItem( row, 0, new QTableWidgetItem( "" ) );
1353 myTable->item( row, 0 )->setFlags(0);
1355 IdEditItem* anEditItem = new IdEditItem( "" );
1356 anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1357 myTable->setItem(row, 1, anEditItem);
1359 myTable->setItem( row, 2, new QTableWidgetItem( "" ) );
1360 myTable->item( row, 2 )->setFlags(0);
1362 myNbCorners = aListCorners.count();
1364 // fill FirstPolygonIds and LastPolygonIds
1365 FirstPolygonIds.resize( aListCorners.count() );
1366 LastPolygonIds .resize( aListCorners.count() );
1367 for ( int i = 0; i < aListCorners.count(); ++i )
1369 FirstPolygonIds[i] = i;
1370 LastPolygonIds [i] = i+1;
1372 LastPolygonIds.back() = 0;
1374 myNbCorners = aListCorners.count();
1378 if ( aListCorners.count() == myNbCorners && theConersValidity )
1380 myTable->setEnabled( true );
1382 // clear the Middle column
1383 for ( int row = 0; row < myTable->rowCount(); row++ )
1384 myTable->item( row, 1 )->setText("");
1386 int* aFirstColIds = 0;
1387 int* aLastColIds = 0;
1389 switch (myGeomType) {
1390 case SMDSEntity_Quad_Edge:
1391 aFirstColIds = FirstEdgeIds;
1392 aLastColIds = LastEdgeIds;
1394 case SMDSEntity_Quad_Triangle:
1395 case SMDSEntity_BiQuad_Triangle:
1396 aFirstColIds = FirstTriangleIds;
1397 aLastColIds = LastTriangleIds;
1399 case SMDSEntity_Quad_Quadrangle:
1400 case SMDSEntity_BiQuad_Quadrangle:
1401 aFirstColIds = FirstQuadrangleIds;
1402 aLastColIds = LastQuadrangleIds;
1404 case SMDSEntity_Quad_Polygon:
1405 aFirstColIds = & FirstPolygonIds[0];
1406 aLastColIds = & LastPolygonIds[0];
1408 case SMDSEntity_Quad_Tetra:
1409 aFirstColIds = FirstTetrahedronIds;
1410 aLastColIds = LastTetrahedronIds;
1412 case SMDSEntity_Quad_Pyramid:
1413 aFirstColIds = FirstPyramidIds;
1414 aLastColIds = LastPyramidIds;
1416 case SMDSEntity_Quad_Penta:
1417 case SMDSEntity_BiQuad_Penta:
1418 aFirstColIds = FirstPentahedronIds;
1419 aLastColIds = LastPentahedronIds;
1421 case SMDSEntity_Quad_Hexa:
1422 case SMDSEntity_TriQuad_Hexa:
1423 aFirstColIds = FirstHexahedronIds;
1424 aLastColIds = LastHexahedronIds;
1429 // fill the First and the Last columns
1430 for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++)
1431 myTable->item( i, 0 )->setText( aListCorners[ aFirstColIds[i] ] );
1433 for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++)
1434 myTable->item( i, 2 )->setText( aListCorners[ aLastColIds[i] ] );
1439 for ( int row = 0; row < myTable->rowCount(); row++ )
1440 for ( int col = 0; col < myTable->columnCount(); col++ )
1441 if ( QTableWidgetItem* aTWI = myTable->item(row, col) ) aTWI->setText("");
1443 myTable->setEnabled( false );
1447 //=================================================================================
1448 // function : onTableActivate()
1450 //=================================================================================
1452 void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol )
1454 myCurrentLineEdit = 0;
1455 displaySimulation();
1459 //=================================================================================
1460 // function : onCellTextChange()
1462 //=================================================================================
1464 void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol)
1466 myCurrentLineEdit = 0;
1467 displaySimulation();
1471 //=================================================================================
1472 // function : keyPressEvent()
1474 //=================================================================================
1476 void SMESHGUI_AddQuadraticElementDlg::keyPressEvent( QKeyEvent* e )
1478 QDialog::keyPressEvent( e );
1479 if ( e->isAccepted() )
1482 if ( e->key() == Qt::Key_F1 ) {
1488 //=======================================================================
1489 //function : updateButtons
1491 //=======================================================================
1493 void SMESHGUI_AddQuadraticElementDlg::updateButtons()
1495 bool valid = IsValid();
1496 buttonOk->setEnabled( valid );
1497 buttonApply->setEnabled( valid );
1500 //=================================================================================
1501 // function : isValid
1503 //=================================================================================
1505 bool SMESHGUI_AddQuadraticElementDlg::isValid()
1507 if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
1508 SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );