Bump release version to 1.5
[lttv.git] / lttv / modules / gui / histogram / histodrawing.h
CommitLineData
1684ba2e 1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2006 Parisa heidari (inspired from CFV by Mathieu Desnoyers)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19
20#ifndef _HISTODRAWING_H
21#define _HISTODRAWING_H
22
23#include <glib.h>
24#include <gdk/gdk.h>
25#include <gtk/gtk.h>
64242d13
YB
26//#include <lttv/tracecontext.h>
27#include <lttv/traceset.h>
1684ba2e 28#include <lttvwindow/lttvwindow.h>
29#include "histocfv.h"
30#include "histodrawitem.h"
31
32
33#define SAFETY 50 // safety pixels at right and bottom of pixmap buffer
34
35typedef enum _draw_color {
36 COL_BLACK,
37 COL_WHITE,
38 COL_RUN_USER_MODE,/* green */
39 COL_RUN_SYSCALL, /* pale blue */
40 COL_RUN_TRAP, /* yellow */
41 COL_RUN_IRQ, /* red */
42 COL_WAIT, /* dark red */
43 COL_WAIT_CPU, /* dark yellow */
44 COL_ZOMBIE, /* dark purple */
45 COL_WAIT_FORK, /* dark green */
46 COL_EXIT, /* "less dark" magenta */
47 COL_MODE_UNKNOWN, /* white */
48 COL_UNNAMED, /* white */
49 NUM_COLORS } draw_color;
50
51extern GdkColor histo_drawing_colors[NUM_COLORS];
52
53/* This part of the viewer does :
54 * Draw horizontal lines, getting graphic context as arg.
55 * Copy region of the screen into another.
56 * Modify the boundaries to reflect a scale change. (resize)
57 * Refresh the physical screen with the pixmap
58 * A helper function is provided here to convert from time to process
59 * identifier to pixels and the contrary (will be useful for mouse selection).
60 * Insert an empty square in the drawing, moving the bottom part.
61 *
62 * Note: The last point is exactly why it would not be so easy to add the
63 * vertical line functionnality as in the original version of LTT. In order
64 * to do so, we should keep all processes in the list for the duration of
65 * all the trace instead of dynamically adding and removing them when we
66 * scroll. Another possibility is to redraw all the visible area when a new
67 * process is added to the list. The second solution seems more appropriate
68 * to me.
69 *
70 *
71 * The pixmap used has the width of the physical window, but the height
72 * of the shown processes.
73 */
74
75#ifndef TYPE_histoDrawing_t_DEFINED
76#define TYPE_histoDrawing_t_DEFINED
77typedef struct _histoDrawing_t histoDrawing_t;
78#endif //TYPE_DRAWING_T_DEFINED
79
80#ifndef TYPE_HistoControlFlowData_DEFINED
81#define TYPE_HistoControlFlowData_DEFINED
82typedef struct _HistoControlFlowData HistoControlFlowData;
83#endif //TYPE_HistoControlFlowData_DEFINED
84
85struct _histoDrawing_t {
86 GtkWidget *vbox;
87 GtkWidget *drawing_area;
88 /*
89 GtkWidget *hbox;
90 GtkWidget *viewport;
91 GtkWidget *scrollbar;*///at this time,not necessary for histogram
92
93 GtkWidget *ruler_hbox;
94 GtkWidget *ruler;
95 GtkWidget *padding;
96//vertical ruler
97 GtkWidget *vruler_drawing_hbox;
98 GtkWidget *vertical_ruler;
99
100 GdkPixmap *pixmap;
101 HistoControlFlowData *histo_control_flow_data;
102
103 PangoLayout *pango_layout;
104
105 gint height, width, depth;
106 /* height and width of allocated buffer pixmap */
107 gint alloc_height, alloc_width;
108
109 /* X coordinate of damaged region */
110 gint damage_begin, damage_end; /* damaged region to be exposed,
111 updated per chunk */
112 LttTime last_start;
113 GdkGC *dotted_gc;
114 GdkGC *gc;
115 GdkGC *ruler_gc_butt;
116 GdkGC *ruler_gc_round;
117
118 /* Position of the horizontal selector, -1 for none */
119 gint horizontal_sel;
120};
121
122histoDrawing_t *histo_drawing_construct(HistoControlFlowData *histo_control_flow_data);
123void histo_drawing_destroy(histoDrawing_t *drawing);
124
125
126void histo_drawing_data_request(histoDrawing_t *drawing,
127 gint x, gint y,
128 gint width,
129 gint height);
130
131 GtkWidget *histo_drawing_get_widget(histoDrawing_t *drawing);
132GtkWidget *histo_drawing_get_drawing_area(histoDrawing_t *drawing);
133
134 void histo_drawing_draw_line(histoDrawing_t *drawing,
135 GdkPixmap *pixmap,
136 guint x1, guint y1,
137 guint x2, guint y2,
138 GdkGC *GC);
139
140//void drawing_copy(histoDrawing_t *drawing,
141// guint xsrc, guint ysrc,
142// guint xdest, guint ydest,
143// guint width, guint height);
144
145/* Clear the drawing : make it 1xwidth. */
146void histo_drawing_clear(histoDrawing_t *drawing,guint clear_from,guint clear_to);
147
1684ba2e 148void histo_drawing_update_ruler(histoDrawing_t *drawing, TimeWindow *time_window);
149
150void histo_drawing_update_vertical_ruler(histoDrawing_t *drawing);//, TimeWindow *time_window);
151
152void histo_drawing_request_expose(EventsRequest *events_request,
64242d13 153 LttvTraceset *traceset,
1684ba2e 154 LttTime end_time);
155
156void histo_drawing_data_request_begin(EventsRequest *events_request,
64242d13
YB
157 LttvTraceset *traceset);
158void histo_drawing_chunk_begin(EventsRequest *events_request, LttvTraceset *traceset);
1684ba2e 159
160
1684ba2e 161/* histo_convert_pixels_to_time
162 *
163 * Convert from window pixel and time interval to an absolute time.
164 */
165static inline void histo_convert_pixels_to_time(
166 gint width,
167 guint x,
168 TimeWindow time_window,
169 LttTime *time)
170{
171 double time_d;
172
173 time_d = time_window.time_width_double;
174 time_d = time_d / (double)width * (double)x;
175 *time = ltt_time_from_double(time_d);
176 *time = ltt_time_add(time_window.start_time, *time);
177}
178
179
180static inline void histo_convert_time_to_pixels(
181 TimeWindow time_window,
182 LttTime time,
183 int width,
184 guint *x)
185{
186 double time_d;
187#ifdef EXTRA_CHECK
188 g_assert(ltt_time_compare(window_time_begin, time) <= 0 &&
189 ltt_time_compare(window_time_end, time) >= 0);
190#endif //EXTRA_CHECK
191
192 time = ltt_time_sub(time, time_window.start_time);
193
194 time_d = ltt_time_to_double(time);
195
196 if(time_window.time_width_double == 0.0) {
197 g_assert(time_d == 0.0);
198 *x = 0;
199 } else {
200 *x = (guint)(time_d / time_window.time_width_double * (double)width);
201 }
202
203}
204
205#endif // _DRAWING_H
This page took 0.086587 seconds and 4 git commands to generate.