__all__ = ['TextureLimit', 'instantiate']
from MessageRegistry import theMessageRegistry
from MessageInterpreter import MessageInterpreter
from UserCustomization import UserCustomBase, CustomInfo
from RunInUiThread import RunInUiThread
TEXTURE_LIMIT_Doc = \
[(
"""
Limit texture size
"""
),
[[("value"),("Limit texture size. -1 for hardware limit.")],
]
]
theMessageRegistry.register("TEXTURE_LIMIT",
(int,), 0, TEXTURE_LIMIT_Doc)
class TextureLimit (UserCustomBase):
def __init__(self):
self.__myCallIdLimit = None
self.__myInterp = LocalInterp()
def getInterpreter(self,isInteractive):
if isInteractive:
return self.__myInterp
return None
def appendMenuItems(self,id,menu):
if "View" == id:
self.__myMenu = menu
menu.appendSeparator()
self.__myCallIdLimit = \
menu.appendCheckItem(_( 'Texture Limit' ),
self.__onTextureLimit )
def enableMenuStates(self,id,enableStates):
if "View" == id:
enableStates[self.__myCallIdLimit] = True
def resetMenuStates(self, id):
if "View" == id:
menuItemStates = {}
menuItemStates[self.__myCallIdLimit] = False
self.__myMenu.checkMenuItems(menuItemStates)
def __onTextureLimit( self, event ):
isOn = bool(self.__myMenu.IsChecked(self.__myCallIdLimit))
if isOn:
self.__myInterp.sendMessage( "TEXTURE_LIMIT", (128, ) )
else:
self.__myInterp.sendMessage( "TEXTURE_LIMIT", (-1, ) )
RunInUiThread( self.__myMenu.updateMenu )
class LocalInterp( MessageInterpreter ):
__kFactorStartId = "FactorStart"
__kFactorId = "Factor"
__kFocusStartId = "FocusStart"
__kFocusId = "Focus"
def __init__( self ):
MessageInterpreter.__init__( self )
self.__myDisplay = None
def SET_DISPLAY(self, message):
(self.__myDisplay,) = message.data
def APPLICATION_CLOSE_SCENE(self, message):
self.__myDisplay = None
self.sendMessage( "TEXTURE_LIMIT", (-1, ) )
def TEXTURE_LIMIT( self, message ):
if self.__myDisplay is None:
return
(val,) = message.data
self.__myDisplay.setTextureSizeLimit(int(val))
def instantiate():
return TextureLimit()
def info():
customInfo = CustomInfo()
customInfo.vendor = 'Autodesk'
customInfo.version = '1.0'
customInfo.api = '2013'
customInfo.shortInfo = "Set the texture size limit."
customInfo.longInfo = \
"""The add-in lets us specify the texture size limit of 128, at which point the subsequent \
texture uploads will be limited to that.
"""
return customInfo