2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "guiselectboundarycodes.h"
24 #include <vtkIntArray.h>
25 #include <vtkCellData.h>
27 #include "guimainwindow.h"
29 GuiSelectBoundaryCodes::GuiSelectBoundaryCodes()
34 void GuiSelectBoundaryCodes::setDisplayBoundaryCodes(const QSet
<int> &bcs
)
36 display_boundary_codes
.clear();
39 display_boundary_codes
.insert(bc
);
43 void GuiSelectBoundaryCodes::before()
45 for (QSet
<int>::iterator i
= m_BoundaryCodes
.begin(); i
!= m_BoundaryCodes
.end(); ++i
) {
46 bool checked
= display_boundary_codes
.contains(*i
);
47 addListItem(ui
.listWidget
,*i
,checked
);
49 connect(ui
.pushButtonSelect
, SIGNAL(clicked()), this, SLOT(selectAll()));
50 connect(ui
.pushButtonDeselect
, SIGNAL(clicked()), this, SLOT(deselectAll()));
51 connect(ui
.pushButton_SaveSelectionAsGrid
, SIGNAL(clicked()), this, SLOT(saveSelectionAsGrid()));
54 void GuiSelectBoundaryCodes::operate()
56 display_boundary_codes
.clear();
57 for (QSet
<int>::iterator i
= m_BoundaryCodes
.begin(); i
!= m_BoundaryCodes
.end(); ++i
) {
58 if (checkListItem(ui
.listWidget
,*i
)) {
59 display_boundary_codes
.insert(*i
);
64 void GuiSelectBoundaryCodes::selectAll()
66 for (int i
= 0; i
< ui
.listWidget
->count(); ++i
) {
67 ui
.listWidget
->item(i
)->setCheckState(Qt::Checked
);
71 void GuiSelectBoundaryCodes::deselectAll()
73 for (int i
= 0; i
< ui
.listWidget
->count(); ++i
) {
74 ui
.listWidget
->item(i
)->setCheckState(Qt::Unchecked
);
78 void GuiSelectBoundaryCodes::saveSelectionAsGrid()
80 display_boundary_codes
.clear();
81 for (QSet
<int>::iterator i
= m_BoundaryCodes
.begin(); i
!= m_BoundaryCodes
.end(); ++i
) {
82 if (checkListItem(ui
.listWidget
,*i
)) {
83 display_boundary_codes
.insert(*i
);
87 QVector
<vtkIdType
> selected_cells
;
88 getSurfaceCells(display_boundary_codes
, selected_cells
, grid
);
89 writeCells(grid
, selected_cells
, GuiMainWindow::pointer()->getFilePath() + "selection.vtu" );
92 void GuiSelectBoundaryCodes::getSelectedBoundaryCodes(QSet
<int> &bcs
)
95 foreach(int bc
, display_boundary_codes
) {