diff --git a/Stuff/Modules/explorer.py b/Stuff/Modules/explorer.py
index 25aba46..bee6f05 100644
--- a/Stuff/Modules/explorer.py
+++ b/Stuff/Modules/explorer.py
@@ -206,21 +206,22 @@ def __init__(self, root):
self.graphLF.grid(column = 0, row = 5, columnspan = 1, pady = 2, padx = 2, sticky = (N, W))
self.fileStorageFrame.grid(column = 8, row = 0, pady = 2, padx = 3, sticky = (N, E))
self.fileFrame.grid(column = 8, row = 1, rowspan = 4, padx = 3, sticky = (N, S))
- self.parametersLF.grid(column = 3, row = 3, columnspan = 3)
- self.timeLabFrame.grid(column = 1, row = 5, columnspan = 4, sticky = (N, W), pady = 2)
+ self.parametersLF.grid(column = 3, row = 3, columnspan = 4, sticky = (E, W))
+ self.timeLabFrame.grid(column = 1, row = 5, columnspan = 4, sticky = (N, W),
+ pady = 2, padx = 2)
self.timeFrame.grid(column = 0, row = 0)
self.arenaFrame.grid(column = 0, row = 0, rowspan = 2, columnspan = 3,
- sticky = (N, S, E, W), padx = 2, pady = 2)
+ sticky = (N, S, W), padx = 2, pady = 2)
self.roomFrame.grid(column = 3, row = 0, rowspan = 2, columnspan = 4,
- sticky = (N, S, E, W), padx = 2, pady = 2)
+ sticky = (N, S, E), padx = 2, pady = 2)
self.speedScaleFrame.grid(column = 7, row = 0, rowspan = 2, sticky = (N, S), padx = 4,
pady = 2)
- self.optionsLF.grid(column = 5, row = 5, columnspan = 2, sticky = (N, W), pady = 2)
+ self.optionsLF.grid(column = 5, row = 5, columnspan = 2, sticky = (N), padx = 2)
self.saveImagesLF.grid(column = 8, row = 5, sticky = (S), pady = 5)
self.arenaCanv.grid(column = 0, row = 0, padx = 1, pady = 1)
self.roomCanv.grid(column = 0, row = 0, padx = 1, pady = 1)
- self.graph.grid(column = 0, row = 4, columnspan = 7, padx = 2, pady = 5, sticky = (E, W))
+ self.graph.grid(column = 0, row = 4, columnspan = 7, padx = 2, pady = 5)
self.playBut.grid(column = 0, row = 0, sticky = (N, S), padx = 2, pady = 2)
self.pauseBut.grid(column = 1, row = 0, sticky = (N, S), padx = 2, pady = 2)
@@ -241,7 +242,7 @@ def __init__(self, root):
pady = 4)
self.distance.grid(column = 1, row = 1, sticky = E)
self.entrances.grid(column = 1, row = 2, sticky = E)
- self.timePar.grid(column = 1, row = 4, sticky = E)
+ self.timePar.grid(column = 1, row = 4, sticky = E, padx = 2)
self.selectedP.grid(column = 1, row = 3, sticky = E)
self.totDistance.grid(column = 2, row = 1, sticky = E, padx = 4)
self.totEntrances.grid(column = 2, row = 2, sticky = E, padx = 4)
diff --git a/Stuff/Modules/graphs.py b/Stuff/Modules/graphs.py
index 4f06b48..7cd51a7 100644
--- a/Stuff/Modules/graphs.py
+++ b/Stuff/Modules/graphs.py
@@ -41,10 +41,52 @@ def getGraphTypes():
-class TheFatherOfAllGraphs():
- def drawParameter(self, cm, parameter):
+class Graphs(Canvas):
+ "parent class for all 'wide' graphs in Explore page"
+ def __init__(self, parent, width = 600, height = 120, **kwargs):
+ super().__init__(parent)
+ self["width"] = width
+ self["height"] = height
+ self["background"] = "white"
+ self.height = height
+ self.width = width
+ self.drawnParameter = None
+ self.parent = parent
+
+
+ def changedTime(self, newTime):
+ "changes position of a time measure on a graph"
+ x = (newTime - self.minTime) * self.width / (self.maxTime - self.minTime)
+ if x < 2:
+ x = 2
+ self.coords("timeMeasure", (x, 0, x, self.height))
+
+
+ def CM_loaded(self, CM, minTime, maxTime, initTime):
+ "basic method called when a file is loaded"
+ # time measure
+ self.create_line((2, 0, 2, self.height), fill = "red", tags = "timeMeasure")
+
+ # maximum time in miliseconds
+ if maxTime == "max":
+ self.maxTime = CM.data[-1][1]
+ else:
+ self.maxTime = maxTime
+
+ if minTime == "min":
+ self.minTime = CM.data[0][1]
+ else:
+ self.minTime = minTime
+
+ # set time measure
+ self.changedTime(initTime)
+
+ self.drawParameter(cm = CM, parameter = self.drawnParameter)
+
+
+ def drawParameter(self, cm, parameter, purpose = "graph"):
"computes selected parameter to be drawn on top of the graph"
- if self.drawnParameter:
+ if self.drawnParameter and purpose == "graph":
self.delete("parameter")
self.drawnParameter = parameter
@@ -129,7 +171,7 @@ def distance(line):
elif content[5] == 2 and prev != 2:
shocks.append(content[1])
prev = 2
- self.drawTimes(shocks)
+ return self.drawTimes(shocks)
elif parameter == "entrances":
entrances = []
prev = 0
@@ -144,7 +186,7 @@ def distance(line):
elif content[5] == 2 and prev != 2:
entrances.append(content[1])
prev = 2
- self.drawTimes(entrances)
+ return self.drawTimes(entrances)
elif parameter == "passes":
passes = []
prev = 0
@@ -159,7 +201,7 @@ def distance(line):
elif content[5] > 0 and content[5] != 5 and prev != 2:
passes.append(content[1])
prev = 2
- self.drawTimes(passes)
+ return self.drawTimes(passes)
elif parameter == "bad points":
if cm.interpolated:
sortd = sorted(cm.interpolated)
@@ -195,49 +237,6 @@ def distance(line):
self.lower("parameter")
-class Graphs(Canvas, TheFatherOfAllGraphs):
- "parent class for all 'wide' graphs in Explore page"
- def __init__(self, parent, width = 620, height = 120):
- super().__init__(parent)
- self["width"] = width
- self["height"] = height
- self["background"] = "white"
- self.height = height
- self.width = width
- self.drawnParameter = None
- self.parent = parent
-
-
- def changedTime(self, newTime):
- "changes position of a time measure on a graph"
- x = (newTime - self.minTime) * self.width / (self.maxTime - self.minTime)
- if x < 2:
- x = 2
- self.coords("timeMeasure", (x, 0, x, self.height))
-
-
- def CM_loaded(self, CM, minTime, maxTime, initTime):
- "basic method called when a file is loaded"
- # time measure
- self.create_line((2, 0, 2, self.height), fill = "red", tags = "timeMeasure")
-
- # maximum time in miliseconds
- if maxTime == "max":
- self.maxTime = CM.data[-1][1]
- else:
- self.maxTime = maxTime
-
- if minTime == "min":
- self.minTime = CM.data[0][1]
- else:
- self.minTime = minTime
-
- # set time measure
- self.changedTime(initTime)
-
- self.drawParameter(cm = CM, parameter = self.drawnParameter)
-
-
def drawPeriods(self, periods, color = "red", width = 3):
"draws selected parameter on top of the graph"
if not periods:
@@ -290,14 +289,19 @@ def drawGraph(self, maxY, valueList):
-class SvgGraph(TheFatherOfAllGraphs):
+class SvgGraph():
"represents graph to be saved in .svg file"
- def __init__(self, parent, cm, width = 620, height = 120):
+ def __init__(self, parent, cm, width = 600, height = 120):
self.height = height
self.width = width
self.drawnParameter = None
self.parent = parent
-
+ self.__class__.__bases__ = (self.__class__.__bases__[1], self.__class__.__bases__[0])
+
+
+ def __del__(self):
+ self.__class__.__bases__ = (self.__class__.__bases__[1], self.__class__.__bases__[0])
+
def saveGraph(self, cm):
"returns information about graph for saving in .svg file"
@@ -345,21 +349,21 @@ def drawTimes(self, times):
return text
+
class SpeedGraph(Graphs, SvgGraph):
"graph depicting speed during the session"
- def __init__(self, parent, cm = None, purpose = "graph"):
- if purpose == "graph":
- Graphs.__init__(self, parent)
- else:
- SvgGraph.__init__(self, parent, cm)
-
+ def __init__(self, parent, cm = None, purpose = "graph", width = 600):
+ self.primaryParent = Graphs if purpose == "graph" else SvgGraph
+ self.primaryParent.__init__(self, parent, cm = cm, width = width)
+
def writeFurtherText(self):
"makes text for svg file representing horizontal lines for every 10cm/s"
self.furtherText = ""
for y in range(1, floor(self.maxY / 10)):
text = '\n'.format(y * 10 * 120 / self.maxY)
+ 'x1="0" y1="{0}" x2="{1}" y2="{0}"/>\n'.format(y * 10 * 120 / self.maxY,
+ self.width)
self.furtherText += text
@@ -431,7 +435,7 @@ def writeFurtherText(self):
"makes text for svg file containing info about line representing border of the arena"
y = ((self.maxY - self.radius) / self.maxY) * 120
self.furtherText = '\n'.format(y)
+ 'y1="{0}" x2="{1}" y2="{0}"/>\n'.format(y, self.width)
def compute(self, cm, smooth = 10):
@@ -484,7 +488,7 @@ def __init__(self, parent, cm = None, purpose = "graph"):
def writeFurtherText(self):
"makes text for svg file containing info about line representing border of the platform"
self.furtherText = '\n'.format(self.platformRadius)
+ 'y1="{0}" x2="{1}" y2="{0}"/>\n'.format(self.platformRadius, self.width)
def compute(self, cm, smooth = 10):
diff --git a/Stuff/Modules/image.py b/Stuff/Modules/image.py
index ebd65b0..3783bd5 100644
--- a/Stuff/Modules/image.py
+++ b/Stuff/Modules/image.py
@@ -57,7 +57,6 @@ class SVG():
def __init__(self, cm, components, root):
self.start = int(root.timeFrame.startTimeVar.get())
self.end = int(root.timeFrame.timeVar.get())
- self.graph = eval(root.graphTypeVar.get()[:-5] + 'root, cm, purpose = "svg")')
self.parameter = "shocks" # for testing
self.cm = cm
@@ -75,6 +74,10 @@ def __init__(self, cm, components, root):
self.computeSize()
self.addIntro()
+ graphWidth = self.x[5] - self.x[2]
+ self.graph = eval(root.graphTypeVar.get()[:-5] +
+ 'root, cm, purpose = "svg", width = graphWidth)')
+
for component in self.components:
if component in ["xgap", "ygap"]:
continue
@@ -116,10 +119,11 @@ def addComponents(self):
def computeSize(self):
x = [0] * 6
y = [0] * 7
+ # sizes [(x.size, column, columnspan), (y.size, row)]
sizes = {"main": [(0, 0), (20, 1)],
"arena": [(300, 3), (300, 2)],
"room": [(300, 5), (300, 2)],
- "graph": [(600, 5), (120, 4)],
+ "graph": [(600, 5, 3), (120, 4)],
"xgap": [(self.xgap, 4), (0, 0)],
"ygap": [(0, 0), (self.ygap, 3)],
"xticks": [(0, 0), (10, 5)],
@@ -129,7 +133,8 @@ def computeSize(self):
}
for component in self.components:
xs, ys = sizes[component]
- difx = (x[max((xs[1]-1, 0))] + xs[0]) - x[xs[1]]
+ xlen = xs[2] if len(xs) == 3 else 1
+ difx = (x[max((xs[1] - xlen, 0))] + xs[0]) - x[xs[1]]
dify = (y[max((ys[1]-1, 0))] + ys[0]) - y[ys[1]]
for i in range(max((1, xs[1])), len(x)):
x[i] += difx
@@ -229,8 +234,9 @@ def addPlaces(self):
def addShocks(self, positions):
+ shocks = ""
for position in positions:
- shocks = '\n'.format(*position)
return shocks
@@ -259,20 +265,14 @@ def addGraph(self):
graph += ",".join(map(str, pair)) + " "
graph += '" style = "fill:none;stroke:black"/>\n'
- graph += self.addGraphLines()
graph += self.addParameter()
- #graph += furtherText
+ graph += furtherText
self.add(graph, 2, 3)
- def addGraphLines(self):
- return ""
-
-
def addParameter(self):
- return "" #
- text = self.graph.drawParameter(self.cm, self.parameter)
+ text = self.graph.drawParameter(self.cm, self.parameter, purpose = "svg")
return text
diff --git a/Stuff/Modules/starter.py b/Stuff/Modules/starter.py
index d25bc0e..106964b 100644
--- a/Stuff/Modules/starter.py
+++ b/Stuff/Modules/starter.py
@@ -51,7 +51,7 @@ def __init__(self):
self.after(250, lambda: print(self.winfo_width()))
self.after(250, lambda: print(self.winfo_height()))
'''
- x, y = 1100, 810
+ x, y = 1120, 810
self.minsize(x, y)
placeWindow(self, x, y)