26 @param self: this object
27 @param viz: visualization object
32 self.
hlines = goocanvas.Path(parent=viz.canvas.get_root_item(), stroke_color_rgba=self.
color)
33 self.hlines.lower(
None)
34 self.
vlines = goocanvas.Path(parent=viz.canvas.get_root_item(), stroke_color_rgba=self.
color)
35 self.vlines.lower(
None)
37 hadj = self.viz.get_hadjustment()
38 vadj = self.viz.get_vadjustment()
42 hadj.connect(
"value-changed", update)
43 vadj.connect(
"value-changed", update)
44 hadj.connect(
"changed", update)
45 vadj.connect(
"changed", update)
53 @param self: this object
54 @param visible: visible indicator
59 self.hlines.props.visibility = goocanvas.ITEM_VISIBLE
60 self.vlines.props.visibility = goocanvas.ITEM_VISIBLE
62 self.hlines.props.visibility = goocanvas.ITEM_HIDDEN
63 self.vlines.props.visibility = goocanvas.ITEM_HIDDEN
65 label.props.visibility = goocanvas.ITEM_HIDDEN
69 Compute divisions function
71 @param self: this object
80 text_width = dx/ndiv/2
84 Compute divisions function
89 return math.floor(x+0.5)
91 dx_over_ndiv = dx / ndiv
94 tbe = math.log10(dx_over_ndiv)
95 div = pow(10, rint(tbe))
96 if math.fabs(div/2 - dx_over_ndiv) < math.fabs(div - dx_over_ndiv):
98 elif math.fabs(div*2 - dx_over_ndiv) < math.fabs(div - dx_over_ndiv):
100 x0 = div*math.ceil(xi / div) - div
102 ndiv = rint(size / text_width)
110 @param self: this object
113 if self.viz.zoom
is None:
116 unused_labels = self.
labels
118 for label
in unused_labels:
119 label.set_property(
"visibility", goocanvas.ITEM_HIDDEN)
124 @param self: this object
128 label = unused_labels.pop(0)
130 label = goocanvas.Text(parent=self.viz.canvas.get_root_item(), stroke_color_rgba=self.
color)
132 label.set_property(
"visibility", goocanvas.ITEM_VISIBLE)
134 self.labels.append(label)
137 hadj = self.viz.get_hadjustment()
138 vadj = self.viz.get_vadjustment()
139 zoom = self.viz.zoom.value
142 x1, y1 = self.viz.canvas.convert_from_pixels(hadj.value, vadj.value)
143 x2, y2 = self.viz.canvas.convert_from_pixels(hadj.value + hadj.page_size, vadj.value + vadj.page_size)
144 line_width = 5.0/self.viz.zoom.value
147 self.hlines.set_property(
"line-width", line_width)
148 yc = y2 - line_width/2
150 sim_x1 = x1/core.PIXELS_PER_METER
151 sim_x2 = x2/core.PIXELS_PER_METER
153 path = [
"M %r %r L %r %r" % (x1, yc, x2, yc)]
156 path.append(
"M %r %r L %r %r" % (core.PIXELS_PER_METER*x, yc - offset, core.PIXELS_PER_METER*x, yc))
158 label.set_properties(font=(
"Sans Serif %f" % int(12/zoom)),
160 fill_color_rgba=self.
color,
161 alignment=pango.ALIGN_CENTER,
163 x=core.PIXELS_PER_METER*x,
168 self.hlines.set_property(
"data",
" ".join(path))
171 self.vlines.set_property(
"line-width", line_width)
172 xc = x1 + line_width/2
174 sim_y1 = y1/core.PIXELS_PER_METER
175 sim_y2 = y2/core.PIXELS_PER_METER
179 path = [
"M %r %r L %r %r" % (xc, y1, xc, y2)]
182 path.append(
"M %r %r L %r %r" % (xc, core.PIXELS_PER_METER*y, xc + offset, core.PIXELS_PER_METER*y))
184 label.set_properties(font=(
"Sans Serif %f" % int(12/zoom)),
186 fill_color_rgba=self.
color,
187 alignment=pango.ALIGN_LEFT,
190 y=core.PIXELS_PER_METER*y)
193 self.vlines.set_property(
"data",
" ".join(path))
197 self.labels.extend(unused_labels)
def __init__(self, viz)
Initializer function.
def _compute_divisions(self, xi, xf)
Compute divisions function.
def set_visible(self, visible)
Set visible function.
def update_view(self)
Update view function.