Skip to content

Commit

Permalink
reduce dependency between qtgl ui components
Browse files Browse the repository at this point in the history
  • Loading branch information
jooste committed Sep 4, 2024
1 parent 506e6f6 commit 1ed7309
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
15 changes: 13 additions & 2 deletions bluesky/ui/qtgl/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
from bluesky.tools import cachefile
from bluesky.tools.misc import cmdsplit
from bluesky.network import subscribe
from bluesky.network.sharedstate import ActData
from . import autocomplete
from bluesky.network.sharedstate import ActData, get
from bluesky.ui.qtgl import autocomplete
from bluesky.ui.radarclick import radarclick


cmdline_stacked = Signal('cmdline_stacked')
Expand Down Expand Up @@ -80,6 +81,7 @@ def __init__(self, parent=None):
# Connect to the io client's activenode changed signal
Signal('CMDLINE').connect(self.set_cmdline)
Signal('actnode-changed').connect(self.actnodeChanged)
Signal('radarclick').connect(self.on_radarclick)

assert Console._instance is None, "Console constructor: console instance " + \
"already exists! Cannot have more than one console."
Expand Down Expand Up @@ -122,6 +124,15 @@ def echo(self, text, flags=None):
self.stackText.verticalScrollBar().setValue(
self.stackText.verticalScrollBar().maximum())

def on_radarclick(self, lat, lon):
actdata = get()
# TODO routedata isn't really a sharedstate, it only gives a selected route
tostack, tocmdline = radarclick(get_cmdline(), lat, lon,
actdata.acdata, getattr(actdata, 'routedata', None))

process_cmdline((tostack + '\n' + tocmdline) if tostack else tocmdline)


def append_cmdline(self, text):
self.set_cmdline(self.command_line + text)

Expand Down
11 changes: 3 additions & 8 deletions bluesky/ui/qtgl/radarwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import bluesky.network.context as ctx
import bluesky.network.sharedstate as ss
from bluesky.ui.qtgl import glhelpers as glh
from bluesky.ui.radarclick import radarclick
from bluesky.ui.qtgl import console

from .gltraffic import Traffic
from .glmap import Map
from .glnavdata import Navdata
Expand Down Expand Up @@ -127,6 +126,7 @@ def __init__(self, parent=None):

# Signals and slots
self.mouse_event = Signal('radarmouse')
self.radarclick_event = Signal('radarclick')
self.panzoom_event = Signal('state-changed.panzoom')
subscribe('PANZOOM').connect(self.on_panzoom)

Expand Down Expand Up @@ -318,12 +318,7 @@ def event(self, event):
elif event.type() == QEvent.Type.MouseButtonRelease and \
event.button() & Qt.MouseButton.LeftButton and not self.mousedragged:
lat, lon = self.pixelCoordsToLatLon(event.pos().x(), event.pos().y())
actdata = ss.get()
# TODO routedata isn't really a sharedstate, it only gives a selected route
tostack, tocmdline = radarclick(console.get_cmdline(), lat, lon,
actdata.acdata, getattr(actdata, 'routedata', None))

console.process_cmdline((tostack + '\n' + tocmdline) if tostack else tocmdline)
self.radarclick_event.emit(lat, lon)

elif event.type() == QEvent.Type.MouseMove:
self.mousedragged = True
Expand Down

0 comments on commit 1ed7309

Please sign in to comment.