Ejemplo n.º 1
0
    def _setupMajorObjectItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtWidgets.QActionGroup(self)

        # open metadata view
        icon = qtsupport.geticon('metadata.svg', __name__)
        QtWidgets.QAction(icon,
                          self.tr('Open &Metadata View'),
                          actionsgroup,
                          objectName='actionOpenItemMetadataView',
                          shortcut=self.tr('Ctrl+M'),
                          toolTip=self.tr('Show metadata in a new window'),
                          statusTip=self.tr('Show metadata in a new window'),
                          triggered=self.openItemMatadataView,
                          enabled=False)  # @TODO: remove

        # show properties
        # @TODO: standard info icon from gdsview package
        icon = qtsupport.geticon('info.svg', 'gsdview')
        QtWidgets.QAction(
            icon,
            self.tr('&Show Properties'),
            actionsgroup,
            objectName='actionShowItemProperties',
            shortcut=self.tr('Ctrl+S'),
            toolTip=self.tr('Show the property dialog for the cutent item'),
            statusTip=self.tr('Show the property dialog for the cutent item'),
            triggered=self.showItemProperties)

        return actionsgroup
Ejemplo n.º 2
0
    def _setupActions(self):
        actions = QtWidgets.QActionGroup(self)

        # KML export
        icon = qtsupport.geticon('area.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('KML export'),
                          actions,
                          objectName='kmlExportAction',
                          statusTip=self.tr('KML export'),
                          triggered=self.exportKML)

        # Open in google earth
        icon = qtsupport.geticon('earth.svg', __name__)
        QtWidgets.QAction(icon,
                          self.tr('Open in Google Earth'),
                          actions,
                          objectName='openInGoogleEarthAction',
                          statusTip=self.tr('Open in Google Earth'),
                          triggered=self.openInGoogleEarth)

        # Open in google maps
        icon = qtsupport.geticon('overview.svg', 'gsdview.gdalbackend')
        QtWidgets.QAction(icon,
                          self.tr('Open in Google Maps'),
                          actions,
                          objectName='openInGoogleMapsAction',
                          statusTip=self.tr('Open in Google Maps'),
                          triggered=self.openInGoogleMaps)

        return actions
Ejemplo n.º 3
0
    def _setupHelpActions(self):
        actionsgroup = QtWidgets.QActionGroup(self)

        # About
        icon = qtsupport.geticon('about.svg', __name__)
        QtWidgets.QAction(
            icon, self.tr('&About'), actionsgroup,
            objectName='aboutAction',
            toolTip=self.tr('Show program information'),
            statusTip=self.tr('Show program information'),
            triggered=lambda: self.aboutdialog.exec_())

        # AboutQt
        icon = QtGui.QIcon(':/qt-project.org/qmessagebox/images/qtlogo-64.png')
        # @COMPATIBILITY: Qt4 --> Qt5
        if not icon.availableSizes():
            icon = QtGui.QIcon(':/trolltech/qmessagebox/images/qtlogo-64.png')
        if not icon.availableSizes():
            icon = QtGui.QIcon.fromTheme('qtlogo-64')
        QtWidgets.QAction(
            icon, self.tr('About &Qt'), actionsgroup,
            objectName='aboutQtAction',
            toolTip=self.tr('Show information about Qt'),
            statusTip=self.tr('Show information about Qt'),
            triggered=lambda: QtWidgets.QMessageBox.aboutQt(self))

        return actionsgroup
Ejemplo n.º 4
0
    def _setupFileActions(self):
        style = self.style()

        actions = QtWidgets.QActionGroup(self)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton)
        QtWidgets.QAction(icon,
                          self.tr('Open Vector'),
                          actions,
                          objectName='openVectorAction',
                          statusTip=self.tr('Open Vector'),
                          triggered=self.onOpenVector)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogResetButton)
        QtWidgets.QAction(icon,
                          self.tr('Close All'),
                          actions,
                          objectName='claseAllAction',
                          statusTip=self.tr('Close All'),
                          triggered=self.reset)

        QtWidgets.QAction(actions).setSeparator(True)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton)
        QtWidgets.QAction(icon,
                          self.tr('Exit'),
                          actions,
                          objectName='exitAction',
                          statusTip=self.tr('Exit'),
                          triggered=self.close)

        return actions
Ejemplo n.º 5
0
    def _setupViewActions(self):
        style = self.style()
        actions = QtWidgets.QActionGroup(self)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogResetButton)
        QtWidgets.QAction(icon,
                          self.tr('Reset'),
                          actions,
                          objectName='resetAction',
                          statusTip=self.tr('Reset'),
                          triggered=self.onReset)

        QtWidgets.QAction(actions).setSeparator(True)

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/zoom-in-32.png')
        QtWidgets.QAction(icon,
                          self.tr('Zoom In'),
                          actions,
                          objectName='zoomInAction',
                          statusTip=self.tr('Zoom In'),
                          shortcut=self.tr('Ctrl++'),
                          triggered=lambda: self.graphicsview.scale(1.2, 1.2))

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/zoom-out-32.png')
        QtWidgets.QAction(
            icon,
            self.tr('Zoom Out'),
            actions,
            objectName='zoomOutAction',
            statusTip=self.tr('Zoom Out'),
            shortcut=self.tr('Ctrl+-'),
            triggered=lambda: self.graphicsview.scale(1 / 1.2, 1 / 1.2))

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/page-setup-24.png')
        QtWidgets.QAction(icon,
                          self.tr('Zoom 1:1'),
                          actions,
                          objectName='zoomResetAction',
                          statusTip=self.tr('Zoom 1:1'),
                          triggered=lambda: self.graphicsview.setTransform(
                              QtGui.QTransform(1, 0, 0, -1, 0, 0)))

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/fit-page-32.png')
        QtWidgets.QAction(
            icon,
            self.tr('Zoom Fit'),
            actions,
            objectName='zoomFitAction',
            statusTip=self.tr('Zoom Fit'),
            #checkable=True,
            triggered=lambda: self.graphicsview.fitInView(
                self.graphicsview.sceneRect(), QtCore.Qt.KeepAspectRatio))

        return actions
Ejemplo n.º 6
0
    def __init__(self, parent=None, stdmodes=True, **kwargs):
        QtCore.QObject.__init__(self, parent, **kwargs)

        self._moderegistry = []
        self.actions = QtWidgets.QActionGroup(self)
        self.actions.setExclusive(True)

        if stdmodes:
            self.registerStandardModes()
Ejemplo n.º 7
0
    def _setupHelpActions(self):
        actions = QtWidgets.QActionGroup(self)

        icon = QtGui.QIcon(
            ':/trolltech/styles/commonstyle/images/fileinfo-32.png')
        QtWidgets.QAction(icon, 'About', actions, triggered=self.about)

        icon = QtGui.QIcon(':/trolltech/qmessagebox/images/qtlogo-64.png')
        QtWidgets.QAction(icon,
                          'About Qt',
                          actions,
                          triggered=QtWidgets.QApplication.aboutQt)

        return actions
Ejemplo n.º 8
0
    def _setupActions(self):
        actions = QtWidgets.QActionGroup(self)

        # Zoom in
        icon = qtsupport.geticon('zoom-in.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Zoom In'),
                          actions,
                          objectName='zoomInAction',
                          statusTip=self.tr('Zoom In'),
                          shortcut=QtGui.QKeySequence(self.tr('Ctrl++')),
                          triggered=self.zoomIn)

        # Zoom out
        icon = qtsupport.geticon('zoom-out.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Zoom Out'),
                          actions,
                          objectName='zoomOutAction',
                          statusTip=self.tr('Zoom Out'),
                          shortcut=QtGui.QKeySequence(self.tr('Ctrl+-')),
                          triggered=self.zoomOut)

        # Zoom fit
        icon = qtsupport.geticon('zoom-fit.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Zoom Fit'),
                          actions,
                          objectName='zoomFitAction',
                          statusTip=self.tr('Zoom to fit the window size'),
                          triggered=self.zoomFit)

        # Zoom 100
        icon = qtsupport.geticon('zoom-100.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Zoom 100%'),
                          actions,
                          objectName='zoom100Action',
                          statusTip=self.tr('Original size'),
                          triggered=self.zoom100)

        # Manual Zoom
        #icon = QtGui.QIcon() #qt4support.geticon('zoom-100.svg', 'gsdview')
        #QtWidgets.QWidgetAction(
        #    icon, self.tr('Zoom 100%'), actions,
        #    statusTip=self.tr('Original size'),
        #    triggered=self.zoom100)

        return actions
Ejemplo n.º 9
0
    def _setupFileActions(self):
        style = self.style()

        actions = QtWidgets.QActionGroup(self)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton)
        QtWidgets.QAction(icon, 'Open', actions, triggered=self.openfile)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCloseButton)
        QtWidgets.QAction(icon, 'Close', actions, triggered=self.scene.clear)

        QtWidgets.QAction(actions).setSeparator(True)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton)
        QtWidgets.QAction(icon, 'Exit', actions, triggered=self.close)

        return actions
Ejemplo n.º 10
0
    def _setupDatasetItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtWidgets.QActionGroup(self)

        # open RGB
        # @TODO: find an icon for RGB
        icon = qtsupport.geticon('rasterband.svg', __name__)
        QtWidgets.QAction(
            icon,
            self.tr('Open as RGB'),
            actionsgroup,
            objectName='actionOpenRGBImageView',
            #shortcut=self.tr('Ctrl+B'),
            toolTip=self.tr('Display the dataset as an RGB image'),
            statusTip=self.tr('Open as RGB'),
            triggered=self.openRGBImageView)

        # build overviews
        icon = qtsupport.geticon('overview.svg', __name__)
        QtWidgets.QAction(
            icon,
            self.tr('&Build overviews'),
            actionsgroup,
            objectName='actionBuidOverviews',
            shortcut=self.tr('Ctrl+B'),
            toolTip=self.tr('Build overviews for all raster bands'),
            statusTip=self.tr('Build overviews for all raster bands'),
            triggered=self.buildOverviews)

        # @TODO: add band, add virtual band, open GCPs view

        # close
        icon = qtsupport.geticon('close.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Close'),
                          actionsgroup,
                          objectName='actionCloseItem',
                          shortcut=self.tr('Ctrl+W'),
                          toolTip=self.tr('Close the current item'),
                          statusTip=self.tr('Close the current item'),
                          triggered=self.closeCurrentItem)

        self._setupMajorObjectItemActions(actionsgroup)

        return actionsgroup
Ejemplo n.º 11
0
    def _setupFileActions(self):
        style = self.style()

        actions = QtWidgets.QActionGroup(self)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton)
        QtWidgets.QAction(icon,
                          self.tr('&Open'),
                          actions,
                          objectName='openAction',
                          shortcut=self.tr('Ctrl+O'),
                          statusTip=self.tr('Open'),
                          triggered=self.onOpen)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogSaveButton)
        QtWidgets.QAction(icon,
                          self.tr('&Save As'),
                          actions,
                          objectName='saveAsAction',
                          shortcut=self.tr('Ctrl+S'),
                          statusTip=self.tr('Save as'),
                          triggered=self.onSave)

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/print-32.png')
        QtWidgets.QAction(icon,
                          self.tr('&Print'),
                          actions,
                          objectName='printAction',
                          shortcut=self.tr('Ctrl+P'),
                          statusTip=self.tr('Print'),
                          triggered=self.onPrint)

        QtWidgets.QAction(actions).setSeparator(True)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton)
        QtWidgets.QAction(icon,
                          self.tr('&Quit'),
                          actions,
                          objectName='exitAction',
                          shortcut=self.tr('Ctrl+Q'),
                          statusTip=self.tr('Quit'),
                          triggered=self.close)

        return actions
Ejemplo n.º 12
0
    def _setupSubDatasetItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtWidgets.QActionGroup(self)

        # open
        icon = qtsupport.geticon('open.svg', __name__)
        QtWidgets.QAction(icon,
                          self.tr('Open Sub Dataset'),
                          actionsgroup,
                          objectName='actionOpenSubDatasetItem',
                          shortcut=self.tr('Ctrl+O'),
                          toolTip=self.tr('Open Sub Dataset'),
                          statusTip=self.tr('Open Sub Dataset'),
                          triggered=self.openSubDataset)

        self._setupDatasetItemActions(actionsgroup)

        return actionsgroup
Ejemplo n.º 13
0
    def _setupFileActions(self):
        # @TODO: add a "close all" (items) action
        actionsgroup = QtWidgets.QActionGroup(self)

        # Open
        icon = qtsupport.geticon('open.svg', __name__)
        QtWidgets.QAction(
            icon, self.tr('&Open'), actionsgroup,
            objectName='openAction',
            shortcut=self.tr('Ctrl+O'),
            toolTip=self.tr('Open an existing file'),
            statusTip=self.tr('Open an existing file'),
            triggered=self.openFile)

        # Close
        icon = qtsupport.geticon('close.svg', __name__)
        QtWidgets.QAction(
            icon, self.tr('&Close'), actionsgroup,
            objectName='closeAction',
            # 'Ctrl+W' shortcu is used for closing windows
            #shortcut=self.tr('Ctrl+W'),
            toolTip=self.tr('Close the current file'),
            statusTip=self.tr('Close the current file'),
            triggered=self.closeItem)

        # Separator
        QtWidgets.QAction(actionsgroup).setSeparator(True)
        # objectName='separator')

        # Exit
        icon = qtsupport.geticon('quit.svg', __name__)
        QtWidgets.QAction(
            icon, self.tr('&Exit'), actionsgroup,
            objectName='exitAction',
            shortcut=self.tr('Ctrl+X'),
            toolTip=self.tr('Exit the program'),
            statusTip=self.tr('Exit the program'),
            triggered=self.close)

        return actionsgroup
Ejemplo n.º 14
0
Archivo: qt.py Proyecto: giumas/gsdview
    def _setupActions(self):
        qstype = QtWidgets.QApplication.style()

        # Setup actions
        self.actions = QtWidgets.QActionGroup(self)

        # Save As
        icon = qstype.standardIcon(QtWidgets.QStyle.SP_DialogSaveButton)
        self.actionSaveAs = QtWidgets.QAction(
            icon,
            self.tr('&Save As'),
            self,
            shortcut=self.tr('Ctrl+S'),
            statusTip=self.tr('Save text to file'),
            triggered=self.save)
        self.actions.addAction(self.actionSaveAs)

        # Clear
        icon = QtGui.QIcon(':/trolltech/styles/commonstyle/images/'
                           'standardbutton-clear-32.png')
        self.actionClear = QtWidgets.QAction(
            icon,
            self.tr('&Clear'),
            self,
            shortcut=self.tr('Shift+F5'),
            statusTip=self.tr('Clear the text'),
            triggered=self.clear)
        self.actions.addAction(self.actionClear)

        # Close
        icon = qstype.standardIcon(QtWidgets.QStyle.SP_DialogCloseButton)
        self.actionHide = QtWidgets.QAction(
            icon,
            self.tr('&Hide'),
            self,
            shortcut=self.tr('Ctrl+W'),
            statusTip=self.tr('Hide the text pane'),
            triggered=self.paneHideRequest)
        self.actions.addAction(self.actionHide)
Ejemplo n.º 15
0
    def _setupSettingsActions(self):
        actionsgroup = QtWidgets.QActionGroup(self)

        # Preferences
        icon = qtsupport.geticon('preferences.svg', __name__)
        QtWidgets.QAction(
            icon, self.tr('&Preferences'), actionsgroup,
            objectName='preferencesAction',
            toolTip=self.tr('Open the program preferences dialog'),
            statusTip=self.tr('Open the program preferences dialog'),
            triggered=self.showPreferencesDialog)

        icon = qtsupport.geticon('full-screen.svg', __name__)
        QtWidgets.QAction(
            icon, self.tr('&Full Screen'), actionsgroup,
            objectName='fullScreenAction',
            shortcut='Ctrl+Meta+F',
            toolTip=self.tr('Toggle full screen mode'),
            statusTip=self.tr('Toggle full screen mode'),
            triggered=self.toggleFullScreenMode)

        return actionsgroup
Ejemplo n.º 16
0
    def _setupBandItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtWidgets.QActionGroup(self)

        # open image view
        icon = qtsupport.geticon('open.svg', __name__)
        QtWidgets.QAction(icon,
                          self.tr('&Open Image View'),
                          actionsgroup,
                          objectName='actionOpenImageView',
                          shortcut=self.tr('Ctrl+O'),
                          toolTip=self.tr('Open an image view'),
                          statusTip=self.tr('Open a new image view'),
                          triggered=self.openImageView)

        # @TODO: add a new action for newImageView

        # @TODO: Masked bands, Compute statistics, Compute histogram
        # @TODO: dataset --> Build overviews

        self._setupMajorObjectItemActions(actionsgroup)

        return actionsgroup
Ejemplo n.º 17
0
    def _setupActions(self):
        actions = QtWidgets.QActionGroup(self)

        # Zoom in
        icon = qtsupport.geticon('zoom-in.svg', 'gsdview')
        QtWidgets.QAction(
            icon, self.tr('Zoom In'), actions,
            objectName='zoomOutAction',
            statusTip=self.tr('Zoom In'),
            shortcut=QtGui.QKeySequence(self.tr('Ctrl++')),
            enabled=False,
            triggered=lambda: self._zoom(+1))

        # Zoom out
        icon = qtsupport.geticon('zoom-out.svg', 'gsdview')
        QtWidgets.QAction(
            icon, self.tr('Zoom Out'), actions,
            objectName='zoomOutAction',
            statusTip=self.tr('Zoom Out'),
            shortcut=QtGui.QKeySequence(self.tr('Ctrl+-')),
            enabled=False,
            triggered=lambda: self._zoom(-1))

        return actions
Ejemplo n.º 18
0
    def _setupActions(self):
        style = QtWidgets.QApplication.style()

        actions = QtWidgets.QActionGroup(self)

        icon = QtGui.QIcon(':/trolltech/styles/commonstyle/images/up-128.png')
        QtWidgets.QAction(icon,
                          self.tr('Move to top'),
                          actions,
                          objectName='moveToTopAction',
                          statusTip=self.tr('Move to top'),
                          shortcut=self.tr('Ctrl+PgUp'))

        icon = style.standardIcon(QtWidgets.QStyle.SP_ArrowUp)
        QtWidgets.QAction(icon,
                          self.tr('Move up'),
                          actions,
                          objectName='moveUpAction',
                          statusTip=self.tr('Move up'),
                          shortcut=self.tr('Ctrl+Up'))

        icon = style.standardIcon(QtWidgets.QStyle.SP_ArrowDown)
        QtWidgets.QAction(icon,
                          self.tr('Move down'),
                          actions,
                          objectName='moveDownAction',
                          statusTip=self.tr('Move down'),
                          shortcut=self.tr('Ctrl+Down'))

        icon = QtGui.QIcon(
            ':/trolltech/styles/commonstyle/images/down-128.png')
        QtWidgets.QAction(icon,
                          self.tr('Move to bottom'),
                          actions,
                          objectName='moveToBottomAction',
                          statusTip=self.tr('Move to bottom'),
                          shortcut=self.tr('Ctrl+PgDown'))

        #~ #'standardbutton-closetab-16.png'
        icon = QtGui.QIcon(':/trolltech/styles/commonstyle/images/'
                           'standardbutton-cancel-128.png')
        QtWidgets.QAction(icon,
                          self.tr('Remove'),
                          actions,
                          objectName='removeLayerAction',
                          statusTip=self.tr('Remove'),
                          shortcut=self.tr('Del'))

        icon = QtGui.QIcon(
            ':/trolltech/styles/commonstyle/images/standardbutton-yes-128.png')
        QtWidgets.QAction(icon,
                          self.tr('Show'),
                          actions,
                          objectName='showLayerAction',
                          statusTip=self.tr('Show the layer'))

        icon = QtGui.QIcon(
            ':/trolltech/styles/commonstyle/images/standardbutton-no-128.png')
        QtWidgets.QAction(icon,
                          self.tr('Hide'),
                          actions,
                          objectName='hideLayerAction',
                          statusTip=self.tr('Hide the layer'))

        return actions
Ejemplo n.º 19
0
    def __init__(self, parent, **kwargs):
        '''Constructs a QtWindowListMenu object.

        The *parent* parameter is passed to the QMenu constructor.
        Although this parameter has the conventional default of 0,
        you will normally want to explicitly provide a parent object,
        since the later adding of this menu object to an action
        container (e.g. QMenuBar) does not cause a reparenting.
        The container is normally the natural choice for *parent*.

        '''

        super(QtWindowListMenu, self).__init__(parent, **kwargs)

        self.mdi = None
        self.setTitle(self.tr('&Windows'))
        self.aboutToShow.connect(self.syncWithMdiArea)

        self._stdGroup = QtWidgets.QActionGroup(self, exclusive=False)
        self._winGroup = QtWidgets.QActionGroup(self, exclusive=True)
        #, triggered=self.activateWindow)

        # @COMPATIBILITY: pyside 1.2.2
        self._winGroup.triggered.connect(self.activateWindow)

        # Create the standard menu items.
        # @Note: Creation order must match the StandardAction enum values ;-)
        QtWidgets.QAction(self.tr('Cl&ose'),
                          self._stdGroup,
                          shortcut=self.tr('Ctrl+F4'),
                          statusTip=self.tr('Close the active window'))

        QtWidgets.QAction(self.tr('Close &All'),
                          self._stdGroup,
                          statusTip=self.tr('Close all the windows'))

        act = self._stdGroup.addAction('')
        act.setSeparator(True)

        QtWidgets.QAction(self.tr('&Tile'),
                          self._stdGroup,
                          statusTip=self.tr('Tile the windows'))

        QtWidgets.QAction(self.tr('&Cascade'),
                          self._stdGroup,
                          statusTip=self.tr('Cascade the windows'))

        act = self._stdGroup.addAction('')
        act.setSeparator(True)

        QtWidgets.QAction(
            self.tr('Ne&xt'),
            self._stdGroup,
            statusTip=self.tr('Move the focus to the next window'))

        QtWidgets.QAction(
            self.tr('Pre&vious'),
            self._stdGroup,
            statusTip=self.tr('Move the focus to the previous window'))

        act = self._stdGroup.addAction('')
        act.setSeparator(True)

        self.addActions(self._stdGroup.actions())

        self._winMap = {}  # QMap<QAction *, QMdiSubWindow *>
        self._iconMap = {}  # QMap<const QMdiSubWindow *, QIcon>
        self._defIcon = QtGui.QIcon()
Ejemplo n.º 20
0
    def _setupContextMenu(self, parent=None):
        menu = QtWidgets.QMenu(parent)
        tr = menu.tr

        # Data pre-processing
        funcs = collections.OrderedDict()
        funcs['None'] = None
        funcs['Abs'] = np.abs
        funcs['Angle'] = np.angle
        funcs['Real'] = np.real
        funcs['Imag'] = np.imag
        #funcs['Pow'] = lambda x: np.abs(x * x)
        #funcs['dB'] = lambda x: 20 * np.log10(np.abs(x))

        inverse_fmap = dict((v, k) for k, v in funcs.items())
        current_func = inverse_fmap.get(self._data_preproc, 'unknown')
        if current_func == 'unknown':
            try:
                current_func = self._data_preproc.__name__
            except AttributeError:
                pass
            funcs[current_func] = self._data_preproc

        # @COMPATIBILITY: addSection is new in Qt 5.1
        #menu.addSection(tr('Transformation functions'))
        menu.addSeparator().setText(tr('Transformation functions'))

        actiongroup = QtWidgets.QActionGroup(menu)
        actiongroup.setExclusive(True)
        for name in funcs.keys():

            def set_proc_func(checked, key=name):
                # @TODO: also adjust the stretch object
                func = funcs[key]
                if func != self._data_preproc:
                    self._data_preproc = func
                    self.update()

            action = QtWidgets.QAction(
                name,
                actiongroup,
                checkable=True,
                enabled=(self._data_preproc is not None and name != 'None'),
                objectName='actionDataPreProc' + name.capitalize(),
                toolTip=tr('Transformation function applied to data'),
                triggered=set_proc_func)
            action.setChecked(bool(name == current_func))
            menu.addAction(action)

        # Colormap
        colortables = collections.OrderedDict()
        colortables['None'] = None
        colortables['Gray'] = qtsupport.GRAY_COLORTABLE
        colortables['Jet'] = qtsupport.JET_COLORTABLE

        inverse_ctmap = dict((id(v), k) for k, v in colortables.items())
        current_colortable = inverse_ctmap.get(id(self.colortable), 'unknown')
        if current_colortable == 'unknown':
            colortables[current_colortable] = self.colortable

        # @COMPATIBILITY: addSection is new in Qt 5.1
        #menu.addSection(tr('Color table'))
        menu.addSeparator().setText(tr('Color table'))

        actiongroup = QtWidgets.QActionGroup(menu)
        actiongroup.setExclusive(True)
        for name in colortables.keys():

            def set_colortable(checked, key=name):
                ct = colortables[key]
                if id(ct) != id(self.colortable):
                    self.colortable = ct
                    self.update()

            action = QtWidgets.QAction(
                name,
                actiongroup,
                checkable=True,
                enabled=bool(self.colortable is not None and name != 'None'),
                objectName='actionColorTable' + name.capitalize(),
                toolTip=tr('Set the color table to %s') % name,
                triggered=set_colortable)
            action.setChecked(bool(name == current_colortable))
            menu.addAction(action)

        return menu