예제 #1
0
    def __init__(self, model, view):
        """
        Standard constructor.

        @type  model: model.workspace.Workspace
        @param model: Corresponding model for this controller.
        @type  view: view.workspace.CabelFrame
        @param view: Corresponding view for this controller.
        """
        Observer.__init__(self)

        self._configDirs = model.config.directories

        self._model = model
        self._view = view

        # Add controller and view to observers of model
        self._model.addObserver(self)
        self._model.addObserver(view)

        # Diverse help variables
        self._actModule = None  # Actual module
        self._lastMousePt = wx.Point()  # Last position of mouse on workspace
        # saved for move modules
        self._lastMouseWorkspaceDragPt = wx.Point(
        )  # Last position of mouse when starting to drag with middle button
        self._connectOutput = -1  # Output number of module while
        # dragging a cable
        self._idToModules = {
        }  # Remeber corresponding module name to id in popup
        self._idToRecent = {}  # Remeber corresponding Cabel workspace file.
        self._openValueFrames = []

        self._saved = True  # Set empty workspace as saved
예제 #2
0
파일: controller.py 프로젝트: nrad/Pythonia
    def __init__(self, model, view):
        """
        Standard constructor.

        @type  model: model.workspace.Workspace
        @param model: Corresponding model for this controller.
        @type  view: view.workspace.CabelFrame
        @param view: Corresponding view for this controller.
        """
        Observer.__init__(self)
        
        self._configDirs = model.config.directories
        
        self._model = model
        self._view = view
        
        # Add controller and view to observers of model
        self._model.addObserver(self)
        self._model.addObserver(view)

        # Diverse help variables
        self._actModule = None             # Actual module
        self._lastMousePt = wx.Point()     # Last position of mouse on workspace
                                           # saved for move modules
        self._lastMouseWorkspaceDragPt = wx.Point()  # Last position of mouse when starting to drag with middle button
        self._connectOutput = -1           # Output number of module while
                                           # dragging a cable
        self._idToModules = {}             # Remeber corresponding module name to id in popup
        self._idToRecent = {}              # Remeber corresponding Cabel workspace file.
        self._openValueFrames = []

        self._saved = True                 # Set empty workspace as saved
예제 #3
0
    def __init__(self, parent):
        """
        Standardconstructor.
        
        @type parent: view.workspace.CabelFrame
        @param parent: Parent frame.
        """
        wx.StatusBar.__init__(self, parent, -1)
        Observer.__init__(self)

        # Config Vars Csound
        self.config = parent._controller._model.config.csound

        # View workspace
        self.workspace = parent
        self.workspace._controller._model.addObserver(self)

        # Number of Fields and it's widths
        self.SetFieldsCount(4)
        self.SetStatusWidths([-3, 80, 60, 115])

        self.Bind(wx.EVT_SIZE, self.onSize)

        #play button
        self.playBmp = wx.Bitmap(
            os.path.join(os.getcwd(), 'stuff', 'play.jpg'),
            wx.BITMAP_TYPE_JPEG)
        playMask = wx.Mask(self.playBmp, wx.LIGHT_GREY)
        self.stopBmp = wx.Bitmap(
            os.path.join(os.getcwd(), 'stuff', 'stop.jpg'),
            wx.BITMAP_TYPE_JPEG)
        stopMask = wx.Mask(self.stopBmp, wx.LIGHT_GREY)

        self.playBmp.SetMask(playMask)
        self.stopBmp.SetMask(stopMask)

        self.playBtn = wx.BitmapButton(self, wx.NewId(), self.playBmp)
        self.playBtn.SetToolTipString("Start Csound. [CTRL-Y]")
        self.Bind(wx.EVT_BUTTON, self.onPlayStopButton, self.playBtn)

        #autoplay checkbox
        self.autoplayCb = wx.CheckBox(self, wx.NewId(), "autoplay")
        self.Bind(wx.EVT_CHECKBOX, self.onAutoplayCheckBox, self.autoplayCb)
        self.autoplayCb.SetValue(
            self.config.getVal(tools.config.Csound.AUTOPLAY))

        #zoom combobox
        self.zoomTxtCtrl = wx.TextCtrl(self,
                                       wx.NewId(),
                                       str(self.workspace.zoom) + ' %',
                                       style=wx.TE_PROCESS_ENTER | wx.TE_RIGHT)
        self.zoomTxtCtrl.SetToolTipString("Zoom the Modules on the Workspace.")
        self.Bind(wx.EVT_TEXT_ENTER, self.onZoomEntered, self.zoomTxtCtrl)

        self._reposition()

        self._play = False
예제 #4
0
파일: csound.py 프로젝트: nrad/Pythonia
    def __init__(self, workspace):
        """
        Standard constructor.

        @type  workspace: model.workspace.Workspace
        @param workspace: Workspace on which the CsoundGenerator works.
        """
        Observer.__init__(self)
        self.workspace = workspace
        self.config = model.workspace.Workspace.config.csound
        self._playing = False
        self.workspace.addObserver(self)
        self._prcss = None
예제 #5
0
파일: valueframe.py 프로젝트: nrad/Pythonia
    def __init__(self, module, parent, model, controller, position=(0, 0)):
        """
        Standard constructor.

        @type  module: model.module.Module
        @param module: This frame can change module's inVars.
        @type  parent: wx.Window
        @param parent: Parent of CabelValueFrame (always on top of parent).
        @type  model: model.workspace.Workspace
        @param model: Corresponding model for this frame.
        @type controller: model.controller.CabelController
        @ivar controller: Controller of model.
        @type  position: tuple
        @param position: Initial position of frame.
        """
        self._model = model
        self._controller = controller
        self._module = module

        Observer.__init__(self)
        self._model.addObserver(self)

        id = -1
        title = module.name + " " + str(module.id)
        wx.Frame.__init__(self, parent, id, title,
                          pos=position, size=(250, 40 * len(self._module.inVars)),
                          style=wx.FRAME_NO_TASKBAR|wx.FRAME_FLOAT_ON_PARENT \
                          |wx.RESIZE_BORDER|wx.CLOSE_BOX|wx.CAPTION\
                          |wx.CLIP_CHILDREN|wx.SYSTEM_MENU)

        panel = wx.Panel(self, -1)  # Panel on which sliders are placed
        # (for keyboard navigation)

        self._sliders = {}
        sizer = wx.BoxSizer(wx.VERTICAL)
        for i in self._module.inVars:
            self._sliders[i] = CabelSlider(panel, i, self._model)
            sizer.Add(self._sliders[i].getSizer(),
                      1,
                      wx.BOTTOM | wx.EXPAND,
                      border=7)
        panel.SetSizer(sizer)

        # Try to set focus to first slider
        try:
            self._sliders[self._module.inVars[0]].setSliderFocus()
        except:
            pass

        self.Bind(wx.EVT_CLOSE, self.onClose)
        self.Bind(wx.EVT_KEY_DOWN, self.onKey)
예제 #6
0
파일: valueframe.py 프로젝트: nrad/Pythonia
    def __init__(self, module, parent, model, controller, position=(0,0)):
        """
        Standard constructor.

        @type  module: model.module.Module
        @param module: This frame can change module's inVars.
        @type  parent: wx.Window
        @param parent: Parent of CabelValueFrame (always on top of parent).
        @type  model: model.workspace.Workspace
        @param model: Corresponding model for this frame.
        @type controller: model.controller.CabelController
        @ivar controller: Controller of model.
        @type  position: tuple
        @param position: Initial position of frame.
        """
        self._model = model
        self._controller = controller
        self._module = module

        Observer.__init__(self)
        self._model.addObserver(self)
        
        id = -1
        title = module.name + " " + str(module.id)
        wx.Frame.__init__(self, parent, id, title,
                          pos=position, size=(250, 40 * len(self._module.inVars)),
                          style=wx.FRAME_NO_TASKBAR|wx.FRAME_FLOAT_ON_PARENT \
                          |wx.RESIZE_BORDER|wx.CLOSE_BOX|wx.CAPTION\
                          |wx.CLIP_CHILDREN|wx.SYSTEM_MENU)


        panel = wx.Panel(self, -1) # Panel on which sliders are placed
                                   # (for keyboard navigation)

        self._sliders = {}
        sizer = wx.BoxSizer(wx.VERTICAL)
        for i in self._module.inVars:
            self._sliders[i] = CabelSlider(panel, i, self._model)
            sizer.Add(self._sliders[i].getSizer(), 1, wx.BOTTOM|wx.EXPAND, border=7)
        panel.SetSizer(sizer)

        # Try to set focus to first slider
        try:
            self._sliders[self._module.inVars[0]].setSliderFocus()
        except:
            pass

        self.Bind(wx.EVT_CLOSE, self.onClose)
        self.Bind(wx.EVT_KEY_DOWN, self.onKey)
예제 #7
0
파일: workspace.py 프로젝트: nrad/Pythonia
    def __init__(self, parent):
        """
        Standardconstructor.
        
        @type parent: view.workspace.CabelFrame
        @param parent: Parent frame.
        """
        wx.StatusBar.__init__(self, parent, -1)
        Observer.__init__(self)
        
        # Config Vars Csound
        self.config = parent._controller._model.config.csound
        
        # View workspace
        self.workspace = parent
        self.workspace._controller._model.addObserver(self)
        
        # Number of Fields and it's widths
        self.SetFieldsCount(4)
        self.SetStatusWidths([-3, 80, 60, 115])

        self.Bind(wx.EVT_SIZE, self.onSize)
        
        #play button
        self.playBmp = wx.Bitmap(os.path.join(os.getcwd(), 'stuff', 'play.jpg'), wx.BITMAP_TYPE_JPEG)
        playMask = wx.Mask(self.playBmp, wx.LIGHT_GREY)
        self.stopBmp = wx.Bitmap(os.path.join(os.getcwd(), 'stuff', 'stop.jpg'), wx.BITMAP_TYPE_JPEG)
        stopMask = wx.Mask(self.stopBmp, wx.LIGHT_GREY)
        
        self.playBmp.SetMask(playMask)
        self.stopBmp.SetMask(stopMask)
        
        self.playBtn = wx.BitmapButton(self, wx.NewId(), self.playBmp)
        self.playBtn.SetToolTipString("Start Csound. [CTRL-Y]")
        self.Bind(wx.EVT_BUTTON, self.onPlayStopButton, self.playBtn)
        
        #autoplay checkbox
        self.autoplayCb = wx.CheckBox(self, wx.NewId(), "autoplay")
        self.Bind(wx.EVT_CHECKBOX, self.onAutoplayCheckBox, self.autoplayCb)
        self.autoplayCb.SetValue(self.config.getVal(tools.config.Csound.AUTOPLAY))
        
        #zoom combobox
        self.zoomTxtCtrl = wx.TextCtrl(self, wx.NewId(), str(self.workspace.zoom) + ' %', style = wx.TE_PROCESS_ENTER|wx.TE_RIGHT)
        self.zoomTxtCtrl.SetToolTipString("Zoom the Modules on the Workspace.")
        self.Bind(wx.EVT_TEXT_ENTER, self.onZoomEntered, self.zoomTxtCtrl)
        
        self._reposition()
        
        self._play = False
예제 #8
0
    def __init__(self, model):
        """
        Standard constructor.

        @type  model: model.workspace.Workspace
        @param model: Corresponding model for this view.
        """
        # Initialize Observer
        Observer.__init__(self)

        parent = None

        # View related config vars
        self.config = model.config.view

        # Filename, etcetera
        self.fileName = ''
        self.filePath = os.path.join(os.getcwd(), 'examples')
        self._cwFileNewCount = 1

        size = wx.Size(self.config.getVal(tools.config.View.FRAMEWIDTH), \
                       self.config.getVal(tools.config.View.FRAMEHEIGHT))
        wx.Frame.__init__(self, parent, -1, self.GetTitle(), size=size)

        # Remember Maximized Frame; Only works on MSW
        if sys.platform in ("win32") and self.config.getVal(
                tools.config.View.FRAME_MAXIMIZED):
            self.Maximize(True)

        # Zoom
        self.zoom = self.config.getVal(tools.config.View.ZOOM_LASTVALUE)

        # initialize controller
        self._controller = CabelController(model, self)

        # List of modules and connections
        self._modules = []
        self._connections = []
        self._draggedCable = None
        self._modulesDict = {}

        # Create menus
        menubar = wx.MenuBar()
        # File
        self._filemenu = wx.Menu()
        self._filemenu.Append(wx.ID_NEW, "&New\tCTRL-N", "New..")
        self._filemenu.Append(wx.ID_OPEN, "&Open\tCTRL-O", "Open a Workspace")
        # RecentMenu
        self._recentMenuId = wx.NewId()
        recentMenu = self._getRecentMenu()
        self._filemenu.AppendMenu(self._recentMenuId, "Open Recent...",
                                  recentMenu)
        if recentMenu.GetMenuItemCount() == 0:
            self._filemenu.Enable(self._recentMenuId, False)
        self._filemenu.AppendSeparator()
        # Save
        self._filemenu.Append(wx.ID_SAVE, "&Save\tCTRL-S", "Save Workspace")
        self._filemenu.Append(wx.ID_SAVEAS, "S&ave As\tALT-S",
                              "Save Workpsace As...")
        self._filemenu.AppendSeparator()
        # Csound start/stop
        self._playStopId = wx.NewId()
        self._filemenu.Append(
            self._playStopId,
            self._controller._model.isPlaying() and 'Stop Csound\tCTRL-Y'
            or 'Start Csound\tCTRL-Y')
        idExportToCsd = wx.NewId()
        self._filemenu.Append(
            idExportToCsd, "&Export to CSD\tCTRL-E",
            "Export workspace to CSD (Csound Unified File Format)")
        self._filemenu.AppendSeparator()
        # Exit
        self._filemenu.Append(wx.ID_EXIT, "E&xit\tCTRL-Q", "Exit Cabel")
        menubar.Append(self._filemenu, "&File")

        # Modules
        self._modulesMenu = self.getModulesMenu(
            self._controller._getXmlModuleList())
        menubar.Append(self._modulesMenu, "&Modules")

        # Options
        self._optionsmenu = wx.Menu()

        # bottom Pane
        # -> properties
        if self.config.getVal(
                tools.config.View.BOTTOMWINDOW_REMEMBERPROPERTIES):
            showBottomPane = self.config.getVal(
                tools.config.View.BOTTOMWINDOW_SHOW)
        else:
            showBottomPane = self.config.getDefault(
                tools.config.View.BOTTOMWINDOW_SHOW)
        # -> menu entry
        self.id_bottomPane = wx.NewId()
        self._optionsmenu.AppendCheckItem(self.id_bottomPane,
                                          "Show &Bottom Pane\tALT-X",
                                          "Show Bottom Pane")
        self._optionsmenu.Check(self.id_bottomPane, showBottomPane)

        id_refreshMods = wx.NewId()
        self._optionsmenu.Append(id_refreshMods, "&Refresh Module List\tALT-R",
                                 "Refresh the Xml-Module List")

        self._optionsmenu.AppendSeparator()

        # Preferences
        id_options = wx.NewId()
        self._optionsmenu.Append(id_options, "Preferences\tALT-P",
                                 "Preferences")

        menubar.Append(self._optionsmenu, "&Options")

        self.SetMenuBar(menubar)

        # Associate menu events to handler functions
        self.Bind(wx.EVT_MENU, self._controller.onNew, id=wx.ID_NEW)
        self.Bind(wx.EVT_MENU, self._controller.onOpen, id=wx.ID_OPEN)
        self.Bind(wx.EVT_MENU, self._controller.onSave, id=wx.ID_SAVE)
        self.Bind(wx.EVT_MENU, self._controller.onSaveAs, id=wx.ID_SAVEAS)
        self.Bind(wx.EVT_MENU,
                  self._controller.onPlayStop,
                  id=self._playStopId)
        self.Bind(wx.EVT_MENU,
                  self._controller.onMenuExportToCsd,
                  id=idExportToCsd)
        self.Bind(wx.EVT_MENU, self._controller.onMenuExit, id=wx.ID_EXIT)
        self.Bind(wx.EVT_MENU, self.onToggleBottomPane, id=self.id_bottomPane)
        self.Bind(wx.EVT_MENU,
                  self._controller._refreshModulesMenu,
                  id=id_refreshMods)
        self.Bind(wx.EVT_MENU, self._controller.onOptionsOpen, id=id_options)
        self.Bind(wx.EVT_CLOSE, self._controller.onClose)

        # Create Statusbar
        self.statusbar = CabelStatusBar(self)
        self.SetStatusBar(self.statusbar)
        self.SetStatusBarPane(0)

        # Create splitted window
        self._splitter = CabelSplitterWindow(self, wx.ID_ANY)

        # Add workspace for synth building
        self.workspace = CabelScrolledWindow(self._splitter, -1, self)

        # wxTextCtrl which gets the stdout and stderr output of the app
        self.ioTextCtrl = None

        # Initialize Splitter
        self._splitter.initialize(self.workspace)

        # Associate mouse events to handler functions
        self.workspace.Bind(wx.EVT_LEFT_DOWN, self._controller.onMouseLeftDown)
        self.workspace.Bind(wx.EVT_LEFT_UP, self._controller.onMouseLeftUp)
        self.workspace.Bind(wx.EVT_LEFT_DCLICK,
                            self._controller.onMouseLeftDclick)
        self.workspace.Bind(wx.EVT_RIGHT_DOWN,
                            self._controller.onMouseRightDown)
        self.workspace.Bind(wx.EVT_MIDDLE_DOWN,
                            self._controller.onMouseMiddleDown)
        self.workspace.Bind(wx.EVT_MOTION, self._controller.onMouseMotion)
        self.Bind(wx.EVT_SIZE, self._controller.onSize)

        # Add additional key events
        self.Bind(wx.EVT_KEY_DOWN, self._controller.onKey)

        self.update(None, None)
예제 #9
0
파일: workspace.py 프로젝트: nrad/Pythonia
    def __init__(self, model):
        """
        Standard constructor.

        @type  model: model.workspace.Workspace
        @param model: Corresponding model for this view.
        """
        # Initialize Observer
        Observer.__init__(self)
        
        parent = None

        # View related config vars
        self.config = model.config.view
        
        # Filename, etcetera
        self.fileName = ''
        self.filePath = os.path.join(os.getcwd(), 'examples')
        self._cwFileNewCount = 1
        
        size = wx.Size(self.config.getVal(tools.config.View.FRAMEWIDTH), \
                       self.config.getVal(tools.config.View.FRAMEHEIGHT))
        wx.Frame.__init__(self, parent, -1, self.GetTitle(), size = size)
        
        # Remember Maximized Frame; Only works on MSW
        if sys.platform in ("win32") and self.config.getVal(tools.config.View.FRAME_MAXIMIZED):
            self.Maximize(True)
            
        # Zoom
        self.zoom = self.config.getVal(tools.config.View.ZOOM_LASTVALUE)

        # initialize controller
        self._controller = CabelController(model, self)

        # List of modules and connections
        self._modules = []
        self._connections = []
        self._draggedCable = None
        self._modulesDict = {}

        # Create menus
        menubar = wx.MenuBar()
        # File
        self._filemenu = wx.Menu()
        self._filemenu.Append(wx.ID_NEW, "&New\tCTRL-N", "New..")
        self._filemenu.Append(wx.ID_OPEN, "&Open\tCTRL-O", "Open a Workspace")
        # RecentMenu
        self._recentMenuId = wx.NewId()
        recentMenu = self._getRecentMenu()
        self._filemenu.AppendMenu(self._recentMenuId, "Open Recent...", recentMenu)
        if recentMenu.GetMenuItemCount() == 0:
            self._filemenu.Enable(self._recentMenuId, False)
        self._filemenu.AppendSeparator()
        # Save
        self._filemenu.Append(wx.ID_SAVE, "&Save\tCTRL-S", "Save Workspace")
        self._filemenu.Append(wx.ID_SAVEAS, "S&ave As\tALT-S", "Save Workpsace As...")
        self._filemenu.AppendSeparator()
        # Csound start/stop
        self._playStopId = wx.NewId()
        self._filemenu.Append(self._playStopId, self._controller._model.isPlaying() and 'Stop Csound\tCTRL-Y' or 'Start Csound\tCTRL-Y')
        idExportToCsd = wx.NewId()
        self._filemenu.Append(idExportToCsd, "&Export to CSD\tCTRL-E",
                              "Export workspace to CSD (Csound Unified File Format)")
        self._filemenu.AppendSeparator()
        # Exit
        self._filemenu.Append(wx.ID_EXIT, "E&xit\tCTRL-Q", "Exit Cabel")
        menubar.Append(self._filemenu, "&File")
        
        # Modules
        self._modulesMenu = self.getModulesMenu(self._controller._getXmlModuleList())
        menubar.Append(self._modulesMenu, "&Modules")
        
        # Options
        self._optionsmenu = wx.Menu()

        # bottom Pane
        # -> properties
        if self.config.getVal(tools.config.View.BOTTOMWINDOW_REMEMBERPROPERTIES):
            showBottomPane = self.config.getVal(tools.config.View.BOTTOMWINDOW_SHOW)
        else:
            showBottomPane = self.config.getDefault(tools.config.View.BOTTOMWINDOW_SHOW)
        # -> menu entry
        self.id_bottomPane = wx.NewId()
        self._optionsmenu.AppendCheckItem(self.id_bottomPane, "Show &Bottom Pane\tALT-X",
                                    "Show Bottom Pane")
        self._optionsmenu.Check(self.id_bottomPane, showBottomPane)
        
        id_refreshMods = wx.NewId()
        self._optionsmenu.Append(id_refreshMods, "&Refresh Module List\tALT-R", "Refresh the Xml-Module List")
        
        self._optionsmenu.AppendSeparator()
        
        # Preferences
        id_options = wx.NewId()
        self._optionsmenu.Append(id_options, "Preferences\tALT-P", "Preferences")
                
        menubar.Append(self._optionsmenu, "&Options")

        self.SetMenuBar(menubar)

        # Associate menu events to handler functions
        self.Bind(wx.EVT_MENU, self._controller.onNew, id = wx.ID_NEW)
        self.Bind(wx.EVT_MENU, self._controller.onOpen, id = wx.ID_OPEN)
        self.Bind(wx.EVT_MENU, self._controller.onSave, id = wx.ID_SAVE)
        self.Bind(wx.EVT_MENU, self._controller.onSaveAs, id = wx.ID_SAVEAS)
        self.Bind(wx.EVT_MENU, self._controller.onPlayStop, id = self._playStopId)
        self.Bind(wx.EVT_MENU, self._controller.onMenuExportToCsd, id = idExportToCsd)
        self.Bind(wx.EVT_MENU, self._controller.onMenuExit, id = wx.ID_EXIT)
        self.Bind(wx.EVT_MENU, self.onToggleBottomPane, id = self.id_bottomPane)
        self.Bind(wx.EVT_MENU, self._controller._refreshModulesMenu, id = id_refreshMods)
        self.Bind(wx.EVT_MENU, self._controller.onOptionsOpen, id = id_options)
        self.Bind(wx.EVT_CLOSE, self._controller.onClose)

        # Create Statusbar
        self.statusbar = CabelStatusBar(self)
        self.SetStatusBar(self.statusbar)
        self.SetStatusBarPane(0)
        
        # Create splitted window
        self._splitter = CabelSplitterWindow(self, wx.ID_ANY)
        
        # Add workspace for synth building
        self.workspace = CabelScrolledWindow(self._splitter, -1, self)

        # wxTextCtrl which gets the stdout and stderr output of the app
        self.ioTextCtrl = None

        # Initialize Splitter
        self._splitter.initialize(self.workspace)

        # Associate mouse events to handler functions
        self.workspace.Bind(wx.EVT_LEFT_DOWN, self._controller.onMouseLeftDown)
        self.workspace.Bind(wx.EVT_LEFT_UP, self._controller.onMouseLeftUp)
        self.workspace.Bind(wx.EVT_LEFT_DCLICK, self._controller.onMouseLeftDclick)
        self.workspace.Bind(wx.EVT_RIGHT_DOWN, self._controller.onMouseRightDown)
        self.workspace.Bind(wx.EVT_MIDDLE_DOWN, self._controller.onMouseMiddleDown)
        self.workspace.Bind(wx.EVT_MOTION, self._controller.onMouseMotion)
        self.Bind(wx.EVT_SIZE, self._controller.onSize)

        # Add additional key events
        self.Bind(wx.EVT_KEY_DOWN, self._controller.onKey)

        self.update(None, None)