File: Graph.h

package info (click to toggle)
quickplot 0.8.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,544 kB
  • ctags: 1,019
  • sloc: cpp: 10,051; sh: 7,597; makefile: 176
file content (166 lines) | stat: -rw-r--r-- 4,020 bytes parent folder | download | duplicates (3)
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
/* Copyright (c) 1998, 1999, 2003, 2004  Lance Arsenault, (GNU GPL (v2+))
 */


class ColorGen;
class Field;
class MainWindow;

class Graph : public DrawingArea, public std::list<Plot *>
{
 public:

  Graph(MainWindow *mainWindow_in);
  void copy(Graph *graph);
  ~Graph(void);

  Plot *createPlot(Field *x, Field *y);
  void createDefaultPlots(Source *s);
  
  // Having a color generater for each graph will make the auto color
  // on all graphs behave similarly.
  ColorGen colorGen;

  void queueRedraw(void);

  void remove(Plot *plot);

  void checkScales(void);

  void drawAutoGrid(Glib::RefPtr<Gdk::Drawable> win,
                    Glib::RefPtr<Gdk::GC> gc);
  void savePNG(const char *filename);

  void zoomToTop(void);
  void zoomOut(void);
  void zoomIn(int x, int y, int w, int h);
  bool isZoomedOutToTop(void);

  void setShowLines(bool show);
  void setShowPoints(bool show);
  
  void setLineWidth(int width, bool oldPlotsToo=true);
  void setPointSize(int size,  bool oldPlotsToo=true);

  void setBackgroundColor(const Gdk::Color& color);
  void setGridColor(const Gdk::Color& color);

  void draw(Glib::RefPtr<Gdk::Drawable> win,
            Glib::RefPtr<Gdk::GC> gc);

  /************************************************************/
  /****************    Properties of a Graph     **************/
  /************************************************************/
  // Do the current plots have the same scale.
  bool isSameScale;
  
  // Do we force all plots to have the same scale.
  bool sameScale;
  
   // Do we make all plots the same scale if it works well.
  bool autoSameScale;

  // Draw the auto Grid.  This requires the Plots to have the same
  // scale (i.e. isSameScale is true).
  bool showAutoGrid;
  bool showGridNumbers;

  inline bool isShowingGrid() { return (showAutoGrid && isSameScale); }
  /************************************************************/

  static SigC::Signal1<void, Graph *> signal_changedSameScale(void);
  static SigC::Signal1<void, Graph *> signal_addedPlot(void);
  static SigC::Signal2<void, Graph *, Plot *> signal_removedPlot(void);
  SigC::Signal0<void> signal_backgroundColorChanged(void);

  
  Gdk::Color gridColor, backgroundColor;

  int gridXLineSpace, gridYLineSpace, gridLineWidth;

  int showLines, showPoints, lineWidth, pointSize;

  enum PICKER_TYPE
  {
    OFF_PLOT=0,
    INTERPOLATED=1,
    NONINTERPOLATED=2,
    NONE=3
  };
  
  PICKER_TYPE pickerType, highestPickerType;

  MainWindow *mainWindow;
  
protected:
  
  bool on_expose_event(GdkEventExpose*);
  bool on_button_press_event(GdkEventButton *event);
  bool on_button_release_event(GdkEventButton *event);
  bool on_motion_notify_event(GdkEventMotion *event);
  
private:

  void setPickerType(void);

  void setStatusXYValues(gdouble x, gdouble y);
  
  static SigC::Signal1<void, Graph *> m_signal_changedSameScale;
  
  static SigC::Signal1<void, Graph *> m_signal_addedPlot;
  static SigC::Signal2<void, Graph *, Plot *> m_signal_removedPlot;

  SigC::Signal0<void> m_signal_backgroundColorChanged;

  
  // used by createPlot(Field *x, Field *y) 
  void checkZoomLevelForNewPlot(Plot *plot);

  Glib::RefPtr<Gdk::Window> win;
  Glib::RefPtr<Gdk::GC> gc, inverted_gc;
  
  // used in Graph::drawAutoGrid()
  Glib::RefPtr<Pango::Layout> pangolayout;

  // for saving event state info
  guint buttonPressed;

  PICKER_TYPE lastPickerType;
  
  // Pointer x,y values when the button of interest was pressed
  int xPress, yPress;
  // The moving corner of the zoom box.
  int xmouse, ymouse, xpick, ypick;

  bool checkScalesQueued;
  bool isDeleting; // flag that says we are in ~Graph()

  int old_width, old_height;
};


class GraphTab : public HBox
{
public:

  GraphTab(int graphNumber, MainWindow *m, Graph *graph);

  void setText(const char *str);
  
  Label label;
  Button removeButton;
  Image closeImage;

  struct DeleteLater
  {
    GraphTab *graphTab;
  } deleteLater;
  
  MainWindow *mainWindow;
  Graph *graph;

private:

  void on_close(void);
  
};