add non-functional c1 Hatchery
[openc2e.git] / qtgui / CreatureGrapher.cpp
blob6dca0554cf16ff067c638511d6879a0ef6f307af
1 /*
2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License along
13 with this program; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 #include "Creature.h"
18 #include "CreatureGrapher.h"
19 #include "qtopenc2e.h"
21 CreatureGrapher::CreatureGrapher(QtOpenc2e *p) : QWidget(p), parent(p) {
22 graph = new GraphWidget(this);
24 QPalette pal(palette());
25 pal.setColor(QPalette::Background, QColor(0, 0, 0));
26 graph->setPalette(pal);
27 graph->setAutoFillBackground(true);
29 resize(minimumSizeHint());
31 QHBoxLayout *layout = new QHBoxLayout(this);
32 layout->addWidget(graph);
33 setLayout(layout);
35 graph->setDataSetColour(2, QColor(255, 0, 0)); // Pyruvate in red
36 graph->setDataSetColour(3, QColor(0, 255, 0)); // Glucose in blue
37 graph->setDataSetColour(4, QColor(0, 0, 255)); // Glycogen in green
40 CreatureGrapher::~CreatureGrapher() {
43 void CreatureGrapher::onCreatureChange() {
44 graph->wipeGraph();
47 void CreatureGrapher::onCreatureTick() {
48 Creature *c = parent->getSelectedCreature();
49 if (!c) return; // TODO: assert
51 // TODO: oldCreature support
52 c2eCreature *cc = dynamic_cast<c2eCreature *>(c);
53 if (!cc) return;
55 graph->addDataPoint(2, cc->getChemical(2));
56 graph->addDataPoint(3, cc->getChemical(3));
57 graph->addDataPoint(4, cc->getChemical(4));
60 QSize CreatureGrapher::minimumSizeHint() const {
61 return QSize(100, 50);