1 // Copyright (C) 2007-2015 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 vector<int> FirstPolygonIds;
122 static 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 ) ),
341 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_Quad_Hexa:
384 anElementName = QString("QUADRATIC_HEXAHEDRON");
386 case SMDSEntity_TriQuad_Hexa:
387 anElementName = QString("TRIQUADRATIC_HEXAHEDRON");
390 myGeomType = SMDSEntity_Quad_Edge;
391 anElementName = QString("QUADRATIC_EDGE");
394 QString iconName = tr(QString("ICON_DLG_%1").arg(anElementName).toLatin1().data());
395 QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(anElementName).toLatin1().data());
396 QString argumentsGrTitle = tr(QString("SMESH_ADD_%1").arg(anElementName).toLatin1().data());
397 QString constructorGrTitle = tr(QString("SMESH_%1").arg(anElementName).toLatin1().data());
399 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName));
400 QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
402 setWindowTitle(caption);
404 setSizeGripEnabled(true);
406 QVBoxLayout* aDialogLayout = new QVBoxLayout(this);
407 aDialogLayout->setSpacing(SPACING);
408 aDialogLayout->setMargin(MARGIN);
410 /***************************************************************/
411 GroupConstructors = new QGroupBox(constructorGrTitle, this);
412 QButtonGroup* ButtonGroup = new QButtonGroup(this);
413 QHBoxLayout* aGroupConstructorsLayout = new QHBoxLayout(GroupConstructors);
414 aGroupConstructorsLayout->setSpacing(SPACING);
415 aGroupConstructorsLayout->setMargin(MARGIN);
417 myRadioButton1 = new QRadioButton(GroupConstructors);
418 myRadioButton1->setIcon(image0);
419 aGroupConstructorsLayout->addWidget(myRadioButton1);
420 ButtonGroup->addButton(myRadioButton1, 0);
422 /***************************************************************/
423 GroupArguments = new QGroupBox(argumentsGrTitle, this);
424 QGridLayout* aGroupArgumentsLayout = new QGridLayout(GroupArguments);
425 aGroupArgumentsLayout->setSpacing(SPACING);
426 aGroupArgumentsLayout->setMargin(MARGIN);
429 QLabel* aCornerNodesLabel = new QLabel(tr("SMESH_CORNER_NODES"), GroupArguments);
430 myCornerSelectButton = new QPushButton(GroupArguments);
431 myCornerSelectButton->setIcon(image1);
432 myCornerNodes = new QLineEdit(GroupArguments);
435 myTable = new QTableWidget(GroupArguments);
438 myMidFaceLabel = new QLabel(tr("SMESH_MIDFACE_NODES"), GroupArguments);
439 myMidFaceSelectButton = new QPushButton(GroupArguments);
440 myMidFaceSelectButton->setIcon(image1);
441 myMidFaceNodes = new QLineEdit(GroupArguments);
442 myMidFaceNodes->setValidator(new SMESHGUI_IdValidator(this, 6));
445 myCenterLabel = new QLabel(tr("SMESH_CENTER_NODE"), GroupArguments);
446 myCenterSelectButton = new QPushButton(GroupArguments);
447 myCenterSelectButton->setIcon(image1);
448 myCenterNode = new QLineEdit(GroupArguments);
449 myCenterNode->setValidator(new SMESHGUI_IdValidator(this, 1));
451 myReverseCB = new QCheckBox(tr("SMESH_REVERSE"), GroupArguments);
453 aGroupArgumentsLayout->addWidget(aCornerNodesLabel, 0, 0);
454 aGroupArgumentsLayout->addWidget(myCornerSelectButton, 0, 1);
455 aGroupArgumentsLayout->addWidget(myCornerNodes, 0, 2);
456 aGroupArgumentsLayout->addWidget(myTable, 1, 0, 1, 3);
457 aGroupArgumentsLayout->addWidget(myMidFaceLabel, 2, 0);
458 aGroupArgumentsLayout->addWidget(myMidFaceSelectButton, 2, 1);
459 aGroupArgumentsLayout->addWidget(myMidFaceNodes, 2, 2);
460 aGroupArgumentsLayout->addWidget(myCenterLabel, 3, 0);
461 aGroupArgumentsLayout->addWidget(myCenterSelectButton, 3, 1);
462 aGroupArgumentsLayout->addWidget(myCenterNode, 3, 2);
463 aGroupArgumentsLayout->addWidget(myReverseCB, 4, 0, 1, 3);
465 /***************************************************************/
466 GroupGroups = new QGroupBox( tr( "SMESH_ADD_TO_GROUP" ), this );
467 GroupGroups->setCheckable( true );
468 QHBoxLayout* GroupGroupsLayout = new QHBoxLayout(GroupGroups);
469 GroupGroupsLayout->setSpacing(SPACING);
470 GroupGroupsLayout->setMargin(MARGIN);
472 TextLabel_GroupName = new QLabel( tr( "SMESH_GROUP" ), GroupGroups );
473 ComboBox_GroupName = new QComboBox( GroupGroups );
474 ComboBox_GroupName->setEditable( true );
475 ComboBox_GroupName->setInsertPolicy( QComboBox::NoInsert );
477 GroupGroupsLayout->addWidget( TextLabel_GroupName );
478 GroupGroupsLayout->addWidget( ComboBox_GroupName, 1 );
480 /***************************************************************/
481 GroupButtons = new QGroupBox(this);
482 QHBoxLayout* aGroupButtonsLayout = new QHBoxLayout(GroupButtons);
483 aGroupButtonsLayout->setSpacing(SPACING);
484 aGroupButtonsLayout->setMargin(MARGIN);
486 buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
487 buttonOk->setAutoDefault(true);
488 buttonOk->setDefault(true);
489 buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
490 buttonApply->setAutoDefault(true);
491 buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
492 buttonCancel->setAutoDefault(true);
493 buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
494 buttonHelp->setAutoDefault(true);
496 aGroupButtonsLayout->addWidget(buttonOk);
497 aGroupButtonsLayout->addSpacing(10);
498 aGroupButtonsLayout->addWidget(buttonApply);
499 aGroupButtonsLayout->addSpacing(10);
500 aGroupButtonsLayout->addStretch();
501 aGroupButtonsLayout->addWidget(buttonCancel);
502 aGroupButtonsLayout->addWidget(buttonHelp);
504 /***************************************************************/
505 aDialogLayout->addWidget(GroupConstructors);
506 aDialogLayout->addWidget(GroupArguments);
507 aDialogLayout->addWidget(GroupGroups);
508 aDialogLayout->addWidget(GroupButtons);
510 Init(); /* Initialisations */
513 //=================================================================================
514 // function : ~SMESHGUI_AddQuadraticElementDlg()
515 // purpose : Destroys the object and frees any allocated resources
516 //=================================================================================
518 SMESHGUI_AddQuadraticElementDlg::~SMESHGUI_AddQuadraticElementDlg()
523 //=================================================================================
526 //=================================================================================
528 void SMESHGUI_AddQuadraticElementDlg::Init()
530 myRadioButton1->setChecked(true);
531 mySMESHGUI->SetActiveDialogBox((QDialog*)this);
533 /* reset "Add to group" control */
534 GroupGroups->setChecked( false );
537 myNbMidFaceNodes = 0;
542 switch (myGeomType) {
543 case SMDSEntity_Quad_Edge:
546 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_edges
548 case SMDSEntity_Quad_Triangle:
551 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_triangles
553 case SMDSEntity_BiQuad_Triangle:
557 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_triangles
559 case SMDSEntity_Quad_Quadrangle:
562 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_quadrangles
564 case SMDSEntity_BiQuad_Quadrangle:
568 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_quadrangles
570 case SMDSEntity_Quad_Polygon:
572 myNbCorners = 0; // no limit
573 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_polygons
575 case SMDSEntity_Quad_Tetra:
578 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_tetrahedrons
580 case SMDSEntity_Quad_Pyramid:
583 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_pyramids
585 case SMDSEntity_Quad_Penta:
588 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_pentahedrons
590 case SMDSEntity_Quad_Hexa:
593 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_hexahedrons
595 case SMDSEntity_TriQuad_Hexa:
598 myNbMidFaceNodes = 6;
600 myHelpFileName = "adding_quadratic_elements_page.html#?"; //Adding_hexahedrons
604 myMidFaceLabel ->setVisible( myNbMidFaceNodes );
605 myMidFaceSelectButton->setVisible( myNbMidFaceNodes );
606 myMidFaceNodes ->setVisible( myNbMidFaceNodes );
607 myCenterLabel ->setVisible( myNbCenterNodes );
608 myCenterSelectButton ->setVisible( myNbCenterNodes );
609 myCenterNode ->setVisible( myNbCenterNodes );
611 myCornerNodes->setValidator(new SMESHGUI_IdValidator(this, myNbCorners));
613 /* initialize table */
614 myTable->setColumnCount(3);
615 myTable->setRowCount(aNumRows);
617 QStringList aColLabels;
618 aColLabels.append(tr("SMESH_FIRST"));
619 aColLabels.append(tr("SMESH_MIDDLE"));
620 aColLabels.append(tr("SMESH_LAST"));
621 myTable->setHorizontalHeaderLabels(aColLabels);
623 for ( int col = 0; col < myTable->columnCount(); col++ )
624 myTable->setColumnWidth(col, 80);
626 //myTable->setColumnReadOnly(0, true); // VSR: TODO
627 //myTable->setColumnReadOnly(2, true); // VSR: TODO
629 myTable->setEnabled( false );
631 for ( int row = 0; row < myTable->rowCount(); row++ )
633 myTable->setItem( row, 0, new QTableWidgetItem( "" ) );
634 myTable->item( row, 0 )->setFlags(0);
636 IdEditItem* anEditItem = new IdEditItem( "" );
637 anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
638 myTable->setItem(row, 1, anEditItem);
640 myTable->setItem( row, 2, new QTableWidgetItem( "" ) );
641 myTable->item( row, 2 )->setFlags(0);
644 /* signals and slots connections */
645 connect(myCornerSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
646 connect(myMidFaceSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
647 connect(myCenterSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
648 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
649 connect(myTable, SIGNAL(cellDoubleClicked(int, int)), SLOT(onCellDoubleClicked(int, int)));
650 connect(myTable, SIGNAL(cellChanged (int, int)), SLOT(onCellTextChange(int, int)));
651 connect(myCornerNodes, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
652 connect(myMidFaceNodes, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
653 connect(myCenterNode, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
654 connect(myReverseCB, SIGNAL(stateChanged(int)), SLOT(onReverse(int)));
656 connect(buttonOk, SIGNAL(clicked()), SLOT(ClickOnOk()));
657 connect(buttonCancel, SIGNAL(clicked()), SLOT(reject()));
658 connect(buttonApply, SIGNAL(clicked()), SLOT(ClickOnApply()));
659 connect(buttonHelp, SIGNAL(clicked()), SLOT(ClickOnHelp()));
661 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
662 connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(reject()));
663 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), SLOT(reject()));
664 connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), SLOT(onOpenView()));
665 connect(mySMESHGUI, SIGNAL (SignalCloseView()), SLOT(onCloseView()));
667 myCurrentLineEdit = myCornerNodes;
669 // set selection mode
670 SMESH::SetPointRepresentation(true);
672 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
673 aViewWindow->SetSelectionMode( NodeSelection );
675 SelectionIntoArgument();
678 //=================================================================================
679 // function : ClickOnApply()
681 //=================================================================================
683 bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply()
688 if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() )
691 BusyLocker lock( myBusy );
693 std::vector<vtkIdType> anIds;
695 switch (myGeomType) {
696 case SMDSEntity_Quad_Edge:
697 anIds.push_back(myTable->item(0, 0)->text().toInt());
698 anIds.push_back(myTable->item(0, 2)->text().toInt());
699 anIds.push_back(myTable->item(0, 1)->text().toInt());
701 case SMDSEntity_Quad_Triangle:
702 case SMDSEntity_Quad_Quadrangle:
703 case SMDSEntity_Quad_Polygon:
704 case SMDSEntity_BiQuad_Triangle:
705 case SMDSEntity_BiQuad_Quadrangle:
706 case SMDSEntity_Quad_Tetra:
707 case SMDSEntity_Quad_Pyramid:
708 case SMDSEntity_Quad_Penta:
709 case SMDSEntity_Quad_Hexa:
710 case SMDSEntity_TriQuad_Hexa:
711 for ( int row = 0; row < myNbCorners; row++ )
712 anIds.push_back(myTable->item(row, 0)->text().toInt());
713 for ( int row = 0; row < myTable->rowCount(); row++ )
714 anIds.push_back(myTable->item(row, 1)->text().toInt());
715 if ( myNbMidFaceNodes )
717 QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
718 for (int i = 0; i < aListId.count(); i++)
719 anIds.push_back( aListId[ i ].toInt() );
721 if ( myNbCenterNodes )
723 QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts);
724 anIds.push_back( aListId[ 0 ].toInt() );
728 if ( myReverseCB->isChecked())
729 ReverseConnectivity( anIds, myGeomType, /*toReverse=*/true, /*toVtkOrder=*/false );
731 int aNumberOfIds = anIds.size();
732 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
733 anArrayOfIdeces->length( aNumberOfIds );
735 for (int i = 0; i < aNumberOfIds; i++)
736 anArrayOfIdeces[i] = anIds[ i ];
738 bool addToGroup = GroupGroups->isChecked();
741 SMESH::SMESH_GroupBase_var aGroup;
744 aGroupName = ComboBox_GroupName->currentText();
745 for ( int i = 1; i <= ComboBox_GroupName->count(); i++ ) {
746 QString aName = ComboBox_GroupName->itemText( i );
747 if ( aGroupName == aName && ( i == ComboBox_GroupName->currentIndex() || idx == 0 ) )
750 if ( idx > 0 && idx <= myGroups.count() ) {
751 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] );
752 if ( !aGeomGroup->_is_nil() ) {
753 int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
754 tr( "MESH_GEOM_GRP_CHOSEN" ).arg( aGroupName ),
755 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
756 if ( res == 1 ) return false;
758 SMESH::SMESH_GroupOnFilter_var aFilterGroup = SMESH::SMESH_GroupOnFilter::_narrow( myGroups[idx-1] );
759 if ( !aFilterGroup->_is_nil() ) {
760 int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
761 tr( "MESH_FILTER_GRP_CHOSEN" ).arg( aGroupName ),
762 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
763 if ( res == 1 ) return false;
765 aGroup = myGroups[idx-1];
769 SMESH::ElementType anElementType;
770 long anElemId = -1, nbElemsBefore = 0;
771 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
772 switch (myGeomType) {
773 case SMDSEntity_Quad_Edge:
774 anElementType = SMESH::EDGE;
775 nbElemsBefore = myMesh->NbEdges();
776 anElemId = aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
777 case SMDSEntity_Quad_Triangle:
778 case SMDSEntity_Quad_Quadrangle:
779 case SMDSEntity_BiQuad_Triangle:
780 case SMDSEntity_BiQuad_Quadrangle:
781 anElementType = SMESH::FACE;
782 nbElemsBefore = myMesh->NbFaces();
783 anElemId = aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
784 case SMDSEntity_Quad_Polygon:
785 anElementType = SMESH::FACE;
786 nbElemsBefore = myMesh->NbFaces();
787 anElemId = aMeshEditor->AddQuadPolygonalFace(anArrayOfIdeces.inout()); break;
788 case SMDSEntity_Quad_Tetra:
789 case SMDSEntity_Quad_Pyramid:
790 case SMDSEntity_Quad_Penta:
791 case SMDSEntity_Quad_Hexa:
792 case SMDSEntity_TriQuad_Hexa:
793 anElementType = SMESH::VOLUME;
794 nbElemsBefore = myMesh->NbVolumes();
795 anElemId = aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
799 if ( anElemId != -1 && addToGroup && !aGroupName.isEmpty() ) {
800 SMESH::SMESH_Group_var aGroupUsed;
801 if ( aGroup->_is_nil() ) {
803 aGroupUsed = SMESH::AddGroup( myMesh, anElementType, aGroupName );
804 if ( !aGroupUsed->_is_nil() ) {
805 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroupUsed));
806 ComboBox_GroupName->addItem( aGroupName );
810 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup );
811 SMESH::SMESH_GroupOnFilter_var aFilterGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGroup );
812 if ( !aGeomGroup->_is_nil() ) {
813 aGroupUsed = myMesh->ConvertToStandalone( aGeomGroup );
814 if ( !aGroupUsed->_is_nil() && idx > 0 ) {
815 myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
816 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
819 else if ( !aFilterGroup->_is_nil() ) {
820 aGroupUsed = myMesh->ConvertToStandalone( aFilterGroup );
821 if ( !aGroupUsed->_is_nil() && idx > 0 ) {
822 myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
823 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
827 aGroupUsed = SMESH::SMESH_Group::_narrow( aGroup );
830 if ( !aGroupUsed->_is_nil() ) {
831 SMESH::long_array_var anIdList = new SMESH::long_array;
832 anIdList->length( 1 );
833 anIdList[0] = anElemId;
834 aGroupUsed->Add( anIdList.inout() );
838 if ( nbElemsBefore == 0 )
840 // 1st element of the type has been added, update actor to show this entity
841 unsigned int aMode = myActor->GetEntityMode();
842 switch ( anElementType ) {
844 myActor->SetRepresentation(SMESH_Actor::eEdge);
845 myActor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break;
847 myActor->SetRepresentation(SMESH_Actor::eSurface);
848 myActor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break;
850 myActor->SetRepresentation(SMESH_Actor::eSurface);
851 myActor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break;
855 SALOME_ListIO aList; aList.Append( myActor->getIO() );
856 mySelector->ClearIndex();
857 mySelectionMgr->setSelectedObjects( aList, false );
859 mySimulation->SetVisibility(false);
863 SetCurrentSelection();
867 SMESHGUI::Modified();
872 //=================================================================================
873 // function : ClickOnOk()
875 //=================================================================================
877 void SMESHGUI_AddQuadraticElementDlg::ClickOnOk()
879 if ( ClickOnApply() )
883 //=================================================================================
884 // function : reject()
886 //=================================================================================
888 void SMESHGUI_AddQuadraticElementDlg::reject()
890 mySelectionMgr->clearSelected();
891 mySimulation->SetVisibility(false);
892 SMESH::SetPointRepresentation(false);
893 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
894 aViewWindow->SetSelectionMode( ActorSelection );
895 disconnect(mySelectionMgr, 0, this, 0);
896 mySMESHGUI->ResetState();
900 //=================================================================================
901 // function : onOpenView()
903 //=================================================================================
904 void SMESHGUI_AddQuadraticElementDlg::onOpenView()
906 if ( mySelector && mySimulation ) {
907 mySimulation->SetVisibility(false);
908 SMESH::SetPointRepresentation(false);
911 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
912 mySimulation = new SMESH::TElementSimulationQuad(
913 dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
914 ActivateThisDialog();
918 //=================================================================================
919 // function : onCloseView()
921 //=================================================================================
922 void SMESHGUI_AddQuadraticElementDlg::onCloseView()
924 DeactivateActiveDialog();
929 //=================================================================================
930 // function : ClickOnHelp()
932 //=================================================================================
934 void SMESHGUI_AddQuadraticElementDlg::ClickOnHelp()
936 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
938 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
942 platform = "winapplication";
944 platform = "application";
946 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
947 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
948 arg(app->resourceMgr()->stringValue("ExternalBrowser",
950 arg(myHelpFileName));
954 //=================================================================================
955 // function : onTextChange()
957 //=================================================================================
959 void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText)
962 BusyLocker lock( myBusy );
964 mySimulation->SetVisibility(false);
966 // hilight entered nodes
967 SMDS_Mesh* aMesh = 0;
969 aMesh = myActor->GetObject()->GetMesh();
971 QLineEdit* send = (QLineEdit*)sender();
972 if (send == myCornerNodes ||
973 send == myMidFaceNodes ||
974 send == myCenterNode)
975 myCurrentLineEdit = send;
978 TColStd_MapOfInteger newIndices;
980 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
982 for (int i = 0; i < aListId.count(); i++) {
983 if ( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
985 newIndices.Add( n->GetID() );
994 mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
995 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
996 aViewWindow->highlight( myActor->getIO(), true, true );
998 if ( myCurrentLineEdit == myCornerNodes )
999 UpdateTable( allOk );
1003 displaySimulation();
1006 //=================================================================================
1007 // function : SelectionIntoArgument()
1008 // purpose : Called when selection has changed
1009 //=================================================================================
1011 void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument()
1014 BusyLocker lock( myBusy );
1016 QString aCurrentEntry = myEntry;
1018 if ( myCurrentLineEdit )
1023 myCurrentLineEdit->setText("");
1025 if (!GroupButtons->isEnabled()) // inactive
1028 mySimulation->SetVisibility(false);
1030 // get selected mesh
1031 SALOME_ListIO aList;
1032 mySelectionMgr->selectedObjects(aList);
1034 if (aList.Extent() != 1)
1041 Handle(SALOME_InteractiveObject) anIO = aList.First();
1042 myEntry = anIO->getEntry();
1043 myMesh = SMESH::GetMeshByIO(anIO);
1044 if (myMesh->_is_nil()) {
1049 myActor = SMESH::FindActorByEntry(anIO->getEntry());
1054 if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
1055 SMESH::ElementType anElementType;
1056 switch ( myGeomType ) {
1057 case SMDSEntity_Quad_Edge:
1058 anElementType = SMESH::EDGE; break;
1059 case SMDSEntity_Quad_Triangle:
1060 case SMDSEntity_Quad_Quadrangle:
1061 case SMDSEntity_Quad_Polygon:
1062 case SMDSEntity_BiQuad_Triangle:
1063 case SMDSEntity_BiQuad_Quadrangle:
1064 anElementType = SMESH::FACE; break;
1065 case SMDSEntity_Quad_Tetra:
1066 case SMDSEntity_Quad_Pyramid:
1067 case SMDSEntity_Quad_Penta:
1068 case SMDSEntity_Quad_Hexa:
1069 case SMDSEntity_TriQuad_Hexa:
1070 anElementType = SMESH::VOLUME; break;
1073 ComboBox_GroupName->clear();
1074 ComboBox_GroupName->addItem( QString() );
1075 SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
1076 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
1077 SMESH::SMESH_GroupBase_var aGroup = aListOfGroups[i];
1078 if ( !aGroup->_is_nil() && aGroup->GetType() == anElementType ) {
1079 QString aGroupName( aGroup->GetName() );
1080 if ( !aGroupName.isEmpty() ) {
1081 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
1082 ComboBox_GroupName->addItem( aGroupName );
1093 // get selected nodes
1094 QString aString = "";
1095 int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString);
1097 if ( myCurrentLineEdit )
1099 if ( myCurrentLineEdit != myCenterNode || nbNodes == 1 )
1100 myCurrentLineEdit->setText(aString);
1102 if ( myCurrentLineEdit == myCornerNodes )
1105 else if ( myTable->isEnabled() && nbNodes == 1 )
1107 int theRow = myTable->currentRow(), theCol = myTable->currentColumn();
1109 myTable->item(theRow, 1)->setText(aString);
1113 displaySimulation();
1116 //=================================================================================
1117 // function : displaySimulation()
1119 //=================================================================================
1121 void SMESHGUI_AddQuadraticElementDlg::displaySimulation()
1125 SMESH::TElementSimulationQuad::TVTKIds anIds;
1127 // Collect ids from the dialog
1130 int aDisplayMode = VTK_SURFACE;
1132 if ( myGeomType == SMDSEntity_Quad_Edge )
1134 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) );
1135 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 2)->text().toInt() ) );
1136 anID = myTable->item(0, 1)->text().toInt(&ok);
1137 if (!ok) anID = myTable->item(0, 0)->text().toInt();
1138 anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
1139 aDisplayMode = VTK_WIREFRAME;
1143 for ( int row = 0; row < myNbCorners; row++ )
1144 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(row, 0)->text().toInt() ) );
1146 for ( int row = 0; row < myTable->rowCount(); row++ )
1148 anID = myTable->item(row, 1)->text().toInt(&ok);
1150 anID = myTable->item(row, 0)->text().toInt();
1151 aDisplayMode = VTK_WIREFRAME;
1153 anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
1155 if ( myNbMidFaceNodes )
1157 QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
1158 for (int i = 0; i < aListId.count(); i++)
1159 anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() ));
1161 if ( myNbCenterNodes )
1163 QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts);
1164 anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ 0 ].toInt() ));
1168 mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked());
1172 mySimulation->SetVisibility(false);
1174 SMESH::UpdateView();
1177 //=================================================================================
1178 // function : SetCurrentSelection()
1180 //=================================================================================
1182 void SMESHGUI_AddQuadraticElementDlg::SetCurrentSelection()
1184 QPushButton* send = (QPushButton*)sender();
1185 myCurrentLineEdit = 0;
1187 if (send == myCornerSelectButton)
1188 myCurrentLineEdit = myCornerNodes;
1189 else if ( send == myMidFaceSelectButton )
1190 myCurrentLineEdit = myMidFaceNodes;
1191 else if ( send == myCenterSelectButton )
1192 myCurrentLineEdit = myCenterNode;
1194 if ( myCurrentLineEdit )
1196 myCurrentLineEdit->setFocus();
1197 SelectionIntoArgument();
1201 //=================================================================================
1202 // function : DeactivateActiveDialog()
1204 //=================================================================================
1206 void SMESHGUI_AddQuadraticElementDlg::DeactivateActiveDialog()
1208 if (GroupConstructors->isEnabled()) {
1209 GroupConstructors->setEnabled(false);
1210 GroupArguments->setEnabled(false);
1211 GroupButtons->setEnabled(false);
1212 mySimulation->SetVisibility(false);
1213 mySMESHGUI->ResetState();
1214 mySMESHGUI->SetActiveDialogBox(0);
1218 //=================================================================================
1219 // function : ActivateThisDialog()
1221 //=================================================================================
1223 void SMESHGUI_AddQuadraticElementDlg::ActivateThisDialog()
1225 /* Emit a signal to deactivate the active dialog */
1226 mySMESHGUI->EmitSignalDeactivateDialog();
1228 GroupConstructors->setEnabled(true);
1229 GroupArguments->setEnabled(true);
1230 GroupButtons->setEnabled(true);
1232 SMESH::SetPointRepresentation(true);
1234 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1235 aViewWindow->SetSelectionMode( NodeSelection );
1236 SelectionIntoArgument();
1239 //=================================================================================
1240 // function : enterEvent()
1242 //=================================================================================
1243 void SMESHGUI_AddQuadraticElementDlg::enterEvent (QEvent*)
1245 if ( !GroupConstructors->isEnabled() ) {
1246 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
1247 if ( aViewWindow && !mySelector && !mySimulation) {
1248 mySelector = aViewWindow->GetSelector();
1249 mySimulation = new SMESH::TElementSimulationQuad(
1250 dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
1252 ActivateThisDialog();
1256 //=================================================================================
1257 // function : onReverse()
1259 //=================================================================================
1261 void SMESHGUI_AddQuadraticElementDlg::onReverse (int state)
1263 mySimulation->SetVisibility(false);
1264 displaySimulation();
1268 //=================================================================================
1269 // function : IsValid()
1271 //=================================================================================
1273 bool SMESHGUI_AddQuadraticElementDlg::IsValid()
1275 SMDS_Mesh* aMesh = 0;
1277 aMesh = myActor->GetObject()->GetMesh();
1282 std::set< int > okIDs;
1283 for ( int row = 0; row < myTable->rowCount(); row++ )
1285 int anID = myTable->item(row, 1)->text().toInt(&ok);
1289 const SMDS_MeshNode * aNode = aMesh->FindNode(anID);
1292 okIDs.insert( anID );
1295 QStringList aListId;
1296 if ( myNbMidFaceNodes )
1297 aListId += myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
1298 if ( myNbCenterNodes )
1299 aListId += myCenterNode->text().split(" ", QString::SkipEmptyParts);
1301 for (int i = 0; i < aListId.count(); i++)
1303 int anID = aListId[ i ].toInt(&ok);
1307 if ( !aMesh->FindNode(anID) )
1309 okIDs.insert( anID );
1312 return okIDs.size() == myTable->rowCount() + myNbMidFaceNodes + myNbCenterNodes;
1315 //=================================================================================
1316 // function : UpdateTable()
1318 //=================================================================================
1320 void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity )
1322 QStringList aListCorners = myCornerNodes->text().split(" ", QString::SkipEmptyParts);
1324 if ( myGeomType == SMDSEntity_Quad_Polygon ) // POLYGON
1326 if ( aListCorners.count() < 3 )
1327 theConersValidity = false;
1329 if ( aListCorners.count() != myTable->rowCount() && theConersValidity )
1331 // adjust nb of rows for the polygon
1332 int oldNbRows = myTable->rowCount();
1333 myTable->setRowCount( aListCorners.count() );
1334 for ( int row = oldNbRows; row < myTable->rowCount(); row++ )
1336 myTable->setItem( row, 0, new QTableWidgetItem( "" ) );
1337 myTable->item( row, 0 )->setFlags(0);
1339 IdEditItem* anEditItem = new IdEditItem( "" );
1340 anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1341 myTable->setItem(row, 1, anEditItem);
1343 myTable->setItem( row, 2, new QTableWidgetItem( "" ) );
1344 myTable->item( row, 2 )->setFlags(0);
1346 myNbCorners = aListCorners.count();
1348 // fill FirstPolygonIds and LastPolygonIds
1349 FirstPolygonIds.resize( aListCorners.count() );
1350 LastPolygonIds .resize( aListCorners.count() );
1351 for ( int i = 0; i < aListCorners.count(); ++i )
1353 FirstPolygonIds[i] = i;
1354 LastPolygonIds [i] = i+1;
1356 LastPolygonIds.back() = 0;
1358 myNbCorners = aListCorners.count();
1362 if ( aListCorners.count() == myNbCorners && theConersValidity )
1364 myTable->setEnabled( true );
1366 // clear the Middle column
1367 for ( int row = 0; row < myTable->rowCount(); row++ )
1368 myTable->item( row, 1 )->setText("");
1373 switch (myGeomType) {
1374 case SMDSEntity_Quad_Edge:
1375 aFirstColIds = FirstEdgeIds;
1376 aLastColIds = LastEdgeIds;
1378 case SMDSEntity_Quad_Triangle:
1379 case SMDSEntity_BiQuad_Triangle:
1380 aFirstColIds = FirstTriangleIds;
1381 aLastColIds = LastTriangleIds;
1383 case SMDSEntity_Quad_Quadrangle:
1384 case SMDSEntity_BiQuad_Quadrangle:
1385 aFirstColIds = FirstQuadrangleIds;
1386 aLastColIds = LastQuadrangleIds;
1388 case SMDSEntity_Quad_Polygon:
1389 aFirstColIds = & FirstPolygonIds[0];
1390 aLastColIds = & LastPolygonIds[0];
1392 case SMDSEntity_Quad_Tetra:
1393 aFirstColIds = FirstTetrahedronIds;
1394 aLastColIds = LastTetrahedronIds;
1396 case SMDSEntity_Quad_Pyramid:
1397 aFirstColIds = FirstPyramidIds;
1398 aLastColIds = LastPyramidIds;
1400 case SMDSEntity_Quad_Penta:
1401 aFirstColIds = FirstPentahedronIds;
1402 aLastColIds = LastPentahedronIds;
1404 case SMDSEntity_Quad_Hexa:
1405 case SMDSEntity_TriQuad_Hexa:
1406 aFirstColIds = FirstHexahedronIds;
1407 aLastColIds = LastHexahedronIds;
1411 // fill the First and the Last columns
1412 for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++)
1413 myTable->item( i, 0 )->setText( aListCorners[ aFirstColIds[i] ] );
1415 for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++)
1416 myTable->item( i, 2 )->setText( aListCorners[ aLastColIds[i] ] );
1421 for ( int row = 0; row < myTable->rowCount(); row++ )
1422 for ( int col = 0; col < myTable->columnCount(); col++ )
1423 if ( QTableWidgetItem* aTWI = myTable->item(row, col) ) aTWI->setText("");
1425 myTable->setEnabled( false );
1429 //=================================================================================
1430 // function : onTableActivate()
1432 //=================================================================================
1434 void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol )
1436 myCurrentLineEdit = 0;
1437 displaySimulation();
1441 //=================================================================================
1442 // function : onCellTextChange()
1444 //=================================================================================
1446 void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol)
1448 myCurrentLineEdit = 0;
1449 displaySimulation();
1453 //=================================================================================
1454 // function : keyPressEvent()
1456 //=================================================================================
1458 void SMESHGUI_AddQuadraticElementDlg::keyPressEvent( QKeyEvent* e )
1460 QDialog::keyPressEvent( e );
1461 if ( e->isAccepted() )
1464 if ( e->key() == Qt::Key_F1 ) {
1470 //=======================================================================
1471 //function : updateButtons
1473 //=======================================================================
1475 void SMESHGUI_AddQuadraticElementDlg::updateButtons()
1477 bool valid = IsValid();
1478 buttonOk->setEnabled( valid );
1479 buttonApply->setEnabled( valid );
1482 //=================================================================================
1483 // function : isValid
1485 //=================================================================================
1487 bool SMESHGUI_AddQuadraticElementDlg::isValid()
1489 if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
1490 SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );