16b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi"""
26b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi File:
36b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi JetCreator.py
46b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
56b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Contents and purpose:
66b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Jet file creation utility for JET sound engine
76b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
86b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Copyright (c) 2008 Android Open Source Project
96b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Licensed under the Apache License, Version 2.0 (the "License");
116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi you may not use this file except in compliance with the License.
126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi You may obtain a copy of the License at
136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi      http://www.apache.org/licenses/LICENSE-2.0
156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi Unless required by applicable law or agreed to in writing, software
176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi distributed under the License is distributed on an "AS IS" BASIS,
186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi See the License for the specific language governing permissions and
206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi limitations under the License.
216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi"""
226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom __future__ import with_statement
246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport wx
266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport sys
276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport thread
286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport copy
296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport wx.html
306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport operator
316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin
336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom eas import *
346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetFile import *
356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetUtils import *
366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetCtrls import *
376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetDialogs import *
386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetSegGraph import SegmentGraph, Marker
396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetAudition import *
406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivifrom JetStatusEvent import *
416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport img_favicon
436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviimport img_New
446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviprovider = wx.SimpleHelpProvider()
466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviwx.HelpProvider_Set(provider)
476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviclass JetCreator(wx.Frame):
506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    """ Main window of JetCreator utility """
516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def __init__(self, parent, id, jetConfigFile, importFlag=False):
526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        wx.Frame.__init__(self, parent, id, size=(1050, 720), style=wx.DEFAULT_FRAME_STYLE | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX)
536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.myicon = img_favicon.getIcon()
556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetIcon(self.myicon)
566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.UndoStack = []
576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.RedoStack = []
586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.queueSegs = []
596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.clipBoard = None
606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet = None
616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.playerLock = threading.RLock()
626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetKeepPlayingFlag(True)
636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentSegmentName = None
646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentSegmentIndex = None
656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentEventName = None
666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentEventIndex = None
676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentCtrl = ""
686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentJetConfigFile = jetConfigFile
696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.paused = False
706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventlistSort = (0, 1)
716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.seglistSort = (0, 1)
726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentJetConfigFile == "":
736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            FileKillClean(JetDefs.UNTITLED_FILE)
746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.currentJetConfigFile = JetDefs.UNTITLED_FILE
756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet_file = JetFile(self.currentJetConfigFile, "")
776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if not ValidateConfig(self.jet_file):
796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            FileKillClean(JetDefs.UNTITLED_FILE)
806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.currentJetConfigFile = JetDefs.UNTITLED_FILE
816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file = JetFile(self.currentJetConfigFile, "")
826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentJetConfigFile == JetDefs.UNTITLED_FILE:
846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadDefaultProperties()
856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.initLayout()
876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.initStatusBar()
886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.createMenuBar()
896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.createToolbar()
906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetCurrentFile(self.currentJetConfigFile)
916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.initHelp()
926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.graph.ClickCallbackFct = self.GraphTriggerClip
946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        EVT_JET_STATUS(self, self.OnJetStatusUpdate)
966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        wx.EVT_CLOSE(self, self.OnClose)
986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Centre()
1006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Show(True)
1016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if importFlag:
1036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.OnJetImportArchive(None)
1046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventList.OnSortOrderChangedAlert = self.OnEventSortOrderChanged
1066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.OnSortOrderChangedAlert = self.OnSegSortOrderChanged
1076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def initLayout(self):
1096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Initializes the screen layout """
1106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        panel = wx.Panel(self, -1)
1116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        hboxMain = wx.BoxSizer(wx.HORIZONTAL)
1136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        leftPanel = wx.Panel(panel, -1)
1156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        leftTopPanel = wx.Panel(leftPanel, -1)
1166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        leftBotPanel = wx.Panel(leftPanel, -1)
1176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        rightPanel = wx.Panel(panel, -1)
1186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList = JetCheckListCtrl(rightPanel)
1206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for title, width, fld in JetDefs.SEGMENT_GRID:
1216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.AddCol(title, width)
1226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventList = JetListCtrl(rightPanel)
1246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for title, width, fld in JetDefs.CLIPS_GRID:
1256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.eventList.AddCol(title, width)
1266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnEventListClick)
1286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSegListClick)
1296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnSegmentUpdate)
1306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventList.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnEventUpdate)
1316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.BindCheckBox(self.OnSegmentChecked)
1336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        BUT_SIZE = (95, 25)
1356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnAddSeg = wx.Button(leftTopPanel, -1, JetDefs.BUT_ADD, size=BUT_SIZE)
1366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnRevSeg = wx.Button(leftTopPanel, -1, JetDefs.BUT_REVISE, size=BUT_SIZE)
1376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnDelSeg = wx.Button(leftTopPanel, -1, JetDefs.BUT_DELETE, size=BUT_SIZE)
1386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnMoveSeg = wx.Button(leftTopPanel, -1, JetDefs.BUT_MOVE, size=BUT_SIZE)
1396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnQueueAll = wx.Button(leftTopPanel, -1, JetDefs.BUT_QUEUEALL, size=BUT_SIZE)
1416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnDequeueAll = wx.Button(leftTopPanel, -1, JetDefs.BUT_DEQUEUEALL, size=BUT_SIZE)
1426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnPlay = wx.Button(leftTopPanel, -1, JetDefs.BUT_PLAY, size=BUT_SIZE)
1436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnPause = wx.Button(leftTopPanel, -1, JetDefs.BUT_PAUSE, size=BUT_SIZE)
1446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnAudition = wx.Button(leftTopPanel, -1, JetDefs.BUT_AUDITION, size=BUT_SIZE)
1456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnAddEvt = wx.Button(leftBotPanel, -1, JetDefs.BUT_ADD, size=BUT_SIZE)
1476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnRevEvt = wx.Button(leftBotPanel, -1, JetDefs.BUT_REVISE, size=BUT_SIZE)
1486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnDelEvt = wx.Button(leftBotPanel, -1, JetDefs.BUT_DELETE, size=BUT_SIZE)
1496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.btnMoveEvents = wx.Button(leftBotPanel, -1, JetDefs.BUT_MOVE, size=BUT_SIZE)
1506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnSegmentAdd, id=self.btnAddSeg.GetId())
1526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnSegmentUpdate, id=self.btnRevSeg.GetId())
1536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnSegmentDelete, id=self.btnDelSeg.GetId())
1546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnSegmentsMove, id=self.btnMoveSeg.GetId())
1556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=self.btnQueueAll.GetId())
1576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=self.btnDequeueAll.GetId())
1586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnPlay, id=self.btnPlay.GetId())
1596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnPause, id=self.btnPause.GetId())
1606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnAudition, id=self.btnAudition.GetId())
1616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnEventAdd, id=self.btnAddEvt.GetId())
1636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnEventUpdate, id=self.btnRevEvt.GetId())
1646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnEventDelete, id=self.btnDelEvt.GetId())
1656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_BUTTON, self.OnEventsMove, id=self.btnMoveEvents.GetId())
1666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        BORDER = 5
1686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        BUT_SPACE = 3
1696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop = wx.BoxSizer(wx.VERTICAL)
1706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftBot = wx.BoxSizer(wx.VERTICAL)
1716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnAddSeg, 0, wx.TOP, BORDER)
1736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnRevSeg, 0, wx.TOP, BUT_SPACE)
1746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnDelSeg, 0, wx.TOP, BUT_SPACE)
1756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnMoveSeg, 0, wx.TOP, BUT_SPACE)
1766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add((-1, 12))
1776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnQueueAll, 0, wx.TOP, BUT_SPACE)
1786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnDequeueAll, 0, wx.TOP, BUT_SPACE)
1796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnPlay, 0, wx.TOP, BUT_SPACE)
1806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnPause, 0, wx.TOP, BUT_SPACE)
1816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftTop.Add(self.btnAudition, 0, wx.TOP, BUT_SPACE)
1826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftBot.Add(self.btnAddEvt, 0)
1846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftBot.Add(self.btnRevEvt, 0, wx.TOP, BUT_SPACE)
1856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftBot.Add(self.btnDelEvt, 0, wx.TOP, BUT_SPACE)
1866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftBot.Add(self.btnMoveEvents, 0, wx.TOP, BUT_SPACE)
1876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        leftTopPanel.SetSizer(vBoxLeftTop)
1896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        leftBotPanel.SetSizer(vBoxLeftBot)
1906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxLeft = wx.BoxSizer(wx.VERTICAL)
1926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxLeft.Add(leftTopPanel, 1, wx.EXPAND)
1936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxLeft.Add(leftBotPanel, 1, wx.EXPAND)
1946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxLeft.Add((-1, 25))
1956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        leftPanel.SetSizer(vboxLeft)
1976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.log = wx.TextCtrl(rightPanel, -1)
1996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.graph = SegmentGraph(rightPanel, size=(-1, 50))
2006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight = wx.BoxSizer(wx.VERTICAL)
2026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight.Add(self.segList, 4, wx.EXPAND | wx.TOP, BORDER)
2036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight.Add((-1, 10))
2046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight.Add(self.eventList, 3, wx.EXPAND | wx.TOP, BORDER)
2056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight.Add((-1, 10))
2066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight.Add(self.log, 0, wx.EXPAND)
2076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight.Add((-1, 5))
2086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight.Add(self.graph, 1, wx.EXPAND)
2096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vboxRight.Add((-1, 10))
2106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        rightPanel.SetSizer(vboxRight)
2126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        hboxMain.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT | wx.LEFT, BORDER)
2146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        hboxMain.Add(rightPanel, 1, wx.EXPAND)
2156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        hboxMain.Add((BORDER, -1))
2166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        panel.SetSizer(hboxMain)
2186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        pnlGraph = wx.Panel(leftBotPanel, -1)
2206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        graphSizer1 = wx.BoxSizer(wx.VERTICAL)
2216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        pnlGraph.SetSizer(graphSizer1)
2226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        graphBox = wx.StaticBox(pnlGraph, wx.ID_ANY, label='Graph')
2246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        graphSizer2 = wx.StaticBoxSizer(graphBox, wx.VERTICAL)
2256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.chkGraphLabels = wx.CheckBox(pnlGraph, -1, JetDefs.GRAPH_LBLS)
2276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.chkGraphClips = wx.CheckBox(pnlGraph, -1, JetDefs.GRAPH_TRIGGER)
2286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.chkGraphAppEvts = wx.CheckBox(pnlGraph, -1, JetDefs.GRAPH_APP)
2296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        graphSizer2.Add(self.chkGraphLabels, 0, wx.TOP, BUT_SPACE)
2316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        graphSizer2.Add(self.chkGraphClips, 0, wx.TOP, BUT_SPACE)
2326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        graphSizer2.Add(self.chkGraphAppEvts, 0, wx.TOP | wx.BOTTOM, BUT_SPACE)
2336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        graphSizer1.Add((-1, 10))
2346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        graphSizer1.Add(graphSizer2)
2356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        vBoxLeftBot.Add(pnlGraph, 0, wx.TOP, BUT_SPACE)
2376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_CHECKBOX, self.OnSetGraphOptions, id=self.chkGraphLabels.GetId())
2396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_CHECKBOX, self.OnSetGraphOptions, id=self.chkGraphClips.GetId())
2406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Bind(wx.EVT_CHECKBOX, self.OnSetGraphOptions, id=self.chkGraphAppEvts.GetId())
2416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def initHelp(self):
2446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Initializes the help text for screen elements """
2456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetHelpText(GetJetHelpText(JetDefs.MAIN_DLG_CTRLS, ''))
2466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.SetHelpText(GetJetHelpText(JetDefs.MAIN_DLG_CTRLS, JetDefs.MAIN_SEGLIST))
2476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventList.SetHelpText(GetJetHelpText(JetDefs.MAIN_DLG_CTRLS, JetDefs.MAIN_EVENTLIST))
2486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.graph.SetHelpText(GetJetHelpText(JetDefs.AUDITION_CTRLS, JetDefs.AUDITION_GRAPH))
2496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def initStatusBar(self):
2516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Initializes the status bar """
2526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.statusbar = self.CreateStatusBar()
2536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSelectAll(self, event):
2556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Called from select all button """
2566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        num = self.segList.GetItemCount()
2576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for i in range(num-1, -1, -1):
2586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.CheckItem(i)
2596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnDeselectAll(self, event):
2616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Called from deselect all button """
2626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        num = self.segList.GetItemCount()
2636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for i in range(num-1, -1, -1):
2646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.CheckItem(i, False)
2656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def LoadSegList(self):
2676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Loads up the list of segments """
2686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        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))
2696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        segments = self.jet_file.GetSegments()
2706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.seglistSort[0] == 0:
2716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "segname")
2726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 1:
2736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "filename")
2746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 2:
2756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "dlsfile")
2766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 3:
2776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "start")
2786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 4:
2796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "end")
2806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 5:
2816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "quantize")
2826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 6:
2836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "transpose")
2846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 7:
2856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "repeat")
2866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 8:
2876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegSort(segments, "mute_flags")
2886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        listDataMap = []
2896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentSegmentIndex = None
2906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentSegmentName = None
2916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.DeleteAllItems()
2926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventList.DeleteAllItems()
2936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_UPDATE_SEG].Enable(False)
2946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_DELETE_SEG].Enable(False)
2956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_MOVE_SEG].Enable(False)
2966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
2976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_ADD_EVENT].Enable(False)
2986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_MOVE_EVENT].Enable(False)
2996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_UPDATE_EVENT].Enable(False)
3006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_DELETE_EVENT].Enable(False)
3016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_MOVE_EVENT].Enable(False)
3026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for segment in self.jet_file.GetSegments():
3036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            index = self.segList.InsertStringItem(sys.maxint, StrNoneChk(segment.segname))
3046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetStringItem(index, 1, FileJustName(StrNoneChk(segment.filename)))
3056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetStringItem(index, 2, FileJustName(StrNoneChk(segment.dlsfile)))
3066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetStringItem(index, 3, mbtFct(segment.start, 1))
3076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetStringItem(index, 4, mbtFct(segment.end, 1))
3086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetStringItem(index, 5, StrNoneChk(segment.quantize))
3096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetStringItem(index, 6, StrNoneChk(segment.transpose))
3106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetStringItem(index, 7, StrNoneChk(segment.repeat))
3116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetStringItem(index, 8, StrNoneChk(segment.mute_flags))
3126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.segList.SetItemData(index, index)
3146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            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))))
3156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.itemDataMap = listDataMap
3176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.InitSorting(9)
3186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.graph.ClearGraph()
3196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def LoadEventsForSeg(self, segName):
3216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Loads up the events associated with a segment """
3226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentEventIndex = None
3236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventList.DeleteAllItems()
3246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_UPDATE_EVENT].Enable(False)
3256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_DELETE_EVENT].Enable(False)
3266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_MOVE_EVENT].Enable(False)
3276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        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))
3286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        segment = self.jet_file.GetSegment(self.currentSegmentName)
3296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if segment is not None:
3306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.eventlistSort[0] == 0:
3316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.EventSort(segment.jetevents, "event_name")
3326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif self.eventlistSort[0] == 1:
3336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.EventSort(segment.jetevents, "event_type")
3346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif self.eventlistSort[0] == 2:
3356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.EventSort(segment.jetevents, "event_start")
3366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif self.eventlistSort[0] == 3:
3376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.EventSort(segment.jetevents, "event_end")
3386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif self.eventlistSort[0] == 4:
3396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.EventSort(segment.jetevents, "track_num")
3406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif self.eventlistSort[0] == 5:
3416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.EventSort(segment.jetevents, "channel_num")
3426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif self.eventlistSort[0] == 6:
3436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.EventSort(segment.jetevents, "event_id")
3446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            listDataMap = []
3456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            for jet_event in self.jet_file.GetEvents(segName):
3466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                index = self.eventList.InsertStringItem(sys.maxint, StrNoneChk(jet_event.event_name))
3476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.eventList.SetStringItem(index, 1, StrNoneChk(jet_event.event_type))
3486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.eventList.SetStringItem(index, 2, mbtFct(jet_event.event_start, 1))
3496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.eventList.SetStringItem(index, 3, mbtFct(jet_event.event_end, 1))
3506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.eventList.SetStringItem(index, 4, StrNoneChk(jet_event.track_num))
3516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.eventList.SetStringItem(index, 5, StrNoneChk(jet_event.channel_num + 1))
3526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.eventList.SetStringItem(index, 6, StrNoneChk(jet_event.event_id))
3536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.eventList.SetItemData(index, index)
3556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                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))))
3566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.eventList.itemDataMap = listDataMap
3586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.eventList.InitSorting(7)
3596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnEventListClick(self, event):
3616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Sets the current event variable when selecting from the list """
3626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentCtrl = "eventList"
3636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentEventIndex = event.m_itemIndex
3646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentEventName = getColumnText(self.eventList, event.m_itemIndex, 0)
3656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_UPDATE_EVENT].Enable(True)
3666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_DELETE_EVENT].Enable(True)
3676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_MOVE_EVENT].Enable(True)
3686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSegmentChecked(self, index, checked):
3706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Selects the segment when checkbox clicked """
3716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        ClearRowSelections(self.segList)
3726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        SetRowSelection(self.segList, index, True)
3736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def SelectSegment(self, segName):
3756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Selects a segment by segment name """
3766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        itm = self.segList.FindItem(-1, segName)
3776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.segList.EnsureVisible(itm)
3786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        ClearRowSelections(self.segList)
3796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        SetRowSelection(self.segList, itm, True)
3806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def SelectEvent(self, eventName):
3826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Selects an event by event name """
3836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        itm = self.eventList.FindItem(-1, eventName)
3846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.eventList.EnsureVisible(itm)
3856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        ClearRowSelections(self.eventList)
3866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        SetRowSelection(self.eventList, itm, True)
3876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
3886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSegListClick(self, event):
3896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Loads up a segment when the list is clicked """
3906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentCtrl = "segList"
3916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentSegmentIndex = event.m_itemIndex
3926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentSegmentName = getColumnText(self.segList, event.m_itemIndex, 0)
3936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.LoadEventsForSeg(getColumnText(self.segList, event.m_itemIndex, 0))
3946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_UPDATE_SEG].Enable(True)
3956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_DELETE_SEG].Enable(True)
3966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_MOVE_SEG].Enable(True)
3976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_ADD_EVENT].Enable(True)
3986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        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'))
3996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if info == None:
4006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.log.SetValue("")
4016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
4026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            iLength = info.iLengthInMs
4036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if iLength > 0:
4046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.log.SetValue("%s      %.2f Seconds" % (self.currentSegmentName, iLength / 1000.00))
4056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
4066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.log.SetValue("%s" % (self.currentSegmentName))
4076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSegmentAdd(self, event):
4096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calls the dialog box for adding a segment """
4106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
4116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = SegEdit(JetDefs.MAIN_ADDSEGTITLE, self.currentJetConfigFile)
4136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for filename in self.jet_file.GetMidiFiles():
4156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dlg.je.ctrls[JetDefs.F_MIDIFILE].Append(filename)
4166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for library in self.jet_file.GetLibraries():
4176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dlg.je.ctrls[JetDefs.F_DLSFILE].Append(library)
4186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
4206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == wx.ID_OK:
4216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(dlg.lstReplicate) > 0:
4226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if dlg.chkReplaceMatching:
4236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.DeleteSegmentsMatchingPrefix(dlg.replicatePrefix)
4246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for replicate in dlg.lstReplicate:
4266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.AddSegment(replicate[0], dlg.GetValue(JetDefs.F_MIDIFILE),
4276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             mbtFct(replicate[1],-1), mbtFct(replicate[2],-1),
4286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             JetDefs.MBT_ZEROSTR,
4296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             SegmentOutputFile(dlg.GetValue(JetDefs.F_SEGNAME), self.currentJetConfigFile),
4306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             dlg.GetValue(JetDefs.F_QUANTIZE),
4316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             [], dlg.GetValue(JetDefs.F_DLSFILE),
4326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             None,
4336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             dlg.GetValue(JetDefs.F_TRANSPOSE),
4346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             dlg.GetValue(JetDefs.F_REPEAT),
4356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             dlg.GetValue(JetDefs.F_MUTEFLAGS))
4366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.LoadSegList()
4386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(dlg.lstReplicate[0][0])
4396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
4406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.jet_file.AddSegment(dlg.GetValue(JetDefs.F_SEGNAME), dlg.GetValue(JetDefs.F_MIDIFILE),
4416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_START), dlg.GetValue(JetDefs.F_END),
4426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     JetDefs.MBT_ZEROSTR,
4436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     SegmentOutputFile(dlg.GetValue(JetDefs.F_SEGNAME), self.currentJetConfigFile),
4446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_QUANTIZE),
4456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     [], dlg.GetValue(JetDefs.F_DLSFILE),
4466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     None,
4476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_TRANSPOSE),
4486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_REPEAT),
4496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_MUTEFLAGS))
4506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.LoadSegList()
4516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(dlg.GetValue(JetDefs.F_SEGNAME))
4526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.UndoAdd(saveState)
4536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
4546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSegmentUpdate(self, event):
4566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calls the dialog box for updating a segment """
4576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentSegmentName is None:
4586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
4596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        segment = self.jet_file.GetSegment(self.currentSegmentName)
4616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if segment == None:
4626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
4636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
4656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = SegEdit(JetDefs.MAIN_REVSEGTITLE, self.currentJetConfigFile)
4676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for filename in self.jet_file.GetMidiFiles():
4696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dlg.je.ctrls[JetDefs.F_MIDIFILE].Append(filename)
4706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for library in self.jet_file.GetLibraries():
4716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dlg.je.ctrls[JetDefs.F_DLSFILE].Append(library)
4726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_SEGNAME, segment.segname)
4746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_MUTEFLAGS, segment.mute_flags)
4756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_MIDIFILE, segment.filename)
4766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_DLSFILE, segment.dlsfile)
4776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_START, segment.start)
4786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_END, segment.end)
4796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_QUANTIZE, segment.quantize)
4806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_TRANSPOSE, segment.transpose)
4816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_REPEAT, segment.repeat)
4826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.jetevents = segment.jetevents
4836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
4856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == wx.ID_OK:
4866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.UpdateSegment(self.currentSegmentName, dlg.GetValue(JetDefs.F_SEGNAME),
4876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_MIDIFILE),
4886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_START), dlg.GetValue(JetDefs.F_END),
4896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     JetDefs.MBT_ZEROSTR, #dlg.GetValue(JetDefs.F_LENGTH),
4906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     SegmentOutputFile(dlg.GetValue(JetDefs.F_SEGNAME), self.currentJetConfigFile),
4916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_QUANTIZE),
4926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     [], dlg.GetValue(JetDefs.F_DLSFILE),
4936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     None,
4946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_TRANSPOSE),
4956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_REPEAT),
4966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_MUTEFLAGS))
4976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
4986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(dlg.lstReplicate) > 0:
4996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if dlg.chkReplaceMatching:
5006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.DeleteSegmentsMatchingPrefix(dlg.replicatePrefix)
5016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for replicate in dlg.lstReplicate:
5036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.AddSegment(replicate[0], dlg.GetValue(JetDefs.F_MIDIFILE),
5046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             mbtFct(replicate[1],-1), mbtFct(replicate[2],-1),
5056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             JetDefs.MBT_ZEROSTR,
5066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             SegmentOutputFile(dlg.GetValue(JetDefs.F_SEGNAME), self.currentJetConfigFile),
5076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             dlg.GetValue(JetDefs.F_QUANTIZE),
5086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             [], dlg.GetValue(JetDefs.F_DLSFILE),
5096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             None,
5106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             dlg.GetValue(JetDefs.F_TRANSPOSE),
5116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             dlg.GetValue(JetDefs.F_REPEAT),
5126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                             dlg.GetValue(JetDefs.F_MUTEFLAGS))
5136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.LoadSegList()
5156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(dlg.lstReplicate[0][0])
5166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
5176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.LoadSegList()
5186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(dlg.GetValue(JetDefs.F_SEGNAME))
5196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.UndoAdd(saveState)
5206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
5216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSegmentDelete(self, event):
5236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Confirms the deletion segment(s) by user action """
5246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentSegmentName is None:
5256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
5266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        segment = self.jet_file.GetSegment(self.currentSegmentName)
5286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if segment == None:
5296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
5306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        count = 0
5326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        deleteMsg = ''
5336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        item = self.segList.GetFirstSelected()
5346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        while item != -1:
5356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if count == 0:
5366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                deleteMsg = getColumnText(self.segList,item,0)
5376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
5386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if count == 40:
5396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    deleteMsg = deleteMsg + "\n" + "....more"
5406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                elif count < 40:
5416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    deleteMsg = deleteMsg + "\n" + getColumnText(self.segList,item,0)
5426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            count = count + 1
5436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            item = self.segList.GetNextSelected(item)
5446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if YesNo(JetDefs.MAIN_CONFIRM, deleteMsg + JetDefs.MAIN_CONFIRM_SEG_DLT, False):
5466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            item = self.segList.GetFirstSelected()
5476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            while item != -1:
5486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                segName = getColumnText(self.segList,item,0)
5496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SegmentDelete(segName)
5506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                item = self.segList.GetNextSelected(item)
5516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.graph.ClearGraph()
5536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadSegList()
5546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def SegmentDelete(self, segName):
5566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Deletes a segment """
5576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
5586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet_file.DeleteSegment(segName)
5596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.UndoAdd(saveState)
5606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSegmentsMove(self, event):
5626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Move segment(s) """
5636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentSegmentName is None:
5646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
5656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        lstMoveItems = []
5676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        count = 0
5686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        item = self.segList.GetFirstSelected()
5696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        while item != -1:
5706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            max = GetMidiInfo(self.jet_file.GetSegment(getColumnText(self.segList,item,0)).filename).endMbtStr
5716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            lstMoveItems.append((getColumnText(self.segList,item,0), mbtFct(getColumnText(self.segList,item,3),-1), mbtFct(getColumnText(self.segList,item,4),-1), max))
5726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            count = count + 1
5736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            item = self.segList.GetNextSelected(item)
5746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if count == 0:
5766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            InfoMsg("Move", "Select one or more items to move.")
5776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
5786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = JetMove("Move Segments")
5806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.lstMoveItems = lstMoveItems
5816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
5826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == wx.ID_OK:
5836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(dlg.lstMoveMbt) > 0:
5846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
5856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for moveitem in dlg.lstMoveMbt:
5876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.MoveSegment(moveitem[0], moveitem[1], moveitem[2])
5886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.LoadSegList()
5906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.UndoAdd(saveState)
5916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
5936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def UndoAdd(self, saveState):
5956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Adds the current state to the undo stack """
5966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.UndoStack.append(saveState)
5976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_UNDO].Enable(True)
5986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
5996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def RedoAdd(self, saveState):
6006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Adds the current state the the redo stack """
6016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.RedoStack.append(saveState)
6026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems[JetDefs.MNU_REDO].Enable(True)
6036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnRedo(self, event):
6056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Redo if there's one in the stack """
6066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if len(self.RedoStack) > 0:
6076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.UndoAdd(JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex))
6086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            state = self.RedoStack.pop()
6096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file = copy.deepcopy(state.jet_file)
6106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadSegList()
6116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.currentSegmentIndex = state.currentSegmentIndex
6126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.currentSegmentIndex != None:
6136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                SetRowSelection(self.segList, self.currentSegmentIndex, True)
6146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(self.RedoStack) == 0:
6156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.menuItems[JetDefs.MNU_REDO].Enable(False)
6166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnUndo(self, event):
6186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Undo if there's one in the stack """
6196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if len(self.UndoStack) > 0:
6206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.RedoAdd(JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex))
6216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            state = self.UndoStack.pop()
6226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file = copy.deepcopy(state.jet_file)
6236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadSegList()
6246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.currentSegmentIndex = state.currentSegmentIndex
6256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.currentSegmentIndex != None:
6266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                SetRowSelection(self.segList, self.currentSegmentIndex, True)
6276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(self.UndoStack) == 0:
6286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.menuItems[JetDefs.MNU_UNDO].Enable(False)
6296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnEventAdd(self, event):
6316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calls a dialog box to add an event to the current segment """
6326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentSegmentName is None:
6336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
6346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        segment = self.jet_file.GetSegment(self.currentSegmentName)
6366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if segment == None:
6376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
6386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
6406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = EventEdit(JetDefs.MAIN_ADDEVENTTITLE, self.currentJetConfigFile)
6426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        editSegment = copy.deepcopy(segment)
6436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetSegment(editSegment)
6446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetEventId()
6456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
6476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == wx.ID_OK:
6486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if dlg.GetValue(JetDefs.F_ETYPE) == JetDefs.E_EOS:
6496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                #check for an existing EOS event
6506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                events = self.jet_file.GetEvents(self.currentSegmentName)
6516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for evt in events:
6526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    if evt.event_type == JetDefs.E_EOS:
6536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        self.jet_file.DeleteEvent(self.currentSegmentName, evt.event_name)
6546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dlg.SetValue(JetDefs.F_ESTART, dlg.GetValue(JetDefs.F_EEND))
6556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(dlg.lstReplicate) > 0:
6576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if dlg.chkReplaceMatching:
6586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.DeleteEventsMatchingPrefix(self.currentSegmentName, dlg.replicatePrefix)
6596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for replicate in dlg.lstReplicate:
6616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.AddEvent(self.currentSegmentName, replicate[0],
6626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         dlg.GetValue(JetDefs.F_ETYPE),
6636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         dlg.GetValue(JetDefs.F_EEVENTID),
6646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         dlg.GetValue(JetDefs.F_ETRACK),
6656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         dlg.GetValue(JetDefs.F_ECHANNEL),
6666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         mbtFct(replicate[1],-1),
6676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         mbtFct(replicate[2],-1))
6686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(self.currentSegmentName)
6696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectEvent(dlg.lstReplicate[0][0])
6706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
6716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.jet_file.AddEvent(self.currentSegmentName, dlg.GetValue(JetDefs.F_ENAME),
6726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ETYPE),
6736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_EEVENTID),
6746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ETRACK),
6756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ECHANNEL),
6766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ESTART),
6776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_EEND))
6786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(self.currentSegmentName)
6806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectEvent(dlg.GetValue(JetDefs.F_ENAME))
6816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.UndoAdd(saveState)
6836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
6846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnEventUpdate(self, event):
6866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calls the dialog box to update the current event """
6876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentSegmentName is None:
6886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
6896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentEventName  is None:
6916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
6926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        segment = self.jet_file.GetSegment(self.currentSegmentName)
6946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if segment == None:
6956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
6966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
6976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        curEvent = copy.deepcopy(self.jet_file.GetEvent(self.currentSegmentName, self.currentEventName))
6986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if curEvent == None:
6996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
7006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
7026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        #only want the event we are editing to show up in graph
7046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        editSegment = copy.deepcopy(segment)
7056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        editSegment.jetevents = []
7066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        editSegment.jetevents.append(curEvent)
7076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = EventEdit(JetDefs.MAIN_REVEVENTTITLE, self.currentJetConfigFile)
7096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetSegment(editSegment)
7106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_ENAME, curEvent.event_name)
7116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_ETYPE, curEvent.event_type)
7126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_ESTART, curEvent.event_start)
7136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_EEND, curEvent.event_end)
7146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_ETRACK, curEvent.track_num)
7156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_ECHANNEL, curEvent.channel_num)
7166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_EEVENTID, curEvent.event_id)
7176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.OnEventSelect()
7186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
7206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == wx.ID_OK:
7216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if dlg.GetValue(JetDefs.F_ETYPE) == JetDefs.E_EOS:
7226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                dlg.SetValue(JetDefs.F_ESTART, dlg.GetValue(JetDefs.F_EEND))
7236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.UpdateEvent(self.currentSegmentName,
7256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                      self.currentEventName,
7266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ENAME),
7276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ETYPE),
7286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_EEVENTID),
7296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ETRACK),
7306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ECHANNEL),
7316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_ESTART),
7326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     dlg.GetValue(JetDefs.F_EEND))
7336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(dlg.lstReplicate) > 0:
7356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if dlg.chkReplaceMatching:
7366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.DeleteEventsMatchingPrefix(self.currentSegmentName, dlg.replicatePrefix)
7376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for replicate in dlg.lstReplicate:
7396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.AddEvent(self.currentSegmentName, replicate[0],
7406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         dlg.GetValue(JetDefs.F_ETYPE),
7416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         dlg.GetValue(JetDefs.F_EEVENTID),
7426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         dlg.GetValue(JetDefs.F_ETRACK),
7436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         dlg.GetValue(JetDefs.F_ECHANNEL),
7446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         mbtFct(replicate[1],-1),
7456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                         mbtFct(replicate[2],-1))
7466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(self.currentSegmentName)
7476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectEvent(dlg.lstReplicate[0][0])
7486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
7496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(self.currentSegmentName)
7506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectEvent(dlg.GetValue(JetDefs.F_ENAME))
7516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.UndoAdd(saveState)
7526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
7536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnEventDelete(self, event):
7556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Confirms the deletion of event(s) """
7566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentSegmentName is None:
7576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
7586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentEventName  is None:
7606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
7616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        curEvent = self.jet_file.GetEvent(self.currentSegmentName, self.currentEventName)
7636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if curEvent == None:
7646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
7656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        count = 0
7676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        deleteMsg = ''
7686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        item = self.eventList.GetFirstSelected()
7696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        while item != -1:
7706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if count == 0:
7716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                deleteMsg = getColumnText(self.eventList,item,0)
7726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
7736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if count == 40:
7746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    deleteMsg = deleteMsg + "\n" + "....more"
7756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                elif count < 40:
7766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    deleteMsg = deleteMsg + "\n" + getColumnText(self.eventList,item,0)
7776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            count = count + 1
7786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            item = self.eventList.GetNextSelected(item)
7796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if YesNo(JetDefs.MAIN_CONFIRM, deleteMsg + JetDefs.MAIN_CONRIRM_EVT_DLT, False):
7826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            item = self.eventList.GetFirstSelected()
7836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            while item != -1:
7846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                eventName = getColumnText(self.eventList,item,0)
7856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.EventDelete(eventName)
7866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                item = self.eventList.GetNextSelected(item)
7876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SelectSegment(self.currentSegmentName)
7896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadEventsForSeg(self.currentSegmentName)
7906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def EventDelete(self, eventName):
7926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Deletes an event """
7936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
7946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet_file.DeleteEvent(self.currentSegmentName, eventName)
7956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.UndoAdd(saveState)
7966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
7976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnEventsMove(self, event):
7986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Move event(s) """
7996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentSegmentName is None:
8006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
8016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentEventName  is None:
8036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
8046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        segment = self.jet_file.GetSegment(self.currentSegmentName)
8066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if segment == None:
8076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
8086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        curEvent = self.jet_file.GetEvent(self.currentSegmentName, self.currentEventName)
8106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if curEvent == None:
8116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
8126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        lstMoveItems = []
8146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        count = 0
8156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        item = self.eventList.GetFirstSelected()
8166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        while item != -1:
8176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            lstMoveItems.append((getColumnText(self.eventList,item,0), mbtFct(getColumnText(self.eventList,item,2),-1), mbtFct(getColumnText(self.eventList,item,3),-1), segment.end))
8186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            count = count + 1
8196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            item = self.eventList.GetNextSelected(item)
8206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if count == 0:
8226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            InfoMsg("Move", "Select one or more items to move.")
8236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
8246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = JetMove("Move Events")
8266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.lstMoveItems = lstMoveItems
8276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
8286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == wx.ID_OK:
8296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(dlg.lstMoveMbt) > 0:
8306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
8316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for moveitem in dlg.lstMoveMbt:
8336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    self.jet_file.MoveEvent(self.currentSegmentName, moveitem[0], moveitem[1], moveitem[2])
8346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SelectSegment(self.currentSegmentName)
8366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.LoadEventsForSeg(self.currentSegmentName)
8376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.UndoAdd(saveState)
8396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
8416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnJetOpen(self, event):
8436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calls a dialog box to get a jet config file to open """
8446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = JetOpen()
8456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
8466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == JetDefs.ID_JET_OPEN:
8476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file = JetFile(dlg.fileName , "")
8486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if not ValidateConfig(self.jet_file):
8496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                FileKillClean(JetDefs.UNTITLED_FILE)
8506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.currentJetConfigFile = JetDefs.UNTITLED_FILE
8516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.jet_file = JetFile(self.currentJetConfigFile, "")
8526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
8536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.SetCurrentFile(dlg.fileName)
8546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif result == JetDefs.ID_JET_NEW:
8556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file = JetFile("" , "")
8566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SetCurrentFile(JetDefs.UNTITLED_FILE)
8576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadDefaultProperties()
8586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif result == JetDefs.ID_JET_IMPORT:
8596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.OnJetImportArchive(event)
8606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
8616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnJetSaveAs(self, event):
8636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calls a dialog box to allow saving the current jet file as another name """
8646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        defDir = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_DEFAULTDIRS, JetDefs.JTC_FILE_SPEC, 'str', str(os.getcwd()))
8656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dialog = wx.FileDialog(None, JetDefs.SAVE_PROMPT, defDir, "", JetDefs.JTC_FILE_SPEC, wx.SAVE | wx.OVERWRITE_PROMPT )
8666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if dialog.ShowModal() == wx.ID_OK:
8676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            IniSetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_DEFAULTDIRS, JetDefs.JTC_FILE_SPEC, str(FileJustPath(dialog.GetPath())))
8686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.currentJetConfigFile = FileJustRoot(dialog.GetPath()) + ".jtc"
8696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.config.filename = FileJustRoot(self.currentJetConfigFile)  + ".jet"
8706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.SaveJetConfig(self.currentJetConfigFile)
8716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.WriteJetFileFromConfig(self.currentJetConfigFile)
8726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SetCurrentFile(self.currentJetConfigFile)
8736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dialog.Destroy()
8746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnJetSave(self, event):
8766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Saves the current jet file to disk """
8776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentJetConfigFile == JetDefs.UNTITLED_FILE:
8786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.OnJetSaveAs(event)
8796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
8806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.SaveJetConfig(self.currentJetConfigFile)
8816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.WriteJetFileFromConfig(self.currentJetConfigFile)
8826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnJetNew(self, event):
8846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Initializes the state to a new jet file """
8856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet_file = JetFile("" , "")
8866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetCurrentFile(JetDefs.UNTITLED_FILE)
8876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.LoadDefaultProperties()
8886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
8896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def SetCurrentFile(self, fileName):
8906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Sets the state for the current jet file """
8916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.clipBoard = None
8926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.currentJetConfigFile = fileName
8936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetTitle(JetDefs.MAIN_TITLEPREFIX + FileJustName(fileName))
8946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        AppendRecentJetFile(fileName)
8956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.LoadSegList()
8966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.graph.ClearGraph()
8976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.chkGraphLabels.SetValue(IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, 'bool', 'True'))
8986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.chkGraphClips.SetValue(IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, 'bool', 'True'))
8996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.chkGraphAppEvts.SetValue(IniGetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, 'bool', 'True'))
9006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def createMenuBar(self):
9026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Creates a menu bar """
9036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.menuItems = {}
9046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        menuBar = wx.MenuBar()
9056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for eachMenuData in JetDefs.MENU_SPEC:
9066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            menuLabel = eachMenuData[0]
9076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            menuItems = eachMenuData[1:]
9086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            menuBar.Append(self.createMenu(menuItems), menuLabel)
9096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetMenuBar(menuBar)
9106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def createMenu(self, menuData):
9126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Creates a menu from the structure menuData in JetDefs """
9136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        menu = wx.Menu()
9146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for eachLabel, eachStatus, eachHandler, eachEnable in menuData:
9156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if not eachLabel:
9166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                menu.AppendSeparator()
9176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                continue
9186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.menuItems[eachLabel] = menu.Append(-1, eachLabel, eachStatus)
9196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.menuItems[eachLabel].Enable(eachEnable)
9206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            try:
9216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.Bind(wx.EVT_MENU, getattr(self, eachHandler) , self.menuItems[eachLabel])
9226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            except:
9236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                print("def " + eachHandler + "(self, event): pass")
9246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        return menu
9256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def createToolbar(self):
9276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Creates the toolbar """
9286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        toolbar = self.CreateToolBar()
9296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        toolbar.SetToolBitmapSize((32,32))
9306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.toolItems = {}
9316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        for eachTool in JetDefs.TOOLBAR_SPEC:
9326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if eachTool[0] == '-':
9336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                toolbar.AddSeparator()
9346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
9356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                b = __import__(eachTool[1])
9366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                bitMap = b.getBitmap()
9376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.toolItems[eachTool[0]] = toolbar.AddLabelTool(-1, label=eachTool[0],
9386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        bitmap=bitMap,
9396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                     shortHelp=eachTool[0], longHelp=eachTool[2])
9406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.Bind(wx.EVT_TOOL, getattr(self, eachTool[3]) , self.toolItems[eachTool[0]])
9416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        toolbar.Realize()
9426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnAudition(self, event):
9446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Calls the audition window for simple preview of jet file """
9456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        jet_file = CreateTempJetFile(self.jet_file)
9466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        w, h = self.GetSize()
9486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        w = w - 50
9496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if w < 900:
9506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            w = 900
9516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        h = h - 50
9526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if h < 650:
9536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            h = 650
9546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = Audition(jet_file, (w,h))
9556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.ShowModal()
9566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        CleanupTempJetFile(jet_file)
9576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def SetKeepPlayingFlag(self, val):
9596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Sets a flag to communicate playing state to the play thread """
9606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        with self.playerLock:
9616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.keepPlaying = val
9626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def GetKeepPlayingFlag(self):
9646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Gets the playing state flag """
9656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        with self.playerLock:
9666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return self.keepPlaying
9676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def GraphTriggerClip(self, sClipName, iEventId):
9696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Triggers a clip when they click on the graph """
9706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        with self.playerLock:
9716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            try:
9726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.jet.TriggerClip(iEventId)
9736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.log.SetValue(JetDefs.PLAY_TRIGGERCLIP_MSG % (iEventId, sClipName))
9746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return True
9756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            except:
9766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return False
9776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnHelpJet(self, event):
9796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Loads the jet help file """
9806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        import webbrowser
9816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        webbrowser.open(JetDefs.MAIN_HELPFILE)
9826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        return
9836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnHelpJetGuidelines(self, event):
9856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Loads the authoring guidelines file """
9866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        import webbrowser
9876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        webbrowser.open(JetDefs.MAIN_HELPGUIDELINESFILE)
9886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        return
9896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnAbout(self, event):
9916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Loads the about dialog box """
9926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = JetAbout()
9936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
9946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
9956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
9966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnJetImportArchive(self, event):
9976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Imports a jet archive file """
9986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        defDir = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_DEFAULTDIRS, JetDefs.ARCHIVE_FILE_SPEC, 'str', str(os.getcwd()))
9996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dialog = wx.FileDialog(None, JetDefs.IMPORT_ARCHIVE_PROMPT, defDir, "", JetDefs.ARCHIVE_FILE_SPEC, wx.OPEN)
10006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if dialog.ShowModal() == wx.ID_OK:
10016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            IniSetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_DEFAULTDIRS, JetDefs.ARCHIVE_FILE_SPEC, str(FileJustPath(dialog.GetPath())))
10026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            defDir = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_DEFAULTDIRS, JetDefs.ARCHIVE_FILE_SPEC + "Dir", 'str', str(os.getcwd()))
10036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dlg1 = wx.DirDialog(self, JetDefs.IMPORT_ARCHIVEDIR_PROMPT, style=wx.DD_DEFAULT_STYLE, defaultPath=defDir)
10046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if dlg1.ShowModal() == wx.ID_OK:
10056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                IniSetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_DEFAULTDIRS, JetDefs.ARCHIVE_FILE_SPEC + "Dir", str(FileJustPath(dlg1.GetPath())))
10066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if YesNo(JetDefs.MAIN_IMPORTTITLE, JetDefs.MAIN_IMPORTMSG % (dialog.GetPath(),dlg1.GetPath()), False):
10076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    projectPath = dlg1.GetPath()
10086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    zipFile = dialog.GetPath()
10096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    z = __import__('zipfile')
10106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    if not z.is_zipfile(zipFile):
10126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        wx.MessageBox(JetDefs.IMPORT_ARCHIVE_NO_JTC)
10136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    else:
10146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        zip = z.ZipFile(zipFile, 'r')
10156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        jtcFile = ""
10176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        fileList = zip.namelist()
10186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        isArchive = False
10206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        for myFile in fileList:
10216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            if myFile == 'JetArchive':
10226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                isArchive = True
10236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                break
10246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        if not isArchive:
10256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            wx.MessageBox(JetDefs.IMPORT_NOT_JET_ARCHIVE)
10266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        else:
10276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            for myFile in fileList:
10286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                if FileJustExt(myFile) == '.JTC':
10296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                    jtcFile = myFile
10306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                    break
10316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            if jtcFile == "":
10326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                wx.MessageBox(JetDefs.IMPORT_ARCHIVE_NO_JTC)
10336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            else:
10346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                for name in zip.namelist():
10356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                    ext = FileJustExt(name)
10366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                    if ext == '.MID' or ext == '.DLS'  or ext == '.JET':
10376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                        file(FileFixPath(projectPath + "/" + name), 'wb').write(zip.read(name))
10386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                    else:
10396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                        if len(ext) > 0 and ext != '.DS_STORE':
10406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                            file(FileFixPath(projectPath + "/" + name), 'w').write(zip.read(name))
10416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            zip.close()
10426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            self.currentJetConfigFile = FileFixPath(projectPath + "/") + jtcFile
10436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            self.jet_file = JetFile(self.currentJetConfigFile, "")
10446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            #fix paths
10466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            self.jet_file.config.filename = FileJustRoot(self.currentJetConfigFile) + ".JET"
10476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            for index, segment in enumerate(self.jet_file.segments):
10486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                self.jet_file.segments[index].filename = FileFixPath(projectPath + "/" + segment.filename)
10496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                if segment.dlsfile > "":
10506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                    self.jet_file.segments[index].dlsfile = FileFixPath(projectPath + "/" + segment.dlsfile)
10516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                self.jet_file.segments[index].output = FileFixPath(projectPath + "/" + segment.output)
10526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            for index, library in enumerate(self.jet_file.libraries):
10546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                self.jet_file.libraries[index] = FileFixPath(projectPath + "/" + library)
10556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            if ValidateConfig(self.jet_file):
10576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                self.jet_file.SaveJetConfig(self.currentJetConfigFile)
10586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                self.jet_file.WriteJetFileFromConfig(self.currentJetConfigFile)
10596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                self.jet_file = JetFile(self.currentJetConfigFile , "")
10606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                                self.SetCurrentFile(self.currentJetConfigFile)
10616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            dlg1.Destroy()
10636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dialog.Destroy()
10646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnJetExportArchive(self, event):
10666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Exports the current setup to an archive file """
10676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.OnJetSave(event)
10686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        defDir = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_DEFAULTDIRS, JetDefs.ARCHIVE_FILE_SPEC, 'str', str(os.getcwd()))
10696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dialog = wx.FileDialog(None, JetDefs.EXPORT_ARCHIVE_PROMPT, defDir, "", JetDefs.ARCHIVE_FILE_SPEC, wx.SAVE | wx.OVERWRITE_PROMPT )
10706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if dialog.ShowModal() == wx.ID_OK:
10716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            IniSetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_DEFAULTDIRS, JetDefs.ARCHIVE_FILE_SPEC, str(FileJustPath(dialog.GetPath())))
10726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            ExportJetArchive(FileJustRoot(dialog.GetPath()) + ".zip", self.currentJetConfigFile, self.jet_file)
10736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dialog.Destroy()
10746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnCopy(self, event):
10766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Copies the current segment or event to the clipboard """
10776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.currentCtrl == JetDefs.MAIN_SEGLIST:
10786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.currentSegmentName is None:
10796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return ""
10806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            segment = self.jet_file.GetSegment(self.currentSegmentName)
10826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if segment == None:
10836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return ""
10846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.clipBoard = JetCutCopy(self.currentCtrl, segment, self.currentSegmentName)
10856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return self.currentCtrl
10866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.currentCtrl == JetDefs.MAIN_EVENTLIST:
10876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.currentSegmentName is None:
10886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return ""
10896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.currentEventName  is None:
10916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return ""
10926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            segment = self.jet_file.GetSegment(self.currentSegmentName)
10946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if segment == None:
10956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return ""
10966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
10976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            curEvent = self.jet_file.GetEvent(self.currentSegmentName, self.currentEventName)
10986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if curEvent == None:
10996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return ""
11006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.clipBoard = JetCutCopy(self.currentCtrl, curEvent, self.currentSegmentName)
11016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return self.currentCtrl
11026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnCut(self, event):
11046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Cuts the current segment or event to the clipboard """
11056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        retCopy = self.OnCopy(event)
11066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if retCopy == JetDefs.MAIN_SEGLIST:
11076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SegmentDelete(self.currentSegmentName)
11086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadSegList()
11096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif retCopy == JetDefs.MAIN_EVENTLIST:
11106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.EventDelete(self.currentEventName)
11116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadEventsForSeg(self.currentSegmentName)
11126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnPaste(self, event):
11146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Pastes the current segment or event from the clipboard """
11156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.clipBoard is not None:
11166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.currentCtrl == JetDefs.MAIN_SEGLIST and self.clipBoard.objType == JetDefs.MAIN_SEGLIST:
11176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
11186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.jet_file.segments.append(self.clipBoard.GetObj(self.jet_file.segments))
11196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.UndoAdd(saveState)
11206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.LoadSegList()
11216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            elif self.currentCtrl == JetDefs.MAIN_EVENTLIST and self.clipBoard.objType == JetDefs.MAIN_EVENTLIST and self.clipBoard.currentSegmentName == self.currentSegmentName:
11226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                for segment in self.jet_file.segments:
11236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    if segment.segname == self.currentSegmentName:
11246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        saveState = JetState(self.jet_file, self.currentSegmentIndex, self.currentEventIndex)
11256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        segment.jetevents.append(self.clipBoard.GetObj(segment.jetevents))
11266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        self.UndoAdd(saveState)
11276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        self.LoadEventsForSeg(self.currentSegmentName)
11286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        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'))
11296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnJetProperties(self, event):
11316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Opens a dialog box for jetfile properties """
11326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = JetPropertiesDialog()
11336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_JETFILENAME, self.jet_file.config.filename)
11346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_COPYRIGHT, StrNoneChk(self.jet_file.config.copyright))
11356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_CHASECONTROLLERS, StrNoneChk(self.jet_file.config.chase_controllers))
11366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_DELETEEMPTYTRACKS, StrNoneChk(self.jet_file.config.delete_empty_tracks))
11376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
11396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == wx.ID_OK:
11406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.config.filename = dlg.je.ctrls[JetDefs.F_JETFILENAME].GetValue()
11416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.config.copyright = dlg.je.ctrls[JetDefs.F_COPYRIGHT].GetValue()
11426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.config.chase_controllers = dlg.je.ctrls[JetDefs.F_CHASECONTROLLERS].GetValue()
11436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet_file.config.delete_empty_tracks = dlg.je.ctrls[JetDefs.F_DELETEEMPTYTRACKS].GetValue()
11446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
11456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnPreferences(self, event):
11476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Opens a dialog box to capture preferences and saves them to a configuration file """
11486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg = JetPreferences()
11496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_COPYRIGHT, IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_COPYRIGHT))
11506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_CHASECONTROLLERS, IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_CHASECONTROLLERS, 'bool', True))
11516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.SetValue(JetDefs.F_DELETEEMPTYTRACKS, IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_DELETEEMPTYTRACKS, 'bool', False))
11526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        result = dlg.ShowModal()
11536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if result == wx.ID_OK:
11546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            IniSetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_COPYRIGHT, dlg.GetValue(JetDefs.F_COPYRIGHT))
11556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            IniSetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_CHASECONTROLLERS, dlg.GetValue(JetDefs.F_CHASECONTROLLERS))
11566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            IniSetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_DELETEEMPTYTRACKS, dlg.GetValue(JetDefs.F_DELETEEMPTYTRACKS))
11576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
11586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def LoadDefaultProperties(self):
11606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Loads default properties from the a configuration file """
11616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet_file.config.copyright = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_COPYRIGHT)
11626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet_file.config.chase_controllers = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_CHASECONTROLLERS, 'bool', True)
11636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet_file.config.delete_empty_tracks = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_PREF_SECTION, JetDefs.F_DELETEEMPTYTRACKS, 'bool', False)
11646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnClose(self, event):
11666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Called upon closing the JetCreator main window """
11676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.isDirty():
11686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            ret = YesNoCancel(JetDefs.MAIN_JETCREATOR, JetDefs.MAIN_SAVEBEFOREEXIT, True)
11696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if ret == wx.ID_YES:
11706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.OnJetSave(None)
11716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if ret == wx.ID_CANCEL:
11726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return
11736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.jet is not None:
11756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            SafeJetShutdown(self.playerLock, self.jet)
11766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.Destroy()
11776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnPlay(self, event):
11796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Plays the currently queued segments """
11806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.btnPlay.GetLabel() == JetDefs.BUT_PLAY:
11816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if not ValidateConfig(self.jet_file):
11826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return
11836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            #make sure something is queued
11856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            iQueued = False
11866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            num = self.segList.GetItemCount()
11876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            for seg_num in range(num):
11886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if self.segList.IsChecked(seg_num):
11896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    iQueued = True
11906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if not iQueued:
11916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                InfoMsg(JetDefs.MAIN_PLAYSEG, JetDefs.MAIN_PLAYSEGMSG)
11926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return
11936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            for segment in self.jet_file.segments:
11956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if FileExists(segment.dlsfile):
11966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    if not segment.dlsfile in self.jet_file.libraries:
11976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        self.jet_file.libraries.append(segment.dlsfile)
11986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
11996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.eventList.DeleteAllItems()
12006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            num = self.segList.GetItemCount()
12016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            for seg_num in range(num):
12026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if seg_num == 0: self.log.Clear()
12036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                if self.segList.IsChecked(seg_num):
12046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    segment = self.jet_file.GetSegment(getColumnText(self.segList, seg_num, 0))
12056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                    if segment != None:
12066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        #so we can determine which segment is playing, make these the same
12076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        userID = seg_num
12086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        if FileExists(segment.dlsfile):
12096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            dls_num = FindDlsNum(self.jet_file.libraries, segment.dlsfile)
12106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        else:
12116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                            dls_num = -1
12126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                        self.queueSegs.append(QueueSeg(segment.segname, userID, seg_num, dls_num, segment.repeat, segment.transpose, segment.mute_flags))
12136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if len(self.queueSegs) == 0:
12156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return
12166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.btnPlay.SetLabel(JetDefs.BUT_STOP)
12186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            thread.start_new_thread(self.PlaySegs, ())
12206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
12216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            with self.playerLock:
12226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                self.jet.Clear_Queue()
12236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SetKeepPlayingFlag(False)
12246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def PlaySegs(self):
12266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Thread writes a temporary copy of the jet file, and calls the library to play it """
12276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if len(self.queueSegs) == 0:
12286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
12296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        jet_file = CreateTempJetFile(self.jet_file)
12316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if not ValidateConfig(jet_file):
12336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            CleanupTempJetFile(jet_file)
12346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
12356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet = JET()
12376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet.eas.StartWave()
12386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet.OpenFile(jet_file.config.filename)
12396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        lastID = -1
12416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        # queue first segment and start playback
12436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        Queue(self.jet, self.queueSegs[0])
12446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        index = 1
12456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.jet.Play()
12466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.paused = False
12476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        # continue playing until all segments are done
12496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.SetKeepPlayingFlag(True)
12506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        while self.GetKeepPlayingFlag():
12516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet.Render()
12526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            status = self.jet.Status()
12536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if status.currentUserID <> lastID and status.currentUserID <> -1:
12556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                wx.PostEvent(self, JetStatusEvent(JetDefs.PST_PLAY, status.currentUserID))
12566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                lastID = status.currentUserID
12576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            # if no more segments - we're done
12596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if status.numQueuedSegments == 0:
12606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                break
12616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet.GetAppEvent()
12636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            # if less than 2 segs queued - queue another one
12656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if (index < len(self.queueSegs)) and (status.numQueuedSegments < 2):
12666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                Queue(self.jet, self.queueSegs[index])
12676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                index += 1
12686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            wx.PostEvent(self, JetStatusEvent(JetDefs.PST_UPD_LOCATION, status.location))
12706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        SafeJetShutdown(self.playerLock, self.jet)
12736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.queueSegs = []
12756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        CleanupTempJetFile(jet_file)
12776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        wx.PostEvent(self, JetStatusEvent(JetDefs.PST_DONE, None))
12796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
12806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnJetStatusUpdate(self, evt):
12816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ These are screen updates called for from within the thread.  Communication
12826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            is via a postevent call.
12836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """
12846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if evt.mode == JetDefs.PST_PLAY:
12856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            segName = getColumnText(self.segList, evt.data, 0)
12866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.LoadEventsForSeg(segName)
12876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.log.SetValue(segName)
12886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            ClearRowSelections(self.segList)
12896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            SetRowSelection(self.segList, evt.data, True)
12906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif evt.mode == JetDefs.PST_UPD_LOCATION:
12916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.graph.UpdateLocation(evt.data)
12926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif evt.mode == 3:
12936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.graph.UpdateLocation(0)
12946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            ClearRowSelections(self.segList)
12956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.eventList.DeleteAllItems()
12966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.SetKeepPlayingFlag(False)
12976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.btnPlay.SetLabel(JetDefs.BUT_PLAY)
12986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.btnPause.SetLabel(JetDefs.BUT_PAUSE)
12996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnPause(self, evt):
13016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Pauses the playback """
13026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.jet is None:
13036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return
13046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if not self.paused:
13056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet.Pause()
13066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.paused = True
13076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.btnPause.SetLabel(JetDefs.BUT_RESUME)
13086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
13096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.jet.Play()
13106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.paused = False
13116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            self.btnPause.SetLabel(JetDefs.BUT_PAUSE)
13126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def isDirty(self):
13146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if len(self.UndoStack) == 0 and len(self.RedoStack) == 0:
13156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return False
13166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
13176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return True
13186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSetGraphOptions(self, evt):
13206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Sets graph options """
13216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        IniSetValue(self.currentJetConfigFile, JetDefs.F_GRAPHLABELS, JetDefs.F_GRAPHLABELS, self.chkGraphLabels.GetValue())
13226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        IniSetValue(self.currentJetConfigFile, JetDefs.F_GRAPHCLIPS, JetDefs.F_GRAPHCLIPS, self.chkGraphClips.GetValue())
13236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        IniSetValue(self.currentJetConfigFile, JetDefs.F_GRAPHAPPEVTS, JetDefs.F_GRAPHAPPEVTS, self.chkGraphAppEvts.GetValue())
13246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        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'))
13256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnEventSortOrderChanged(self):
13276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Called when sort order has changed """
13286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        IniSetValue(self.currentJetConfigFile, JetDefs.INI_EVENTSORT, JetDefs.INI_EVENTSORT_0, self.eventList.GetSortState()[0])
13296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        IniSetValue(self.currentJetConfigFile, JetDefs.INI_EVENTSORT, JetDefs.INI_EVENTSORT_1, self.eventList.GetSortState()[1])
13306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.LoadEventsForSeg(self.currentSegmentName)
13316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        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'))
13326b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13336b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def EventSortCmp(self, a, b):
13346b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Sorts based on selected sort order """
13356b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.eventlistSort[0] == 0 or self.eventlistSort[0] == 1:
13366b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.eventlistSort[1] == 1:
13376b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(a[0].upper(), b[0].upper())
13386b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
13396b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(b[0].upper(), a[0].upper())
13406b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.eventlistSort[0] == 2 or self.eventlistSort[0] == 3:
13416b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.eventlistSort[1] == 1:
13426b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(MbtVal(a[0]), MbtVal(b[0]))
13436b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
13446b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(MbtVal(b[0]), MbtVal(a[0]))
13456b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
13466b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return cmp(a[0], b[0])
13476b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13486b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def EventSort2(self, seq, attr):
13496b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Does Sorting """
13506b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        intermed = map(None, map(getattr, seq, (attr,)*len(seq)), xrange(len(seq)), seq)
13516b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        intermed.sort(self.EventSortCmp)
13526b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        return map(operator.getitem, intermed, (-1,) * len(intermed))
13536b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13546b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def EventSort(self, lst, attr):
13556b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Does Sorting """
13566b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        lst[:] = self.EventSort2(lst, attr)
13576b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13586b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def OnSegSortOrderChanged(self):
13596b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Called when sort order has changed """
13606b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        IniSetValue(self.currentJetConfigFile, JetDefs.INI_SEGSORT, JetDefs.INI_SEGSORT_0, self.segList.GetSortState()[0])
13616b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        IniSetValue(self.currentJetConfigFile, JetDefs.INI_SEGSORT, JetDefs.INI_SEGSORT_1, self.segList.GetSortState()[1])
13626b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        self.LoadEventsForSeg(self.currentSegmentName)
13636b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        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'))
13646b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13656b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def SegSortCmp(self, a, b):
13666b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Sorts based on selected sort order """
13676b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        if self.seglistSort[0] == 0:
13686b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.seglistSort[1] == 1:
13696b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(a[0].upper(), b[0].upper())
13706b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
13716b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(b[0].upper(), a[0].upper())
13726b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 1 or self.seglistSort[0] == 2:
13736b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.seglistSort[1] == 1:
13746b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(FileJustName(a[0]).upper(), FileJustName(b[0]).upper())
13756b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
13766b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(FileJustName(b[0]).upper(), FileJustName(a[0]).upper())
13776b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        elif self.seglistSort[0] == 3 or self.seglistSort[0] == 4:
13786b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            if self.seglistSort[1] == 1:
13796b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(MbtVal(a[0]), MbtVal(b[0]))
13806b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            else:
13816b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi                return cmp(MbtVal(b[0]), MbtVal(a[0]))
13826b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        else:
13836b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi            return cmp(a[0], b[0])
13846b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13856b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def SegSort2(self, seq, attr):
13866b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Does Sorting """
13876b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        intermed = map(None, map(getattr, seq, (attr,)*len(seq)), xrange(len(seq)), seq)
13886b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        intermed.sort(self.SegSortCmp)
13896b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        return map(operator.getitem, intermed, (-1,) * len(intermed))
13906b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13916b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    def SegSort(self, lst, attr):
13926b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        """ Does Sorting """
13936b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        lst[:] = self.SegSort2(lst, attr)
13946b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13956b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Triviif __name__ == '__main__':
13966b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    """ Sets the logging level, then calls the open dialog box before initializing main window"""
13976b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
13986b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    logLevel = IniGetValue(JetDefs.JETCREATOR_INI, JetDefs.INI_LOGGING, JetDefs.INI_LOGGING)
13996b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    if logLevel == 'DEBUG':
14006b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        logging.basicConfig(level=logging.DEBUG, format='%(funcName)s[%(lineno)d]: %(message)s')
14016b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    elif logLevel == 'INFO':
14026b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        logging.basicConfig(level=logging.INFO, format='%(funcName)s[%(lineno)d]: %(message)s')
14036b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    elif logLevel == 'ERROR':
14046b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        logging.basicConfig(level=logging.ERROR, format='%(funcName)s[%(lineno)d]: %(message)s')
14056b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    elif logLevel == 'WARNING':
14066b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        logging.basicConfig(level=logging.WARNING, format='%(funcName)s[%(lineno)d]: %(message)s')
14076b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    else:
14086b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        install_release_loggers()
14096b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
14106b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    app = wx.App(None)
14116b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
14126b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    if not os.path.isdir(JetDefs.TEMP_JET_DIR):
14136b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        os.mkdir(JetDefs.TEMP_JET_DIR)
14146b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
14156b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    openFile = ""
14166b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    dlg = JetOpen()
14176b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    result = dlg.ShowModal()
14186b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    if result == wx.ID_CANCEL:
14196b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
14206b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    elif result == JetDefs.ID_JET_IMPORT:
14216b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
14226b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
14236b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        au = JetCreator(None, -1, "", importFlag=True)
14246b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        app.MainLoop()
14256b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi    else:
14266b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        openFile = dlg.fileName
14276b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        dlg.Destroy()
14286b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
14296b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        au = JetCreator(None, -1, openFile)
14306b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi        app.MainLoop()
14316b065d0f7161fe54e6f58fd2b8ad6c650b2d3657Jean-Michel Trivi
1432