# Path: message_box.py
# class MessageBox(Popup):
#     text = StringProperty('')
#     cb = ObjectProperty()
# 
#     ok_text = StringProperty('OK')
#     cancel_text = StringProperty('Cancel')
# 
#     def ok(self):
#         if self.cb:
#             self.cb(True)
#         self.dismiss()
# 
#     def cancel(self):
#         if self.cb:
#             self.cb(False)
#         self.dismiss()
# 
# Path: input_box.py
# class InputBox(Popup):
#     text = StringProperty('')
#     value = StringProperty('')
#     cb = ObjectProperty()
# 
#     ok_text = StringProperty('OK')
#     cancel_text = StringProperty('Cancel')
# 
#     def __init__(self, **kwargs):
#         self.window = Window
#         super(InputBox, self).__init__(**kwargs)
#         self.content = self.ids["content"]
# 
#     def on_open(self):
#         self.ids.input.focus = True
# 
#     def ok(self):
#         if self.cb:
#             s = self.ids.input.text
#             self.cb(s)
#         self.dismiss()
# 
#     def cancel(self):
#         if self.cb:
#             self.cb(None)
#         self.dismiss()


from kivy.uix.scatter import Scatter
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.logger import Logger, LOG_LEVELS
from kivy.graphics import Color, Line, Scale, Translate, PopMatrix, PushMatrix, Rectangle
from kivy.graphics import InstructionGroup
from kivy.properties import NumericProperty, BooleanProperty, ListProperty, ObjectProperty
from kivy.graphics.transformation import Matrix
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.clock import Clock, mainthread
from kivy.core.text import Label as CoreLabel
from message_box import MessageBox
from input_box import InputBox
import logging
import sys
import re
import math
import time
import traceback
    def next_layer(self):
        if self.twod_mode:
            self.above_layer -= self.slice_size
            self.below_layer -= self.slice_size

        self.loading()

    def prev_layer(self):
        if self.twod_mode:
            self.above_layer += self.slice_size
            self.below_layer += self.slice_size
            self.loading()

        else:
            if len(self.layers) > 2:
                self.layers.pop()
                self.layers.pop()
                self.loading()

    def _set_slice(self, val):
        if val:
            try:
                self.slice_size = float(val)
                self.above_layer = -self.slice_size
                self.below_layer = 0.0
                self.loading()
            except Exception as e:
                pass

    def set_slice(self):

# Path: message_box.py
# class MessageBox(Popup):
#     text = StringProperty('')
#     cb = ObjectProperty()
# 
#     ok_text = StringProperty('OK')
#     cancel_text = StringProperty('Cancel')
# 
#     def ok(self):
#         if self.cb:
#             self.cb(True)
#         self.dismiss()
# 
#     def cancel(self):
#         if self.cb:
#             self.cb(False)
#         self.dismiss()
# 
# Path: input_box.py
# class InputBox(Popup):
#     text = StringProperty('')
#     value = StringProperty('')
#     cb = ObjectProperty()
# 
#     ok_text = StringProperty('OK')
#     cancel_text = StringProperty('Cancel')
# 
#     def __init__(self, **kwargs):
#         self.window = Window
#         super(InputBox, self).__init__(**kwargs)
#         self.content = self.ids["content"]
# 
#     def on_open(self):
#         self.ids.input.focus = True
# 
#     def ok(self):
#         if self.cb:
#             s = self.ids.input.text
#             self.cb(s)
#         self.dismiss()
# 
#     def cancel(self):
#         if self.cb:
#             self.cb(None)
#         self.dismiss()


# Path: viewer.py
from kivy.uix.scatter import Scatter
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.logger import Logger, LOG_LEVELS
from kivy.graphics import Color, Line, Scale, Translate, PopMatrix, PushMatrix, Rectangle
from kivy.graphics import InstructionGroup
from kivy.properties import NumericProperty, BooleanProperty, ListProperty, ObjectProperty
from kivy.graphics.transformation import Matrix
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.clock import Clock, mainthread
from kivy.core.text import Label as CoreLabel
from message_box import MessageBox
from input_box import InputBox
import logging
import sys
import re
import math
import time
import traceback

    def next_layer(self):
        if self.twod_mode:
            self.above_layer -= self.slice_size
            self.below_layer -= self.slice_size

        self.loading()

    def prev_layer(self):
        if self.twod_mode:
            self.above_layer += self.slice_size
            self.below_layer += self.slice_size
            self.loading()

        else:
            if len(self.layers) > 2:
                self.layers.pop()
                self.layers.pop()
                self.loading()

    def _set_slice(self, val):
        if val:
            try:
                self.slice_size = float(val)
                self.above_layer = -self.slice_size
                self.below_layer = 0.0
                self.loading()
            except Exception as e:
                pass

    def set_slice(self):

        o = InputBox(title='Set Slice', text='enter size in mm of slice to view', cb=self._set_slice)