コード例 #1
0
ファイル: base.py プロジェクト: effting/odemis
    def __init__(self,
                 colour=gui.SELECTION_COLOUR,
                 center=(0, 0),
                 edit_mode=EDIT_MODE_BOX):

        DragMixin.__init__(self)

        # The start and end points of the selection rectangle in view port
        # coordinates
        self.select_v_start_pos = None
        self.select_v_end_pos = None

        self.edit_v_start_pos = None  # The view port coordinates where a drag/edit originated
        self.edit_hover = None  # What edge is being edited (gui.HOVER_*)
        self.edit_mode = edit_mode

        self.hover = gui.HOVER_NONE

        # Selection modes (none, create, edit and drag)
        self.selection_mode = SEL_MODE_NONE

        # This attribute can be used to see if the canvas has shifted or scaled
        self._last_shiftscale = None

        self.v_edges = {}

        # TODO: Move these to the super classes
        self.colour = conversion.hex_to_frgba(colour)
        self.highlight = conversion.hex_to_frgba(gui.FG_COLOUR_HIGHLIGHT)
        self.center = center
コード例 #2
0
ファイル: view.py プロジェクト: arijitxx/odemis
    def __init__(self, cnvs, sequence_va, colour=gui.SELECTION_COLOUR):
        """ :param sequence_va: (ListVA) VA to store the sequence in
        """
        super(DichotomyOverlay, self).__init__(cnvs)

        self.colour = conversion.hex_to_frgba(colour)
        # Color for quadrant that will expand the sequence
        self.hover_forw = conversion.hex_to_frgba(colour, 0.5)
        # Color for quadrant that will cut the sequence
        self.hover_back = conversion.change_brightness(self.hover_forw, -0.2)

        self.sequence_va = sequence_va
        self.sequence_rect = []

        # This attribute is used to track the position of the mouse cursor.
        # The first value denotes the smallest quadrant (in size) in the
        # sequence and the second one the quadrant index number that will
        # be added if the mouse is clicked.
        # This value should be set to (None, None) if the mouse is outside the
        # canvas or when we are not interested in updating the sequence.
        self.hover_pos = (None, None)

        # maximum number of sub-quadrants (6->2**6 smaller than the whole area)
        self.max_len = 6

        self.sequence_va.subscribe(self.on_sequence_change, init=True)

        # Disabling the overlay will allow the event handlers to ignore events
        self.active = False
コード例 #3
0
ファイル: view.py プロジェクト: PierreBizouard/odemis
    def __init__(self, cnvs, sequence_va, colour=gui.SELECTION_COLOUR):
        """ :param sequence_va: (ListVA) VA to store the sequence in
        """
        super(DichotomyOverlay, self).__init__(cnvs)

        self.colour = conversion.hex_to_frgba(colour)
        # Color for quadrant that will expand the sequence
        self.hover_forw = conversion.hex_to_frgba(colour, 0.5)
        # Color for quadrant that will cut the sequence
        self.hover_back = conversion.change_brightness(self.hover_forw, -0.2)

        self.sequence_va = sequence_va
        self.sequence_rect = []

        # This attribute is used to track the position of the mouse cursor.
        # The first value denotes the smallest quadrant (in size) in the
        # sequence and the second one the quadrant index number that will
        # be added if the mouse is clicked.
        # This value should be set to (None, None) if the mouse is outside the
        # canvas or when we are not interested in updating the sequence.
        self.hover_pos = (None, None)

        # maximum number of sub-quadrants (6->2**6 smaller than the whole area)
        self.max_len = 6

        self.sequence_va.subscribe(self.on_change, init=True)

        # Disabling the overlay will allow the event handlers to ignore events
        self.enabled = False
コード例 #4
0
ファイル: view.py プロジェクト: pieleric/odemis-old
    def __init__(self, cnvs, colour=gui.FG_COLOUR_CURVE, colour_peaks=gui.FG_COLOUR_PEAK, length=256):

        base.ViewOverlay.__init__(self, cnvs)
        base.DragMixin.__init__(self)

        self.length = length  # curve length
        self.label = None
        self.colour = conversion.hex_to_frgba(colour, 0.5)
        self.colour_peaks = conversion.hex_to_frgba(colour_peaks)

        # The current highlighted position
        self.selected_wl = None  # in same unit as the range

        self.peaks = None  # list of peak data
        self.peak_offset = None
        self.range = None  # array of wl/px
        self.unit = None  # str
        self.type = None  # str
        # Cached computation of the peak curve. The global curve is index None
        self._curves = {}  # wavelength/None -> list of values
        self.list_labels = []
        self.width_labels = []
        self.amplitude_labels = []
        self.peak_labels = []

        self.line_width = 2
コード例 #5
0
ファイル: base.py プロジェクト: pieleric/odemis
    def __init__(self, colour=gui.SELECTION_COLOUR, center=(0, 0), edit_mode=EDIT_MODE_BOX):

        DragMixin.__init__(self)

        # The start and end points of the selection rectangle in view port
        # coordinates
        self.select_v_start_pos = None
        self.select_v_end_pos = None

        self.edit_v_start_pos = None  # The view port coordinates where a drag/edit originated
        self.edit_hover = None  # What edge is being edited (gui.HOVER_*)
        self.edit_mode = edit_mode

        self.hover = gui.HOVER_NONE

        # Selection modes (none, create, edit and drag)
        self.selection_mode = SEL_MODE_NONE

        # This attribute can be used to see if the canvas has shifted or scaled
        self._last_shiftscale = None

        self.v_edges = {}

        # TODO: Move these to the super classes
        self.colour = conversion.hex_to_frgba(colour)
        self.highlight = conversion.hex_to_frgba(gui.FG_COLOUR_HIGHLIGHT)
        self.center = center
コード例 #6
0
ファイル: world.py プロジェクト: PierreBizouard/odemis
    def __init__(self, cnvs):
        super(PointsOverlay, self).__init__(cnvs)

        # A VA tracking the selected point
        self.point = None
        # The possible choices for point as a world pos => point mapping
        self.choices = {}

        self.min_dist = None

        # Appearance
        self.point_colour = conversion.hex_to_frgb(
                                        gui.FG_COLOUR_HIGHLIGHT)
        self.select_colour = conversion.hex_to_frgba(
                                        gui.FG_COLOUR_EDIT, 0.5)
        self.dot_colour = (0, 0, 0, 0.1)
        # The float radius of the dots to draw
        self.dot_size = MIN_DOT_RADIUS
        # None or the point over which the mouse is hovering
        self.cursor_over_point = None
        # The box over which the mouse is hovering, or None
        self.b_hover_box = None
        self.offset = None

        self.enabled = False
コード例 #7
0
ファイル: view.py プロジェクト: arijitxx/odemis
    def _draw_play(self, ctx):

        width, height, right, _, margin = self._get_dimensions()

        half_height = height / 2

        x = right - margin - width + 0.5
        y = margin + 0.5

        ctx.set_line_width(1)
        ctx.set_source_rgba(
            *conversion.hex_to_frgba(gui.FG_COLOUR_HIGHLIGHT, self.play))

        ctx.move_to(x, y)

        x = right - margin - 0.5
        y += half_height

        ctx.line_to(x, y)

        x = right - margin - width + 0.5
        y += half_height

        ctx.line_to(x, y)
        ctx.close_path()

        ctx.fill_preserve()

        ctx.set_source_rgba(0, 0, 0, self.play)
        ctx.stroke()
コード例 #8
0
ファイル: view.py プロジェクト: PierreBizouard/odemis
    def _draw_play(self, ctx):

        width, height, right, _, margin = self._get_dimensions()

        half_height = height / 2

        x = right - margin - width + 0.5
        y = margin + 0.5

        ctx.set_line_width(1)
        ctx.set_source_rgba(
            *conversion.hex_to_frgba(
                gui.FG_COLOUR_HIGHLIGHT, self.play))

        ctx.move_to(x, y)

        x = right - margin - 0.5
        y += half_height

        ctx.line_to(x, y)

        x = right - margin - width + 0.5
        y += half_height

        ctx.line_to(x, y)
        ctx.close_path()

        ctx.fill_preserve()

        ctx.set_source_rgba(0, 0, 0, self.play)
        ctx.stroke()
コード例 #9
0
ファイル: view.py プロジェクト: PierreBizouard/odemis
    def __init__(self, cnvs):
        super(StreamIconOverlay, self).__init__(cnvs)
        self.pause = False  # if True: displayed
        self.play = 0  # opacity of the play icon

        self.colour = conversion.hex_to_frgba(gui.FG_COLOUR_HIGHLIGHT,
                                              self.opacity)
コード例 #10
0
ファイル: view.py プロジェクト: pieleric/odemis-old
    def __init__(self, cnvs, colour=gui.SELECTION_COLOUR, orientation=None, map_y_from_x=False):
        """
        map_y_from_x (bool): If True, the Y coordinate of the value will be
          based on the data, obtained via cnvs.val_x_to_val(), and .val will
          contain None as Y => 1D movement.
          If False, both X and Y will be based on the mouse position (2D movement).
        """

        base.ViewOverlay.__init__(self, cnvs)
        base.DragMixin.__init__(self)

        self.label = None
        self.colour = conversion.hex_to_frgba(colour)
        self.map_y_from_x = map_y_from_x

        # highlighted position (in the data format, but not necessarily part of the data)
        self.val = model.VigilantAttribute(None)  # tuple (X, Y) or None

        self._x_label = self.add_label("", colour=self.colour)
        self._y_label = self.add_label("", colour=self.colour, align=wx.ALIGN_BOTTOM)

        self.orientation = orientation or self.HORIZONTAL
        self.label_orientation = self.orientation

        self.line_width = 2
コード例 #11
0
ファイル: view.py プロジェクト: PierreBizouard/odemis
    def __init__(self, cnvs):
        super(StreamIconOverlay, self).__init__(cnvs)
        self.pause = False # if True: displayed
        self.play = 0 # opacity of the play icon

        self.colour = conversion.hex_to_frgba(
                                        gui.FG_COLOUR_HIGHLIGHT,
                                        self.opacity)
コード例 #12
0
ファイル: view.py プロジェクト: PierreBizouard/odemis
    def __init__(self, cnvs,
                 colour=gui.CROSSHAIR_COLOR, size=gui.CROSSHAIR_SIZE,
                 center=(0, 0)):
        super(CrossHairOverlay, self).__init__(cnvs)

        self.colour = conversion.hex_to_frgba(colour)
        self.size = size
        self.center = center
コード例 #13
0
ファイル: view.py プロジェクト: arijitxx/odemis
    def __init__(self,
                 cnvs,
                 colour=gui.CROSSHAIR_COLOR,
                 size=gui.CROSSHAIR_SIZE):
        super(CrossHairOverlay, self).__init__(cnvs)

        self.colour = conversion.hex_to_frgba(colour)
        self.size = size
        self.center = self.cnvs.get_half_view_size()
コード例 #14
0
ファイル: view.py プロジェクト: PierreBizouard/odemis
    def __init__(self,
                 cnvs,
                 colour=gui.CROSSHAIR_COLOR,
                 size=gui.CROSSHAIR_SIZE,
                 center=(0, 0)):
        super(CrossHairOverlay, self).__init__(cnvs)

        self.colour = conversion.hex_to_frgba(colour)
        self.size = size
        self.center = center
コード例 #15
0
 def _draw_selection(self, ctx, height):
     ctx.set_source_rgba(*self.select_color)
     left, right = self.pixel_value
     ctx.rectangle(left, 0.0, right - left, height)
     ctx.fill()
     if self.Enabled:
         # draw the "edit" bars on each side
         ctx.set_source_rgba(*hex_to_frgba(gui.FG_COLOUR_EDIT, 0.8))
         self._draw_line(ctx, left, height, left, 0)
         self._draw_line(ctx, right, height, right, 0)
コード例 #16
0
ファイル: world.py プロジェクト: arijitxx/odemis
    def __init__(self, cnvs):
        super(PixelSelectOverlay, self).__init__(cnvs)
        DragMixin.__init__(self)

        # The current position of the mouse cursor in view coordinates
        self._mouse_vpos = None

        # External values
        self._mpp = None  # Meter per pixel
        self._physical_center = None  # in meter (float, float)
        self._resolution = None  # Pixels in linked data (int, int)
        self._selected_pixel = None  # TupleVA (int, int)

        # Calculated values
        self._topleft_wpos = None  # in world units (float, float)
        self._pixel_wsize = None  # cnvs size of the pixel block (float, float)
        self._pixel_pos = None  # position of the current pixel (int, int)

        self.colour = conversion.hex_to_frgba(gui.SELECTION_COLOUR, 0.5)
        self.select_color = conversion.hex_to_frgba(gui.FG_COLOUR_HIGHLIGHT, 0.5)
コード例 #17
0
ファイル: world.py プロジェクト: arijitxx/odemis
    def __init__(self, cnvs):
        super(PixelSelectOverlay, self).__init__(cnvs)
        DragMixin.__init__(self)

        # The current position of the mouse cursor in view coordinates
        self._mouse_vpos = None

        # External values
        self._mpp = None  # Meter per pixel
        self._physical_center = None  # in meter (float, float)
        self._resolution = None  # Pixels in linked data (int, int)
        self._selected_pixel = None  # TupleVA (int, int)

        # Calculated values
        self._topleft_wpos = None  # in world units (float, float)
        self._pixel_wsize = None  # cnvs size of the pixel block (float, float)
        self._pixel_pos = None  # position of the current pixel (int, int)

        self.colour = conversion.hex_to_frgba(gui.SELECTION_COLOUR, 0.5)
        self.select_color = conversion.hex_to_frgba(gui.FG_COLOUR_HIGHLIGHT,
                                                    0.5)
コード例 #18
0
ファイル: view.py プロジェクト: arijitxx/odemis
    def __init__(self, cnvs, colour=gui.SELECTION_COLOUR, orientation=None):

        super(MarkingLineOverlay, self).__init__(cnvs)
        DragMixin.__init__(self)

        self.label = None
        self.colour = conversion.hex_to_frgba(colour)

        self.v_pos = model.VigilantAttribute(None)

        self._x_label = self.add_label("", colour=self.colour)
        self._y_label = self.add_label("", colour=self.colour, align=wx.ALIGN_BOTTOM)

        self.orientation = orientation or self.HORIZONTAL
        self.line_width = 2
コード例 #19
0
ファイル: view.py プロジェクト: PierreBizouard/odemis
    def __init__(self, cnvs):
        super(PolarOverlay, self).__init__(cnvs)

        self.canvas_padding = 0
        # self.cnvs.canDrag = False
        # Rendering attributes
        self.center_x = None
        self.center_y = None
        self.radius = None
        self.inner_radius = None
        self.tau = 2 * math.pi
        self.num_ticks = 6
        self.ticks = []

        self.ticksize = 10

        # Value attributes
        self.px, self.py = None, None
        self.tx, self.ty = None, None

        self.colour = conversion.hex_to_frgb(gui.SELECTION_COLOUR)
        self.colour_drag = conversion.hex_to_frgba(gui.SELECTION_COLOUR, 0.5)
        self.colour_highlight = conversion.hex_to_frgb(gui.FG_COLOUR_HIGHLIGHT)
        self.intensity_label = self.add_label("",
                                              align=wx.ALIGN_CENTER_HORIZONTAL,
                                              colour=self.colour_highlight)

        self.phi = None  # Phi angle in radians
        self.phi_line_rad = None  # Phi drawing angle in radians (is phi -90)
        self.phi_line_pos = None  # End point in pixels of the Phi line
        self.phi_label = self.add_label("",
                                        colour=self.colour,
                                        align=wx.ALIGN_CENTER_HORIZONTAL
                                        | wx.ALIGN_BOTTOM)
        self.theta = None  # Theta angle in radians
        self.theta_radius = None  # Radius of the theta circle in pixels
        self.theta_label = self.add_label("",
                                          colour=self.colour,
                                          align=wx.ALIGN_CENTER_HORIZONTAL)
        self.intersection = None  # The intersection of the cirle and line in
        # pixels

        self.dragging = False

        # Calculate the characteristic values for the first time
        self.on_size()
コード例 #20
0
ファイル: view.py プロジェクト: arijitxx/odemis
    def __init__(self, cnvs, colour=gui.SELECTION_COLOUR, orientation=None):

        super(MarkingLineOverlay, self).__init__(cnvs)
        DragMixin.__init__(self)

        self.label = None
        self.colour = conversion.hex_to_frgba(colour)

        self.v_pos = model.VigilantAttribute(None)

        self._x_label = self.add_label("", colour=self.colour)
        self._y_label = self.add_label("",
                                       colour=self.colour,
                                       align=wx.ALIGN_BOTTOM)

        self.orientation = orientation or self.HORIZONTAL
        self.line_width = 2
コード例 #21
0
ファイル: view.py プロジェクト: PierreBizouard/odemis
    def __init__(self, cnvs):
        super(PolarOverlay, self).__init__(cnvs)

        self.canvas_padding = 0
        # self.cnvs.canDrag = False
        # Rendering attributes
        self.center_x = None
        self.center_y = None
        self.radius = None
        self.inner_radius = None
        self.tau = 2 * math.pi
        self.num_ticks = 6
        self.ticks = []

        self.ticksize = 10

        # Value attributes
        self.px, self.py = None, None
        self.tx, self.ty = None, None

        self.colour = conversion.hex_to_frgb(gui.SELECTION_COLOUR)
        self.colour_drag = conversion.hex_to_frgba(gui.SELECTION_COLOUR, 0.5)
        self.colour_highlight = conversion.hex_to_frgb(
                                            gui.FG_COLOUR_HIGHLIGHT)
        self.intensity_label = self.add_label(
                                    "", align=wx.ALIGN_CENTER_HORIZONTAL,
                                    colour=self.colour_highlight)

        self.phi = None             # Phi angle in radians
        self.phi_line_rad = None    # Phi drawing angle in radians (is phi -90)
        self.phi_line_pos = None    # End point in pixels of the Phi line
        self.phi_label = self.add_label("", colour=self.colour,
                           align=wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_BOTTOM)
        self.theta = None           # Theta angle in radians
        self.theta_radius = None    # Radius of the theta circle in pixels
        self.theta_label = self.add_label("", colour=self.colour,
                                          align=wx.ALIGN_CENTER_HORIZONTAL)
        self.intersection = None    # The intersection of the cirle and line in
                                    # pixels

        self.dragging = False

        # Calculate the characteristic values for the first time
        self.on_size()
コード例 #22
0
ファイル: base.py プロジェクト: PierreBizouard/odemis
    def __init__(self, sel_cur=None, colour=gui.SELECTION_COLOUR, center=(0, 0)):
        # The start and end points of the selection rectangle in view port
        # coordinates
        self.v_start_pos = None
        self.v_end_pos = None

        # The view port coordinates where a drag/edit originated
        self.edit_start_pos = None
        # What edge is being edited
        self.edit_edge = None # gui.HOVER_*

        self.dragging = False
        self.edit = False

        # This attribute can be used to see if the cnvs has shifted or scaled
        self._last_shiftscale = None

        self.edges = {}

        self.colour = conversion.hex_to_frgba(colour)
        self.center = center
コード例 #23
0
ファイル: base.py プロジェクト: arijitxx/odemis
    def __init__(self, colour=gui.SELECTION_COLOUR, center=(0, 0)):
        # The start and end points of the selection rectangle in view port
        # coordinates
        self.v_start_pos = None
        self.v_end_pos = None

        self.edit_v_start_pos = None  # The view port coordinates where a drag/edit originated
        self.edit_edge = None  # What edge is being edited (gui.HOVER_*)

        # Selection modes
        self.selection_mode = SEL_MODE_NONE

        # This attribute can be used to see if the canvas has shifted or scaled
        self._last_shiftscale = None

        self.edges = {}

        self.colour = conversion.hex_to_frgba(colour)
        self.center = center

        self.hover = gui.HOVER_NONE
コード例 #24
0
    def __init__(self,
                 sel_cur=None,
                 colour=gui.SELECTION_COLOUR,
                 center=(0, 0)):
        # The start and end points of the selection rectangle in view port
        # coordinates
        self.v_start_pos = None
        self.v_end_pos = None

        # The view port coordinates where a drag/edit originated
        self.edit_start_pos = None
        # What edge is being edited
        self.edit_edge = None  # gui.HOVER_*

        self.dragging = False
        self.edit = False

        # This attribute can be used to see if the cnvs has shifted or scaled
        self._last_shiftscale = None

        self.edges = {}

        self.colour = conversion.hex_to_frgba(colour)
        self.center = center
コード例 #25
0
ファイル: view.py プロジェクト: pieleric/odemis-old
    def __init__(self, cnvs, colour=gui.CROSSHAIR_COLOR, size=gui.CROSSHAIR_SIZE):
        base.ViewOverlay.__init__(self, cnvs)

        self.colour = conversion.hex_to_frgba(colour)
        self.size = size
コード例 #26
0
ファイル: view.py プロジェクト: pieleric/odemis-old
 def __init__(self, cnvs):
     base.ViewOverlay.__init__(self, cnvs)
     self.pause = False  # if True: displayed
     self.play = 0  # opacity of the play icon
     self.colour = conversion.hex_to_frgba(gui.FG_COLOUR_HIGHLIGHT, self.opacity)
コード例 #27
0
ファイル: view.py プロジェクト: arijitxx/odemis
    def __init__(self, cnvs, colour=gui.CROSSHAIR_COLOR, size=gui.CROSSHAIR_SIZE):
        super(CrossHairOverlay, self).__init__(cnvs)

        self.colour = conversion.hex_to_frgba(colour)
        self.size = size
        self.center = self.cnvs.get_half_view_size()