Beispiel #1
0
    def on_cmapsel(self, event):
        key = self.cmapsel.GetValue()
        lut = ColorManager.gets(key)
        n = self.spn_num.GetValue() + 1
        idx = np.linspace(0, 255, n).astype(int)
        cs = list(lut[idx]) + [(128, 128, 128)] * (16 - n)
        for btn, c in zip(self.btns, cs):
            btn.SetBackgroundColour(c)

        ips = ImageManager.get()
        if ips is None: return
        newlut = lut * 0
        newlut[:n] = lut[idx]
        ips.lut = newlut
        ips.update()
Beispiel #2
0
from ..lookuptables_plg import LUT
from imagepy.app import ColorManager

plgs = [LUT(i, j) for i, j, _ in ColorManager.gets(tag='adv')]
Beispiel #3
0
	def __init__( self, parent, app=None):
		wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size(-1,-1), style = wx.TAB_TRAVERSAL )
		outsizer = wx.BoxSizer(wx.HORIZONTAL)
		sizer = wx.BoxSizer( wx.VERTICAL )
		sizer_color = wx.BoxSizer( wx.HORIZONTAL )
		self.app = app
		self.btns = []
		self.btn_make =  wx.Button( self, wx.ID_ANY, 'New Mark', wx.DefaultPosition, wx.DefaultSize, 0 )
		sizer_color.Add(self.btn_make, 0, wx.ALL, 2)
		for i in range(11):
			btn = wx.Button( self, wx.ID_ANY, str(i), wx.DefaultPosition, wx.DefaultSize, 0 )
			btn.SetMaxSize( wx.Size( 30,-1 ) )
			self.btns.append(btn)
			sizer_color.Add( btn, 0, wx.ALL, 2 )
		self.spn_num = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 2, 15, 0 )
		self.spn_num.SetMaxSize(wx.Size(45, -1))
		sizer_color.Add( self.spn_num, 0, wx.ALL|wx.EXPAND, 2 )

		sizer.Add(sizer_color, 0, wx.ALL|wx.EXPAND, 0)

		sizer_other = wx.BoxSizer( wx.HORIZONTAL )

		self.btn_update =  wx.Button( self, wx.ID_ANY, 'Update', wx.DefaultPosition, wx.DefaultSize, 0 )
		sizer_other.Add( self.btn_update, 0, wx.ALL, 2)

		self.cmapsel = CMapSelCtrl(self)
		self.cmapsel.SetItems(ColorManager.gets(tag='base'))
		sizer_other.Add(self.cmapsel, 0, wx.ALL|wx.EXPAND, 2 )

		com_backChoices = [ u"No Background" ]
		self.com_back = wx.ComboBox( self, wx.ID_ANY, u"No Background", wx.DefaultPosition, wx.DefaultSize, com_backChoices, wx.CB_READONLY)
		self.com_back.SetSelection( 0 )
		sizer_other.Add( self.com_back, 1, wx.ALL|wx.EXPAND, 2 )
		
		com_modeChoices = [ u"None", u"Max", u"Min", u"Mask", u"2-8mix", u"4-6mix", u"5-5mix", u"6-4mix", u"8-2mix" ]
		self.com_mode = wx.ComboBox( self, wx.ID_ANY, u"Min", wx.DefaultPosition, wx.DefaultSize, com_modeChoices, wx.CB_READONLY )
		self.com_mode.SetSelection( 0 )
		sizer_other.Add( self.com_mode, 0, wx.ALL|wx.EXPAND, 2 )

		self.chk_hide = wx.CheckBox( self, wx.ID_ANY, u"Hide", wx.DefaultPosition, wx.DefaultSize, 0 )
		sizer_other.Add( self.chk_hide, 0, wx.ALIGN_CENTER|wx.ALL, 0 )

		sizer.Add(sizer_other, 0, wx.ALL|wx.EXPAND, 0)

		#sizer_tol = wx.GridSizer( 0, 3, 0, 0 )
		self.pens = []
		name = ['01.gif','03.gif','05.gif','10.gif','fill.gif']
		path = osp.abspath(osp.dirname(__file__))
		for i in (0,1,2,3,4):
			pen = wx.BitmapButton(self, wx.ID_ANY, make_bitmap(wx.Bitmap(osp.join(path, 'imgs', name[i]))),#make_bitmap(wx.Bitmap(data[1])), 
            wx.DefaultPosition, (30, 30), wx.BU_AUTODRAW|wx.RAISED_BORDER ) 
            #wx.Button( self, wx.ID_ANY, str(i), wx.DefaultPosition, wx.DefaultSize, 0 )
			pen.SetMaxSize( wx.Size( 30,-1 ) )
			self.pens.append( pen )
			sizer_color.Add( pen, 0, wx.ALL, 2 )

		outsizer.AddStretchSpacer(prop=1)
		#outsizer.Add(sizer_tol, 0, wx.ALL, 0)
		outsizer.Add(sizer, 0, wx.ALL, 0)
		outsizer.AddStretchSpacer(prop=1)

		self.SetSizer( outsizer )
		self.Layout()
		
		# Connect Events
		self.spn_num.Bind( wx.EVT_SPINCTRL, self.on_cmapsel )
		self.com_back.Bind(wx.EVT_COMBOBOX_DROPDOWN, self.on_items )
		self.cmapsel.Bind(wx.EVT_COMBOBOX,  self.on_cmapsel)
		self.com_back.Bind( wx.EVT_COMBOBOX, self.on_setback)
		self.com_mode.Bind( wx.EVT_COMBOBOX, self.on_mode)
		self.chk_hide.Bind( wx.EVT_CHECKBOX, self.on_mode)
		self.pens[-1].Bind( wx.EVT_BUTTON, self.on_fill)
		for i in self.btns: i.Bind(wx.EVT_BUTTON, self.on_color)
		for i in range(4): self.pens[i].Bind(wx.EVT_BUTTON, \
			lambda e, x=(1,3,5,10)[i]: self.on_pen(x))
		self.btn_make.Bind( wx.EVT_BUTTON, self.on_make)