import nuke, os, sys
import createFolders
import exploreThis
import read_from_write
import makewritefromread
import pasteToSelected
import set_renderdirectory, set_prerenderdirectory
import our_clearAllCaches
import autoBackdrop
import kellertools
import stamps
import GrayAutoBackdrop
#import ffmpeg_render


class KellerPluginKoppler(KellerNukePlugin):

    def configurePlugin(self):
        print ("Keller Plugin Koppler: Plugin loaded")
        ############################################################################################################################################
        # TOOLBARS
        ############################################################################################################################################
        
        # Workgroup Toolbar
        toolbar = nuke.menu("Nodes")
        m = toolbar.addMenu("Workgroup", "Toolbar_Workgroup.png")
        m.addCommand("Neutral Grade", 'nuke.createNode("NeutralGrade")', icon="Sampler.png")
        m.addCommand('Gray Auto Backdrop', lambda: GrayAutoBackdrop.GrayAutoBackdrop(), "alt+b", shortcutContext=2)
        
        # Stereo Toolbar
        toolbar = nuke.menu("Nodes")
        m = toolbar.addMenu("Stereo", "Toolbar_Stereo.png")
        m.addCommand("BlendCamera", "nuke.createNode(\"BlendCamera\")")
        m.addCommand("ourAnaglyph", "nuke.createNode(\"ourAnaglyph\")", icon="ourAnaglyph.png")
        m.addCommand("ourOptimizedAnaglyph", "nuke.createNode(\"ourOptimizedAnaglyph\")", icon="ourAnaglyph.png")
        m.addCommand("ourInterlacedStereo", "nuke.createNode(\"ourInterlacedStereo\")", icon="ourInterlacedStereo.png")

        # 3DE Menu
        # Lens Distortion
        toolbar = nuke.menu("Nodes")
        m = toolbar.addMenu("3DE4", "LensDistort.png")
        nuke.menu("Nodes").addCommand("3DE4/LD_3DE4_Anamorphic_Standard_Degree_4", "nuke.createNode('LD_3DE4_Anamorphic_Standard_Degree_4')")
        nuke.menu("Nodes").addCommand("3DE4/LD_3DE4_Anamorphic_Rescaled_Degree_4", "nuke.createNode('LD_3DE4_Anamorphic_Rescaled_Degree_4')")
        nuke.menu("Nodes").addCommand("3DE4/LD_3DE4_Anamorphic_Degree_6", "nuke.createNode('LD_3DE4_Anamorphic_Degree_6')")
        nuke.menu("Nodes").addCommand("3DE4/LD_3DE4_Radial_Standard_Degree_4", "nuke.createNode('LD_3DE4_Radial_Standard_Degree_4')")
        nuke.menu("Nodes").addCommand("3DE4/LD_3DE4_Radial_Fisheye_Degree_8", "nuke.createNode('LD_3DE4_Radial_Fisheye_Degree_8')")
        nuke.menu("Nodes").addCommand("3DE4/LD_3DE_Classic_LD_Model", "nuke.createNode('LD_3DE_Classic_LD_Model')")

        ############################################################################################################################################
        # MENU
        ############################################################################################################################################
        
        # RENDER MENU
        menubar = nuke.menu("Nuke")
        m = menubar.addMenu("&Render")
        m.addCommand("Autocrop", "nukescripts.autocrop()('nukescripts.autocrop()')", index=11)
       
        # CACHE MENU
        menubar = nuke.menu("Nuke")
        m = menubar.addMenu("&Cache")
        m.addCommand("Clear All Caches", 'our_clearAllCaches.clearAllCaches()', "F13")

        # WORKGROUP MENU
        m = menubar.addMenu("Workgroup", index=5)
        m.addCommand("Explore This", 'exploreThis.exploreThis()', "#+E")
        m.addCommand("Read from Write", 'read_from_write.ReadFromWrite()', "#+R")
        m.addCommand("Write from Read", 'makewritefromread.make_write_from_read()', "shift+R")
        m.addCommand("Paste to selected", 'pasteToSelected.pasteToSelected()', 'ctrl+shift+v')

        # SCENECONTROL MENU IS DEFINED INSIDE sceneControl.py