Example #1
0
    def execute(self, context):
        scene = context.scene
        edit_driver = self.driver
        if edit_driver is not None:
            gui = edit_driver.driver_gui(scene)
            if gui is not None:
                gui.varname = self.varname
                gui.var_index = edit_driver.fcurve.driver.variables.find(self.varname)
            else:
                debug.print("NO GUI")
            #dm.set_edit_driver_gui(context)

        return {'FINISHED'}
Example #2
0
    def execute(self, context):
        scene = context.scene
        edit_driver = self.driver
        if edit_driver is not None:
            gui = edit_driver.driver_gui(scene)
            if gui is not None:
                gui.varname = self.varname
                gui.var_index = edit_driver.fcurve.driver.variables.find(
                    self.varname)
            else:
                debug.print("NO GUI")
            # dm.set_edit_driver_gui(context)

        return {'FINISHED'}
Example #3
0
def SOUND_DRIVERS_load(dummy):
    debug.print("SOUND_DRIVERS_load")

    register_props()

    # remove it for reload same file.
    # unload should be called from pre load handler
    # SOUND_DRIVERS_unload(dummy)
    print("Setting Up Driver Manager")

    dm = bpy.app.driver_namespace.get("DriverManager")
    if not dm:
        dm = DriverManager()
        bpy.app.driver_namespace["DriverManager"] = dm
    else:
        dm.edit_driver = None
Example #4
0
def SOUND_DRIVERS_load(dummy):
    debug.print("SOUND_DRIVERS_load")

    register_props()

    # remove it for reload same file.
    # unload should be called from pre load handler
    # SOUND_DRIVERS_unload(dummy)
    print("Setting Up Driver Manager")

    dm = bpy.app.driver_namespace.get("DriverManager")
    if not dm:
        dm = DriverManager()
        bpy.app.driver_namespace["DriverManager"] = dm
    else:
        dm.edit_driver = None
 def visualise(self, context):
     """
     Override BGLWidget visualise
     it's the handle passed to the ScreenArea to draw
     """
     sp = context.scene.speaker
     if sp is None:
         return None
     action = getAction(sp)
     # action = context.area.sound_action # NEW IDEA REFACTO
     if action is None:
         return None
     area_settings = self.area_settings(context)
     if not area_settings:
         debug.print("No Area Settings")
         return None
     self.draw_strips(action, context)
Example #6
0
 def visualise(self, context):
     '''
     Override BGLWidget visualise
     it's the handle passed to the ScreenArea to draw
     '''
     sp = context.scene.speaker
     if sp is None:
         return None
     action = getAction(sp)
     # action = context.area.sound_action # NEW IDEA REFACTO
     if action is None:
         return None
     area_settings = self.area_settings(context)
     if not area_settings:
         debug.print("No Area Settings")
         return None
     self.draw_strips(action, context)
Example #7
0
def SOUND_DRIVERS_unload(dummy):
    debug.print("SPEAKER_TOOLS_unload")

    try:
        #global dm
        dm = bpy.app.driver_namespace.get("DriverManager")
        if dm:
            dm.clear()
            debug.print("Clearing Driver Manager")
        if hasattr(dummy, "driver_objects"):
            for x in dummy.driven_objects:
                x.clear()
    except:
        debug.print("PROBLEM UNLOADING DM")
        pass
Example #8
0
def SOUND_DRIVERS_unload(dummy):
    debug.print("SPEAKER_TOOLS_unload")

    try:
        #global dm
        dm = bpy.app.driver_namespace.get("DriverManager")
        if dm:
            dm.clear()
            debug.print("Clearing Driver Manager")
        if hasattr(dummy, "driver_objects"):
            for x in dummy.driven_objects:
                x.clear()
    except:
        debug.print("PROBLEM UNLOADING DM")
        pass
    def draw_midi_keyboard(self, mx, my, w, h, action=None, frame=0):
        """
        Intented to create a keyboard where key widths are
        accurately in position.

        See http://www.mathpages.com/home/kmath043.htm
        for the math.

        This keyboard has following properties (x=octave width).
        1. All white keys have equal width in front (W=x/7).
        2. All black keys have equal width (B=x/12).
        3. The narrow part of white keys C, D and E is W - B*2/3
        4. The narrow part of white keys F, G, A, and B is W - B*3/4
        """
        bgl.glEnable(bgl.GL_BLEND)
        octaves = 7
        octave_width = (w - 20) / octaves
        wkw = octave_width / 7
        bkw = octave_width / 12
        cde = wkw - 2 * bkw / 3
        fgab = wkw - 3 * bkw / 4
        wkh = h
        bkh = 0.60 * h

        by = my + wkh - bkh
        x = mx
        y = my
        white = (1.0, 1.0, 1.0, 1.0)
        black = (0.0, 0.0, 0.0, 1.0)
        # draw the white keys
        fc_color = True
        whitenotes = [0, 2, 4, 5, 7, 9, 11]
        blacknotes_1 = [1, 3]
        blacknotes_2 = [6, 8, 10]
        for octave in range(octaves):

            for i in range(7):
                col = white
                if action:
                    # print("XXXXXXXX", '%d"]' % (octave * 12 + whitenotes[i]))
                    fcurves = [
                        fc
                        for fc in action.fcurves
                        if (fc.group.select or fc.select)
                        and fc.data_path.endswith('%d"]' % (octave * 12 + whitenotes[i]))
                    ]
                    # fc = action.fcurves.find('["%s%d"]' % (action["channel_name"], octave * 12 + whitenotes[i]))
                    for fc in fcurves:
                        if fc.evaluate(frame) > 0:
                            debug.print("BGL", fc.data_path)
                            r, g, b = fc.color if fc_color else (1, 0, 0)
                            col = (r, g, b, 1.0)
                self.draw_box(x, y, wkw, wkh, color=col)
                x += wkw + 1
            # draw the black keys
            x = octave * 7 * (wkw + 1) + cde + mx + 1

            for i in range(2):
                col = black
                if action:
                    fc = action.fcurves.find('["%s%d"]' % (action["channel_name"], octave * 12 + blacknotes_1[i]))
                    if fc:
                        if fc.evaluate(frame) > 0:
                            r, g, b = fc.color if fc_color else (1, 0, 0)
                            col = (r, g, b, 1.0)
                self.draw_box(x, by, bkw, bkh, color=col)
                x += cde + bkw + 1
            x += fgab
            for i in range(3):
                col = black
                if action:
                    fc = action.fcurves.find('["%s%d"]' % (action["channel_name"], octave * 12 + blacknotes_2[i]))
                    if fc:
                        if fc.evaluate(frame) > 0:
                            r, g, b = fc.color if fc_color else (1, 0, 0)
                            col = (r, g, b, 1.0)
                self.draw_box(x, by, bkw, bkh, color=col)
                x += fgab + bkw + 1
            x += 1
Example #10
0
    def draw_midi_keyboard(self, mx, my, w, h, action=None, frame=0):
        '''
        Intented to create a keyboard where key widths are
        accurately in position.

        See http://www.mathpages.com/home/kmath043.htm
        for the math.

        This keyboard has following properties (x=octave width).
        1. All white keys have equal width in front (W=x/7).
        2. All black keys have equal width (B=x/12).
        3. The narrow part of white keys C, D and E is W - B*2/3
        4. The narrow part of white keys F, G, A, and B is W - B*3/4
        '''
        bgl.glEnable(bgl.GL_BLEND)
        octaves = 7
        octave_width = (w - 20) / octaves
        wkw = octave_width / 7
        bkw = octave_width / 12
        cde = wkw - 2 * bkw / 3
        fgab = wkw - 3 * bkw / 4
        wkh = h
        bkh = 0.60 * h

        by = my + wkh - bkh
        x = mx
        y = my
        white = (1.0, 1.0, 1.0, 1.0)
        black = (0.0, 0.0, 0.0, 1.0)
        # draw the white keys
        fc_color = True
        whitenotes = [0, 2, 4, 5, 7, 9, 11]
        blacknotes_1 = [1, 3]
        blacknotes_2 = [6, 8, 10]
        for octave in range(octaves):

            for i in range(7):
                col = white
                if action:
                    #print("XXXXXXXX", '%d"]' % (octave * 12 + whitenotes[i]))
                    fcurves = [fc for fc in action.fcurves if (fc.group.select or fc.select) and fc.data_path.endswith('%d"]' % (octave * 12 + whitenotes[i]))]
                    #fc = action.fcurves.find('["%s%d"]' % (action["channel_name"], octave * 12 + whitenotes[i]))
                    for fc in fcurves:
                        if fc.evaluate(frame) > 0:
                            debug.print("BGL", fc.data_path)
                            r, g, b = fc.color if fc_color else (1, 0, 0)
                            col = (r, g, b, 1.0)
                self.draw_box(x, y, wkw, wkh, color=col)
                x += (wkw + 1)
            # draw the black keys
            x = octave * 7 * (wkw + 1) + cde + mx + 1

            for i in range(2):
                col = black
                if action:
                    fc = action.fcurves.find('["%s%d"]' % (action["channel_name"], octave * 12 + blacknotes_1[i]))
                    if fc:
                        if fc.evaluate(frame) > 0:
                            r, g, b = fc.color if fc_color else (1, 0, 0)
                            col = (r, g, b, 1.0)
                self.draw_box(x, by, bkw, bkh, color=col)
                x += cde + bkw + 1
            x += fgab
            for i in range(3):
                col = black
                if action:
                    fc = action.fcurves.find('["%s%d"]' % (action["channel_name"], octave * 12 + blacknotes_2[i]))
                    if fc:
                        if fc.evaluate(frame) > 0:
                            r, g, b = fc.color if fc_color else (1, 0, 0)
                            col = (r, g, b, 1.0)
                self.draw_box(x, by, bkw, bkh, color=col)
                x += fgab + bkw + 1
            x += 1