comparison scripts/timeline_view_movement.py @ 1075:056a8454500e

Bug fixes in scripts: display plays in last timeline segment of each fragment (post last move); call sub-processes of generate_report.py in same folder (pass on argument); indentation in LaTeX file.
author Brecht De Man <BrechtDeMan@users.noreply.github.com>
date Wed, 16 Sep 2015 13:31:40 +0100
parents f1201566b54b
children adbaff4bf3f0 235594325b84
comparison
equal deleted inserted replaced
1074:2b8c36924bfd 1075:056a8454500e
135 previous_position = initial_position 135 previous_position = initial_position
136 previous_time = 0 136 previous_time = 0
137 137
138 # assume not playing at start 138 # assume not playing at start
139 currently_playing = False # keep track of whether fragment is playing during move event 139 currently_playing = False # keep track of whether fragment is playing during move event
140 140
141 # draw all segments except final one 141 # draw all segments except final one
142 for event in move_events: 142 for event in move_events:
143 # mark this plot as not empty 143 # mark this plot as not empty
144 plot_empty = False 144 plot_empty = False
145 145
196 color='r' if currently_playing else colormap[increment%len(colormap)], 196 color='r' if currently_playing else colormap[increment%len(colormap)],
197 linewidth=3 197 linewidth=3
198 ) 198 )
199 199
200 # vertical line from previous to current position 200 # vertical line from previous to current position
201 #TODO red if currently playing, orig color if not
202 plt.plot([new_time, new_time], # x-values 201 plt.plot([new_time, new_time], # x-values
203 [previous_position, new_position], # y-values 202 [previous_position, new_position], # y-values
204 # color depends on playing during move event or not: 203 # color depends on playing during move event or not:
205 color='r' if currently_playing else colormap[increment%len(colormap)], 204 color='r' if currently_playing else colormap[increment%len(colormap)],
206 linewidth=3 205 linewidth=3
208 207
209 # update previous_position value 208 # update previous_position value
210 previous_position = new_position 209 previous_position = new_position
211 previous_time = new_time 210 previous_time = new_time
212 211
213 # draw final segment 212
213
214 # draw final horizontal segment (or only segment if audioelement not moved)
214 # horizontal line from previous time to end of audioholder 215 # horizontal line from previous time to end of audioholder
215 plt.plot([previous_time, audioholder_time-time_offset], # x-values 216
217 # get play/stop events since last move until current move event
218 stop_times = []
219 start_times = []
220 # is there a play and/or stop event between previous_time and new_time?
221 for time in start_times_global:
222 if time>previous_time and time<audioholder_time-time_offset:
223 start_times.append(time)
224 for time in stop_times_global:
225 if time>previous_time and time<audioholder_time-time_offset:
226 stop_times.append(time)
227 # if no play/stop events between move events, find out whether playing
228
229 segment_start = previous_time # first segment starts at previous move event
230
231 # draw segments (horizontal line)
232 while len(start_times)+len(stop_times)>0: # while still play/stop events left
233 # mark this plot as not empty
234 plot_empty = False
235 if len(stop_times)<1: # upcoming event is 'play'
236 # draw non-playing segment from segment_start to 'play'
237 currently_playing = False
238 segment_stop = start_times.pop(0) # remove and return first item
239 elif len(start_times)<1: # upcoming event is 'stop'
240 # draw playing segment (red) from segment_start to 'stop'
241 currently_playing = True
242 segment_stop = stop_times.pop(0) # remove and return first item
243 elif start_times[0]<stop_times[0]: # upcoming event is 'play'
244 # draw non-playing segment from segment_start to 'play'
245 currently_playing = False
246 segment_stop = start_times.pop(0) # remove and return first item
247 else: # stop_times[0]<start_times[0]: upcoming event is 'stop'
248 # draw playing segment (red) from segment_start to 'stop'
249 currently_playing = True
250 segment_stop = stop_times.pop(0) # remove and return first item
251
252 # draw segment
253 plt.plot([segment_start, segment_stop], # x-values
254 [previous_position, previous_position], # y-values
255 color='r' if currently_playing else colormap[increment%len(colormap)],
256 linewidth=3
257 )
258 segment_start = segment_stop # move on to next segment
259 currently_playing = not currently_playing # toggle to draw final segment correctly
260
261 # draw final segment (horizontal line) from last 'segment_start' to current move event time
262 plt.plot([segment_start, audioholder_time-time_offset], # x-values
216 [previous_position, previous_position], # y-values 263 [previous_position, previous_position], # y-values
217 color=colormap[increment%len(colormap)], 264 # color depends on playing during move event or not:
265 color='r' if currently_playing else colormap[increment%len(colormap)],
218 linewidth=3 266 linewidth=3
219 ) 267 )
268
269 # plt.plot([previous_time, audioholder_time-time_offset], # x-values
270 # [previous_position, previous_position], # y-values
271 # color=colormap[increment%len(colormap)],
272 # linewidth=3
273 # )
220 274
221 # display fragment name at end 275 # display fragment name at end
222 plt.text(audioholder_time-time_offset,previous_position,\ 276 plt.text(audioholder_time-time_offset,previous_position,\
223 audio_id,color=colormap[increment%len(colormap)]) #,rotation=45 277 audio_id,color=colormap[increment%len(colormap)]) #,rotation=45
224 278