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_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
605 myMidFaceLabel ->setVisible( myNbMidFaceNodes );
606 myMidFaceSelectButton->setVisible( myNbMidFaceNodes );
607 myMidFaceNodes ->setVisible( myNbMidFaceNodes );
608 myCenterLabel ->setVisible( myNbCenterNodes );
609 myCenterSelectButton ->setVisible( myNbCenterNodes );
610 myCenterNode ->setVisible( myNbCenterNodes );
612 myCornerNodes->setValidator(new SMESHGUI_IdValidator(this, myNbCorners));
614 /* initialize table */
615 myTable->setColumnCount(3);
616 myTable->setRowCount(aNumRows);
618 QStringList aColLabels;
619 aColLabels.append(tr("SMESH_FIRST"));
620 aColLabels.append(tr("SMESH_MIDDLE"));
621 aColLabels.append(tr("SMESH_LAST"));
622 myTable->setHorizontalHeaderLabels(aColLabels);
624 for ( int col = 0; col < myTable->columnCount(); col++ )
625 myTable->setColumnWidth(col, 80);
627 //myTable->setColumnReadOnly(0, true); // VSR: TODO
628 //myTable->setColumnReadOnly(2, true); // VSR: TODO
630 myTable->setEnabled( false );
632 for ( int row = 0; row < myTable->rowCount(); row++ )
634 myTable->setItem( row, 0, new QTableWidgetItem( "" ) );
635 myTable->item( row, 0 )->setFlags(0);
637 IdEditItem* anEditItem = new IdEditItem( "" );
638 anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
639 myTable->setItem(row, 1, anEditItem);
641 myTable->setItem( row, 2, new QTableWidgetItem( "" ) );
642 myTable->item( row, 2 )->setFlags(0);
645 /* signals and slots connections */
646 connect(myCornerSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
647 connect(myMidFaceSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
648 connect(myCenterSelectButton, SIGNAL(clicked()), SLOT(SetCurrentSelection()));
649 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
650 connect(myTable, SIGNAL(cellDoubleClicked(int, int)), SLOT(onCellDoubleClicked(int, int)));
651 connect(myTable, SIGNAL(cellChanged (int, int)), SLOT(onCellTextChange(int, int)));
652 connect(myCornerNodes, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
653 connect(myMidFaceNodes, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
654 connect(myCenterNode, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
655 connect(myReverseCB, SIGNAL(stateChanged(int)), SLOT(onReverse(int)));
657 connect(buttonOk, SIGNAL(clicked()), SLOT(ClickOnOk()));
658 connect(buttonCancel, SIGNAL(clicked()), SLOT(reject()));
659 connect(buttonApply, SIGNAL(clicked()), SLOT(ClickOnApply()));
660 connect(buttonHelp, SIGNAL(clicked()), SLOT(ClickOnHelp()));
662 connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
663 connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(reject()));
664 connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), SLOT(reject()));
665 connect(mySMESHGUI, SIGNAL (SignalActivatedViewManager()), SLOT(onOpenView()));
666 connect(mySMESHGUI, SIGNAL (SignalCloseView()), SLOT(onCloseView()));
668 myCurrentLineEdit = myCornerNodes;
670 // set selection mode
671 SMESH::SetPointRepresentation(true);
673 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
674 aViewWindow->SetSelectionMode( NodeSelection );
676 SelectionIntoArgument();
679 //=================================================================================
680 // function : ClickOnApply()
682 //=================================================================================
684 bool SMESHGUI_AddQuadraticElementDlg::ClickOnApply()
689 if ( mySMESHGUI->isActiveStudyLocked() || myBusy || !IsValid() )
692 BusyLocker lock( myBusy );
694 std::vector<vtkIdType> anIds;
696 switch (myGeomType) {
697 case SMDSEntity_Quad_Edge:
698 anIds.push_back(myTable->item(0, 0)->text().toInt());
699 anIds.push_back(myTable->item(0, 2)->text().toInt());
700 anIds.push_back(myTable->item(0, 1)->text().toInt());
702 case SMDSEntity_Quad_Triangle:
703 case SMDSEntity_Quad_Quadrangle:
704 case SMDSEntity_Quad_Polygon:
705 case SMDSEntity_BiQuad_Triangle:
706 case SMDSEntity_BiQuad_Quadrangle:
707 case SMDSEntity_Quad_Tetra:
708 case SMDSEntity_Quad_Pyramid:
709 case SMDSEntity_Quad_Penta:
710 case SMDSEntity_Quad_Hexa:
711 case SMDSEntity_TriQuad_Hexa:
712 for ( int row = 0; row < myNbCorners; row++ )
713 anIds.push_back(myTable->item(row, 0)->text().toInt());
714 for ( int row = 0; row < myTable->rowCount(); row++ )
715 anIds.push_back(myTable->item(row, 1)->text().toInt());
716 if ( myNbMidFaceNodes )
718 QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
719 for (int i = 0; i < aListId.count(); i++)
720 anIds.push_back( aListId[ i ].toInt() );
722 if ( myNbCenterNodes )
724 QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts);
725 anIds.push_back( aListId[ 0 ].toInt() );
730 if ( myReverseCB->isChecked())
731 ReverseConnectivity( anIds, myGeomType, /*toReverse=*/true, /*toVtkOrder=*/false );
733 int aNumberOfIds = anIds.size();
734 SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
735 anArrayOfIdeces->length( aNumberOfIds );
737 for (int i = 0; i < aNumberOfIds; i++)
738 anArrayOfIdeces[i] = anIds[ i ];
740 bool addToGroup = GroupGroups->isChecked();
743 SMESH::SMESH_GroupBase_var aGroup;
746 aGroupName = ComboBox_GroupName->currentText();
747 for ( int i = 1; i <= ComboBox_GroupName->count(); i++ ) {
748 QString aName = ComboBox_GroupName->itemText( i );
749 if ( aGroupName == aName && ( i == ComboBox_GroupName->currentIndex() || idx == 0 ) )
752 if ( idx > 0 && idx <= myGroups.count() ) {
753 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( myGroups[idx-1] );
754 if ( !aGeomGroup->_is_nil() ) {
755 int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
756 tr( "MESH_GEOM_GRP_CHOSEN" ).arg( aGroupName ),
757 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
758 if ( res == 1 ) return false;
760 SMESH::SMESH_GroupOnFilter_var aFilterGroup = SMESH::SMESH_GroupOnFilter::_narrow( myGroups[idx-1] );
761 if ( !aFilterGroup->_is_nil() ) {
762 int res = SUIT_MessageBox::question( this, tr( "SMESH_WRN_WARNING" ),
763 tr( "MESH_FILTER_GRP_CHOSEN" ).arg( aGroupName ),
764 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 );
765 if ( res == 1 ) return false;
767 aGroup = myGroups[idx-1];
771 SMESH::ElementType anElementType = SMESH::ALL;
772 long anElemId = -1, nbElemsBefore = 0;
773 SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
774 switch (myGeomType) {
775 case SMDSEntity_Quad_Edge:
776 anElementType = SMESH::EDGE;
777 nbElemsBefore = myMesh->NbEdges();
778 anElemId = aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
779 case SMDSEntity_Quad_Triangle:
780 case SMDSEntity_Quad_Quadrangle:
781 case SMDSEntity_BiQuad_Triangle:
782 case SMDSEntity_BiQuad_Quadrangle:
783 anElementType = SMESH::FACE;
784 nbElemsBefore = myMesh->NbFaces();
785 anElemId = aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
786 case SMDSEntity_Quad_Polygon:
787 anElementType = SMESH::FACE;
788 nbElemsBefore = myMesh->NbFaces();
789 anElemId = aMeshEditor->AddQuadPolygonalFace(anArrayOfIdeces.inout()); break;
790 case SMDSEntity_Quad_Tetra:
791 case SMDSEntity_Quad_Pyramid:
792 case SMDSEntity_Quad_Penta:
793 case SMDSEntity_Quad_Hexa:
794 case SMDSEntity_TriQuad_Hexa:
795 anElementType = SMESH::VOLUME;
796 nbElemsBefore = myMesh->NbVolumes();
797 anElemId = aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
801 if ( anElemId != -1 && addToGroup && !aGroupName.isEmpty() ) {
802 SMESH::SMESH_Group_var aGroupUsed;
803 if ( aGroup->_is_nil() ) {
805 aGroupUsed = SMESH::AddGroup( myMesh, anElementType, aGroupName );
806 if ( !aGroupUsed->_is_nil() ) {
807 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroupUsed));
808 ComboBox_GroupName->addItem( aGroupName );
812 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGroup );
813 SMESH::SMESH_GroupOnFilter_var aFilterGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGroup );
814 if ( !aGeomGroup->_is_nil() ) {
815 aGroupUsed = myMesh->ConvertToStandalone( aGeomGroup );
816 if ( !aGroupUsed->_is_nil() && idx > 0 ) {
817 myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
818 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
821 else if ( !aFilterGroup->_is_nil() ) {
822 aGroupUsed = myMesh->ConvertToStandalone( aFilterGroup );
823 if ( !aGroupUsed->_is_nil() && idx > 0 ) {
824 myGroups[idx-1] = SMESH::SMESH_GroupBase::_duplicate(aGroupUsed);
825 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser();
829 aGroupUsed = SMESH::SMESH_Group::_narrow( aGroup );
832 if ( !aGroupUsed->_is_nil() ) {
833 SMESH::long_array_var anIdList = new SMESH::long_array;
834 anIdList->length( 1 );
835 anIdList[0] = anElemId;
836 aGroupUsed->Add( anIdList.inout() );
840 if ( nbElemsBefore == 0 )
842 // 1st element of the type has been added, update actor to show this entity
843 unsigned int aMode = myActor->GetEntityMode();
844 switch ( anElementType ) {
846 myActor->SetRepresentation(SMESH_Actor::eEdge);
847 myActor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break;
849 myActor->SetRepresentation(SMESH_Actor::eSurface);
850 myActor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break;
852 myActor->SetRepresentation(SMESH_Actor::eSurface);
853 myActor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break;
858 SALOME_ListIO aList; aList.Append( myActor->getIO() );
859 mySelector->ClearIndex();
860 mySelectionMgr->setSelectedObjects( aList, false );
862 mySimulation->SetVisibility(false);
866 SetCurrentSelection();
870 SMESHGUI::Modified();
875 //=================================================================================
876 // function : ClickOnOk()
878 //=================================================================================
880 void SMESHGUI_AddQuadraticElementDlg::ClickOnOk()
882 if ( ClickOnApply() )
886 //=================================================================================
887 // function : reject()
889 //=================================================================================
891 void SMESHGUI_AddQuadraticElementDlg::reject()
893 mySelectionMgr->clearSelected();
894 mySimulation->SetVisibility(false);
895 SMESH::SetPointRepresentation(false);
896 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
897 aViewWindow->SetSelectionMode( ActorSelection );
898 disconnect(mySelectionMgr, 0, this, 0);
899 mySMESHGUI->ResetState();
903 //=================================================================================
904 // function : onOpenView()
906 //=================================================================================
907 void SMESHGUI_AddQuadraticElementDlg::onOpenView()
909 if ( mySelector && mySimulation ) {
910 mySimulation->SetVisibility(false);
911 SMESH::SetPointRepresentation(false);
914 mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
915 mySimulation = new SMESH::TElementSimulationQuad(
916 dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
917 ActivateThisDialog();
921 //=================================================================================
922 // function : onCloseView()
924 //=================================================================================
925 void SMESHGUI_AddQuadraticElementDlg::onCloseView()
927 DeactivateActiveDialog();
932 //=================================================================================
933 // function : ClickOnHelp()
935 //=================================================================================
937 void SMESHGUI_AddQuadraticElementDlg::ClickOnHelp()
939 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
941 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
945 platform = "winapplication";
947 platform = "application";
949 SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
950 tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
951 arg(app->resourceMgr()->stringValue("ExternalBrowser",
953 arg(myHelpFileName));
957 //=================================================================================
958 // function : onTextChange()
960 //=================================================================================
962 void SMESHGUI_AddQuadraticElementDlg::onTextChange (const QString& theNewText)
965 BusyLocker lock( myBusy );
967 mySimulation->SetVisibility(false);
969 // hilight entered nodes
970 SMDS_Mesh* aMesh = 0;
972 aMesh = myActor->GetObject()->GetMesh();
974 QLineEdit* send = (QLineEdit*)sender();
975 if (send == myCornerNodes ||
976 send == myMidFaceNodes ||
977 send == myCenterNode)
978 myCurrentLineEdit = send;
981 TColStd_MapOfInteger newIndices;
983 QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
985 for (int i = 0; i < aListId.count(); i++) {
986 if ( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
988 newIndices.Add( n->GetID() );
997 mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
998 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
999 aViewWindow->highlight( myActor->getIO(), true, true );
1001 if ( myCurrentLineEdit == myCornerNodes )
1002 UpdateTable( allOk );
1006 displaySimulation();
1009 //=================================================================================
1010 // function : SelectionIntoArgument()
1011 // purpose : Called when selection has changed
1012 //=================================================================================
1014 void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument()
1017 BusyLocker lock( myBusy );
1019 QString aCurrentEntry = myEntry;
1021 if ( myCurrentLineEdit )
1026 myCurrentLineEdit->setText("");
1028 if (!GroupButtons->isEnabled()) // inactive
1031 mySimulation->SetVisibility(false);
1033 // get selected mesh
1034 SALOME_ListIO aList;
1035 mySelectionMgr->selectedObjects(aList);
1037 if (aList.Extent() != 1)
1044 Handle(SALOME_InteractiveObject) anIO = aList.First();
1045 myEntry = anIO->getEntry();
1046 myMesh = SMESH::GetMeshByIO(anIO);
1047 if (myMesh->_is_nil()) {
1052 myActor = SMESH::FindActorByEntry(anIO->getEntry());
1057 if ( !myMesh->_is_nil() && myEntry != aCurrentEntry ) {
1058 SMESH::ElementType anElementType = SMESH::ALL;
1059 switch ( myGeomType ) {
1060 case SMDSEntity_Quad_Edge:
1061 anElementType = SMESH::EDGE; break;
1062 case SMDSEntity_Quad_Triangle:
1063 case SMDSEntity_Quad_Quadrangle:
1064 case SMDSEntity_Quad_Polygon:
1065 case SMDSEntity_BiQuad_Triangle:
1066 case SMDSEntity_BiQuad_Quadrangle:
1067 anElementType = SMESH::FACE; break;
1068 case SMDSEntity_Quad_Tetra:
1069 case SMDSEntity_Quad_Pyramid:
1070 case SMDSEntity_Quad_Penta:
1071 case SMDSEntity_Quad_Hexa:
1072 case SMDSEntity_TriQuad_Hexa:
1073 anElementType = SMESH::VOLUME; break;
1077 ComboBox_GroupName->clear();
1078 ComboBox_GroupName->addItem( QString() );
1079 SMESH::ListOfGroups aListOfGroups = *myMesh->GetGroups();
1080 for ( int i = 0, n = aListOfGroups.length(); i < n; i++ ) {
1081 SMESH::SMESH_GroupBase_var aGroup = aListOfGroups[i];
1082 if ( !aGroup->_is_nil() && aGroup->GetType() == anElementType ) {
1083 QString aGroupName( aGroup->GetName() );
1084 if ( !aGroupName.isEmpty() ) {
1085 myGroups.append(SMESH::SMESH_GroupBase::_duplicate(aGroup));
1086 ComboBox_GroupName->addItem( aGroupName );
1097 // get selected nodes
1098 QString aString = "";
1099 int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString);
1101 if ( myCurrentLineEdit )
1103 if ( myCurrentLineEdit != myCenterNode || nbNodes == 1 )
1104 myCurrentLineEdit->setText(aString);
1106 if ( myCurrentLineEdit == myCornerNodes )
1109 else if ( myTable->isEnabled() && nbNodes == 1 )
1111 int theRow = myTable->currentRow(), theCol = myTable->currentColumn();
1113 myTable->item(theRow, 1)->setText(aString);
1117 displaySimulation();
1120 //=================================================================================
1121 // function : displaySimulation()
1123 //=================================================================================
1125 void SMESHGUI_AddQuadraticElementDlg::displaySimulation()
1129 SMESH::TElementSimulationQuad::TVTKIds anIds;
1131 // Collect ids from the dialog
1134 int aDisplayMode = VTK_SURFACE;
1136 if ( myGeomType == SMDSEntity_Quad_Edge )
1138 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) );
1139 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 2)->text().toInt() ) );
1140 anID = myTable->item(0, 1)->text().toInt(&ok);
1141 if (!ok) anID = myTable->item(0, 0)->text().toInt();
1142 anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
1143 aDisplayMode = VTK_WIREFRAME;
1147 for ( int row = 0; row < myNbCorners; row++ )
1148 anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(row, 0)->text().toInt() ) );
1150 for ( int row = 0; row < myTable->rowCount(); row++ )
1152 anID = myTable->item(row, 1)->text().toInt(&ok);
1154 anID = myTable->item(row, 0)->text().toInt();
1155 aDisplayMode = VTK_WIREFRAME;
1157 anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
1159 if ( myNbMidFaceNodes )
1161 QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
1162 for (int i = 0; i < aListId.count(); i++)
1163 anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() ));
1165 if ( myNbCenterNodes )
1167 QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts);
1168 anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ 0 ].toInt() ));
1172 mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked());
1176 mySimulation->SetVisibility(false);
1178 SMESH::UpdateView();
1181 //=================================================================================
1182 // function : SetCurrentSelection()
1184 //=================================================================================
1186 void SMESHGUI_AddQuadraticElementDlg::SetCurrentSelection()
1188 QPushButton* send = (QPushButton*)sender();
1189 myCurrentLineEdit = 0;
1191 if (send == myCornerSelectButton)
1192 myCurrentLineEdit = myCornerNodes;
1193 else if ( send == myMidFaceSelectButton )
1194 myCurrentLineEdit = myMidFaceNodes;
1195 else if ( send == myCenterSelectButton )
1196 myCurrentLineEdit = myCenterNode;
1198 if ( myCurrentLineEdit )
1200 myCurrentLineEdit->setFocus();
1201 SelectionIntoArgument();
1205 //=================================================================================
1206 // function : DeactivateActiveDialog()
1208 //=================================================================================
1210 void SMESHGUI_AddQuadraticElementDlg::DeactivateActiveDialog()
1212 if (GroupConstructors->isEnabled()) {
1213 GroupConstructors->setEnabled(false);
1214 GroupArguments->setEnabled(false);
1215 GroupButtons->setEnabled(false);
1216 mySimulation->SetVisibility(false);
1217 mySMESHGUI->ResetState();
1218 mySMESHGUI->SetActiveDialogBox(0);
1222 //=================================================================================
1223 // function : ActivateThisDialog()
1225 //=================================================================================
1227 void SMESHGUI_AddQuadraticElementDlg::ActivateThisDialog()
1229 /* Emit a signal to deactivate the active dialog */
1230 mySMESHGUI->EmitSignalDeactivateDialog();
1232 GroupConstructors->setEnabled(true);
1233 GroupArguments->setEnabled(true);
1234 GroupButtons->setEnabled(true);
1236 SMESH::SetPointRepresentation(true);
1238 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1239 aViewWindow->SetSelectionMode( NodeSelection );
1240 SelectionIntoArgument();
1243 //=================================================================================
1244 // function : enterEvent()
1246 //=================================================================================
1247 void SMESHGUI_AddQuadraticElementDlg::enterEvent (QEvent*)
1249 if ( !GroupConstructors->isEnabled() ) {
1250 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
1251 if ( aViewWindow && !mySelector && !mySimulation) {
1252 mySelector = aViewWindow->GetSelector();
1253 mySimulation = new SMESH::TElementSimulationQuad(
1254 dynamic_cast<SalomeApp_Application*>( mySMESHGUI->application() ) );
1256 ActivateThisDialog();
1260 //=================================================================================
1261 // function : onReverse()
1263 //=================================================================================
1265 void SMESHGUI_AddQuadraticElementDlg::onReverse (int state)
1267 mySimulation->SetVisibility(false);
1268 displaySimulation();
1272 //=================================================================================
1273 // function : IsValid()
1275 //=================================================================================
1277 bool SMESHGUI_AddQuadraticElementDlg::IsValid()
1279 SMDS_Mesh* aMesh = 0;
1281 aMesh = myActor->GetObject()->GetMesh();
1286 std::set< int > okIDs;
1287 for ( int row = 0; row < myTable->rowCount(); row++ )
1289 int anID = myTable->item(row, 1)->text().toInt(&ok);
1293 const SMDS_MeshNode * aNode = aMesh->FindNode(anID);
1296 okIDs.insert( anID );
1299 QStringList aListId;
1300 if ( myNbMidFaceNodes )
1301 aListId += myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
1302 if ( myNbCenterNodes )
1303 aListId += myCenterNode->text().split(" ", QString::SkipEmptyParts);
1305 for (int i = 0; i < aListId.count(); i++)
1307 int anID = aListId[ i ].toInt(&ok);
1311 if ( !aMesh->FindNode(anID) )
1313 okIDs.insert( anID );
1316 return (int) okIDs.size() == myTable->rowCount() + myNbMidFaceNodes + myNbCenterNodes;
1319 //=================================================================================
1320 // function : UpdateTable()
1322 //=================================================================================
1324 void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity )
1326 QStringList aListCorners = myCornerNodes->text().split(" ", QString::SkipEmptyParts);
1328 if ( myGeomType == SMDSEntity_Quad_Polygon ) // POLYGON
1330 if ( aListCorners.count() < 3 )
1331 theConersValidity = false;
1333 if ( aListCorners.count() != myTable->rowCount() && theConersValidity )
1335 // adjust nb of rows for the polygon
1336 int oldNbRows = myTable->rowCount();
1337 myTable->setRowCount( aListCorners.count() );
1338 for ( int row = oldNbRows; row < myTable->rowCount(); row++ )
1340 myTable->setItem( row, 0, new QTableWidgetItem( "" ) );
1341 myTable->item( row, 0 )->setFlags(0);
1343 IdEditItem* anEditItem = new IdEditItem( "" );
1344 anEditItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
1345 myTable->setItem(row, 1, anEditItem);
1347 myTable->setItem( row, 2, new QTableWidgetItem( "" ) );
1348 myTable->item( row, 2 )->setFlags(0);
1350 myNbCorners = aListCorners.count();
1352 // fill FirstPolygonIds and LastPolygonIds
1353 FirstPolygonIds.resize( aListCorners.count() );
1354 LastPolygonIds .resize( aListCorners.count() );
1355 for ( int i = 0; i < aListCorners.count(); ++i )
1357 FirstPolygonIds[i] = i;
1358 LastPolygonIds [i] = i+1;
1360 LastPolygonIds.back() = 0;
1362 myNbCorners = aListCorners.count();
1366 if ( aListCorners.count() == myNbCorners && theConersValidity )
1368 myTable->setEnabled( true );
1370 // clear the Middle column
1371 for ( int row = 0; row < myTable->rowCount(); row++ )
1372 myTable->item( row, 1 )->setText("");
1374 int* aFirstColIds = 0;
1375 int* aLastColIds = 0;
1377 switch (myGeomType) {
1378 case SMDSEntity_Quad_Edge:
1379 aFirstColIds = FirstEdgeIds;
1380 aLastColIds = LastEdgeIds;
1382 case SMDSEntity_Quad_Triangle:
1383 case SMDSEntity_BiQuad_Triangle:
1384 aFirstColIds = FirstTriangleIds;
1385 aLastColIds = LastTriangleIds;
1387 case SMDSEntity_Quad_Quadrangle:
1388 case SMDSEntity_BiQuad_Quadrangle:
1389 aFirstColIds = FirstQuadrangleIds;
1390 aLastColIds = LastQuadrangleIds;
1392 case SMDSEntity_Quad_Polygon:
1393 aFirstColIds = & FirstPolygonIds[0];
1394 aLastColIds = & LastPolygonIds[0];
1396 case SMDSEntity_Quad_Tetra:
1397 aFirstColIds = FirstTetrahedronIds;
1398 aLastColIds = LastTetrahedronIds;
1400 case SMDSEntity_Quad_Pyramid:
1401 aFirstColIds = FirstPyramidIds;
1402 aLastColIds = LastPyramidIds;
1404 case SMDSEntity_Quad_Penta:
1405 aFirstColIds = FirstPentahedronIds;
1406 aLastColIds = LastPentahedronIds;
1408 case SMDSEntity_Quad_Hexa:
1409 case SMDSEntity_TriQuad_Hexa:
1410 aFirstColIds = FirstHexahedronIds;
1411 aLastColIds = LastHexahedronIds;
1416 // fill the First and the Last columns
1417 for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++)
1418 myTable->item( i, 0 )->setText( aListCorners[ aFirstColIds[i] ] );
1420 for (int i = 0, iEnd = myTable->rowCount(); i < iEnd; i++)
1421 myTable->item( i, 2 )->setText( aListCorners[ aLastColIds[i] ] );
1426 for ( int row = 0; row < myTable->rowCount(); row++ )
1427 for ( int col = 0; col < myTable->columnCount(); col++ )
1428 if ( QTableWidgetItem* aTWI = myTable->item(row, col) ) aTWI->setText("");
1430 myTable->setEnabled( false );
1434 //=================================================================================
1435 // function : onTableActivate()
1437 //=================================================================================
1439 void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol )
1441 myCurrentLineEdit = 0;
1442 displaySimulation();
1446 //=================================================================================
1447 // function : onCellTextChange()
1449 //=================================================================================
1451 void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol)
1453 myCurrentLineEdit = 0;
1454 displaySimulation();
1458 //=================================================================================
1459 // function : keyPressEvent()
1461 //=================================================================================
1463 void SMESHGUI_AddQuadraticElementDlg::keyPressEvent( QKeyEvent* e )
1465 QDialog::keyPressEvent( e );
1466 if ( e->isAccepted() )
1469 if ( e->key() == Qt::Key_F1 ) {
1475 //=======================================================================
1476 //function : updateButtons
1478 //=======================================================================
1480 void SMESHGUI_AddQuadraticElementDlg::updateButtons()
1482 bool valid = IsValid();
1483 buttonOk->setEnabled( valid );
1484 buttonApply->setEnabled( valid );
1487 //=================================================================================
1488 // function : isValid
1490 //=================================================================================
1492 bool SMESHGUI_AddQuadraticElementDlg::isValid()
1494 if( GroupGroups->isChecked() && ComboBox_GroupName->currentText().isEmpty() ) {
1495 SUIT_MessageBox::warning( this, tr( "SMESH_WRN_WARNING" ), tr( "GROUP_NAME_IS_EMPTY" ) );