Restore values for vectors (just in case!)

This commit is contained in:
DarkPhoenix
2019-06-26 20:06:51 +03:00
parent b733205541
commit 5320e99276

View File

@@ -173,16 +173,28 @@ class GraphControlPanel(wx.Panel):
self.inputs[(inputDef.handle, inputDef.unit)] = (fieldTextBox, fieldIcon, fieldLabel) self.inputs[(inputDef.handle, inputDef.unit)] = (fieldTextBox, fieldIcon, fieldLabel)
self.inputsSizer.Add(fieldSizer, 0, wx.EXPAND | wx.BOTTOM, 5) self.inputsSizer.Add(fieldSizer, 0, wx.EXPAND | wx.BOTTOM, 5)
def handleVector(vectorDef, vector, handledHandles):
handledHandles.add(vectorDef.lengthHandle)
handledHandles.add(vectorDef.angleHandle)
try:
storedLength = self._storedConsts[(vectorDef.lengthHandle, vectorDef.lengthUnit)]
except KeyError:
pass
else:
vector.SetLength(storedLength / 100)
try:
storedAngle = self._storedConsts[(vectorDef.angleHandle, vectorDef.angleUnit)]
except KeyError:
pass
else:
vector.SetAngle(storedAngle)
view = self.graphFrame.getView() view = self.graphFrame.getView()
handledHandles = set() handledHandles = set()
srcVectorDef = view.srcVectorDef if view.srcVectorDef is not None:
if srcVectorDef is not None: handleVector(view.srcVectorDef, self.srcVector, handledHandles)
handledHandles.add(srcVectorDef.lengthHandle) if view.tgtVectorDef is not None:
handledHandles.add(srcVectorDef.angleHandle) handleVector(view.tgtVectorDef, self.tgtVector, handledHandles)
tgtVectorDef = view.tgtVectorDef
if tgtVectorDef is not None:
handledHandles.add(tgtVectorDef.lengthHandle)
handledHandles.add(tgtVectorDef.angleHandle)
selectedX = view.xDefMap[self.xType] selectedX = view.xDefMap[self.xType]
# Always add main input # Always add main input
addInputField(view.inputMap[selectedX.mainInput], handledHandles, mainInput=True) addInputField(view.inputMap[selectedX.mainInput], handledHandles, mainInput=True)