1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 #include "guiselectboundarycodes.h"
22 #include <vtkIntArray.h>
23 #include <vtkCellData.h>
25 #include "guimainwindow.h"
27 GuiSelectBoundaryCodes::GuiSelectBoundaryCodes()
32 void GuiSelectBoundaryCodes::setDisplayBoundaryCodes(const QSet
<int> &bcs
)
34 m_DisplayBoundaryCodes
= bcs
;
37 void GuiSelectBoundaryCodes::before()
39 populateBoundaryCodes(m_Ui
.listWidget
);
40 for (int row
= 0; row
< m_Ui
.listWidget
->count(); ++row
) {
41 QString txt
= m_Ui
.listWidget
->item(row
)->text();
42 QStringList words
= txt
.split(":");
43 if (words
.size() < 1) {
46 int bc
= words
[0].toInt();
47 bool checked
= m_DisplayBoundaryCodes
.contains(bc
);
49 m_Ui
.listWidget
->item(row
)->setCheckState(Qt::Checked
);
51 m_Ui
.listWidget
->item(row
)->setCheckState(Qt::Unchecked
);
55 connect(m_Ui
.pushButtonSelect
, SIGNAL(clicked()), this, SLOT(selectAll()));
56 connect(m_Ui
.pushButtonDeselect
, SIGNAL(clicked()), this, SLOT(deselectAll()));
57 connect(m_Ui
.pushButton_SaveSelectionAsGrid
, SIGNAL(clicked()), this, SLOT(saveSelectionAsGrid()));
60 void GuiSelectBoundaryCodes::operate()
62 getSelectedItems(m_Ui
.listWidget
, m_DisplayBoundaryCodes
);
65 void GuiSelectBoundaryCodes::selectAll()
67 for (int i
= 0; i
< m_Ui
.listWidget
->count(); ++i
) {
68 m_Ui
.listWidget
->item(i
)->setCheckState(Qt::Checked
);
72 void GuiSelectBoundaryCodes::deselectAll()
74 for (int i
= 0; i
< m_Ui
.listWidget
->count(); ++i
) {
75 m_Ui
.listWidget
->item(i
)->setCheckState(Qt::Unchecked
);
79 void GuiSelectBoundaryCodes::saveSelectionAsGrid()
81 getSelectedItems(m_Ui
.listWidget
, m_DisplayBoundaryCodes
);
82 QVector
<vtkIdType
> selected_cells
;
83 getSurfaceCells(m_DisplayBoundaryCodes
, selected_cells
, m_Grid
);
84 writeCells(m_Grid
, selected_cells
, GuiMainWindow::pointer()->getFilePath() + "selection.vtu" );
87 void GuiSelectBoundaryCodes::getSelectedBoundaryCodes(QSet
<int> &bcs
)
89 bcs
= m_DisplayBoundaryCodes
;