Enable "add currently open fit" context menu for graphs
This commit is contained in:
@@ -227,3 +227,9 @@ class CommandView(d.Display):
|
||||
continue
|
||||
commandFits.append(commandFit)
|
||||
return commandFits
|
||||
|
||||
def addFit(self, fit):
|
||||
if fit is None:
|
||||
return
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID=fitID, commandFitID=fit.ID))
|
||||
|
||||
@@ -374,3 +374,9 @@ class ProjectedView(d.Display):
|
||||
continue
|
||||
projectors.append(projector)
|
||||
return projectors
|
||||
|
||||
def addFit(self, fit):
|
||||
if fit is None:
|
||||
return
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
self.mainFrame.command.Submit(cmd.GuiAddProjectedFitCommand(fitID=fitID, projectedFitID=fit.ID, amount=1))
|
||||
|
||||
@@ -15,7 +15,10 @@ class AddCurrentlyOpenFit(ContextMenuUnconditional):
|
||||
|
||||
def display(self, callingWindow, srcContext):
|
||||
|
||||
if self.mainFrame.getActiveFit() is None or srcContext not in ('projected', 'commandView'):
|
||||
if srcContext not in ('projected', 'commandView', 'graphFitList', 'graphTgtList'):
|
||||
return False
|
||||
|
||||
if srcContext in ('projected', 'commandView') and self.mainFrame.getActiveFit() is None:
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -26,6 +29,7 @@ class AddCurrentlyOpenFit(ContextMenuUnconditional):
|
||||
def getSubMenu(self, callingWindow, context, rootMenu, i, pitem):
|
||||
self.fitLookup = {}
|
||||
self.context = context
|
||||
self.callingWindow = callingWindow
|
||||
sFit = Fit.getInstance()
|
||||
|
||||
m = wx.Menu()
|
||||
@@ -50,14 +54,8 @@ class AddCurrentlyOpenFit(ContextMenuUnconditional):
|
||||
return m
|
||||
|
||||
def handleSelection(self, event):
|
||||
fitID = self.mainFrame.getActiveFit()
|
||||
|
||||
fit = self.fitLookup[event.Id]
|
||||
|
||||
if self.context == 'commandView':
|
||||
self.mainFrame.command.Submit(cmd.GuiAddCommandFitCommand(fitID=fitID, commandFitID=fit.ID))
|
||||
elif self.context == 'projected':
|
||||
self.mainFrame.command.Submit(cmd.GuiAddProjectedFitCommand(fitID=fitID, projectedFitID=fit.ID, amount=1))
|
||||
self.callingWindow.addFit(fit)
|
||||
|
||||
|
||||
AddCurrentlyOpenFit.register()
|
||||
|
||||
@@ -166,6 +166,15 @@ class BaseList(gui.display.Display):
|
||||
self.graphFrame.mainFrame.Unbind(EVT_FIT_RENAMED, handler=self.OnFitRenamed)
|
||||
self.graphFrame.mainFrame.Unbind(GE.FIT_REMOVED, handler=self.OnFitRemoved)
|
||||
|
||||
# Context menu handlers
|
||||
def addFit(self, fit):
|
||||
if fit is None:
|
||||
return
|
||||
if fit in self.fits:
|
||||
return
|
||||
self.fits.append(fit)
|
||||
self.updateView()
|
||||
self.graphFrame.draw()
|
||||
|
||||
class FitList(BaseList):
|
||||
|
||||
@@ -224,7 +233,7 @@ class TargetList(BaseList):
|
||||
|
||||
def __init__(self, graphFrame, parent):
|
||||
super().__init__(graphFrame, parent)
|
||||
|
||||
|
||||
self.Bind(wx.EVT_CONTEXT_MENU, self.spawnMenu)
|
||||
|
||||
self.profiles = []
|
||||
|
||||
Reference in New Issue
Block a user