Commit e574645e94d1a87fc7441c62ad768b1dce5c86d2

Authored by Thiago Franco de Moraes
1 parent 2d500448

Removed the local colorselect

invesalius/gui/default_viewers.py
... ... @@ -302,9 +302,9 @@ class VolumeInteraction(wx.Panel):
302 302 import wx.lib.platebtn as pbtn
303 303 import wx.lib.buttons as btn
304 304 import wx.lib.pubsub as ps
  305 +import wx.lib.colourselect as csel
305 306  
306 307 import invesalius.constants as const
307   -import invesalius.gui.widgets.colourselect as csel
308 308  
309 309 [BUTTON_RAYCASTING, BUTTON_VIEW, BUTTON_SLICE_PLANE, BUTTON_3D_STEREO] = [wx.NewId() for num in xrange(4)]
310 310 RAYCASTING_TOOLS = wx.NewId()
... ...
invesalius/gui/task_navigator.py
... ... @@ -26,6 +26,7 @@ import wx.lib.hyperlink as hl
26 26 import wx.lib.masked.numctrl
27 27 import wx.lib.foldpanelbar as fpb
28 28 from wx.lib.pubsub import pub as Publisher
  29 +import wx.lib.colourselect as csel
29 30  
30 31 import invesalius.constants as const
31 32 import invesalius.data.bases as db
... ... @@ -34,7 +35,6 @@ import invesalius.data.coregistration as dcr
34 35 import invesalius.data.trackers as dt
35 36 import invesalius.data.trigger as trig
36 37 import invesalius.gui.dialogs as dlg
37   -import invesalius.gui.widgets.colourselect as csel
38 38  
39 39 class TaskPanel(wx.Panel):
40 40 def __init__(self, parent):
... ...
invesalius/gui/task_slice.py
... ... @@ -24,6 +24,7 @@ import wx
24 24 import wx.lib.hyperlink as hl
25 25 import wx.lib.platebtn as pbtn
26 26 import wx.lib.foldpanelbar as fpb
  27 +import wx.lib.colourselect as csel
27 28 from wx.lib.pubsub import pub as Publisher
28 29  
29 30 import invesalius.data.mask as mask
... ... @@ -31,7 +32,6 @@ import invesalius.data.slice_ as slice_
31 32 import invesalius.constants as const
32 33 import invesalius.gui.dialogs as dlg
33 34 import invesalius.gui.widgets.gradient as grad
34   -import invesalius.gui.widgets.colourselect as csel
35 35  
36 36 from invesalius.project import Project
37 37 import invesalius.session as ses
... ... @@ -421,7 +421,7 @@ class MaskProperties(wx.Panel):
421 421 self.combo_mask_name = combo_mask_name
422 422  
423 423 # Mask colour
424   - button_colour= csel.ColourSelect(self, 111,colour=(0,255,0),size=(-1,22))
  424 + button_colour= csel.ColourSelect(self, 111,colour=(0,255,0),size=(22,-1))
425 425 self.button_colour = button_colour
426 426  
427 427 # Sizer which represents the first line
... ...
invesalius/gui/task_surface.py
... ... @@ -23,11 +23,11 @@ import wx
23 23 import wx.lib.hyperlink as hl
24 24 from wx.lib.pubsub import pub as Publisher
25 25 import wx.lib.foldpanelbar as fpb
  26 +import wx.lib.colourselect as csel
26 27  
27 28 import invesalius.constants as const
28 29 import invesalius.data.slice_ as slice_
29 30 import invesalius.gui.dialogs as dlg
30   -import invesalius.gui.widgets.colourselect as csel
31 31 import wx.lib.platebtn as pbtn
32 32 import invesalius.project as prj
33 33 import invesalius.utils as utl
... ... @@ -415,7 +415,7 @@ class SurfaceProperties(wx.Panel):
415 415 self.combo_surface_name = combo_surface_name
416 416  
417 417 # Mask colour
418   - button_colour= csel.ColourSelect(self, -1,colour=(0,0,255),size=(-1,22))
  418 + button_colour= csel.ColourSelect(self, -1,colour=(0,0,255),size=(22, -1))
419 419 button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour)
420 420 self.button_colour = button_colour
421 421  
... ...
invesalius/gui/widgets/colourselect.py
... ... @@ -1,176 +0,0 @@
1   -#----------------------------------------------------------------------------
2   -# Name: ColourSelect.py
3   -# Purpose: Colour Box Selection Control
4   -#
5   -# Author: Lorne White, Lorne.White@telusplanet.net
6   -#
7   -# Created: Feb 25, 2001
8   -# Licence: wxWindows license
9   -#----------------------------------------------------------------------------
10   -
11   -# creates a colour wxButton with selectable color
12   -# button click provides a colour selection box
13   -# button colour will change to new colour
14   -# GetColour method to get the selected colour
15   -
16   -# Updates:
17   -# call back to function if changes made
18   -
19   -# Cliff Wells, logiplexsoftware@earthlink.net:
20   -# - Made ColourSelect into "is a button" rather than "has a button"
21   -# - Added label parameter and logic to adjust the label colour according to the background
22   -# colour
23   -# - Added id argument
24   -# - Rearranged arguments to more closely follow wx conventions
25   -# - Simplified some of the code
26   -
27   -# Cliff Wells, 2002/02/07
28   -# - Added ColourSelect Event
29   -
30   -# 12/01/2003 - Jeff Grimmett (grimmtooth@softhome.net)
31   -#
32   -# o Updated for 2.5 compatability.
33   -#
34   -
35   -"""
36   -Provides a `ColourSelect` button that, when clicked, will display a
37   -colour selection dialog. The selected colour is displayed on the
38   -button itself.
39   -"""
40   -
41   -#----------------------------------------------------------------------------
42   -
43   -import wx
44   -
45   -#----------------------------------------------------------------------------
46   -
47   -wxEVT_COMMAND_COLOURSELECT = wx.NewEventType()
48   -
49   -class ColourSelectEvent(wx.PyCommandEvent):
50   - def __init__(self, id, value):
51   - wx.PyCommandEvent.__init__(self, id = id)
52   - self.SetEventType(wxEVT_COMMAND_COLOURSELECT)
53   - self.value = value
54   -
55   - def GetValue(self):
56   - return self.value
57   -
58   -EVT_COLOURSELECT = wx.PyEventBinder(wxEVT_COMMAND_COLOURSELECT, 1)
59   -
60   -#----------------------------------------------------------------------------
61   -
62   -class ColourSelect(wx.BitmapButton):
63   - def __init__(self, parent, id=wx.ID_ANY, label="", colour=wx.BLACK,
64   - pos=wx.DefaultPosition, size=wx.DefaultSize,
65   - callback=None, style=0):
66   - if label:
67   - w, h = parent.GetTextExtent(label)
68   - w += 6
69   - h += 6
70   - else:
71   - w, h = 20, 20
72   - wx.BitmapButton.__init__(self, parent, id, wx.EmptyBitmap(w,h),
73   - pos=pos, size=size, style=style|wx.BU_AUTODRAW)
74   -
75   - if type(colour) == type( () ):
76   - colour = wx.Colour(*colour)
77   - self.colour = colour
78   - self.SetLabel(label)
79   - self.callback = callback
80   - bmp = self.MakeBitmap()
81   - self.SetBitmap(bmp)
82   - parent.Bind(wx.EVT_BUTTON, self.OnClick, self)
83   -
84   -
85   - def GetColour(self):
86   - return self.colour
87   -
88   - def GetValue(self):
89   - return self.colour
90   -
91   - def SetValue(self, colour):
92   - self.SetColour(colour)
93   -
94   - def SetColour(self, colour):
95   - if type(colour) == tuple:
96   - colour = wx.Colour(*colour)
97   - if type(colour) == str:
98   - colour = wx.NamedColour(colour)
99   -
100   - self.colour = colour
101   - bmp = self.MakeBitmap()
102   - self.SetBitmap(bmp)
103   -
104   -
105   - def SetLabel(self, label):
106   - self.label = label
107   -
108   - def GetLabel(self):
109   - return self.label
110   -
111   -
112   - def MakeBitmap(self):
113   - bdr = 8
114   - width, height = self.GetSize()
115   -
116   - # yes, this is weird, but it appears to work around a bug in wxMac
117   - if "wxMac" in wx.PlatformInfo and width == height:
118   - height -= 1
119   -
120   - bmp = wx.EmptyBitmap(width-bdr, height-bdr)
121   - dc = wx.MemoryDC()
122   - dc.SelectObject(bmp)
123   - dc.SetFont(self.GetFont())
124   - label = self.GetLabel()
125   - # Just make a little colored bitmap
126   - dc.SetBackground(wx.Brush(self.colour))
127   - dc.Clear()
128   -
129   - if label:
130   - # Add a label to it
131   - avg = reduce(lambda a, b: a + b, self.colour.Get()) / 3
132   - fcolour = avg > 128 and wx.BLACK or wx.WHITE
133   - dc.SetTextForeground(fcolour)
134   - dc.DrawLabel(label, (0,0, width-bdr, height-bdr),
135   - wx.ALIGN_CENTER)
136   -
137   - dc.SelectObject(wx.NullBitmap)
138   - return bmp
139   -
140   -
141   - def SetBitmap(self, bmp):
142   - self.SetBitmapLabel(bmp)
143   - #self.SetBitmapSelected(bmp)
144   - #self.SetBitmapDisabled(bmp)
145   - #self.SetBitmapFocus(bmp)
146   - #self.SetBitmapSelected(bmp)
147   - self.Refresh()
148   -
149   -
150   - def OnChange(self):
151   - evt = ColourSelectEvent(self.GetId(), self.GetValue())
152   - evt.SetEventObject(self)
153   - wx.PostEvent(self, evt)
154   - if self.callback is not None:
155   - self.callback()
156   -
157   - def OnClick(self, event):
158   - data = wx.ColourData()
159   - data.SetChooseFull(True)
160   - data.SetColour(self.colour)
161   - dlg = wx.ColourDialog(wx.GetTopLevelParent(self), data)
162   -
163   - try:
164   - changed = dlg.ShowModal() == wx.ID_OK
165   - except(wx._core.PyAssertionError):
166   - changed = True
167   -
168   - if changed:
169   - data = dlg.GetColourData()
170   - self.SetColour(data.GetColour())
171   - dlg.Destroy()
172   -
173   - # moved after dlg.Destroy, since who knows what the callback will do...
174   - if changed:
175   - self.OnChange()
176   -