Debian Codegraph @

HercStudio/MipsGauge.cpp

raw symbols SCIP
1 /*
2 * File: MipsGauge.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Jun 15, 2010
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25 #include "MipsGauge.h"
26 #include "HerculesStudio.h"
27
28 #include <QPaintEvent>
29 #include <QPainter>
30
31 MipsGauge::MipsGauge(QWidget * parent)
32 : Mips(parent)
33 {
34 mHwm = 0.0;
35 resize(120,120);
36 mPenColor = QColor::fromRgb(250,250,250,50);
37 }
38
39 MipsGauge::~MipsGauge()
40 {
41 }
42
43 void MipsGauge::move(int x, int y)
44 {
45 QWidget::move(x,y);
46 }
47
48 void MipsGauge::display(double value)
49 {
50 mValue = value;
51 hOutDebug(5,"mValue=" << mValue);
52 if (mValue > mHwm)
53 mHwm = mValue;
54 static QRect rect(0,0,120,120);
55 update(rect);
56 }
57
58 void MipsGauge::setActive(bool active)
59 {
60 hOutDebug(5, "MipsGauge " << (active? "Active" : "NotActive"));
61 if (active)
62 mPenColor = QColor::fromRgb(250,250,250,255);
63 else
64 mPenColor = QColor::fromRgb(250,250,250,50);
65 this->repaint();
66 }
67
68 void MipsGauge::setToolTip(const QString & tip)
69 {
70 QWidget::setToolTip(tip);
71 }
72
73 void MipsGauge::paintEvent(QPaintEvent *)
74 {
75 hOutDebug(5,"Gauge paint" << std::endl);
76 QPainter painter(this);
77 painter.setPen(mPenColor);
78
79 painter.drawArc(0,10,120,120,30*16,120*16);
80 painter.translate(60,70);
81
82 painter.rotate(30.0);
83 for (int angle=30; angle<=150; angle+=10)
84 {
85 painter.drawLine(-65,0,-60,0);
86 painter.rotate(10.0);
87 }
88 painter.rotate(-160.0);
89 mPrevAngle = 30.0;
90
91 double angle = 30.0 ;
92 if (mHwm > 0.0)
93 angle = 30 + (mValue/mHwm*120);
94 hOutDebug(5,"angle="<<angle << " hwm=" << mHwm << std::endl);
95
96 painter.rotate(angle);
97 painter.drawLine(-50,0,-20,0);
98 }
99
100 void MipsGauge::deleteLater()
101 {
102 QWidget::deleteLater();
103 }
104
105 bool MipsGauge::isVisible()
106 {
107 return QWidget::isVisible();
108 }