3 from gi.repository
import Pango
4 from gi.repository
import Gtk
5 from gi.repository
import GooCanvas
26 @param self: this object 27 @param viz: visualization object 32 self.
hlines = GooCanvas.CanvasPath(parent=viz.canvas.get_root_item(), stroke_color_rgba=self.
color)
34 self.
vlines = GooCanvas.CanvasPath(parent=viz.canvas.get_root_item(), stroke_color_rgba=self.
color)
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.CanvasItemVisibility.VISIBLE
60 self.
vlines.props.visibility = GooCanvas.CanvasItemVisibility.VISIBLE
62 self.
hlines.props.visibility = GooCanvas.CanvasItemVisibility.HIDDEN
63 self.
vlines.props.visibility = GooCanvas.CanvasItemVisibility.HIDDEN
65 label.props.visibility = GooCanvas.CanvasItemVisibility.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.CanvasItemVisibility.HIDDEN)
124 @param self: this object 128 label = unused_labels.pop(0)
130 label = GooCanvas.CanvasText(parent=self.
viz.canvas.get_root_item(), stroke_color_rgba=self.
color)
132 label.set_property(
"visibility", GooCanvas.CanvasItemVisibility.VISIBLE)
137 hadj = self.
viz.get_hadjustment()
138 vadj = self.
viz.get_vadjustment()
139 zoom = self.
viz.zoom.get_value()
142 x1, y1 = self.
viz.canvas.convert_from_pixels(hadj.get_value(), vadj.get_value())
143 x2, y2 = self.
viz.canvas.convert_from_pixels(hadj.get_value() + hadj.get_page_size(), vadj.get_value() + vadj.get_page_size())
144 line_width = 5.0/self.
viz.zoom.get_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.Alignment.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.Alignment.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.