3
* TOra - An Oracle Toolkit for DBA's and developers
4
* Copyright (C) 2003-2005 Quest Software, Inc
5
* Portions Copyright (C) 2005 Other Contributors
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; only version 2 of
10
* the License is valid for this program.
12
* This program 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 this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* As a special exception, you have permission to link this program
22
* with the Oracle Client libraries and distribute executables, as long
23
* as you follow the requirements of the GNU GPL in regard to all of the
24
* software in the executable aside from Oracle client libraries.
26
* Specifically you are not permitted to link this program with the
27
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
28
* And you are not permitted to distribute binaries compiled against
29
* these libraries without written consent from Quest Software, Inc.
30
* Observe that this does not disallow linking to the Qt Free Edition.
32
* You may link this product with any GPL'd Qt library such as Qt/Free
34
* All trademarks belong to their respective owners.
39
#include <qworkspace.h>
41
#include "tobarchart.h"
45
#include "tobarchart.moc"
47
toBarChart::toBarChart(QWidget *parent, const char *name, WFlags f)
48
: toLineChart(parent, name, f)
53
#define FONT_ALIGN AlignLeft|AlignTop|ExpandTabs
55
void toBarChart::paintChart(QPainter *p, QRect &rect)
57
QFontMetrics fm = p->fontMetrics();
64
std::list<std::list<double> >::reverse_iterator i = Values.rbegin();
65
if (i != Values.rend())
67
for (std::list<double>::iterator j = (*i).begin();j != (*i).end();j++)
74
else if (zMinValue > *j)
82
std::list<double> total;
83
std::list<bool>::iterator e = Enabled.begin();
85
for (std::list<std::list<double> >::iterator i = Values.begin();i != Values.end();i++)
87
std::list<double>::iterator k = total.begin();
88
if (e == Enabled.end() || *e)
90
for (std::list<double>::iterator j = (*i).begin();j != (*i).end();j++)
94
total.insert(total.end(), *j);
104
if (e != Enabled.end())
108
for (std::list<double>::iterator i = total.begin();i != total.end();i++)
115
else if (zMaxValue < *i)
120
zMinValue = MinValue;
123
zMinValue = round(zMinValue, false);
124
MinValue = zMinValue;
127
zMaxValue = MaxValue;
130
zMaxValue = round(zMaxValue, true);
131
MaxValue = zMaxValue;
136
paintLegend(p, rect);
139
std::list<QPointArray> Points;
141
int samples = countSamples();
142
int zeroy = int(rect.height() - 2 - ( -zMinValue / (zMaxValue - zMinValue) * (rect.height() - 4)));
145
const QWMatrix &mtx = p->worldMatrix();
146
p->setClipRect(int(mtx.dx() + 2), int(mtx.dy() + 2), rect.width() - 3, rect.height() - 3);
148
p->drawText(2, 2, rect.width() - 4, rect.height() - 4,
149
AlignLeft | AlignTop, tr("Zoom"));
150
std::list<bool>::reverse_iterator e = Enabled.rbegin();
151
for (std::list<std::list<double> >::reverse_iterator i = Values.rbegin();i != Values.rend();i++)
153
if (e == Enabled.rend() || *e)
155
std::list<double> &val = *i;
157
int skip = SkipSamples;
158
QPointArray a(samples + 10);
159
int x = rect.width() - 2;
160
for (std::list<double>::reverse_iterator j = val.rbegin();j != val.rend() && x >=
168
int val = int(rect.height() - 2 - ((*j - zMinValue) / (zMaxValue - zMinValue) * (rect.height() - 4)));
169
x = rect.width() - 2 - count * (rect.width() - 4) / (samples - 1);
170
a.setPoint(count, x, val);
172
if (count >= samples)
177
Points.insert(Points.end(), a);
180
if (e != Enabled.rend())
185
std::map<int, int> Bottom;
186
std::list<bool>::reverse_iterator e = Enabled.rbegin();
187
for (std::list<QPointArray>::iterator i = Points.begin();i != Points.end();)
189
while (e != Enabled.rend() && !*e)
194
if (e != Enabled.rend())
201
for (unsigned int j = 0;j < a.size() / 2;j++)
205
if (Bottom.find(x) == Bottom.end())
209
a.setPoint(a.size() - 1 - j, x, zeroy - lb);
212
Bottom[x] = zeroy - y;
217
QBrush brush(toChartBrush(cp));
218
p->setBrush(brush.color());
220
if (brush.style() != QBrush::SolidPattern)
222
p->setBrush(QBrush(Qt::white, brush.style()));
230
toBarChart::toBarChart (toBarChart *chart, QWidget *parent, const char *name, WFlags f)
231
: toLineChart(chart, parent, name, f)
234
toLineChart *toBarChart::openCopy(QWidget *parent)
236
toBarChart *newWin = new toBarChart(this,
237
parent ? parent : toMainWidget()->workspace(),
238
NULL, parent ? 0 : WDestructiveClose);
245
toMainWidget()->windowsMenu();
247
#if QT_VERSION < 0x030100
248
// This is a really ugly workaround for a Qt layout bug
250
QWidget *tmp2 = NULL;
252
#if QT_VERSION < 0x030200
254
for (unsigned int i = 0;i < toMainWidget()->workspace()->windowList().count();i++)
256
QWidget *widget = toMainWidget()->workspace()->windowList().at(i);
259
for (unsigned int i = 0;i < toMainWidget()->workspace()->windowList(QWorkspace::CreationOrder).count();i++)
261
QWidget *widget = toMainWidget()->workspace()->windowList(QWorkspace::CreationOrder).at(i);
264
if (newWin != widget)