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 "operation.h"
24 #include "guimainwindow.h"
26 #include <QApplication>
29 QSet
<Operation
*> Operation::garbage_operations
;
31 void Operation::collectGarbage()
33 QSet
<Operation
*> delete_operations
;
34 foreach (Operation
*op
, garbage_operations
) {
35 if (!op
->getThread().isRunning()) {
36 delete_operations
.insert(op
);
37 cout
<< "deleting Operation " << op
<< endl
;
41 foreach (Operation
*op
, delete_operations
) {
42 garbage_operations
.remove(op
);
46 Operation::Operation()
54 Operation::~Operation()
62 void OperationThread::run()
65 GuiMainWindow::lock();
66 GuiMainWindow::pointer()->setBusy();
69 op
->err
= new Error();
72 GuiMainWindow::unlock();
73 GuiMainWindow::pointer()->setIdle();
76 void Operation::operator()()
79 if (GuiMainWindow::tryLock()) {
81 thread
.setOperation(this);
82 GuiMainWindow::unlock();
83 thread
.start(QThread::LowPriority
);
85 QMessageBox::warning(NULL
, "not permitted", "Operation is not permitted while background process is running!");
97 void Operation::setAllCells()
99 QVector
<vtkIdType
> all_cells
;
100 getAllCells(all_cells
, grid
);
104 void Operation::setAllVolumeCells()
106 QVector
<vtkIdType
> cells
;
107 getAllVolumeCells(cells
, grid
);
111 void Operation::setAllSurfaceCells()
113 QVector
<vtkIdType
> cells
;
114 getAllSurfaceCells(cells
, grid
);
118 void Operation::initMapping()
120 nodes_map
.resize(nodes
.size());
121 for (int i_nodes
= 0; i_nodes
< nodes
.size(); ++i_nodes
) {
122 nodes_map
[i_nodes
] = nodes
[i_nodes
];
124 cells_map
.resize(cells
.size());
125 for (int i_cells
= 0; i_cells
< cells
.size(); ++i_cells
) {
126 cells_map
[i_cells
] = cells
[i_cells
];
130 void Operation::checkGrid()
133 grid
= GuiMainWindow::pointer()->getGrid();
135 if ((cells
.size() == 0) && autoset
) {
140 void Operation::updateActors()
142 mainWindow()->updateActors();
145 GuiMainWindow
* Operation::mainWindow()
147 return GuiMainWindow::pointer();