Add vectors to panel (not yet functional)

This commit is contained in:
DarkPhoenix
2019-06-20 00:02:02 +03:00
parent 30d03f0ab5
commit 2c1905f041
2 changed files with 9 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ import wx
from gui.bitmap_loader import BitmapLoader
from service.fit import Fit
from .lists import FitList, TargetList
from .vector import VectorPicker
class GraphControlPanel(wx.Panel):
@@ -56,6 +57,10 @@ class GraphControlPanel(wx.Panel):
self.fitList = FitList(graphFrame, self)
self.fitList.SetMinSize((270, -1))
srcTgtSizer.Add(self.fitList, 1, wx.EXPAND)
self.srcVector = VectorPicker(self, style=wx.NO_BORDER, size=60, offset=90, label='Src', labelpos=2)
srcTgtSizer.Add(self.srcVector, flag=wx.SHAPED | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
self.tgtVector = VectorPicker(self, style=wx.NO_BORDER, size=60, offset=-90, label='Tgt', labelpos=3)
srcTgtSizer.Add(self.tgtVector, flag=wx.SHAPED | wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
self.targets = []
self.targetList = TargetList(graphFrame, self)
self.targetList.SetMinSize((270, -1))
@@ -83,7 +88,7 @@ class GraphControlPanel(wx.Panel):
self.graphSubselSizer.Clear()
self.inputsSizer.Clear()
for child in self.Children:
if child not in (self.showY0Cb, self.fitList, self.targetList):
if child not in (self.showY0Cb, self.fitList, self.targetList, self.srcVector, self.tgtVector):
child.Destroy()
self.fields.clear()

View File

@@ -24,7 +24,7 @@ import math
import wx
class VectorPicker(wx.Control):
class VectorPicker(wx.Window):
myEVT_VECTOR_CHANGED = wx.NewEventType()
EVT_VECTOR_CHANGED = wx.PyEventBinder(myEVT_VECTOR_CHANGED, 1)
@@ -35,7 +35,7 @@ class VectorPicker(wx.Control):
self._offset = float(kwargs.pop('offset', 0))
self._size = max(0, float(kwargs.pop('size', 50)))
self._fontsize = max(1, float(kwargs.pop('fontsize', 8)))
wx.Control.__init__(self, *args, **kwargs)
wx.Window.__init__(self, *args, **kwargs)
self._font = wx.Font(self._fontsize, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
self._angle = 0
self._length = 1
@@ -183,7 +183,7 @@ class VectorPicker(wx.Control):
width, height = self.GetClientSize()
if width and height:
center = min(width, height) / 2
x, y = event.GetPositionTuple()
x, y = event.GetPosition()
x = x - center
y = center - y
angle = self._angle