flat y-range
This commit is contained in:
parent
cf349bb0b1
commit
72bdf822bc
|
@ -145,6 +145,7 @@ class Configuration(RawConfigParser):
|
|||
set_option(section, "prompt-text-size", "42", False)
|
||||
set_option(section, "template-nodeset", "L 0 0, 1000 1", False)
|
||||
set_option(section, "template-nodeset-name", "template", False)
|
||||
set_option(section, "flat-y-range", "1", False)
|
||||
|
||||
def add_section(self, name):
|
||||
if name not in self.order:
|
||||
|
@ -413,7 +414,7 @@ class TypeDeclarations(dict):
|
|||
"axis-label-count", "label-precision",
|
||||
"prompt-border-width",
|
||||
"prompt-character-limit",
|
||||
"prompt-text-size"],
|
||||
"prompt-text-size", "flat-y-range"],
|
||||
|
||||
"int-list": ["marker-color", "curve-color",
|
||||
"prompt-size",
|
||||
|
|
|
@ -76,17 +76,21 @@ class Nodeset(list):
|
|||
def add_node(self, coordinates, refresh=True):
|
||||
x = coordinates[0]
|
||||
inserted = False
|
||||
index = 0
|
||||
for ii, node in enumerate(self):
|
||||
if x < node.x:
|
||||
self.insert(ii, Node(coordinates))
|
||||
inserted = True
|
||||
index = ii
|
||||
break
|
||||
elif x == node.x:
|
||||
return
|
||||
return None
|
||||
if not inserted:
|
||||
self.append(Node(coordinates))
|
||||
index = len(self) - 1
|
||||
if refresh:
|
||||
self.set_splines()
|
||||
return index
|
||||
|
||||
def parse_list(self, nodes):
|
||||
for node in nodes:
|
||||
|
@ -246,6 +250,7 @@ class GUI(Animation):
|
|||
self.label_precision = config["label-precision"]
|
||||
self.template_nodeset = config["template-nodeset"]
|
||||
self.template_nodeset_name = config["template-nodeset-name"]
|
||||
self.flat_y_range = config["flat-y-range"]
|
||||
|
||||
def set_temporary_file(self):
|
||||
self.temporary_file = open(join(gettempdir(), "pgfw-config"), "w")
|
||||
|
@ -327,6 +332,11 @@ class GUI(Animation):
|
|||
elif y > yrange[1]:
|
||||
yrange[1] = y
|
||||
x += width * .01
|
||||
if yrange[1] - yrange[0] == 0:
|
||||
offset = self.flat_y_range / 2.0
|
||||
yrange[0] -= offset
|
||||
yrange[1] += offset
|
||||
print yrange, offset
|
||||
self.set_axis_labels()
|
||||
|
||||
def set_axis_labels(self):
|
||||
|
@ -453,14 +463,15 @@ class GUI(Animation):
|
|||
if result:
|
||||
try:
|
||||
nodeset = self.get_nodeset()
|
||||
nodeset.remove(nodeset[index], False)
|
||||
nodeset.add_node(map(float, result.group(1, 2)))
|
||||
self.store_in_configuration()
|
||||
self.set_yrange()
|
||||
self.set_axis_labels()
|
||||
self.set_markers()
|
||||
self.draw()
|
||||
return True
|
||||
old = nodeset[index]
|
||||
if nodeset.add_node(map(float, result.group(1, 2))) is not None:
|
||||
nodeset.remove(old, False)
|
||||
self.store_in_configuration()
|
||||
self.set_yrange()
|
||||
self.set_axis_labels()
|
||||
self.set_markers()
|
||||
self.draw()
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue