def OnEndDrag(self, node, event): """Copy layer into target""" self.copy_mode = wx.GetMouseState().ControlDown() if node: self.DefineItems([node]) if self._restricted and gisenv( )['MAPSET'] != self.selected_mapset[0].label: GMessage(_( "To move or copy maps to other mapsets, unlock editing of other mapsets" ), parent=self) event.Veto() return event.Allow() Debug.msg(1, "DROP DONE") self.OnPasteMap(event)
def OnKeyUp(self, evt): if self.tabSwitchByKey == 0: evt.Skip() return # For Linux the test must be done this way. # Meta is always reported as pressed (at least for PC), so ignore it mstate = wx.GetMouseState() if mstate.ControlDown() or mstate.ShiftDown() or mstate.AltDown() or \ mstate.CmdDown(): # Some modifier keys are pressed yet evt.Skip() return self.tabSwitchByKey = 0 self._mruTabIndexPushToTop(self.GetSelection()) self.presenters[self.GetSelection()].SetFocus()
def on_mouse_move(self, event): """Get mouse position when moving""" ms = wx.GetMouseState() self.box_dirty = False if ms.leftIsDown: self.zoom.set_mouse_diff(event.xdata, event.ydata) self.do_plot(event) else: self.zoom.set_mouse_diff_zero() if self.zoom.check_none(event.xdata, event.ydata): if self.zoom.zoom_box_enabled: self.panel.SetCursor(wx.StockCursor(wx.CURSOR_CROSS)) else: self.panel.SetCursor(wx.StockCursor(wx.CURSOR_HAND)) else: self.panel.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
def ensureSelection(self, clickedPos): """ On windows with Ctrl is pressed, or on Mac, when right-click on any item happens, the item doesn't get selected. This method ensures that only clicked item is selected. """ if ('wxMac' in wx.PlatformInfo or ('wxMSW' in wx.PlatformInfo and wx.GetMouseState().GetModifiers() == wx.MOD_CONTROL)): if clickedPos != -1: selectedPoss = self.getSelectedRows() if clickedPos not in selectedPoss: self.unselectAll() self.Select(clickedPos) # Change focus only when we manipulate selection focusedPos = self.GetFocusedItem() if clickedPos != focusedPos: self.Focus(clickedPos)
def MouseMotion(self, evt): state = wx.GetMouseState() x, y = evt.GetPosition() [lastX, lastY] = self.MousePos self.handleMouseStuff(x, y) dX = self.MousePos[0] - lastX dY = self.MousePos[1] - lastY if evt.Dragging(): #Translate/rotate shape if evt.MiddleIsDown(): self.camera.translate(dX, dY) elif evt.RightIsDown(): self.camera.zoom(-dY) #Want to zoom in as the mouse goes up elif evt.LeftIsDown(): self.camera.orbitLeftRight(dX) self.camera.orbitUpDown(dY) self.Refresh()
def on_down(self, event): if paint.pipette_on: self.Refresh() event.Skip() elif paint.fill_on: self.fill_process() event.Skip() elif paint.shape_on: ms = wx.GetMouseState() client_coord = self.ScreenToClient(ms.GetX(), ms.GetY()) client_coord_scaled = (int(client_coord[0]), int(client_coord[1])) self.starting_point = client_coord_scaled self.t_shape.Start(1) event.Skip() else: self.t.Start(1) event.Skip()
def addModule(self, x, y, srcIdx): '''Add a module from the market browser''' mstate = wx.GetMouseState() dstRow, _ = self.HitTest((x, y)) if dstRow != -1 and dstRow not in self.blanks: sFit = service.Fit.getInstance() fitID = self.mainFrame.getActiveFit() moduleChanged = sFit.changeModule(fitID, self.mods[dstRow].position, srcIdx) if moduleChanged is None: # the new module doesn't fit in specified slot, try to simply append it wx.PostEvent(self.mainFrame, gui.marketBrowser.ItemSelected(itemID=srcIdx)) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit()))
def addItem(self, event): item = Market.getInstance().getItem(event.itemID, eager='group.category') if item is None or not item.isDrone: event.Skip() return fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if not fit or fit.isStructure: event.Skip() return amount = droneStackLimit(fit, event.itemID) if wx.GetMouseState().GetModifiers() == wx.MOD_ALT else 1 if self.mainFrame.command.Submit(cmd.GuiAddLocalDroneCommand(fitID=fitID, itemID=event.itemID, amount=amount)): self.mainFrame.additionsPane.select('Drones') event.Skip()
def handleAmmoSwitch(self, event): charge = self.chargeIds.get(event.Id, False) if charge is False: event.Skip() return fitID = self.mainFrame.getActiveFit() sFit = Fit.getInstance() fit = sFit.getFit(fitID) mstate = wx.GetMouseState() # Switch in selection or all modules, depending on modifier key state and settings switchAll = sFit.serviceFittingOptions['ammoChangeAll'] is not (mstate.GetModifiers() in (wx.MOD_ALT, wx.MOD_CONTROL)) if switchAll: if self.srcContext == 'fittingModule': command = cmd.GuiChangeLocalModuleChargesCommand modContainer = fit.modules elif self.srcContext == 'projectedModule': command = cmd.GuiChangeProjectedModuleChargesCommand modContainer = fit.projectedModules else: return positions = getSimilarModPositions(modContainer, self.module) self.mainFrame.command.Submit(command( fitID=fitID, positions=positions, chargeItemID=charge.ID if charge is not None else None)) else: if self.srcContext == 'fittingModule': command = cmd.GuiChangeLocalModuleChargesCommand modContainer = fit.modules elif self.srcContext == 'projectedModule': command = cmd.GuiChangeProjectedModuleChargesCommand modContainer = fit.projectedModules else: return positions = [] for position, mod in enumerate(modContainer): if mod in self.selection: modCharges = self.getChargesForMod(mod) if modCharges.issubset(self.mainCharges): positions.append(position) self.mainFrame.command.Submit(command( fitID=fitID, positions=positions, chargeItemID=charge.ID if charge is not None else None))
def OnRightDown(self, evt): self.SetFocus() for t in self.getActiveTrajectories(): if t.getInsideRect(evt.GetPosition()): t.clear() if len(self.getActiveTrajectories()) > 0: self.setSelected(self.getActiveTrajectories()[0]) else: self.setSelected(self.getTrajectory(0)) self.needBitmap = True self.Refresh() return mouseState = wx.GetMouseState() mousePos = (mouseState.GetX(), mouseState.GetY()) for fxball in self.fxballs.values(): if fxball.getInside(evt.GetPosition(), small=True): fxball.openControls(mousePos) return
def deleteBtnCB(self): if self.tcFitName.IsShown(): self.RestoreEditButton() return # to prevent accidental deletion, give dialog confirmation unless shift is depressed mstate = wx.GetMouseState() if mstate.GetModifiers() == wx.MOD_SHIFT or mstate.MiddleIsDown(): self.deleteFit() else: dlg = wx.MessageDialog(self, "Do you really want to delete this fit?", "Confirm Delete", wx.YES | wx.NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.deleteFit() else: dlg.Destroy()
def toggleMetaButton(self, event): """Process clicks on toggle buttons""" clickedBtn = event.EventObject if wx.GetMouseState().GetModifiers() == wx.MOD_CONTROL: activeBtns = [btn for btn in self.metaButtons if btn.GetValue()] if activeBtns: clickedBtn.setUserSelection(clickedBtn.GetValue()) self.itemView.filterItemStore() else: # Do 'nothing' if we're trying to turn last active button off # Keep button in the same state clickedBtn.setUserSelection(True) else: for btn in self.metaButtons: btn.setUserSelection(btn == clickedBtn) self.itemView.filterItemStore()
def swapCargo(self, x, y, cargoItemID): """Swap a module from cargo to fitting window""" dstRow, _ = self.HitTest((x, y)) if dstRow != -1 and dstRow not in self.blanks: mod = self.mods[dstRow] if not isinstance(mod, Module): return fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if mod in fit.modules: position = fit.modules.index(mod) self.mainFrame.command.Submit(cmd.GuiCargoToLocalModuleCommand( fitID=fitID, cargoItemID=cargoItemID, modPosition=position, copy=wx.GetMouseState().GetModifiers() == wx.MOD_CONTROL))
def Notify(self): ui = self.ui control = ui.control if ui.control is None: # Looks like someone forgot to tell us that the ui has been closed: self.Stop() return mx, my = wx.GetMousePosition() cx, cy = control.ClientToScreenXY(0, 0) cdx, cdy = control.GetSizeTuple() if self.is_activated: # Don't close the popup if any mouse buttons are currently pressed: ms = wx.GetMouseState() if ms.LeftIsDown() or ms.MiddleIsDown() or ms.RightIsDown(): return # Check for the special case of the mouse pointer having to be # within the original bounds of the object the popup was created # for: if self.is_info: parent = control.GetParent() if isinstance(parent, wx.Window): px, py, pdx, pdy = parent.GetScreenRect() else: px, py, pdx, pdy = control._control_region if ((mx < px) or (mx >= (px + pdx)) or (my < py) or (my >= (py + pdy))): ui.owner.close_popup() self.is_activated = False else: # Allow for a 'dead zone' border around the window to allow for # small motor control problems: border = self.border if ((mx < (cx - border)) or (mx >= (cx + cdx + border)) or (my < (cy - border)) or (my >= (cy + cdy + border))): ui.owner.close_popup() self.is_activated = False elif (cx <= mx < (cx + cdx)) and (cy <= my < (cy + cdy)): self.is_activated = True
def swapModule(self, x, y, modIdx): """Swap a module from fitting window with cargo""" sFit = Fit.getInstance() fit = sFit.getFit(self.mainFrame.getActiveFit()) dstRow, _ = self.HitTest((x, y)) if dstRow > -1: try: dstCargoItemID = getattr(self.cargo[dstRow], 'itemID', None) except IndexError: dstCargoItemID = None else: dstCargoItemID = None self.mainFrame.command.Submit(cmd.GuiLocalModuleToCargoCommand( fitID=self.mainFrame.getActiveFit(), modPosition=modIdx, cargoItemID=dstCargoItemID, copy=wx.GetMouseState().GetModifiers() == wx.MOD_CONTROL))
def swapCargo(self, x, y, srcIdx): """Swap a module from cargo to fitting window""" mstate = wx.GetMouseState() dstRow, _ = self.HitTest((x, y)) if dstRow != -1 and dstRow not in self.blanks: module = self.mods[dstRow] if not isinstance(module, Module): return sFit = Fit.getInstance() fit = sFit.getFit(self.activeFitID) typeID = fit.cargo[srcIdx].item.ID sFit.moveCargoToModule(self.mainFrame.getActiveFit(), module.modPosition, srcIdx, mstate.CmdDown() and module.isEmpty) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit(), action="modadd", typeID=typeID))
def __handleProjectedModule(self, varItem): fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: positions = getSimilarModPositions(fit.projectedModules, self.mainItem) else: sMkt = Market.getInstance() positions = [] for mod in self.selection: if mod is self.mainItem: positions.append(fit.projectedModules.index(mod)) continue if mod not in fit.projectedModules: continue modVariations = sMkt.getVariationsByItems((mod.item,)) if modVariations == self.mainVariations: positions.append(fit.projectedModules.index(mod)) self.mainFrame.command.Submit(cmd.GuiChangeProjectedModuleMetasCommand( fitID=fitID, positions=positions, newItemID=varItem.ID))
def fitSelected(self, event): count = -1 # @todo pheonix: _pages is supposed to be private? for index, page in enumerate(self.multiSwitch._pages): if not isinstance( page, gui.builtinViews.emptyView.BlankPage ): # Don't try and process it if it's a blank page. try: if page.activeFitID == event.fitID: count += 1 self.multiSwitch.SetSelection(index) wx.PostEvent(self.mainFrame, GE.FitChanged(fitIDs=(event.fitID, ))) break except (KeyboardInterrupt, SystemExit): raise except Exception as e: pyfalog.critical("Caught exception in fitSelected") pyfalog.critical(e) if count < 0: startup = getattr(event, "startup", False) # see OpenFitsThread in gui.mainFrame from_import = getattr(event, "from_import", False) # always open imported into a new tab sFit = Fit.getInstance() openFitInNew = sFit.serviceFittingOptions["openFitInNew"] mstate = wx.GetMouseState() modifierKey = mstate.GetModifiers() == wx.MOD_CONTROL if from_import or (not openFitInNew and modifierKey) or startup or ( openFitInNew and not modifierKey): self.multiSwitch.AddPage() view = self.multiSwitch.GetSelectedPage() if not isinstance(view, FittingView): view = FittingView(self.multiSwitch) pyfalog.debug("###################### Created new view:" + repr(view)) self.multiSwitch.ReplaceActivePage(view) view.fitSelected(event)
def swapModule(self, x, y, modIdx): """Swap a module from fitting window with cargo""" sFit = Fit.getInstance() fit = sFit.getFit(self.mainFrame.getActiveFit()) dstRow, _ = self.HitTest((x, y)) mstate = wx.GetMouseState() # Gather module information to get position module = fit.modules[modIdx] if module.item.isAbyssal: dlg = wx.MessageDialog( self, "Moving this Abyssal module to the cargo will convert it to the base module. Do you wish to proceed?", "Confirm", wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() == wx.ID_YES if not result: return if dstRow != -1: # we're swapping with cargo if mstate.cmdDown: # if copying, append to cargo sFit.addCargo( self.mainFrame.getActiveFit(), module.item.ID if not module.item.isAbyssal else module.baseItemID) else: # else, move / swap sFit.moveCargoToModule(self.mainFrame.getActiveFit(), module.position, dstRow) else: # dragging to blank spot, append sFit.addCargo( self.mainFrame.getActiveFit(), module.item.ID if not module.item.isAbyssal else module.baseItemID) if not mstate.cmdDown: # if not copying, remove module sFit.removeModule(self.mainFrame.getActiveFit(), module.position) wx.PostEvent( self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit(), action="moddel", typeID=module.item.ID))
def on_right_click(self, event): """Show a menu when the user presses the mouse right button This method takes a single argument: event the event.""" # If the left or middle button are down, don't show the context # menu. LeftIsDown and MiddleIsDown are only available for wx # versions 2.9 and later. mouse_state = wx.GetMouseState() try: if mouse_state.LeftIsDown() or mouse_state.MiddleIsDown(): return except AttributeError: if mouse_state.LeftDown() or mouse_state.MiddleDown(): return self.SetGridCursor(event.GetRow(), event.GetCol()) self.show_context_menu()
def fill_process(self): ms = wx.GetMouseState() client_coord = self.CalcUnscrolledPosition( self.ScreenToClient(ms.GetX(), ms.GetY())) client_coord_scaled = (int(client_coord[0] / self.user_scale), int(client_coord[1] / self.user_scale)) dc = wx.BufferedDC(None, self.buffer) dc.SetBrush(wx.Brush(self.color, wx.BRUSHSTYLE_SOLID)) pixel_color = dc.GetPixel(client_coord_scaled[0], client_coord_scaled[1]) dc.FloodFill(client_coord_scaled[0], client_coord_scaled[1], pixel_color, wx.FLOOD_SURFACE) buffer_image = self.buffer.ConvertToImage() buffer_image.Rescale(self.size[0] * self.user_scale, self.size[1] * self.user_scale, wx.IMAGE_QUALITY_NORMAL) self.front_buffer = buffer_image.ConvertToBitmap(-1) self.Refresh()
def __handleProjectedFighter(self, varItem): fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if wx.GetMouseState().GetModifiers() == wx.MOD_ALT: fighters = getSimilarFighters(fit.projectedFighters, self.mainItem) else: fighters = self.selection sMkt = Market.getInstance() positions = [] for fighter in fighters: if fighter not in fit.projectedFighters: continue if fighter is self.mainItem: positions.append(fit.projectedFighters.index(fighter)) continue fighterVariations = sMkt.getVariationsByItems((fighter.item,)) if fighterVariations == self.mainVariations: positions.append(fit.projectedFighters.index(fighter)) self.mainFrame.command.Submit(cmd.GuiChangeProjectedFighterMetasCommand( fitID=fitID, positions=positions, newItemID=varItem.ID))
def MouseMotion(self, evt): state = wx.GetMouseState() x, y = evt.GetPosition() [lastX, lastY] = self.MousePos self.handleMouseStuff(x, y) dX = self.MousePos[0] - lastX dY = self.MousePos[1] - lastY if evt.Dragging(): idx = self.laplaceCurrentIdx if self.GUIState == STATE_CHOOSELAPLACEVERTICES and ( state.CmdDown() or self.pressingC ) and self.laplaceCurrentIdx in self.laplacianConstraints: #Move up laplacian mesh constraint based on where the user drags #the mouse t = self.camera.towards u = self.camera.up r = np.cross(t, u) P0 = self.laplacianConstraints[idx] #Construct a plane going through the point which is parallel to the #viewing plane plane = Plane3D(P0, t) #Construct a ray through the pixel where the user is clicking tanFOV = math.tan(self.camera.yfov / 2) scaleX = tanFOV * (self.MousePos[0] - self.size.x / 2) / (self.size.x / 2) scaleY = tanFOV * (self.MousePos[1] - self.size.y / 2) / (self.size.y / 2) V = t + scaleX * r + scaleY * u ray = Ray3D(self.camera.eye, V) self.laplacianConstraints[idx] = ray.intersectPlane(plane)[1] else: #Translate/rotate shape if evt.MiddleIsDown(): self.camera.translate(dX, dY) elif evt.RightIsDown(): self.camera.zoom( -dY) #Want to zoom in as the mouse goes up elif evt.LeftIsDown(): self.camera.orbitLeftRight(dX) self.camera.orbitUpDown(dY) self.Refresh()
def OnEndDrag(self, node, event): """Copy layer into target""" if not wx.GetMouseState().ControlDown(): GMessage(_("Moving maps not implemented"), parent=self) event.Veto() return if node: self.DefineItems(node) if self._restricted and gisenv( )['MAPSET'] != self.selected_mapset.label: GMessage(_("Maps can be copied only to current mapset"), parent=self) event.Veto() return if self.selected_location == self.copy_location and self.selected_mapset: event.Allow() self.OnPasteMap(event) Debug.msg(1, "DROP DONE") else: event.Veto()
def swapItems(self, x, y, srcIdx): """Swap two modules in fitting window""" mstate = wx.GetMouseState() sFit = Fit.getInstance() fit = sFit.getFit(self.activeFitID) if mstate.CmdDown(): clone = True else: clone = False dstRow, _ = self.HitTest((x, y)) if dstRow != -1 and dstRow not in self.blanks: mod1 = fit.modules[srcIdx] mod2 = self.mods[dstRow] if not isinstance(mod2, Module): return # can't swap modules to different racks if mod1.slot != mod2.slot: return if getattr(mod2, "modPosition") is not None: if clone and mod2.isEmpty and mod1.getModifiedItemAttr( "maxGroupFitted", 0) < 1.0: sFit.cloneModule(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition) else: sFit.swapModules(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition) wx.PostEvent( self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit())) else: pyfalog.error("Missing module position for: {0}", str(getattr(mod2, "ID", "Unknown")))
def activate(self, callingWindow, fullContext, mainItem, selection, i): fitID = self.mainFrame.getActiveFit() if isinstance(mainItem, EosFit): try: value = mainItem.getProjectionInfo(fitID).projectionRange except AttributeError: return else: value = mainItem.projectionRange if value is not None: value /= 1000 with RangeChanger(self.mainFrame, value) as dlg: if dlg.ShowModal() == wx.ID_OK: cleanInput = re.sub(r'[^0-9.]', '', dlg.input.GetLineText(0).strip()) if cleanInput: try: cleanInputFloat = float(cleanInput) except ValueError: return newRange = cleanInputFloat * 1000 else: newRange = None fitID = self.mainFrame.getActiveFit() items = selection if wx.GetMouseState().GetModifiers() in (wx.MOD_ALT, wx.MOD_CONTROL): if isinstance(mainItem, EosModule): fit = Fit.getInstance().getFit(fitID) positions = getSimilarModPositions( fit.projectedModules, mainItem) items = [fit.projectedModules[p] for p in positions] elif isinstance(mainItem, EosFighter): fit = Fit.getInstance().getFit(fitID) items = getSimilarFighters(fit.projectedFighters, mainItem) self.mainFrame.command.Submit( cmd.GuiChangeProjectedItemsProjectionRangeCommand( fitID=fitID, items=items, projectionRange=newRange))
def swapModule(self, x, y, modIdx): """Swap a module from fitting window with cargo""" sFit = Fit.getInstance() fit = sFit.getFit(self.mainFrame.getActiveFit()) dstRow, _ = self.HitTest((x, y)) mstate = wx.GetMouseState() # Gather module information to get position module = fit.modules[modIdx] if dstRow != -1: # we're swapping with cargo if mstate.CmdDown(): # if copying, append to cargo sFit.addCargo(self.mainFrame.getActiveFit(), module.item.ID) else: # else, move / swap sFit.moveCargoToModule(self.mainFrame.getActiveFit(), module.position, dstRow) else: # dragging to blank spot, append sFit.addCargo(self.mainFrame.getActiveFit(), module.item.ID) if not mstate.CmdDown(): # if not copying, remove module sFit.removeModule(self.mainFrame.getActiveFit(), module.position) wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.mainFrame.getActiveFit(), action="moddel", typeID=module.item.ID))
def appendItem(self, event): """ Adds items that are double clicks from the market browser. We handle both modules and ammo """ if not self: event.Skip() return if self.parent.IsActive(self): itemID = event.itemID fitID = self.activeFitID if fitID is not None: item = Market.getInstance().getItem(itemID, eager='group.category') if item is None: event.Skip() return batchOp = wx.GetMouseState().GetModifiers() == wx.MOD_ALT and getattr(event, 'allowBatch', None) is not False if (item.isModule and not batchOp) or item.isSubsystem: self.mainFrame.command.Submit(cmd.GuiAddLocalModuleCommand(fitID=fitID, itemID=itemID)) elif item.isModule and batchOp: self.mainFrame.command.Submit(cmd.GuiFillWithNewLocalModulesCommand(fitID=fitID, itemID=itemID)) event.Skip()
def swapItems(self, x, y, srcIdx): """Swap two modules in fitting window""" sFit = Fit.getInstance() fit = sFit.getFit(self.activeFitID) dstRow, _ = self.HitTest((x, y)) if dstRow != -1 and dstRow not in self.blanks: try: mod1 = fit.modules[srcIdx] mod2 = self.mods[dstRow] except IndexError: return if not isinstance(mod2, Module): return # can't swap modules to different racks if mod1.slot != mod2.slot: return if mod2 not in fit.modules: pyfalog.error("Missing module position for: {0}", str(getattr(mod2, "ID", "Unknown"))) return mod2Position = fit.modules.index(mod2) mstate = wx.GetMouseState() if mstate.GetModifiers() == wx.MOD_CONTROL | wx.MOD_ALT: self.mainFrame.command.Submit( cmd.GuiFillWithClonedLocalModulesCommand( fitID=self.activeFitID, position=srcIdx)) elif mstate.GetModifiers() == wx.MOD_CONTROL and mod2.isEmpty: self.mainFrame.command.Submit( cmd.GuiCloneLocalModuleCommand(fitID=self.activeFitID, srcPosition=srcIdx, dstPosition=mod2Position)) elif mstate.GetModifiers() == wx.MOD_NONE: self.mainFrame.command.Submit( cmd.GuiSwapLocalModulesCommand(fitID=self.activeFitID, position1=srcIdx, position2=mod2Position))
def appendItem(self, event): """ Adds items that are double clicks from the market browser. We handle both modules and ammo """ if not self: event.Skip() return if self.parent.IsActive(self): itemID = event.itemID fitID = self.activeFitID if fitID is not None: item = Market.getInstance().getItem(itemID, eager='group.category') if item is None: event.Skip() return batchOp = wx.GetMouseState().GetModifiers() == wx.MOD_ALT and getattr(event, 'allowBatch', None) is not False # If we've selected ammo, then apply to the selected module(s) if item.isCharge: positions = [] fit = Fit.getInstance().getFit(fitID) if batchOp: for position, mod in enumerate(fit.modules): if isinstance(mod, Module) and not mod.isEmpty: positions.append(position) else: for mod in self.getSelectedMods(): if mod.isEmpty or mod not in fit.modules: continue positions.append(fit.modules.index(mod)) if len(positions) > 0: self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleChargesCommand( fitID=fitID, positions=positions, chargeItemID=itemID)) elif (item.isModule and not batchOp) or item.isSubsystem: self.mainFrame.command.Submit(cmd.GuiAddLocalModuleCommand(fitID=fitID, itemID=itemID)) elif item.isModule and batchOp: self.mainFrame.command.Submit(cmd.GuiFillWithNewLocalModulesCommand(fitID=fitID, itemID=itemID)) event.Skip()