Skip to content

Commit

Permalink
myvi
Browse files Browse the repository at this point in the history
  • Loading branch information
yxdragon committed Mar 9, 2019
1 parent 10b590e commit c4eefb8
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions imagepy/core/myvi/canvas3d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys
import sys, platform
import moderngl
import numpy as np
import wx, math
Expand All @@ -8,16 +8,13 @@
from wx.lib.pubsub import pub
from .util import *

#----------------------------------------------------------------------
from wx.glcanvas import WX_GL_DEPTH_SIZE
attribs=[WX_GL_DEPTH_SIZE,32,0,0];

class Canvas3D(glcanvas.GLCanvas):
def __init__(self, parent, manager=None):
attribList = attribs = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24)
attribList = attribs = (glcanvas.WX_GL_CORE_PROFILE, glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24)
glcanvas.GLCanvas.__init__(self, parent, -1, attribList=attribList)
self.init = False
self.context = glcanvas.GLContext(self)
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
self.manager = self.manager = Manager() if manager is None else manager
self.size = None

Expand Down Expand Up @@ -108,6 +105,11 @@ def OnMouseWheel(self, evt):
self.Refresh(False)
#self.update()

def make_bitmap(bmp):
img = bmp.ConvertToImage()
img.Resize((20, 20), (2, 2))
return img.ConvertToBitmap()

class Viewer3D(wx.Panel):
def __init__( self, parent, manager=None):
wx.Panel.__init__(self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.TAB_TRAVERSAL )
Expand All @@ -121,26 +123,27 @@ def __init__( self, parent, manager=None):

#self.SetIcon(wx.Icon('data/logo.ico', wx.BITMAP_TYPE_ICO))

self.btn_x = wx.BitmapButton( self.toolbar, wx.ID_ANY, wx.Bitmap( osp.join(root, 'imgs/x-axis.png'), wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_x, 0, wx.ALL, 1 )
self.btn_y = wx.BitmapButton( self.toolbar, wx.ID_ANY, wx.Bitmap( osp.join(root, 'imgs/y-axis.png'), wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_y, 0, wx.ALL, 1 )
self.btn_z = wx.BitmapButton( self.toolbar, wx.ID_ANY, wx.Bitmap( osp.join(root, 'imgs/z-axis.png'), wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_z, 0, wx.ALL, 1 )
self.btn_x = wx.BitmapButton( self.toolbar, wx.ID_ANY, make_bitmap(wx.Bitmap( osp.join(root, 'imgs/x-axis.png'), wx.BITMAP_TYPE_ANY )), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_x, 0, wx.ALIGN_CENTER|wx.ALL, 0 )
self.btn_y = wx.BitmapButton( self.toolbar, wx.ID_ANY, make_bitmap(wx.Bitmap( osp.join(root, 'imgs/y-axis.png'), wx.BITMAP_TYPE_ANY )), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_y, 0, wx.ALIGN_CENTER|wx.ALL, 0 )
self.btn_z = wx.BitmapButton( self.toolbar, wx.ID_ANY, make_bitmap(wx.Bitmap( osp.join(root, 'imgs/z-axis.png'), wx.BITMAP_TYPE_ANY )), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_z, 0, wx.ALIGN_CENTER|wx.ALL, 0 )
tsizer.Add(wx.StaticLine( self.toolbar, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL), 0, wx.ALL|wx.EXPAND, 2 )
self.btn_pers = wx.BitmapButton( self.toolbar, wx.ID_ANY, wx.Bitmap( osp.join(root, 'imgs/isometric.png'), wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_pers, 0, wx.ALL, 1 )
self.btn_orth = wx.BitmapButton( self.toolbar, wx.ID_ANY, wx.Bitmap( osp.join(root, 'imgs/parallel.png'), wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_orth, 0, wx.ALL, 1 )
self.btn_pers = wx.BitmapButton( self.toolbar, wx.ID_ANY, make_bitmap(wx.Bitmap( osp.join(root, 'imgs/isometric.png'), wx.BITMAP_TYPE_ANY )), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_pers, 0, wx.ALIGN_CENTER|wx.ALL, 0 )
self.btn_orth = wx.BitmapButton( self.toolbar, wx.ID_ANY, make_bitmap(wx.Bitmap( osp.join(root, 'imgs/parallel.png'), wx.BITMAP_TYPE_ANY )), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_orth, 0, wx.ALIGN_CENTER|wx.ALL, 0 )
tsizer.Add(wx.StaticLine( self.toolbar, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_VERTICAL), 0, wx.ALL|wx.EXPAND, 2 )
self.btn_open = wx.BitmapButton( self.toolbar, wx.ID_ANY, wx.Bitmap(osp.join(root, 'imgs/open.png'), wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_open, 0, wx.ALL, 1 )
self.btn_stl = wx.BitmapButton( self.toolbar, wx.ID_ANY, wx.Bitmap(osp.join(root, 'imgs/stl.png'), wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_stl, 0, wx.ALL, 1 )

self.btn_color = wx.ColourPickerCtrl( self.toolbar, wx.ID_ANY, wx.Colour( 128, 128, 128 ), wx.DefaultPosition, wx.DefaultSize, wx.CLRP_DEFAULT_STYLE )
tsizer.Add( self.btn_color, 0, wx.ALIGN_CENTER|wx.ALL, 1 )
self.btn_open = wx.BitmapButton( self.toolbar, wx.ID_ANY, make_bitmap(wx.Bitmap(osp.join(root, 'imgs/open.png'), wx.BITMAP_TYPE_ANY )), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_open, 0, wx.ALIGN_CENTER|wx.ALL, 0 )
self.btn_stl = wx.BitmapButton( self.toolbar, wx.ID_ANY, make_bitmap(wx.Bitmap(osp.join(root, 'imgs/stl.png'), wx.BITMAP_TYPE_ANY )), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
tsizer.Add( self.btn_stl, 0, wx.ALIGN_CENTER|wx.ALL, 0 )
#pan = wx.Panel(self.toolbar, size=(50, 50))
self.btn_color = wx.ColourPickerCtrl( self.toolbar, wx.ID_ANY, wx.Colour( 128, 128, 128 ), wx.DefaultPosition, [(33, 38), (-1, -1)][platform.system() in ['Windows', 'Linux']], wx.CLRP_DEFAULT_STYLE )
tsizer.Add( self.btn_color, 0, wx.ALIGN_CENTER|wx.ALL|(0, wx.EXPAND)[platform.system() in ['Windows', 'Linux']], 0 )
self.toolbar.SetSizer( tsizer )
tsizer.Layout()

self.settingbar = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
ssizer = wx.BoxSizer( wx.HORIZONTAL )
Expand All @@ -152,7 +155,7 @@ def __init__( self, parent, manager=None):
cho_objChoices = ['None']
self.cho_obj = wx.Choice( self.settingbar, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, cho_objChoices, 0 )
self.cho_obj.SetSelection( 0 )
ssizer.Add( self.cho_obj, 0, wx.ALL, 1 )
ssizer.Add( self.cho_obj, 0, wx.ALIGN_CENTER|wx.ALL, 1 )

self.chk_visible = wx.CheckBox( self.settingbar, wx.ID_ANY, u"visible", wx.DefaultPosition, wx.DefaultSize, 0 )
ssizer.Add( self.chk_visible, 0, wx.ALIGN_CENTER|wx.LEFT, 10 )
Expand All @@ -175,7 +178,7 @@ def __init__( self, parent, manager=None):
cho_objChoices = ['mesh', 'grid']
self.cho_mode = wx.Choice( self.settingbar, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, cho_objChoices, 0 )
self.cho_mode.SetSelection( 0 )
ssizer.Add( self.cho_mode, 0, wx.ALL, 1 )
ssizer.Add( self.cho_mode, 0, wx.ALIGN_CENTER|wx.ALL, 1 )

sizer.Add( self.toolbar, 0, wx.EXPAND |wx.ALL, 0 )
sizer.Add( self.canvas, 1, wx.EXPAND |wx.ALL, 0)
Expand Down

0 comments on commit c4eefb8

Please sign in to comment.