/usr/include/vdk2/vdk/chart.h is in libvdk2-dev 2.4.0-5.3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | /*
* ===========================
* VDK Component Library
* Version 0.2
* ===========================
* Copyright (C) 1998, Mario Motta
* Developed by Mario Motta <mmotta@guest.net>
* ===========================================
* This library is a component of:
* VDK Visual Development Kit
* Version 0.4.1
* Copyright (C) 1998, Mario Motta
* Developed by Mario Motta <mmotta@guest.net>
* ===========================================
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-130
*/
#ifndef CHART_H
#define CHART_H
#include <vdk/vdk.h>
/*!
\class Coord
\brief provides a 2D object
*/
class Coord
{
public:
double x,y;
Coord(double x = 0.0, double y = 0.0):x(x),y(y) {}
~Coord() {}
};
typedef VDKValueList<Coord> CoordList;
typedef VDKValueListIterator<Coord> CoordListIterator;
typedef VDKArray<double> Darray;
class VDKChart;
////////////////////////////////
/*!
\class Series
\brief Is a list of 2D points with some propreties and behaviours added
*/
class Series: public CoordList
{
Coord max,min;
VDKString title;
public:
/*!
Sets/gets color (defaults to black)
*/
VDKReadWriteValueProp<Series,VDKRgb> Color;
/*!
Sets/gets line style (defaults to GDK_LINE_SOLID)
can be:
\arg GDK_LINE_SOLID
\arg GDK_LINE_ON_OFF_DASH
\arg GDK_LINE_DOUBLE_DASH
*/
VDKReadWriteValueProp<Series,GdkLineStyle> LineStyle;
/*!
Sets/gets line width (defaults to 1)
*/
VDKReadWriteValueProp<Series,int> LineWidth;
/*!
Sets/gets line cap style (defaults to GDK_CAP_NOT_LAST)
can be:
\arg GDK_CAP_NOT_LAST
\arg GDK_CAP_BUTT
\arg GDK_CAP_ROUND
\arg GDK_CAP_PROJECTING
*/
VDKReadWriteValueProp<Series,GdkCapStyle> LineCapStyle;
/*!
Sets/gets line join style (defaults to GDK_JOIN_MITER)
can be:
\arg GDK_JOIN_MITER
\arg GDK_JOIN_ROUND
\arg GDK_JOIN_BEVEL
*/
VDKReadWriteValueProp<Series,GdkJoinStyle> LineJoinStyle;
/*!
Constructor
\param title series title (should be unique)
*/
Series(char* title):
CoordList(),
title(title),
Color("Color",this,VDKRgb(0,0,0)),
LineStyle("LineStyle",this,GDK_LINE_SOLID),
LineWidth("LineWidth",this,1),
LineCapStyle("LineCapStyle",this,GDK_CAP_NOT_LAST),
LineJoinStyle("LineJoinStyle",this,GDK_JOIN_MITER)
{}
/*!
Destructor
*/
~Series() {}
/*!
Adds a 2D point to a series
\param x x coordinate
\param y y coordinate
*/
void Add(double x, double y);
/*!
Adds an array of 2D points to series
\param x array
\param y array
\param n array length
*/
void Add(double* x, double* y, int n);
/*!
Returns minimum 2D point of a series
*/
Coord Min() { return min; }
/*!
Returns maximum 2D point of a series
*/
Coord Max() { return max; }
/*!
Returns series title
*/
char* Title() { return (char*) title; }
/*!
Equality operator
*/
bool operator==(Series& s) { return title == s.title; }
};
typedef VDKList<Series> SeriesList;
typedef VDKListiterator<Series> SeriesListIterator;
///////////////////////////////////
/*!
\class ChartAxis
\internal
*/
class ChartAxis
{
VDKRect domain;
VDKChart* owner;
public:
ChartAxis():owner((VDKChart*) NULL) {}
ChartAxis(VDKChart* owner,int w, int h);
ChartAxis(ChartAxis& a);
~ChartAxis() {}
void Draw();
VDKRect& Domain() { return domain; }
};
enum
{
chart_class = 4096,
linechart_class,
scatteredchart_class,
barchart_class
};
///////////////////////////////////
/*!
\class VDKChart
\brief Provides a char base class
VDKChart is a component that allows to plot 2D data in various format,
is a base class that implements common functionalities to all subclasses
actually supported:
\arg VDKLineChart
\arg VDKScatteredChart
\arg VDKBarChart
\par Usage
Use of VDKChart is straigthforward, user adds 2D points to a Series,
eventually sets some series font and properties. VDKChart will assure
data plotting and takes care of rescaling/resizing stuff.
\par Subclassing VDKChart
Normally user should override only Plot() in order to draw data in desired
format.
\par EXAMPLES
Into ./testvdk/chart.cc
*/
class VDKChart: public VDKCanvas
{
protected:
GtkWidget *tip_window;
VDKPoint size;
double xn1,yn1,xn2,yn2,xv1,yv1,xv2,yv2,kx,ky;
Coord domainmax,domainmin;
SeriesList series;
bool OnConfigure(VDKObject* sender, GdkEvent* event);
bool OnClick(VDKObject* sender, GdkEvent* event);
bool OnClickRelease(VDKObject* sender, GdkEvent* event);
ChartAxis axis;
void ComputeDomainLimits(Series* s);
virtual void DrawChart();
void DrawTitle();
void DrawTicks();
void DrawLabels();
public:
/*!
Sets/gets char border, this area is left to draw axis,
title and labels. Defaults to 20 but a larger border is often better.
*/
VDKReadWriteValueProp<VDKChart, int> ChartBorder;
/*!
Sets/gets chart title
*/
VDKReadWriteValueProp<VDKChart, VDKString> Title;
/*!
Sets/gets x axis label
*/
VDKReadWriteValueProp<VDKChart, VDKString> LabelX;
/*!
Sets/gets y axis label
*/
VDKReadWriteValueProp<VDKChart, VDKString> LabelY;
/*!
Sets get how many decimal digits are displayed int x labels
*/
VDKReadWriteValueProp<VDKChart, int> LabelXDigits;
/*!
Sets get how many decimal digits are displayed int y labels
*/
VDKReadWriteValueProp<VDKChart, int> LabelYDigits;
/*!
Constructor
\param owner
\param w width
\param h height
*/
VDKChart(VDKForm* owner, int w = 100, int h = 100);
/*!
Destructor
*/
virtual ~VDKChart();
/*!
Returns chart_class
*/
virtual int isA() { return chart_class; }
/*!
Adds a series to chart
\param s series to be added.
Series name is checked for unicity, if a match is found
<s> will substitute the old series that will be destroyed.
So series to be added should be always constructed in the heap
with new operator.
*/
void AddSeries(Series* s);
/*!
Clears chart destroying all series
*/
void Clear();
void SetChartBorder(int b);
int GetChartBorder() { return ChartBorder; }
/*!
Returns chart gc
*/
GdkGC* GC() { return gc; }
/*!
Sets drawing color, this affects plottin area only, to change
axiz, titles and labels color use Foreground property
*/
void SetColor(VDKRgb rgb);
/*!
Sets line attributes
*/
void SetLineAttributes(gint lineWidth,
GdkLineStyle lineStyle,
GdkCapStyle capStyle,
GdkJoinStyle joinStyle);
/*!
Plots data,placeholder for subclasses.
\param p point to be plotted
\param i i-th point of the series
\param s series address
\par Programming tips
Items p contains coordinates ready to be plotted, scaled or resized
to chart size and data domain.
*/
virtual void Plot(VDKPoint& p , int i, Series* s) {}
DECLARE_EVENT_LIST(VDKChart);
};
///////////////////////////////////////
/*!
\class VDKLineChart
\provides a line chart
*/
class VDKLineChart: public VDKChart
{
public:
VDKLineChart(VDKForm* owner, int w = 100, int h = 100):
VDKChart(owner,w,h) {}
virtual ~VDKLineChart() {}
/*!
Plots data
*/
virtual void Plot(VDKPoint& p, int t, Series*);
/*!
Returns linechart_class
*/
virtual int isA() { return linechart_class; }
};
///////////////////////////////////////
/*!
\class VDKScatteredChart
\provides a line chart
*/
class VDKScatteredChart: public VDKChart
{
public:
VDKScatteredChart(VDKForm* owner, int w = 100, int h = 100):
VDKChart(owner,w,h) {}
virtual ~VDKScatteredChart() {}
virtual void Plot(VDKPoint& p, int t, Series*);
virtual int isA() { return scatteredchart_class; }
};
///////////////////////////////////////
/*!
\class VDKBarChart
\brief Provides a bar chart
*/
class VDKBarChart: public VDKChart
{
public:
/*!
Sets/gets bar width
*/
VDKReadWriteValueProp<VDKBarChart,int> BarWidth;
/*
Sets/gets label flag
*/
VDKReadWriteValueProp<VDKBarChart,bool> Labels;
VDKBarChart(VDKForm* owner, int w = 100, int h = 100):
VDKChart(owner,w,h),
BarWidth("BarWidth",this,20),
Labels("Labels",this,true)
{}
virtual ~VDKBarChart() {}
/*!
Plots data
*/
virtual void Plot(VDKPoint& p, int t, Series*);
/*!
Returns barchart_class
*/
virtual int isA() { return barchart_class; }
};
#endif
|