- Hopefully improved the attack displays. Needs checking.
This commit is contained in:
parent
68e9ad9cf4
commit
2886e1a7e5
@ -18,6 +18,9 @@ if Preference.usePIL():
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class AttackDisplay(wx.ScrolledWindow):
|
class AttackDisplay(wx.ScrolledWindow):
|
||||||
|
"""
|
||||||
|
Display an attack (inside a tab or not)
|
||||||
|
"""
|
||||||
def __init__(self, daddy, parent, attack):
|
def __init__(self, daddy, parent, attack):
|
||||||
|
|
||||||
self.win = daddy
|
self.win = daddy
|
||||||
@ -28,10 +31,7 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
# [CC][X] The below statement might be iffy on older versions.
|
# [CC][X] The below statement might be iffy on older versions.
|
||||||
# (Python 2.3? What settings?)
|
# (Python 2.3? What settings?)
|
||||||
# Cf. bug report Vimal Subra
|
# Cf. bug report Vimal Subra
|
||||||
# So for now, we just don't set it. It's not that important, and
|
self.SetBackgroundColour(wx.Colour(255,255,255))
|
||||||
# if it helps avoiding breaking the tool, then we just throw it
|
|
||||||
# out for now. This *is* a beta, remember.
|
|
||||||
#self.SetBackgroundColour(wx.Colour(255,255,255))
|
|
||||||
|
|
||||||
self.Bind(wx.EVT_SIZE, self.OnSize)
|
self.Bind(wx.EVT_SIZE, self.OnSize)
|
||||||
self.Image = wx.StaticBitmap(self, -1, wx.EmptyBitmap(1,1))
|
self.Image = wx.StaticBitmap(self, -1, wx.EmptyBitmap(1,1))
|
||||||
@ -66,15 +66,17 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
if not self.win.fit:
|
if not self.win.fit:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# This is needed, don't ask me why.
|
||||||
self.SetScrollbars(0,0,0,0,0,0)
|
self.SetScrollbars(0,0,0,0,0,0)
|
||||||
(sw,sh) = self.GetClientSizeTuple()
|
|
||||||
(W,H) = (sw,sh)
|
|
||||||
|
|
||||||
def makefit(W,H):
|
(framewidth,frameheight) = self.GetClientSizeTuple()
|
||||||
|
(virtualwidth,virtualheight) = (framewidth,frameheight)
|
||||||
|
|
||||||
|
def makefit(width,height):
|
||||||
if self.win.fit:
|
if self.win.fit:
|
||||||
# determine scaling factors for fitting
|
# determine scaling factors for fitting
|
||||||
wfactor = float(sw) / W
|
wfactor = float(framewidth) / width
|
||||||
hfactor = float(sh) / H
|
hfactor = float(frameheight) / height
|
||||||
|
|
||||||
# select smallest factor (so it will fit)
|
# select smallest factor (so it will fit)
|
||||||
if hfactor < wfactor:
|
if hfactor < wfactor:
|
||||||
@ -83,42 +85,49 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
factor = wfactor
|
factor = wfactor
|
||||||
|
|
||||||
# apply scaling factor
|
# apply scaling factor
|
||||||
W = W * factor
|
width = width * factor
|
||||||
H = H * factor
|
height = height * factor
|
||||||
return (int(W),int(H))
|
else:
|
||||||
|
factor = 1.0
|
||||||
|
|
||||||
|
return (factor, int(width), int(height))
|
||||||
|
|
||||||
if self.attack.filetype == "png":
|
if self.attack.filetype == "png":
|
||||||
bmp = self.original
|
bmp = self.original
|
||||||
if not bmp.Ok():
|
if not bmp.Ok():
|
||||||
bmp = wx.EmptyImage(1,1)
|
bmp = wx.EmptyImage(1,1)
|
||||||
else:
|
else:
|
||||||
(W,H) = (bmp.GetWidth(), bmp.GetHeight())
|
(originalwidth,originalheight) = (bmp.GetWidth(), bmp.GetHeight())
|
||||||
if self.win.fit:
|
if self.win.fit:
|
||||||
(W,H) = makefit(W,H)
|
(factor, virtualwidth, virtualheight) = makefit(originalwidth,originalheight)
|
||||||
bmp = self.original.Scale(W,H)
|
bmp = self.original.Scale(virtualwidth,virtualheight)
|
||||||
self.Image.SetBitmap(wx.BitmapFromImage(bmp))
|
self.Image.SetBitmap(wx.BitmapFromImage(bmp))
|
||||||
|
|
||||||
elif self.attack.filetype == "ps":
|
elif self.attack.filetype == "ps":
|
||||||
pil = self.original.copy()
|
pil = self.original.copy()
|
||||||
(W,H) = pil.size
|
(originalwidth,originalheight) = pil.size
|
||||||
(W,H) = makefit(W,H)
|
(factor, virtualwidth, virtualheight) = makefit(originalwidth,originalheight)
|
||||||
# we really only want antialias when it's smaller
|
# we really only want antialias when it's smaller
|
||||||
pil.thumbnail((W,H),Image.ANTIALIAS)
|
if factor < 1.0:
|
||||||
|
pil.thumbnail((virtualwidth,virtualheight),Image.ANTIALIAS)
|
||||||
|
else:
|
||||||
|
pil.thumbnail((virtualwidth,virtualheight))
|
||||||
|
|
||||||
image = wx.EmptyImage(pil.size[0],pil.size[1])
|
image = wx.EmptyImage(pil.size[0],pil.size[1])
|
||||||
image.SetData(pil.convert('RGB').tostring())
|
image.SetData(pil.convert('RGB').tostring())
|
||||||
self.Image.SetBitmap(image.ConvertToBitmap())
|
self.Image.SetBitmap(image.ConvertToBitmap())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "Unknown file type %s." % (self.attack.filetype)
|
print "Unknown file type %s." % (self.attack.filetype)
|
||||||
|
|
||||||
|
self.SetVirtualSize((virtualwidth,virtualheight))
|
||||||
|
|
||||||
#self.box.SetItemMinSize(self.Image.GetContainingSizer())
|
#self.box.SetItemMinSize(self.Image.GetContainingSizer())
|
||||||
self.box.Layout()
|
self.box.Layout()
|
||||||
|
|
||||||
# wx.StaticBitmap(self, -1, bmp, (0, 0), (bmp.GetWidth(), bmp.GetHeight()))
|
|
||||||
step = 20
|
step = 20
|
||||||
xn = int(W / step) + 1
|
xn = int(virtualwidth / step) + 1
|
||||||
yn = int(H / step) + 1
|
yn = int(virtualheight / step) + 1
|
||||||
self.SetScrollbars(step,step,xn,yn,0,0)
|
self.SetScrollbars(step,step,xn,yn,0,0)
|
||||||
|
|
||||||
self.Refresh()
|
self.Refresh()
|
||||||
@ -127,8 +136,9 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
|
|
||||||
class AttackWindow(wx.Frame):
|
class AttackWindow(wx.Frame):
|
||||||
def __init__(self,cl):
|
def __init__(self,cl):
|
||||||
super(AttackWindow, self).__init__(None, size=(400,700))
|
super(AttackWindow, self).__init__(None, size=(800,800))
|
||||||
self.SetBackgroundColour('Default')
|
# [CC][X] Same here; no background set for safety.
|
||||||
|
#self.SetBackgroundColour('Default')
|
||||||
self.claim = cl
|
self.claim = cl
|
||||||
|
|
||||||
# TODO maybe fitting defaults should come from Preferences.
|
# TODO maybe fitting defaults should come from Preferences.
|
||||||
|
@ -138,7 +138,9 @@ class AttackThread(threading.Thread):
|
|||||||
fp.write(l)
|
fp.write(l)
|
||||||
if l.startswith("digraph"):
|
if l.startswith("digraph"):
|
||||||
# Write additional stuff for this graph
|
# Write additional stuff for this graph
|
||||||
graphLine("dpi=96")
|
#
|
||||||
|
# [CC][x] This dpi setting messed up quite a bit
|
||||||
|
#graphLine("dpi=96")
|
||||||
graphLine("rankdir=TB")
|
graphLine("rankdir=TB")
|
||||||
graphLine("nodesep=0.1")
|
graphLine("nodesep=0.1")
|
||||||
graphLine("ranksep=0.001")
|
graphLine("ranksep=0.001")
|
||||||
|
Loading…
Reference in New Issue
Block a user