File: graphplot.h

package info (click to toggle)
mixviews 1.10-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 2,440 kB
  • ctags: 6,314
  • sloc: cpp: 31,647; ansic: 2,100; makefile: 1,782; sh: 17
file content (109 lines) | stat: -rw-r--r-- 3,594 bytes parent folder | download | duplicates (4)
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
// graphplot.h

/******************************************************************************
 *
 *  MiXViews - an X window system based sound & data editor/processor
 *
 *  Copyright (c) 1993, 1994 Regents of the University of California
 *
 *  Author:     Douglas Scott
 *  Date:       December 13, 1994
 *
 *  Permission to use, copy and modify this software and its documentation
 *  for research and/or educational purposes and without fee is hereby granted,
 *  provided that the above copyright notice appear in all copies and that
 *  both that copyright notice and this permission notice appear in
 *  supporting documentation. The author reserves the right to distribute this
 *  software and its documentation.  The University of California and the author
 *  make no representations about the suitability of this software for any 
 *  purpose, and in no event shall University of California be liable for any
 *  damage, loss of data, or profits resulting from its use.
 *  It is provided "as is" without express or implied warranty.
 *
 ******************************************************************************/


// GraphPlot and its subclasses encapsulate the persistant state of the
// actual displayed graph line(s) for any single channel of data.  They are
// created and contained by the Graph subclass instances, and are intimately
// linked to them due to the necessity of sharing graphic state, hence the 
// 'graph' member in the base class.

#ifndef GRAPHPLOT_H
#ifdef __GNUG__
#pragma interface
#endif
#define GRAPHPLOT_H

#include <InterViews/resource.h>

class Canvas;
class Painter;
class Perspective;
class Margin;
class Graph;
class Data;

class GraphPlot : public Resource {
public:
	GraphPlot(Graph* gr, int points) : graph(gr), maxPoints(points) {}
	virtual ~GraphPlot() {}
	virtual void load(Data *, EnvelopeType=PeakToPeakAmplitude) = 0;
	virtual void plot() = 0;
	virtual void setPlotLength(int) = 0;
	virtual void draw(Canvas *, Painter *) = 0;
	virtual boolean contains(Coord l, Coord b, Coord r, Coord t) = 0;
protected:
	Graph* graph;			// reference to associated graph
	int maxPoints;
};

class SimplePlot : public GraphPlot {
	enum Traces { MaxTraces = 2 };
public:
	SimplePlot(Graph *gr, int points);
	virtual ~SimplePlot();
	redefined void load(Data *d, EnvelopeType type);
	redefined void plot();
	redefined void setPlotLength(int newlen);
	redefined boolean contains(Coord l, Coord b, Coord r, Coord t);
protected:
	int currentTraces() { return nTraces; }
	Data *plotdata;				// internal plot storage
	Coord *xlocs[MaxTraces], *ylocs[MaxTraces];
	Coord maxVertLoc, minVertLoc;
	int nPoints, maxTraces, nTraces;
};

// LinePlot draws a graph line.  If more than one value is represented by a
// single point, two lines are drawn, one for the max's and one for the min's

class LinePlot : public SimplePlot {
public:
	LinePlot(Graph *gr, int points) : SimplePlot(gr, points) {}
	virtual ~LinePlot() {}
	redefined void draw(Canvas *, Painter *);
};

// BarPlot draws a solid bar-graph style representation of the data values

class BarPlot : public SimplePlot {
public:
	BarPlot(Graph *gr, int points) : SimplePlot(gr, points + 1) {}
	virtual ~BarPlot() {}
	redefined void plot();
	redefined void draw(Canvas *, Painter *);
};

// SolidPlot draws a "mountain range" style, filled graph for use in cascade-
// style multi-graphs

class SolidPlot : public SimplePlot {
public:
	SolidPlot(Graph *gr, int points) : SimplePlot(gr, points + 2) {}
	virtual ~SolidPlot() {}
	redefined void plot();
	redefined void draw(Canvas *, Painter *);
};

#endif