From c97750a5939e28878bce41e99fb9360a95bf34c7 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Sat, 24 Nov 2018 21:38:50 -0500 Subject: [PATCH 1/2] Attempt to save the charge when changing module variations. Move caching of old module into Do function. Having it in `change_module` causes it to run even with the Undo command, whch causes funkiness --- gui/fitCommands/calc/fitReplaceModule.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gui/fitCommands/calc/fitReplaceModule.py b/gui/fitCommands/calc/fitReplaceModule.py index 19674df80..b7edf21b4 100644 --- a/gui/fitCommands/calc/fitReplaceModule.py +++ b/gui/fitCommands/calc/fitReplaceModule.py @@ -23,6 +23,13 @@ class FitReplaceModuleCommand(wx.Command): self.old_module = None def Do(self): + fit = eos.db.getFit(self.fitID) + + mod = fit.modules[self.position] + if not mod.isEmpty: + self.old_module = ModuleInfoCache(mod.modPosition, mod.item.ID, mod.state, mod.charge, mod.baseItemID, + mod.mutaplasmidID) + return self.change_module(self.fitID, self.position, self.itemID) def Undo(self): @@ -30,7 +37,6 @@ class FitReplaceModuleCommand(wx.Command): fit = eos.db.getFit(self.fitID) fit.modules.toDummy(self.position) return True - self.change_module(self.fitID, self.position, self.old_module.itemID) self.module.state = self.old_module.state self.module.charge = self.old_module.charge @@ -52,10 +58,7 @@ class FitReplaceModuleCommand(wx.Command): pyfalog.debug("Changing position of module from position ({0}) for fit ID: {1}", self.position, fitID) item = eos.db.getItem(itemID, eager=("attributes", "group.category")) - mod = fit.modules[self.position] - if not mod.isEmpty: - self.old_module = ModuleInfoCache(mod.modPosition, mod.item.ID, mod.state, mod.charge, mod.baseItemID, mod.mutaplasmidID) try: self.module = Module(item) @@ -75,6 +78,9 @@ class FitReplaceModuleCommand(wx.Command): if self.module.isValidState(State.ACTIVE): self.module.state = State.ACTIVE + if self.old_module.charge and self.module.isValidCharge(self.old_module.charge): + self.module.charge = self.old_module.charge + # Then, check states of all modules and change where needed. This will recalc if needed # self.checkStates(fit, m) From 9e08783802988674daeb2386de064b8601759156 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Sun, 25 Nov 2018 15:12:12 -0500 Subject: [PATCH 2/2] Add middle click to close fitting tab (#1804) --- gui/chrome_tabs.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gui/chrome_tabs.py b/gui/chrome_tabs.py index b50073565..66c1c262e 100644 --- a/gui/chrome_tabs.py +++ b/gui/chrome_tabs.py @@ -736,6 +736,7 @@ class _TabsContainer(wx.Panel): self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnErase) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) + self.Bind(wx.EVT_MIDDLE_UP, self.OnMiddleUp) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_SYS_COLOUR_CHANGED, self.OnSysColourChanged) @@ -776,6 +777,29 @@ class _TabsContainer(wx.Panel): self.dragged_tab = tab + def OnMiddleUp(self, event): + mposx, mposy = event.GetPosition() + + tab = self.FindTabAtPos(mposx, mposy) + + if tab is None or not tab.closeable: # if not able to close, return False + return False + + index = self.tabs.index(tab) + ev = PageClosing(index) + wx.PostEvent(self.Parent, ev) + + if ev.isVetoed(): + return False + + index = self.GetTabIndex(tab) + self.Parent.DeletePage(index) + wx.PostEvent(self.Parent, PageClosed(index=index)) + + sel = self.GetSelected() + if sel is not None: + wx.PostEvent(self.Parent, PageChanged(-1, sel)) + def OnMotion(self, event): """ Determines what happens when the mouse moves. This handles primarily