Implement method which gathers values across control panel boxes

This commit is contained in:
DarkPhoenix
2019-06-26 16:50:54 +03:00
parent ee4a1f936b
commit 22ca78cb68
3 changed files with 28 additions and 7 deletions

View File

@@ -178,7 +178,8 @@ class GraphFrame(wx.Frame):
return self.graphSelection.GetClientData(self.graphSelection.GetSelection())
def clearCache(self, key=None):
self.getView().clearCache(key=key)
pass
#self.getView().clearCache(key=key)
def draw(self):
global mpl_version
@@ -188,7 +189,7 @@ class GraphFrame(wx.Frame):
if not self:
pyfalog.warning('GraphFrame handled event, however GraphFrame no longer exists. Ignoring event')
return
self.ctrlPanel.getValues()
# values = self.ctrlPanel.getValues()
# view = self.getView()
# self.subplot.clear()

View File

@@ -18,10 +18,10 @@
# =============================================================================
import wx
import re
import wx
def valToStr(val):
if val is None:
@@ -83,7 +83,7 @@ class RangeBox(wx.TextCtrl):
if currentValue == self._storedValue:
event.Skip()
return
if currentValue == '' or re.match('^\d*\.?\d*\-?\d*\.?\d*$', currentValue):
if currentValue == '' or re.match('^\d*\.?\d*-?\d*\.?\d*$', currentValue):
self._storedValue = currentValue
event.Skip()
else:

View File

@@ -214,11 +214,31 @@ class GraphControlPanel(wx.Panel):
def OnDrawTimer(self, event):
event.Skip()
# self.graphFrame.clearCache()
# self.graphFrame.draw()
self.graphFrame.clearCache()
self.graphFrame.draw()
def getValues(self):
view = self.graphFrame.getView()
values = {}
# Vectors
srcVectorDef = view.srcVectorDef
if srcVectorDef is not None:
if not self.srcVector.IsDirectionOnly:
values[srcVectorDef.lengthHandle] = (self.srcVector.GetLength() * 100, srcVectorDef.lengthUnit)
values[srcVectorDef.angleHandle] = (self.srcVector.GetAngle(), srcVectorDef.angleUnit)
tgtVectorDef = view.tgtVectorDef
if tgtVectorDef is not None:
if not self.tgtVector.IsDirectionOnly:
values[tgtVectorDef.lengthHandle] = (self.tgtVector.GetLength() * 100, tgtVectorDef.lengthUnit)
values[tgtVectorDef.angleHandle] = (self.tgtVector.GetAngle(), srcVectorDef.angleUnit)
# Input boxes which were set up overwrite values if needed
for k, v in self.inputs.items():
inputHandle, inputUnit = k
inputBox = v[0]
if isinstance(inputBox, RangeBox):
values[inputHandle] = (inputBox.GetValueRange(), inputUnit)
elif isinstance(inputBox, ConstantBox):
values[inputHandle] = (inputBox.GetValueFloat(), inputUnit)
return values
@property