drawing.cxx
Go to the documentation of this file.
1 #include <gtk/gtk.h>
2 #include <vector>
3 #include <stdint.h>
4 #include "event.h"
5 #include "drawing.h"
6 #include "status.h"
7 #include "geo.h"
8 #include "hits.h"
9 #include "tracks.h"
10 #include "vertices.h"
11 
12 extern std::vector<noeevent> theevents;
13 extern int gevi;
14 extern bool isfd;
15 extern rect screenview[kXorY], screenmu;
16 extern int first_mucatcher;
17 extern int nplanes;
18 
19 
20 GtkWidget * edarea[kXorY] = { NULL }; // X and Y views
21 cairo_pattern_t * eventpattern[kXorY] = { NULL };
22 
23 // Blank the drawing area and draw the detector bounding boxes
24 static void draw_background(cairo_t ** cr)
25 {
26  setboxes();
27  for(int i = 0; i < kXorY; i++){
28  cairo_set_source_rgb(cr[i], 0, 0, 0);
29  cairo_paint(cr[i]);
30 
31  cairo_set_source_rgb(cr[i], 1, 0, 1);
32  cairo_set_line_width(cr[i], 1.0);
33 
34  // detector box
35  cairo_rectangle(cr[i], 0.5+screenview[i].xmin, 0.5+screenview[i].ymin,
36  screenview[i].xsize, screenview[i].ysize);
37  cairo_stroke(cr[i]);
38  }
39 
40  // Y-view muon catcher empty box
42  cairo_rectangle(cr[kY], 0.5+screenmu.xmin, 0.5+screenmu.ymin,
43  screenmu.xsize, screenmu.ysize);
44  cairo_stroke(cr[kY]);
45  }
46 }
47 
48 
49 // Size the drawing areas to the detector sizes at the starting zoom level.
50 // This would not make sense if called after the user zooms and pans, so it
51 // is only called on startup.
53 {
54  for(int i = 0; i < kXorY; i++)
55  gtk_widget_set_size_request(edarea[i],
56  std::max(screenview[kX].xmax(), screenview[kY].xmax()) + 1,
57  std::max(screenview[kX].ymax(), screenview[kY].ymax()) + 1);
58 }
59 
60 void draw_event(const DRAWPARS * const drawpars)
61 {
63  if(theevents.empty()) return;
64 
65  if(!isfd && theevents[gevi].fdlike){
66  setfd();
68  }
69 
70  cairo_t * cr[kXorY];
71  for(int i = 0; i < kXorY; i++)
72  cairo_push_group(cr[i] = gdk_cairo_create(edarea[i]->window));
73 
74  // Do not blank the display in the middle of an animation unless necessary
75  if(drawpars->clear) draw_background(cr);
76 
77  draw_hits(cr, drawpars, edarea);
78 
79  set_eventn_status(); // overwrite anything that draw_hits did
80 
81  // Draw and save the state with hits but not reco objects so that we can easily
82  // redraw with differently highlighted things later
83  for(int i = 0; i < kXorY; i++){
84  if(eventpattern[i] != NULL) cairo_pattern_destroy(eventpattern[i]);
85  eventpattern[i] = cairo_pop_group(cr[i]);
86  cairo_push_group(cr[i]);
87  cairo_set_source(cr[i], eventpattern[i]);
88  cairo_paint(cr[i]);
89  }
90 
91  draw_tracks(cr, drawpars);
92  draw_vertices(cr, drawpars);
93 
94  for(int i = 0; i < kXorY; i++){
95  cairo_pop_group_to_source(cr[i]);
96  cairo_paint(cr[i]);
97  cairo_destroy(cr[i]);
98  }
99 }
100 
101 gboolean redraw_event(__attribute__((unused)) GtkWidget *widg,
102  __attribute__((unused)) GdkEventExpose * ee,
103  __attribute__((unused)) gpointer data)
104 {
105  DRAWPARS drawpars;
106  drawpars.firsttick = theevents[gevi].current_mintick;
107  drawpars.lasttick = theevents[gevi].current_maxtick;
108  drawpars.clear = true;
109  draw_event(&drawpars);
110 
111  return FALSE;
112 }
GtkWidget * edarea[kXorY]
Definition: drawing.cxx:20
T max(const caf::Proxy< T > &a, T b)
void setboxes()
Definition: geo.cxx:149
int first_mucatcher
Definition: geo.cxx:21
std::map< std::string, double > xmax
gboolean redraw_event(__attribute__((unused)) GtkWidget *widg, __attribute__((unused)) GdkEventExpose *ee, __attribute__((unused)) gpointer data)
Definition: drawing.cxx:101
Supply basic geometry functions.
Definition: geo.h:1
rect screenmu
Definition: geo.cxx:29
int xmin
Definition: geo.h:4
int nplanes
Definition: geom.C:145
bool isfd
Definition: geo.cxx:18
void draw_vertices(cairo_t **cr, const DRAWPARS *const drawpars)
Definition: vertices.cxx:49
bool clear
Definition: drawing.h:5
int xsize
Definition: geo.h:5
int gevi
Definition: main.cxx:76
std::vector< noeevent > theevents
Definition: noe_module.cc:29
int ymin
Definition: geo.h:4
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
const XML_Char const XML_Char * data
Definition: expat.h:268
void setfd()
Definition: geo.cxx:80
#define FALSE
Definition: crcmodel.h:85
Double_t ymax
Definition: plot.C:25
rect screenview[kXorY]
Definition: geo.cxx:29
void draw_event(const DRAWPARS *const drawpars)
Definition: drawing.cxx:60
void draw_tracks(cairo_t **cr, const DRAWPARS *const drawpars)
Definition: tracks.cxx:47
void draw_hits(cairo_t **cr, const DRAWPARS *const drawpars, GtkWidget **edarea)
Definition: hits.cxx:116
void request_edarea_size()
Definition: drawing.cxx:52
__attribute__((unused)) static void Console(TMinuit &mn)
Definition: geo.h:3
int ysize
Definition: geo.h:5
void set_eventn_status()
Definition: status.cxx:192
Definition: geo.h:1
Double_t ymin
Definition: plot.C:24
int32_t firsttick
Definition: drawing.h:4
int32_t lasttick
Definition: drawing.h:4
static void draw_background(cairo_t **cr)
Definition: drawing.cxx:24
cairo_pattern_t * eventpattern[kXorY]
Definition: drawing.cxx:21