From 2c1905f04112ca5a73947690dd12248a642f1df6 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Thu, 20 Jun 2019 00:02:02 +0300 Subject: [PATCH] Add vectors to panel (not yet functional) --- gui/graphFrame/panel.py | 7 ++++++- gui/graphFrame/vector.py | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gui/graphFrame/panel.py b/gui/graphFrame/panel.py index 3e9c46c2b..a28f95e3f 100644 --- a/gui/graphFrame/panel.py +++ b/gui/graphFrame/panel.py @@ -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() diff --git a/gui/graphFrame/vector.py b/gui/graphFrame/vector.py index ba99a3cda..b93ab68f9 100644 --- a/gui/graphFrame/vector.py +++ b/gui/graphFrame/vector.py @@ -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