Skip to content

Commit

Permalink
Merge branch 'gamaanderson-master'
Browse files Browse the repository at this point in the history
ENH: Separator in Modes menu.
  • Loading branch information
nguy committed May 9, 2016
2 parents ffa7f32 + 7fdbd23 commit 5bd6498
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 28 deletions.
10 changes: 10 additions & 0 deletions artview/components/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ def addMenuAction(self, position, *args):
menus = {}
return menu.addAction(*args)

def addMenuSeparator(self, position, *args):
menu, menus = self.menus()
for key in position:
if key in menus:
menu, menus = menus[key]
else:
menu = menu.addMenu(key)
menus = {}
return menu.addSeparator(*args)

def CreateMenu(self):
'''Create the main menubar.'''
self.menubar = self.menuBar()
Expand Down
20 changes: 16 additions & 4 deletions artview/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,27 +175,39 @@

modes = [
{'label': 'Add RadarDisplay',
'group': 'graph',
'action': radar_mode},
{'label': 'Add GridDisplay',
'group': 'graph',
'action': grid_mode},
{'label': 'Map Radar to Grid',
'group': 'map',
'action': map_to_grid_mode},
{'label': 'Apply corrections to Radar',
'group': 'correct',
'action': corrections_mode},
{'label': 'Apply a filter to gates',
'group': 'correct',
'action': gatefilter_mode},
{'label': 'Apply a filter to data',
'group': 'correct',
'action': manual_filter_mode},
{'label': 'Manually unfold velocity',
'group': 'correct',
'action': manual_unfold_mode},
{'label': 'Query a selectable region of interest ',
'group': 'select',
'action': select_region_mode},
{'label': 'Extract a selected region of points',
'group': 'select',
'action': extract_points_mode},
{'label': 'Manually unfold velocity',
'action': manual_unfold_mode},
{'label': 'Apply a filter to data',
'action': manual_filter_mode},
{'label': 'File navigator',
'group': 'io',
'action': navigate_mode},
{'label': 'File details',
'group': 'io',
'action': filedetail_mode},
{'label': 'Directory View',
'group': 'io',
'action': filelist_mode},
]
2 changes: 2 additions & 0 deletions artview/plugins/cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ def NewColormap(self, variable, strong):

_modes = [
{'label': 'Edit Colormap (radar)',
'group': 'graph',
'action': radar_mode},
{'label': 'Edit Colormap (grid)',
'group': 'graph',
'action': grid_mode},
]

24 changes: 14 additions & 10 deletions artview/scripts/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,20 @@ def startMainMenu(DirIn=None, filename=None):

try:
from ..modes import modes
for mode in modes:
action = QtGui.QAction(mode['label'], MainMenu)
action.triggered[()].connect(
lambda mode=mode: MainMenu.change_mode(mode['action']))
if (mode['label'] != 'Directory View' and
mode['label'] != 'File details' and
mode['label'] != 'File navigator'):
MainMenu.addMenuAction(("Modes",), action)
else:
MainMenu.addMenuAction(("File",), action)
group_names = [m['group'] for m in modes]
seen = set()
group_names = [x for x in group_names if x not in seen and not seen.add(x)]
groups = [[m for m in modes if m['group']==name] for name in group_names]
for group in groups:
for mode in group:
action = QtGui.QAction(mode['label'], MainMenu)
action.triggered[()].connect(
lambda mode=mode: MainMenu.change_mode(mode['action']))
if mode['group'] != 'io':
MainMenu.addMenuAction(("Modes",), action)
else:
MainMenu.addMenuAction(("File",), action)
MainMenu.addMenuSeparator(("Modes",))
except:
import warnings
warnings.warn("Loading Modes Fail")
Expand Down
19 changes: 7 additions & 12 deletions artview/scripts/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,8 @@ def run(DirIn=None, filename=None, field=None):
from ._common import startMainMenu
from .. import view

app = QtGui.QApplication(sys.argv)
if view.checkifmac():
app.setAttribute(QtCore.Qt.AA_MacPluginApplication, True)

# start Menu and initiate Vradar
MainMenu = startMainMenu(DirIn, filename)
Vradar = MainMenu.Vradar
view.start(DirIn, filename)
Vradar = view.MainMenu.Vradar

# handle input
if field is None:
Expand All @@ -50,17 +45,17 @@ def run(DirIn=None, filename=None, field=None):
# start Displays
Vtilt = Variable(0)
plot1 = RadarDisplay(Vradar, Variable(field), Vtilt, name="Display1",
parent=MainMenu)
parent=view.MainMenu)
plot2 = RadarDisplay(Vradar, Variable(field), Vtilt, name="Display2",
parent=MainMenu)
parent=view.MainMenu)

# start ComponentsControl
control = LinkSharedVariables()
control.setComponent0(plot1.name)
control.setComponent1(plot2.name)

# add control to Menu
MainMenu.addLayoutWidget(control)
view.MainMenu.addLayoutWidget(control)

# Replace in Screen
desktop_rect = QtGui.QDesktopWidget().screenGeometry()
Expand All @@ -71,13 +66,13 @@ def run(DirIn=None, filename=None, field=None):
menu_width = 500
menu_height = 180

MainMenu.setGeometry(0, 0, menu_width, menu_height)
view.MainMenu.setGeometry(0, 0, menu_width, menu_height)

plot_size = min(height-60-menu_height, width/2) - 50
plot1.setGeometry(0, height-plot_size, plot_size, plot_size)
plot2.setGeometry(width/2, height-plot_size, plot_size, plot_size)

# start program
app.exec_()
view.execute()
print("You used ARTView. What you think and what you need of ARTView? "
"Send your comment to [email protected]")
4 changes: 2 additions & 2 deletions artview/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def view(containers, field=reflectivity):
execute()


def start():
def start(DirIn=os.getcwd(), filename=False):
''' Start Qt Application and :py:class:`~artview.components.Menu` '''
global app
if app is None:
Expand All @@ -71,7 +71,7 @@ def start():
app.setAttribute(QtCore.Qt.AA_MacPluginApplication, True)

global MainMenu
MainMenu = startMainMenu(os.getcwd(), False)
MainMenu = startMainMenu(DirIn, filename)

# resize menu
menu_width = 300
Expand Down

0 comments on commit 5bd6498

Please sign in to comment.