Home | History | Annotate | Download | only in JetCreator

Lines Matching refs:self

51     def __init__(self, parent, id, jetConfigFile, importFlag=False):

52 wx.Frame.__init__(self, parent, id, size=(1050, 720), style=wx.DEFAULT_FRAME_STYLE | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX)
54 self.myicon = img_favicon.getIcon()
55 self.SetIcon(self.myicon)
56 self.UndoStack = []
57 self.RedoStack = []
58 self.queueSegs = []
59 self.clipBoard = None
60 self.jet = None
61 self.playerLock = threading.RLock()
62 self.SetKeepPlayingFlag(True)
63 self.currentSegmentName = None
64 self.currentSegmentIndex = None
65 self.currentEventName = None
66 self.currentEventIndex = None
67 self.currentCtrl = ""
68 self.currentJetConfigFile = jetConfigFile
69 self.paused = False
70 self.eventlistSort = (0, 1)
71 self.seglistSort = (0, 1)
72 if self.currentJetConfigFile == "":
74 self.currentJetConfigFile = JetDefs.UNTITLED_FILE
76 self.jet_file = JetFile(self.currentJetConfigFile, "")
78 if not ValidateConfig(self.jet_file):
80 self.currentJetConfigFile = JetDefs.UNTITLED_FILE
81 self.jet_file = JetFile(self.currentJetConfigFile, "")
83 if self.currentJetConfigFile == JetDefs.UNTITLED_FILE:
84 self.LoadDefaultProperties()
86 self.initLayout()
87 self.initStatusBar()
88 self.createMenuBar()
89 self.createToolbar()
90 self.SetCurrentFile(self.currentJetConfigFile)
91 self.initHelp()
93 self.graph.ClickCallbackFct = self.GraphTriggerClip
95 EVT_JET_STATUS(self, self.OnJetStatusUpdate)
97 wx.EVT_CLOSE(self, self.OnClose)
99 self.Centre()
100 self.Show(True)
103 self.OnJetImportArchive(None)
105 self.eventList.OnSortOrderChangedAlert = self.OnEventSortOrderChanged
106 self.segList.OnSortOrderChangedAlert = self.OnSegSortOrderChanged
108 def initLayout(self):
110 panel = wx.Panel(self, -1)
119 self.segList = JetCheckListCtrl(rightPanel)
121 self.segList.AddCol(title, width)
123 self.eventList = JetListCtrl(rightPanel)
125 self.eventList.AddCol(title, width)
127 self.eventList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnEventListClick)
128 self.segList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSegListClick)
129 self.segList.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnSegmentUpdate)
130 self.eventList.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnEventUpdate)
132 self.segList.BindCheckBox(self.OnSegmentChecked)
135 self.btnAddSeg = wx.Button(leftTopPanel, -1, JetDefs.BUT_ADD, size=BUT_SIZE)
136 self.btnRevSeg = wx.Button(leftTopPanel, -1, JetDefs.BUT_REVISE, size=BUT_SIZE)
137 self.btnDelSeg = wx.Button(leftTopPanel, -1, JetDefs.BUT_DELETE, size=BUT_SIZE)
138 self.btnMoveSeg = wx.Button(leftTopPanel, -1, JetDefs.BUT_MOVE, size=BUT_SIZE)
140 self.btnQueueAll = wx.Button(leftTopPanel, -1, JetDefs.BUT_QUEUEALL, size=BUT_SIZE)
141 self.btnDequeueAll = wx.Button(leftTopPanel, -1, JetDefs.BUT_DEQUEUEALL, size=BUT_SIZE)
142 self.btnPlay = wx.Button(leftTopPanel, -1, JetDefs.BUT_PLAY, size=BUT_SIZE)
143 self.btnPause = wx.Button(leftTopPanel, -1, JetDefs.BUT_PAUSE, size=BUT_SIZE)
144 self.btnAudition = wx.Button(leftTopPanel, -1, JetDefs.BUT_AUDITION, size=BUT_SIZE)
146 self.btnAddEvt = wx.Button(leftBotPanel, -1, JetDefs.BUT_ADD, size=BUT_SIZE)
147 self.btnRevEvt = wx.Button(leftBotPanel, -1, JetDefs.BUT_REVISE, size=BUT_SIZE)
148 self.btnDelEvt = wx.Button(leftBotPanel, -1, JetDefs.BUT_DELETE, size=BUT_SIZE)
149 self.btnMoveEvents = wx.Button(leftBotPanel, -1, JetDefs.BUT_MOVE, size=BUT_SIZE)
151 self.Bind(wx.EVT_BUTTON, self.OnSegmentAdd, id=self.btnAddSeg.GetId())
152 self.Bind(wx.EVT_BUTTON, self.OnSegmentUpdate, id=self.btnRevSeg.GetId())
153 self.Bind(wx.EVT_BUTTON, self.OnSegmentDelete, id=self.btnDelSeg.GetId())
154 self.Bind(wx.EVT_BUTTON, self.OnSegmentsMove, id=self.btnMoveSeg.GetId())
156 self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=self.btnQueueAll.GetId())
157 self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=self.btnDequeueAll.GetId())
158 self.Bind(wx.EVT_BUTTON, self.OnPlay, id=self.btnPlay.GetId())
159 self.Bind(wx.EVT_BUTTON, self.OnPause, id=self.btnPause.GetId())
160 self.Bind(wx.EVT_BUTTON, self.OnAudition, id=self.btnAudition.GetId())
162 self.Bind(wx.EVT_BUTTON, self.OnEventAdd, id=self.btnAddEvt.GetId())
163 self.Bind(wx.EVT_BUTTON, self.OnEventUpdate, id=self.btnRevEvt.GetId())
164 self.Bind(wx.EVT_BUTTON, self.OnEventDelete, id=self.btnDelEvt.GetId())
165 self.Bind(wx.EVT_BUTTON, self.OnEventsMove, id=self.btnMoveEvents.GetId())
172 vBoxLeftTop.Add(self.btnAddSeg, 0, wx.TOP, BORDER)
173 vBoxLeftTop.Add(self.btnRevSeg, 0, wx.TOP, BUT_SPACE)
174 vBoxLeftTop.Add(self.btnDelSeg, 0, wx.TOP, BUT_SPACE)
175 vBoxLeftTop.Add(self.btnMoveSeg, 0, wx.TOP, BUT_SPACE)
177 vBoxLeftTop.Add(self.btnQueueAll, 0, wx.TOP, BUT_SPACE)
178 vBoxLeftTop.Add(self.btnDequeueAll, 0, wx.TOP, BUT_SPACE)
179 vBoxLeftTop.Add(self.btnPlay, 0, wx.TOP, BUT_SPACE)
180 vBoxLeftTop.Add(self.btnPause, 0, wx.TOP, BUT_SPACE)
181 vBoxLeftTop.Add(self.btnAudition, 0, wx.TOP, BUT_SPACE)
183 vBoxLeftBot.Add(self.btnAddEvt, 0)
184 vBoxLeftBot.Add(self.btnRevEvt, 0, wx.TOP, BUT_SPACE)
185 vBoxLeftBot.Add(self.btnDelEvt, 0, wx.TOP, BUT_SPACE)
186 vBoxLeftBot.Add(self.btnMoveEvents, 0, wx.TOP, BUT_SPACE)
198 self.log = wx.TextCtrl(rightPanel, -1)
199 self.graph = SegmentGraph(rightPanel, size=(-1, 50))
202 vboxRight.Add(self.segList, 4, wx.EXPAND | wx.TOP, BORDER)
204 vboxRight.Add(self.eventList, 3, wx.EXPAND | wx.TOP, BORDER)
206 vboxRight.Add(self.log, 0, wx.EXPAND)
208 vboxRight.Add(self.graph, 1, wx.EXPAND)
226 self.chkGraphLabels = wx.CheckBox(pnlGraph, -1, JetDefs.GRAPH_LBLS)
227 self.chkGraphClips = wx.CheckBox(pnlGraph, -1, JetDefs.GRAPH_TRIGGER)
228 self.chkGraphAppEvts = wx.CheckBox(pnlGraph, -1, JetDefs.GRAPH_APP)
230 graphSizer2.Add(self.chkGraphLabels, 0, wx.TOP, BUT_SPACE)
231 graphSizer2.Add(self.chkGraphClips, 0, wx.TOP, BUT_SPACE)
232 graphSizer2.Add(self.chkGraphAppEvts, 0, wx.TOP | wx.BOTTOM, BUT_SPACE)
238 self.Bind(wx.EVT_CHECKBOX, self.OnSetGraphOptions, id=self.chkGraphLabels.GetId())
239 self.Bind(wx.EVT_CHECKBOX, self.OnSetGraphOptions, id=self.chkGraphClips.GetId())
240 self.Bind(wx.EVT_CHECKBOX, self.OnSetGraphOptions, id=self.chkGraphAppEvts.GetId())
243 def initHelp(self):
245 self.SetHelpText(GetJetHelpText(JetDefs.MAIN_DLG_CTRLS, ''))
246 self.segList.SetHelpText(GetJetHelpText(JetDefs.MAIN_DLG_CTRLS, JetDefs.MAIN_SEGLIST))
247 self.eventList.SetHelpText(GetJetHelpText(JetDefs.MAIN_DLG_CTRLS, JetDefs.MAIN_EVENTLIST))
248 self.graph.SetHelpText(GetJetHelpText(JetDefs.AUDITION_CTRLS, JetDefs.AUDITION_GRAPH))
250 def initStatusBar(self):
252 self.statusbar = self.CreateStatusBar()
254 def OnSelectAll(self, event):
256 num = self.segList.GetItemCount()
258 self.segList.CheckItem(i)
260 def OnDeselectAll(self, event):
262 num = self.segList.GetItemCount()
264 self.segList.CheckItem(i, False)
266 def LoadSegList(self):
268 self.seglistSort = (IniGetValue(self.currentJetConfigFile, JetDefs.INI_SEGSORT, JetDefs.INI_SEGSORT_0, 'int', 0), IniGetValue(self.currentJetConfigFile, JetDefs.INI_SEGSORT, JetDefs.INI_SEGSORT_1, 'int', 1))
269 segments = self.jet_file.GetSegments()
270 if self.seglistSort[0] == 0:
271 self.SegSort(segments, "segname")
272 elif self.seglistSort[0] == 1:
273 self.SegSort(segments, "filename")
274 elif self.seglistSort[0] == 2:
275 self.SegSort(segments, "dlsfile")
276 elif self.seglistSort[0] == 3:
277 self.SegSort(segments, "start")
278 elif self.seglistSort[0] == 4:
279 self.SegSort(segments, "end")
280 elif self.seglistSort[0] == 5:
281 self.SegSort(segments, "quantize")
282 elif self.seglistSort[0] == 6:
283 self.SegSort(segments, "transpose")
284 elif self.seglistSort[0] == 7:
285 self.SegSort(segments, "repeat")
286 elif self.seglistSort[0] == 8:
287 self.SegSort(segments, "mute_flags")
289 self.currentSegmentIndex = None
290 self.currentSegmentName = None
291 self.segList.DeleteAllItems()
292 self.eventList.DeleteAllItems()
293 self.menuItems[JetDefs.MNU_UPDATE_SEG].Enable(False)
294 self.menuItems[JetDefs.MNU_DELETE_SEG].Enable(False)
295 self.menuItems[JetDefs.MNU_MOVE_SEG].Enable(False)
297 self.menuItems[JetDefs.MNU_ADD_EVENT].Enable(False)
298 self.menuItems[JetDefs.MNU_MOVE_EVENT].Enable(False)
299 self.menuItems[JetDefs.MNU_UPDATE_EVENT].Enable(False)
300 self.menuItems[JetDefs.MNU_DELETE_EVENT].Enable(False)
301 self.menuItems[JetDefs.MNU_MOVE_EVENT].Enable(False)
302 for segment in self.jet_file.GetSegments():
303 index = self.segList.InsertStringItem(sys.maxint, StrNoneChk(segment.segname))
304 self.segList.SetStringItem(index, 1, FileJustName(StrNoneChk(segment.filename)))
305 self.segList.SetStringItem(index, 2, FileJustName(StrNoneChk(segment.dlsfile)))
306 self.segList.SetStringItem(index, 3, mbtFct(segment.start, 1))
307 self.segList.SetStringItem(index, 4, mbtFct(segment.end, 1))
308 self.segList.SetStringItem(index, 5, StrNoneChk(segment.quantize))
309 self.segList.SetStringItem(index, 6, StrNoneChk(segment.transpose))
310 self.segList.SetStringItem(index, 7, StrNoneChk(segment.repeat))
311 self.segList.SetStringItem(index, 8, StrNoneChk(segment.mute_flags))
313 self.segList.SetItemData(index, index)
314 listDataMap.append((getColumnText(self.segList, index, 0).upper(), getColumnText(self.segList, index, 1).upper(), getColumnText(self.segList, index, 2).upper(), MbtVal(getColumnText(self.segList, index, 3)), MbtVal(getColumnText(self.segList, index, 4)), int(getColumnText(self.segList, index, 5)), int(getColumnText(self.segList, index, 6)), int(getColumnText(self.segList, index, 7)), int(getColumnText(self.segList, index, 8))))
316 self.segList.itemDataMap = listDataMap
317 self.segList.InitSorting(9)
318 self.graph.ClearGraph()
320 def LoadEventsForSeg(self, segName):
322 self.currentEventIndex = None
323 self.eventList.DeleteAllItems()
324 self.menuItems[JetDefs.MNU_UPDATE_EVENT].Enable(False)
325 self.menuItems[JetDefs.MNU_DELETE_EVENT].Enable(False)
326 self.menuItems[JetDefs.MNU_MOVE_EVENT].Enable(False)
327 self.eventlistSort = (IniGetValue(self.currentJetConfigFile, JetDefs.INI_EVENTSORT, JetDefs.INI_EVENTSORT_0, 'int', 0), IniGetValue(self.currentJetConfigFile, JetDefs.INI_EVENTSORT, JetDefs.INI_EVENTSORT_1, 'int', 1))
328 segment = self.jet_file.GetSegment(self.currentSegmentName)
330 if self.eventlistSort[0] == 0:
331 self.EventSort(segment.jetevents, "event_name")
332 elif self.eventlistSort[0] == 1:
333 self.EventSort(segment.jetevents, "event_type")
334 elif self.eventlistSort[0] == 2:
335 self.EventSort(segment.jetevents, "event_start")
336 elif self.eventlistSort[0] == 3:
337 self.EventSort(segment.jetevents, "event_end")
338 elif self.eventlistSort[0] == 4:
339 self.EventSort(segment.jetevents, "track_num")
340 elif self.eventlistSort[0] == 5:
341 self.EventSort(segment.jetevents, "channel_num")
342 elif self.eventlistSort[0] == 6:
343 self.EventSort(segment.jetevents, "event_id")
345 for jet_event in self.jet_file.GetEvents(segName):
346 index = self.eventList.InsertStringItem(sys.maxint, StrNoneChk(jet_event.event_name))
347 self.eventList.SetStringItem(index, 1, StrNoneChk(jet_event.event_type))
348 self.eventList.SetStringItem(index, 2, mbtFct(jet_event.event_start, 1))
349 self.eventList.SetStringItem(index, 3, mbtFct(jet_event.event_end, 1))
350 self.eventList.SetStringItem(index, 4, StrNoneChk(jet_event.track_num))
351 self
352 self.eventList.SetStringItem(index, 6, StrNoneChk(jet_event.event_id))
354 self.eventList.SetItemData(index, index)
355 listDataMap.append((getColumnText(self.eventList, index, 0).upper(), getColumnText(self.eventList, index, 1).upper(), MbtVal(getColumnText(self.eventList, index, 2)), MbtVal(getColumnText(self.eventList, index, 3)), int(getColumnText(self.eventList, index, 4)), int(getColumnText(self.eventList, index, 5)), int(getColumnText(self.eventList, index, 6))))
357 self.eventList.itemDataMap = listDataMap
358 self.eventList.InitSorting(7)
360 def OnEventListClick(self, event):
362 self.currentCtrl = "eventList"
363 self.currentEventIndex = event.m_itemIndex
364 self.currentEventName = getColumnText(self.eventList, event.m_itemIndex, 0)
365 self.menuItems[JetDefs.MNU_UPDATE_EVENT].Enable(True)
366 self.menuItems[JetDefs.MNU_DELETE_EVENT].Enable(True)
367 self.menuItems[JetDefs.MNU_MOVE_EVENT].Enable(True)
369 def OnSegmentChecked(self, index, checked):
371 ClearRowSelections(self.segList)
372 SetRowSelection(self.segList, index, True)
374 def SelectSegment(self, segName):
376 itm = self.segList.FindItem(-1, segName)
377 self.segList.EnsureVisible(itm)
378 ClearRowSelections(self.segList)
379 SetRowSelection(self.segList, itm, True)
381 def SelectEvent(self, eventName):
383 itm = self.eventList.FindItem(-1, eventName)
384 self.eventList.EnsureVisible(itm)
385 ClearRowSelections(self.eventList)
386 SetRowSelection(self.eventList, itm, True)
388 def OnSegListClick(self, event):
390 self.currentCtrl = "segList"
391 self.currentSegmentIndex = event.m_itemIndex
392 self.currentSegmentName = getColumnText(self.segList, event.m_itemIndex, 0)
393 self.LoadEventsForSeg(getColumnText(self.segList, event.m_itemIndex, 0))
394 self.menuItems[JetDefs.MNU_UPDATE_SEG].Enable(True)
395 self.menuItems[JetDefs.MNU_DELETE_SEG].Enable(True)
396 self.menuItems[JetDefs.MNU_MOVE_SEG].Enable(True)
397 self.menuItems[JetDefs.MNU_ADD_EVENT].Enable(True)
398 info = self.graph.LoadSegment(self.jet_file.GetSegment(self.currentSegmentName), showLabels=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, 'bool', 'True'), showClips=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, 'bool', 'True'), showAppEvts=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, 'bool', 'True'))
400 self.log.SetValue("")
404 self.log.SetValue("%s %.2f Seconds" % (self.currentSegmentName, iLength / 1000.00))
406 self.log.SetValue("%s" % (self.currentSegmentName))
408 def OnSegmentAdd(self, event):
410 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
412 dlg = SegEdit(JetDefs.MAIN_ADDSEGTITLE, self.currentJetConfigFile)
414 for filename in self.jet_file.GetMidiFiles():
416 for library in self.jet_file.GetLibraries():
423 self.jet_file.DeleteSegmentsMatchingPrefix(dlg.replicatePrefix)
426 self.jet_file.AddSegment(replicate[0], dlg.GetValue(JetDefs.F_MIDIFILE),
429 SegmentOutputFile(dlg.GetValue(JetDefs.F_SEGNAME), self.currentJetConfigFile),
437 self.LoadSegList()
438 self.SelectSegment(dlg.lstReplicate[0][0])
440 self.jet_file.AddSegment(dlg.GetValue(JetDefs.F_SEGNAME), dlg.GetValue(JetDefs.F_MIDIFILE),
443 SegmentOutputFile(dlg.GetValue(JetDefs.F_SEGNAME), self.currentJetConfigFile),
450 self.LoadSegList()
451 self.SelectSegment(dlg.GetValue(JetDefs.F_SEGNAME))
452 self.UndoAdd(saveState)
455 def OnSegmentUpdate(self, event):
457 if self.currentSegmentName is None:
460 segment = self.jet_file.GetSegment(self.currentSegmentName)
464 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
466 dlg = SegEdit(JetDefs.MAIN_REVSEGTITLE, self.currentJetConfigFile)
468 for filename in self.jet_file.GetMidiFiles():
470 for library in self.jet_file.GetLibraries():
486 self.jet_file.UpdateSegment(self.currentSegmentName, dlg.GetValue(JetDefs.F_SEGNAME),
490 SegmentOutputFile(dlg.GetValue(JetDefs.F_SEGNAME), self.currentJetConfigFile),
500 self.jet_file.DeleteSegmentsMatchingPrefix(dlg.replicatePrefix)
503 self.jet_file.AddSegment(replicate[0], dlg.GetValue(JetDefs.F_MIDIFILE),
506 SegmentOutputFile(dlg.GetValue(JetDefs.F_SEGNAME), self.currentJetConfigFile),
514 self.LoadSegList()
515 self.SelectSegment(dlg.lstReplicate[0][0])
517 self.LoadSegList()
518 self.SelectSegment(dlg.GetValue(JetDefs.F_SEGNAME))
519 self.UndoAdd(saveState)
522 def OnSegmentDelete(self, event):
524 if self.currentSegmentName is None:
527 segment = self.jet_file.GetSegment(self.currentSegmentName)
533 item = self.segList.GetFirstSelected()
536 deleteMsg = getColumnText(self.segList,item,0)
541 deleteMsg = deleteMsg + "\n" + getColumnText(self.segList,item,0)
543 item = self.segList.GetNextSelected(item)
546 item = self.segList.GetFirstSelected()
548 segName = getColumnText(self.segList,item,0)
549 self.SegmentDelete(segName)
550 item = self.segList.GetNextSelected(item)
552 self.graph.ClearGraph()
553 self.LoadSegList()
555 def SegmentDelete(self, segName):
557 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
558 self.jet_file.DeleteSegment(segName)
559 self.UndoAdd(saveState)
561 def OnSegmentsMove(self, event):
563 if self.currentSegmentName is None:
568 item = self.segList.GetFirstSelected()
570 max = GetMidiInfo(self.jet_file.GetSegment(getColumnText(self.segList,item,0)).filename).endMbtStr
571 lstMoveItems.append((getColumnText(self.segList,item,0), mbtFct(getColumnText(self.segList,item,3),-1), mbtFct(getColumnText(self.segList,item,4),-1), max))
573 item = self.segList.GetNextSelected(item)
584 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
587 self.jet_file.MoveSegment(moveitem[0], moveitem[1], moveitem[2])
589 self.LoadSegList()
590 self.UndoAdd(saveState)
594 def UndoAdd(self, saveState):
596 self.UndoStack.append(saveState)
597 self.menuItems[JetDefs.MNU_UNDO].Enable(True)
599 def RedoAdd(self, saveState):
601 self.RedoStack.append(saveState)
602 self.menuItems[JetDefs.MNU_REDO].Enable(True)
604 def OnRedo(self, event):
606 if len(self.RedoStack) > 0:
607 self.UndoAdd(JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex))
608 state = self.RedoStack.pop()
609 self.jet_file = copy.deepcopy(state.jet_file)
610 self.LoadSegList()
611 self.currentSegmentIndex = state.currentSegmentIndex
612 if self.currentSegmentIndex != None:
613 SetRowSelection(self.segList, self.currentSegmentIndex, True)
614 if len(self.RedoStack) == 0:
615 self.menuItems[JetDefs.MNU_REDO].Enable(False)
617 def OnUndo(self, event):
619 if len(self.UndoStack) > 0:
620 self.RedoAdd(JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex))
621 state = self.UndoStack.pop()
622 self.jet_file = copy.deepcopy(state.jet_file)
623 self.LoadSegList()
624 self.currentSegmentIndex = state.currentSegmentIndex
625 if self.currentSegmentIndex != None:
626 SetRowSelection(self.segList, self.currentSegmentIndex, True)
627 if len(self.UndoStack) == 0:
628 self.menuItems[JetDefs.MNU_UNDO].Enable(False)
630 def OnEventAdd(self, event):
632 if self.currentSegmentName is None:
635 segment = self.jet_file.GetSegment(self.currentSegmentName)
639 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
641 dlg = EventEdit(JetDefs.MAIN_ADDEVENTTITLE, self.currentJetConfigFile)
650 events = self.jet_file.GetEvents(self.currentSegmentName)
653 self.jet_file.DeleteEvent(self.currentSegmentName, evt.event_name)
658 self.jet_file.DeleteEventsMatchingPrefix(self.currentSegmentName, dlg.replicatePrefix)
661 self.jet_file.AddEvent(self.currentSegmentName, replicate[0],
668 self.SelectSegment(self.currentSegmentName)
669 self.SelectEvent(dlg.lstReplicate[0][0])
671 self.jet_file.AddEvent(self.currentSegmentName, dlg.GetValue(JetDefs.F_ENAME),
679 self.SelectSegment(self.currentSegmentName)
680 self.SelectEvent(dlg.GetValue(JetDefs.F_ENAME))
682 self.UndoAdd(saveState)
685 def OnEventUpdate(self, event):
687 if self.currentSegmentName is None:
690 if self.currentEventName is None:
693 segment = self.jet_file.GetSegment(self.currentSegmentName)
697 curEvent = copy.deepcopy(self.jet_file.GetEvent(self.currentSegmentName, self.currentEventName))
701 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
708 dlg = EventEdit(JetDefs.MAIN_REVEVENTTITLE, self.currentJetConfigFile)
724 self.jet_file.UpdateEvent(self.currentSegmentName,
725 self.currentEventName,
736 self.jet_file.DeleteEventsMatchingPrefix(self.currentSegmentName, dlg.replicatePrefix)
739 self.jet_file.AddEvent(self.currentSegmentName, replicate[0],
746 self.SelectSegment(self.currentSegmentName)
747 self.SelectEvent(dlg.lstReplicate[0][0])
749 self.SelectSegment(self.currentSegmentName)
750 self.SelectEvent(dlg.GetValue(JetDefs.F_ENAME))
751 self.UndoAdd(saveState)
754 def OnEventDelete(self, event):
756 if self.currentSegmentName is None:
759 if self.currentEventName is None:
762 curEvent = self.jet_file.GetEvent(self.currentSegmentName, self.currentEventName)
768 item = self.eventList.GetFirstSelected()
771 deleteMsg = getColumnText(self.eventList,item,0)
776 deleteMsg = deleteMsg + "\n" + getColumnText(self.eventList,item,0)
778 item = self.eventList.GetNextSelected(item)
782 item = self.eventList.GetFirstSelected()
784 eventName = getColumnText(self.eventList,item,0)
785 self.EventDelete(eventName)
786 item = self.eventList.GetNextSelected(item)
788 self.SelectSegment(self.currentSegmentName)
789 self.LoadEventsForSeg(self.currentSegmentName)
791 def EventDelete(self, eventName):
793 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
794 self.jet_file.DeleteEvent(self.currentSegmentName, eventName)
795 self.UndoAdd(saveState)
797 def OnEventsMove(self, event):
799 if self.currentSegmentName is None:
802 if self.currentEventName is None:
805 segment = self.jet_file.GetSegment(self.currentSegmentName)
809 curEvent = self.jet_file.GetEvent(self.currentSegmentName, self.currentEventName)
815 item = self.eventList.GetFirstSelected()
817 lstMoveItems.append((getColumnText(self.eventList,item,0), mbtFct(getColumnText(self.eventList,item,2),-1), mbtFct(getColumnText(self.eventList,item,3),-1), segment.end))
819 item = self.eventList.GetNextSelected(item)
830 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
833 self.jet_file.MoveEvent(self.currentSegmentName, moveitem[0], moveitem[1], moveitem[2])
835 self.SelectSegment(self.currentSegmentName)
836 self.LoadEventsForSeg(self.currentSegmentName)
838 self.UndoAdd(saveState)
842 def OnJetOpen(self, event):
847 self.jet_file = JetFile(dlg.fileName , "")
848 if not ValidateConfig(self.jet_file):
850 self.currentJetConfigFile = JetDefs.UNTITLED_FILE
851 self.jet_file = JetFile(self.currentJetConfigFile, "")
853 self.SetCurrentFile(dlg.fileName)
855 self.jet_file = JetFile("" , "")
856 self.SetCurrentFile(JetDefs.UNTITLED_FILE)
857 self.LoadDefaultProperties()
859 self.OnJetImportArchive(event)
862 def OnJetSaveAs(self, event):
868 self.currentJetConfigFile = FileJustRoot(dialog.GetPath()) + ".jtc"
869 self.jet_file.config.filename = FileJustRoot(self.currentJetConfigFile) + ".jet"
870 self.jet_file.SaveJetConfig(self.currentJetConfigFile)
871 self.jet_file.WriteJetFileFromConfig(self.currentJetConfigFile)
872 self.SetCurrentFile(self.currentJetConfigFile)
875 def OnJetSave(self, event):
877 if self.currentJetConfigFile == JetDefs.UNTITLED_FILE:
878 self.OnJetSaveAs(event)
880 self.jet_file.SaveJetConfig(self.currentJetConfigFile)
881 self.jet_file.WriteJetFileFromConfig(self.currentJetConfigFile)
883 def OnJetNew(self, event):
885 self.jet_file = JetFile("" , "")
886 self.SetCurrentFile(JetDefs.UNTITLED_FILE)
887 self.LoadDefaultProperties()
889 def SetCurrentFile(self, fileName):
891 self.clipBoard = None
892 self.currentJetConfigFile = fileName
893 self.SetTitle(JetDefs.MAIN_TITLEPREFIX + FileJustName(fileName))
895 self.LoadSegList()
896 self.graph.ClearGraph()
897 self.chkGraphLabels.SetValue(IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, 'bool', 'True'))
898 self.chkGraphClips.SetValue(IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, 'bool', 'True'))
899 self.chkGraphAppEvts.SetValue(IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, 'bool', 'True'))
901 def createMenuBar(self):
903 self.menuItems = {}
908 menuBar.Append(self.createMenu(menuItems), menuLabel)
909 self.SetMenuBar(menuBar)
911 def createMenu(self, menuData):
918 self.menuItems[eachLabel] = menu.Append(-1, eachLabel, eachStatus)
919 self.menuItems[eachLabel].Enable(eachEnable)
921 self.Bind(wx.EVT_MENU, getattr(self, eachHandler) , self.menuItems[eachLabel])
923 print("def " + eachHandler + "(self, event): pass")
926 def createToolbar(self):
928 toolbar = self.CreateToolBar()
930 self.toolItems = {}
937 self.toolItems[eachTool[0]] = toolbar.AddLabelTool(-1, label=eachTool[0],
940 self.Bind(wx.EVT_TOOL, getattr(self, eachTool[3]) , self.toolItems[eachTool[0]])
943 def OnAudition(self, event):
945 jet_file = CreateTempJetFile(self.jet_file)
947 w, h = self.GetSize()
958 def SetKeepPlayingFlag(self, val):
960 with self.playerLock:
961 self.keepPlaying = val
963 def GetKeepPlayingFlag(self):
965 with self.playerLock:
966 return self.keepPlaying
968 def GraphTriggerClip(self, sClipName, iEventId):
970 with self.playerLock:
972 self.jet.TriggerClip(iEventId)
973 self.log.SetValue(JetDefs.PLAY_TRIGGERCLIP_MSG % (iEventId, sClipName))
978 def OnHelpJet(self, event):
984 def OnHelpJetGuidelines(self, event):
990 def OnAbout(self, event):
996 def OnJetImportArchive(self, event):
1003 dlg1 = wx.DirDialog(self, JetDefs.IMPORT_ARCHIVEDIR_PROMPT, style=wx.DD_DEFAULT_STYLE, defaultPath=defDir)
1042 self.currentJetConfigFile = FileFixPath(projectPath + "/") + jtcFile
1043 self.jet_file = JetFile(self.currentJetConfigFile, "")
1046 self.jet_file.config.filename = FileJustRoot(self.currentJetConfigFile) + ".JET"
1047 for index, segment in enumerate(self.jet_file.segments):
1048 self.jet_file.segments[index].filename = FileFixPath(projectPath + "/" + segment.filename)
1050 self.jet_file.segments[index].dlsfile = FileFixPath(projectPath + "/" + segment.dlsfile)
1051 self.jet_file.segments[index].output = FileFixPath(projectPath + "/" + segment.output)
1053 for index, library in enumerate(self.jet_file.libraries):
1054 self.jet_file.libraries[index] = FileFixPath(projectPath + "/" + library)
1056 if ValidateConfig(self.jet_file):
1057 self.jet_file.SaveJetConfig(self.currentJetConfigFile)
1058 self.jet_file.WriteJetFileFromConfig(self.currentJetConfigFile)
1059 self.jet_file = JetFile(self.currentJetConfigFile , "")
1060 self.SetCurrentFile(self.currentJetConfigFile)
1065 def OnJetExportArchive(self, event):
1067 self.OnJetSave(event)
1072 ExportJetArchive(FileJustRoot(dialog.GetPath()) + ".zip", self.currentJetConfigFile, self.jet_file)
1075 def OnCopy(self, event):
1077 if self.currentCtrl == JetDefs.MAIN_SEGLIST:
1078 if self.currentSegmentName is None:
1081 segment = self.jet_file.GetSegment(self.currentSegmentName)
1084 self.clipBoard = JetCutCopy(self.currentCtrl, segment, self.currentSegmentName)
1085 return self.currentCtrl
1086 elif self.currentCtrl == JetDefs.MAIN_EVENTLIST:
1087 if self.currentSegmentName is None:
1090 if self.currentEventName is None:
1093 segment = self.jet_file.GetSegment(self.currentSegmentName)
1097 curEvent = self.jet_file.GetEvent(self.currentSegmentName, self.currentEventName)
1100 self.clipBoard = JetCutCopy(self.currentCtrl, curEvent, self.currentSegmentName)
1101 return self.currentCtrl
1103 def OnCut(self, event):
1105 retCopy = self.OnCopy(event)
1107 self.SegmentDelete(self.currentSegmentName)
1108 self.LoadSegList()
1110 self.EventDelete(self.currentEventName)
1111 self.LoadEventsForSeg(self.currentSegmentName)
1113 def OnPaste(self, event):
1115 if self.clipBoard is not None:
1116 if self.currentCtrl == JetDefs.MAIN_SEGLIST and self.clipBoard.objType == JetDefs.MAIN_SEGLIST:
1117 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
1118 self.jet_file.segments.append(self.clipBoard.GetObj(self.jet_file.segments))
1119 self.UndoAdd(saveState)
1120 self.LoadSegList()
1121 elif self.currentCtrl == JetDefs.MAIN_EVENTLIST and self.clipBoard.objType == JetDefs.MAIN_EVENTLIST and self.clipBoard.currentSegmentName == self.currentSegmentName:
1122 for segment in self.jet_file.segments:
1123 if segment.segname == self.currentSegmentName:
1124 saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
1125 segment.jetevents.append(self.clipBoard.GetObj(segment.jetevents))
1126 self.UndoAdd(saveState)
1127 self.LoadEventsForSeg(self.currentSegmentName)
1128 self.graph.LoadSegment(self.jet_file.GetSegment(self.currentSegmentName), showLabels=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, 'bool', 'True'), showClips=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, 'bool', 'True'), showAppEvts=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, 'bool', 'True'))
1130 def OnJetProperties(self, event):
1133 dlg.SetValue(JetDefs.F_JETFILENAME, self.jet_file.config.filename)
1134 dlg.SetValue(JetDefs.F_COPYRIGHT, StrNoneChk(self.jet_file.config.copyright))
1135 dlg.SetValue(JetDefs.F_CHASECONTROLLERS, StrNoneChk(self.jet_file.config.chase_controllers))
1136 dlg.SetValue(JetDefs.F_DELETEEMPTYTRACKS, StrNoneChk(self.jet_file.config.delete_empty_tracks))
1140 self.jet_file.config.filename = dlg.je.ctrls[JetDefs.F_JETFILENAME].GetValue()
1141 self.jet_file.config.copyright = dlg.je.ctrls[JetDefs.F_COPYRIGHT].GetValue()
1142 self.jet_file.config.chase_controllers = dlg.je.ctrls[JetDefs.F_CHASECONTROLLERS].GetValue()
1143 self.jet_file.config.delete_empty_tracks = dlg.je.ctrls[JetDefs.F_DELETEEMPTYTRACKS].GetValue()
1146 def OnPreferences(self, event):
1159 def LoadDefaultProperties(self):
1161 self.jet_file.config.copyright = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_COPYRIGHT)
1162 self.jet_file.config.chase_controllers = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_CHASECONTROLLERS, 'bool', True)
1163 self.jet_file.config.delete_empty_tracks = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_DELETEEMPTYTRACKS, 'bool', False)
1165 def OnClose(self, event):
1167 if self.isDirty():
1170 self.OnJetSave(None)
1174 if self.jet is not None:
1175 SafeJetShutdown(self.playerLock, self.jet)
1176 self.Destroy()
1178 def OnPlay(self, event):
1180 if self.btnPlay.GetLabel() == JetDefs.BUT_PLAY:
1181 if not ValidateConfig(self.jet_file):
1186 num = self.segList.GetItemCount()
1188 if self.segList.IsChecked(seg_num):
1194 for segment in self.jet_file.segments:
1196 if not segment.dlsfile in self.jet_file.libraries:
1197 self.jet_file.libraries.append(segment.dlsfile)
1199 self.eventList.DeleteAllItems()
1200 num = self.segList.GetItemCount()
1202 if seg_num == 0: self.log.Clear()
1203 if self.segList.IsChecked(seg_num):
1204 segment = self.jet_file.GetSegment(getColumnText(self.segList, seg_num, 0))
1209 dls_num = FindDlsNum(self.jet_file.libraries, segment.dlsfile)
1212 self.queueSegs.append(QueueSeg(segment.segname, userID, seg_num, dls_num, segment.repeat, segment.transpose, segment.mute_flags))
1214 if len(self.queueSegs) == 0:
1217 self.btnPlay.SetLabel(JetDefs.BUT_STOP)
1219 thread.start_new_thread(self.PlaySegs, ())
1221 with self.playerLock:
1222 self.jet.Clear_Queue()
1223 self.SetKeepPlayingFlag(False)
1225 def PlaySegs(self):
1227 if len(self.queueSegs) == 0:
1230 jet_file = CreateTempJetFile(self.jet_file)
1236 self.jet = JET()
1237 self.jet.eas.StartWave()
1238 self.jet.OpenFile(jet_file.config.filename)
1243 Queue(self.jet, self.queueSegs[0])
1245 self.jet.Play()
1246 self.paused = False
1249 self.SetKeepPlayingFlag(True)
1250 while self.GetKeepPlayingFlag():
1251 self.jet.Render()
1252 status = self.jet.Status()
1255 wx.PostEvent(self, JetStatusEvent(JetDefs.PST_PLAY, status.currentUserID))
1262 self.jet.GetAppEvent()
1265 if (index < len(self.queueSegs)) and (status.numQueuedSegments < 2):
1266 Queue(self.jet, self.queueSegs[index])
1269 wx.PostEvent(self, JetStatusEvent(JetDefs.PST_UPD_LOCATION, status.location))
1272 SafeJetShutdown(self.playerLock, self.jet)
1274 self.queueSegs = []
1278 wx.PostEvent(self, JetStatusEvent(JetDefs.PST_DONE, None))
1280 def OnJetStatusUpdate(self, evt):
1285 segName = getColumnText(self.segList, evt.data, 0)
1286 self.LoadEventsForSeg(segName)
1287 self.log.SetValue(segName)
1288 ClearRowSelections(self.segList)
1289 SetRowSelection(self.segList, evt.data, True)
1291 self.graph.UpdateLocation(evt.data)
1293 self.graph.UpdateLocation(0)
1294 ClearRowSelections(self.segList)
1295 self.eventList.DeleteAllItems()
1296 self.SetKeepPlayingFlag(False)
1297 self.btnPlay.SetLabel(JetDefs.BUT_PLAY)
1298 self.btnPause.SetLabel(JetDefs.BUT_PAUSE)
1300 def OnPause(self, evt):
1302 if self.jet is None:
1304 if not self.paused:
1305 self.jet.Pause()
1306 self.paused = True
1307 self.btnPause.SetLabel(JetDefs.BUT_RESUME)
1309 self.jet.Play()
1310 self.paused = False
1311 self.btnPause.SetLabel(JetDefs.BUT_PAUSE)
1313 def isDirty(self):
1314 if len(self.UndoStack) == 0 and len(self.RedoStack) == 0:
1319 def OnSetGraphOptions(self, evt):
1321 IniSetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, self.chkGraphLabels.GetValue())
1322 IniSetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, self.chkGraphClips.GetValue())
1323 IniSetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, self.chkGraphAppEvts.GetValue())
1324 self.graph.LoadSegment(self.jet_file.GetSegment(self.currentSegmentName), showLabels=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, 'bool', 'True'), showClips=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, 'bool', 'True'), showAppEvts=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, 'bool', 'True'))
1326 def OnEventSortOrderChanged(self):
1328 self.currentJetConfigFile, JetDefs.INI_EVENTSORT, JetDefs.INI_EVENTSORT_0, self.eventList.GetSortState()[0])
1329 IniSetValue(self.currentJetConfigFile, JetDefs.INI_EVENTSORT, JetDefs.INI_EVENTSORT_1, self.eventList.GetSortState()[1])
1330 self.LoadEventsForSeg(self.currentSegmentName)
1331 self.graph.LoadSegment(self.jet_file.GetSegment(self.currentSegmentName), showLabels=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, 'bool', 'True'), showClips=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, 'bool', 'True'), showAppEvts=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, 'bool', 'True'))
1333 def EventSortCmp(self, a, b):
1335 if self.eventlistSort[0] == 0 or self.eventlistSort[0] == 1:
1336 if self.eventlistSort[1] == 1:
1340 elif self.eventlistSort[0] == 2 or self.eventlistSort[0] == 3:
1341 if self.eventlistSort[1] == 1:
1348 def EventSort2(self, seq, attr):
1351 intermed.sort(self.EventSortCmp)
1354 def EventSort(self, lst, attr):
1356 lst[:] = self.EventSort2(lst, attr)
1358 def OnSegSortOrderChanged(self):
1360 IniSetValue(self.currentJetConfigFile, JetDefs.INI_SEGSORT, JetDefs.INI_SEGSORT_0, self.segList.GetSortState()[0])
1361 IniSetValue(self.currentJetConfigFile, JetDefs.INI_SEGSORT, JetDefs.INI_SEGSORT_1, self.segList.GetSortState()[1])
1362 self.LoadEventsForSeg(self.currentSegmentName)
1363 self.graph.LoadSegment(self.jet_file.GetSegment(self.currentSegmentName), showLabels=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, 'bool', 'True'), showClips=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, 'bool', 'True'), showAppEvts=IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, 'bool', 'True'))
1365 def SegSortCmp(self, a, b):
1367 if self.seglistSort[0] == 0:
1368 if self.seglistSort[1] == 1:
1372 elif self.seglistSort[0] == 1 or self.seglistSort[0] == 2:
1373 if self.seglistSort[1] == 1:
1377 elif self.seglistSort[0] == 3 or self.seglistSort[0] == 4:
1378 if self.seglistSort[1] == 1:
1385 def SegSort2(self, seq, attr):
1388 intermed.sort(self.SegSortCmp)
1391 def SegSort(self, lst, attr):
1393 lst[:] = self.SegSort2(lst, attr)