Ejemplo n.º 1
0
    def __init__(self, viewer, **kwargs):
        super(GingaSpectrumMode, self).__init__(viewer, **kwargs)

        self._shape_obj = None
        self._shape = 'rectangle'

        self._tool = SpectrumTool(self.viewer, self)
Ejemplo n.º 2
0
 def __init__(self, widget=None):
     GingaTool.__init__(self, widget.canvas)
     SpectrumTool.__init__(self, widget)
Ejemplo n.º 3
0
 def __init__(self, widget=None):
     GingaMode.__init__(self, widget)
     SpectrumTool.__init__(self, widget, self)
     self._release_callback = self._update_profile
     self._move_callback = self._move_profile
Ejemplo n.º 4
0
class GingaSpectrumMode(GingaROIMode):

    icon = 'glue_spectrum'
    tool_id = 'ginga:spectrum'
    action_text = 'Spectrum'
    tool_tip = 'Extract a spectrum from the selection'

    def __init__(self, viewer, **kwargs):
        super(GingaSpectrumMode, self).__init__(viewer, **kwargs)

        self._shape_obj = None
        self._shape = 'rectangle'

        self._tool = SpectrumTool(self.viewer, self)
        #self._move_callback = self._tool._move_profile

    def menu_actions(self):

        result = []

        a = QtWidgets.QAction('Rectangle', None)
        a.triggered.connect(nonpartial(self.set_roi_tool, 'rectangle'))
        result.append(a)

        a = QtWidgets.QAction('Circle', None)
        a.triggered.connect(nonpartial(self.set_roi_tool, 'circle'))
        result.append(a)

        a = QtWidgets.QAction('Lasso', None)
        a.triggered.connect(nonpartial(self.set_roi_tool, 'freepolygon'))
        result.append(a)

        a = QtWidgets.QAction('Polygon', None)
        a.triggered.connect(nonpartial(self.set_roi_tool, 'polygon'))
        result.append(a)

        return result

    def set_roi_tool(self, mode):
        self._shape = mode
        self.viewer._set_roi_mode(self,
                                  mode,
                                  'draw',
                                  color='red',
                                  linewidth=2,
                                  linestyle='solid',
                                  fill=False,
                                  alpha=1.0)

    def activate(self):
        self.set_roi_tool(self._shape)

    def deactivate(self):
        self.clear()
        self.viewer._set_roi_mode(None, self._shape, None)

    def opn_init(self, viewer, tag):
        self.clear()

    def opn_exec(self, viewer, tag, obj):
        self.clear()
        self._shape_obj = obj

        roi = ginga_graphic_to_roi(obj)
        self._tool._update_from_roi(roi)

    def clear(self):
        if self._shape_obj is not None:
            try:
                self.viewer.canvas.delete_object(self._shape_obj)
            except:
                pass
            self._shape_obj = None

    def close(self):
        self.clear()
        self._tool.close()
        return super(GingaSpectrumMode, self).close()
Ejemplo n.º 5
0
 def __init__(self, widget=None):
     GingaTool.__init__(self, widget.canvas)
     SpectrumTool.__init__(self, widget)