#MyProject1MyFrame1.py

"""Subclass of MyFrame1, which is generated by wxFormBuilder."""

import wx

from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
import numpy as np
import os
import cv2
import matplotlib.pyplot as plt
from matplotlib.image import imread
from PIL import Image
from mpl_toolkits.mplot3d import Axes3D

# Implementing MyFrame1
class MyProject1MyFrame1( myframe1.MyFrame1 ):
    def __init__( self, parent ):
        myframe1.MyFrame1.__init__( self, parent )

    # Handlers for MyFrame1 events.
    def CubeSetOnButtonClick( self, event ):
        # TODO: Implement CubeSetOnButtonClick

        cx=int(self.CubeX.GetValue())
        cy=int(self.CubeY.GetValue())
        cz=int(self.CubeZ.GetValue())
        vol=cx*cy*cz
        volt=str(vol)
        self.m_staticText5.SetLabel(volt)

        self.px.SetRange(0,cx-1)
        self.py.SetRange(0,cy-1)
        self.pz.SetRange(0,cz-1)

        ppx=self.px.GetValue()
        ppy=self.py.GetValue()
        ppz=self.pz.GetValue()

        global test3D
        test3D=np.arange(vol).reshape(cx,cy,cz)
        ximage=test3D[ppx,:,:]
        yimage=test3D[:,ppy,:]
        zimage=test3D[:,:,ppz]

        imgx=wx.Image(ximage.shape[0], ximage.shape[1])
        imgx=imgx.Scale(250, 250, wx.IMAGE_QUALITY_HIGH)
        self.x_image.SetBitmap(wx.Bitmap(imgx))

        imgy=wx.Image(yimage.shape[0], yimage.shape[1])
        imgy=imgy.Scale(250, 250, wx.IMAGE_QUALITY_HIGH)
        self.y_image.SetBitmap(wx.Bitmap(imgy))

        imgz=wx.Image(zimage.shape[0], zimage.shape[1])
        imgz=imgz.Scale(250, 250, wx.IMAGE_QUALITY_HIGH)
        self.z_image.SetBitmap(wx.Bitmap(imgz))
        self.Refresh()
        pass

if __name__ == '__main__':
    app = wx.App(False)
    frame = MyProject1MyFrame1(None)
    frame.Show(True)

    app.MainLoop()