def SingleContextHandlerInstance(context_code): try: c = dsight.ContextHandler(context_code, 3, 3) c = dsight.ContextHandler(context_code, 3, 3) except dsight.PythonExceptionWrapper as e: message, code = e.args if code == dsight.EXCEPTION_CODE_MULTIPLE_CONTEXT: return True raise e return False
def DestructorResetStates(context_code): try: c1 = dsight.ContextHandler(context_code, 3, 3) c1 = None c2 = dsight.ContextHandler(context_code, 3, 3) except dsight.PythonExceptionWrapper as e: message, code = e.args if code == dsight.EXCEPTION_CODE_MULTIPLE_CONTEXT: return False raise e return True
def AddOutOfBoundViewport(context_code): context = dsight.ContextHandler(context_code, 3, 3) canvas = context.AddCanvas(2, 2, None) try: canvas.AddViewport(0, 0, 4, 4) except dsight.PythonExceptionWrapper as e: message, code = e.args if code == dsight.EXCEPTION_CODE_INVALID_COORDINATES_OUT_OF_BOUNDS: return 1 raise e return 0
def ZeroSubdivision(context_code): context = dsight.ContextHandler(context_code, 3, 3) canvas = context.AddCanvas(0, 0, None) try: canvas.AddViewport(0, 0, 1, 1) except dsight.PythonExceptionWrapper as e: message, code = e.args if e.code == dsight.EXCEPTION_CODE_INVALID_COORDINATES_OUT_OF_BOUNDS: return 0 raise e return 1
def PreventViewportOverlapFromZeroZeroToOneOne(context_code): context = dsight.ContextHandler(context_code, 3, 3) canvas = context.AddCanvas(2, 2, None) canvas.AddViewport(0, 0, 1, 1) try: canvas.AddViewport(0, 0, 1, 1) except dsight.PythonExceptionWrapper as e: message, code = e.args if code == dsight.EXCEPTION_CODE_INVALID_COORDINATES_OVERLAP: return 1 raise e return 0
def DoNotOverlap(context_code): context = dsight.ContextHandler(context_code, 3, 3) canvas = context.AddCanvas(4, 4, None) canvas.AddViewport(0, 0, 2, 2) try: canvas.AddViewport(2, 2, 5, 5) except dsight.PythonExceptionWrapper as e: message, code = e.args if code == dsight.EXCEPTION_CODE_INVALID_COORDINATES_OVERLAP: return 0 raise e return 1
def CheckRefCountSetDefaultCanvasSize(context_code): r1 = dsight.ContextHandler(context_code, 3, 3) r2 = r1.SetDefaultCanvasSize(100, 100) return sys.getrefcount(r1) == 3
def CheckRefCountChainWhithSetDefaultCanvasSize(context_code): context = dsight.ContextHandler(context_code, 3, 3).SetDefaultCanvasSize(100, 100) return sys.getrefcount(context) == 2
def ChainWhithSetDefaultCanvasSize(context_code): context = dsight.ContextHandler(context_code, 3, 3).SetDefaultCanvasSize(100, 100) return type(context) == dsight.ContextHandler
def SetDefaultCanvasSizeMustReturnItself(context_code): context = dsight.ContextHandler(context_code, 3, 3) return context == context.SetDefaultCanvasSize(100, 100)
def CannotRemoveCanvasViewportTwice(context_code): context = dsight.ContextHandler(context_code, 3, 3) canvas = context.AddCanvas(0, 0, None) context.RemoveCanvas(canvas) return not context.RemoveCanvas(canvas)
def RemoveCanvas(context_code): context = dsight.ContextHandler(context_code, 3, 3) canvas = context.AddCanvas(0, 0, None) return context.RemoveCanvas(canvas)
def CannotRemoveViewportTwice(context_code): context = dsight.ContextHandler(context_code, 3, 3) canvas = context.AddCanvas(0, 0, None) viewport = canvas.AddViewport(0, 0, 1, 1) canvas.RemoveViewport(viewport) return not canvas.RemoveViewport(viewport)