def setupStyleRangeMarker(range_): params = { "range/line/style" : 'SolidLine', "range/line/color" : "gray", # "#ff9393", "range/line/width" : 1, "range/sel_line/style" : 'SolidLine', "range/sel_line/color" : "gray", # "red", "range/sel_line/width" : 1 + 0* 2, "range/fill" : "gray", "range/shade" : 0.10, "range/symbol/marker" : "Ellipse", "range/symbol/size" : 7+1, "range/symbol/edgecolor" : "white", "range/symbol/facecolor" : "gray", # "#ff9393", "range/symbol/alpha" : 1 - 0.2, "range/sel_symbol/marker" : "Ellipse", "range/sel_symbol/size" : 9-1, "range/sel_symbol/edgecolor" : "white", "range/sel_symbol/facecolor" : "gray", # "red", "range/sel_symbol/alpha" : .9, "range/multi/color" : "#806060", } CONF.update_defaults(dict(histogram=params)) range_.shapeparam.read_config(CONF, "histogram", "range") range_.shapeparam.update_range(range_)
def setupStyleRangeMarker(range_): params = { "range/line/style": 'SolidLine', "range/line/color": "gray", # "#ff9393", "range/line/width": 1, "range/sel_line/style": 'SolidLine', "range/sel_line/color": "gray", # "red", "range/sel_line/width": 1 + 0 * 2, "range/fill": "gray", "range/shade": 0.10, "range/symbol/marker": "Ellipse", "range/symbol/size": 7 + 1, "range/symbol/edgecolor": "white", "range/symbol/facecolor": "gray", # "#ff9393", "range/symbol/alpha": 1 - 0.2, "range/sel_symbol/marker": "Ellipse", "range/sel_symbol/size": 9 - 1, "range/sel_symbol/edgecolor": "white", "range/sel_symbol/facecolor": "gray", # "red", "range/sel_symbol/alpha": .9, "range/multi/color": "#806060", } CONF.update_defaults(dict(histogram=params)) range_.shapeparam.read_config(CONF, "histogram", "range") range_.shapeparam.update_range(range_)
def setupCommonStyle(line, marker): markerSymbol = "Ellipse" # in this case a circle, because we give only one size parameter. edgeColor = "#555555" faceColor = "#cc0000" alpha = 0.8 size = 6 params = { "marker/cross/symbol/marker": markerSymbol, "marker/cross/symbol/edgecolor": edgeColor, "marker/cross/symbol/facecolor": faceColor, "marker/cross/symbol/alpha": alpha, "marker/cross/symbol/size": size, "marker/cross/line/color": "#000000", #"marker/cross/line/width": 0.0, "marker/cross/line/style": "NoPen", } CONF.update_defaults(dict(plot=params)) marker.markerparam.read_config(CONF, "plot", "marker/cross") marker.markerparam.update_marker(marker) params = { "shape/drag/symbol/marker": markerSymbol, "shape/drag/symbol/size": size, "shape/drag/symbol/edgecolor": edgeColor, "shape/drag/symbol/facecolor": faceColor, "shape/drag/symbol/alpha": alpha, } CONF.update_defaults(dict(plot=params)) line.shapeparam.read_config(CONF, "plot", "shape/drag") line.shapeparam.update_shape(line)
def setupCommonStyle(line, marker): markerSymbol = "Ellipse" # in this case a circle, because we give only one size parameter. edgeColor = "#555555" faceColor = "#cc0000" alpha = 0.8 size = 6 params = { "marker/cross/symbol/marker": markerSymbol, "marker/cross/symbol/edgecolor": edgeColor, "marker/cross/symbol/facecolor": faceColor, "marker/cross/symbol/alpha": alpha, "marker/cross/symbol/size": size, "marker/cross/line/color" : "#000000", #"marker/cross/line/width": 0.0, "marker/cross/line/style": "NoPen", } CONF.update_defaults(dict(plot=params)) marker.markerparam.read_config(CONF, "plot", "marker/cross") marker.markerparam.update_marker(marker) params = { "shape/drag/symbol/marker": markerSymbol, "shape/drag/symbol/size": size, "shape/drag/symbol/edgecolor": edgeColor, "shape/drag/symbol/facecolor": faceColor, "shape/drag/symbol/alpha": alpha, "shape/drag/line/color": "#555555", } CONF.update_defaults(dict(plot=params)) line.shapeparam.read_config(CONF, "plot", "shape/drag") line.shapeparam.update_shape(line)
def create_peakmap_labels(self): plot = self.widget.plot rect_marker = RectangleShape() rect_label = make.info_label("TR", [PeakmapCursorRangeInfo(rect_marker)], title=None) rect_label.labelparam.label = "" rect_label.setVisible(1) plot.rect_label = rect_label plot.add_item(rect_label) params = { "shape/drag/symbol/size": 0, "shape/drag/line/color": "#cccccc", "shape/drag/line/width": 1.5, "shape/drag/line/alpha": 0.4, "shape/drag/line/style": "SolidLine", } CONF.update_defaults(dict(plot=params)) rect_marker.shapeparam.read_config(CONF, "plot", "shape/drag") rect_marker.shapeparam.update_shape(rect_marker) rect_marker.setVisible(0) rect_marker.set_rect(0, 0, np.nan, np.nan) plot.add_item(rect_marker) plot.canvas_pointer = True # x-cross marker on # we hack label_cb for updating legend: def label_cb(rt, mz): # passing None here arives as np.nan if you call get_rect later, so we use # np.nan here: rect_marker.set_rect(rt, mz, np.nan, np.nan) return "" cross_marker = plot.cross_marker cross_marker.label_cb = label_cb params = { "marker/cross/line/color": "#cccccc", "marker/cross/line/width": 1.5, "marker/cross/line/alpha": 0.4, "marker/cross/line/style": "DashLine", "marker/cross/symbol/marker": "NoSymbol", "marker/cross/markerstyle": "Cross", } CONF.update_defaults(dict(plot=params)) cross_marker.markerparam.read_config(CONF, "plot", "marker/cross") cross_marker.markerparam.update_marker(cross_marker) self.cross_marker = cross_marker self.rect_marker = rect_marker
def create_peakmap_labels(plot): rect_marker = RectangleShape() rect_label = make.info_label("TR", [PeakmapCursorRangeInfo(rect_marker)], title=None) rect_label.labelparam.label = "" rect_label.labelparam.font.size = 12 rect_label.labelparam.update_label(rect_label) rect_label.setVisible(1) plot.rect_label = rect_label plot.add_item(rect_label) params = { "shape/drag/symbol/size": 0, "shape/drag/line/color": "#cccccc", "shape/drag/line/width": 1.5, "shape/drag/line/alpha": 0.4, "shape/drag/line/style": "SolidLine", } CONF.update_defaults(dict(plot=params)) rect_marker.shapeparam.read_config(CONF, "plot", "shape/drag") rect_marker.shapeparam.update_shape(rect_marker) rect_marker.setVisible(0) rect_marker.set_rect(0, 0, np.nan, np.nan) plot.add_item(rect_marker) plot.canvas_pointer = True # x-cross marker on # we hack label_cb for updating legend: def label_cb(rt, mz): # passing None here arives as np.nan if you call get_rect later, so we use # np.nan here: rect_marker.set_rect(rt, mz, np.nan, np.nan) return "" cross_marker = plot.cross_marker cross_marker.label_cb = label_cb params = { "marker/cross/line/color": "#cccccc", "marker/cross/line/width": 1.5, "marker/cross/line/alpha": 0.4, "marker/cross/line/style": "DashLine", "marker/cross/symbol/marker": "NoSymbol", "marker/cross/markerstyle": "Cross", } CONF.update_defaults(dict(plot=params)) cross_marker.markerparam.read_config(CONF, "plot", "marker/cross") cross_marker.markerparam.update_marker(cross_marker)
def start_tracking(self, filter, event): plot = filter.plot self.inside = False self.active = None self.handle = None self.first_pos = pos = event.pos() self.last_pos = QPoint(pos) selected = plot.get_active_item() distance = CONF.get("plot", "selection/distance", 6) (nearest, nearest_dist, nearest_handle, nearest_inside) = plot.get_nearest_object(pos, distance) if nearest is not None: # Is the nearest object the real deal? if not nearest.can_select() or nearest_dist >= distance: # Looking for the nearest object in z containing cursor position (nearest, nearest_dist, nearest_handle, nearest_inside) = plot.get_nearest_object_in_z(pos) # This will unselect active item only if it's not moved afterwards: self.unselection_pending = selected is nearest if selected and not self.multiselection: # An item is selected self.active = selected (dist, self.handle, self.inside, other_object) = self.active.hit_test(pos) if other_object is not None: # e.g. LegendBoxItem: 'other_object' is the selected curve plot.set_active_item(other_object) return if dist >= distance and not self.inside: # The following allows to move together selected items by # clicking inside any of them (instead of active item only) other_selitems = [_it for _it in plot.get_selected_items() if _it is not self.active and _it.can_move()] for selitem in other_selitems: dist, handle, inside, _other = selitem.hit_test(pos) if dist < distance or inside: self.inside = inside break else: self.__unselect_objects(filter) filter.set_state(self.start_state, event) return else: # No item is selected self.active = nearest self.handle = nearest_handle self.inside = nearest_inside dist = nearest_dist if nearest is not None: plot.set_active_item(nearest) if not nearest.selected: if not self.multiselection: plot.unselect_all() plot.select_item(nearest) # Eventually move or resize selected object: self.__move_or_resize_object(dist, distance, event, filter) plot.replot()
def __init__(self, parent=None): super(LevelsHistogram, self).__init__(parent=parent, title="", section="histogram") self.antialiased = False # a dict of dict : plot -> selected items -> HistogramItem self._tracked_items = {} self.curveparam = CurveParam(_("Curve"), icon="curve.png") self.curveparam.read_config(CONF, "histogram", "curve") self.histparam = HistogramParam(_("Histogram"), icon="histogram.png") self.histparam.logscale = False self.histparam.n_bins = 256 self.range = XRangeSelection(0, 1) self.range_mono_color = self.range.shapeparam.sel_line.color self.range_multi_color = CONF.get("histogram", "range/multi/color", "red") self.add_item(self.range, z=5) self.SIG_RANGE_CHANGED.connect(self.range_changed) self.set_active_item(self.range) self.setMinimumHeight(80) self.setAxisMaxMajor(self.Y_LEFT, 5) self.setAxisMaxMinor(self.Y_LEFT, 0) if parent is None: self.set_axis_title("bottom", "Levels")
def __init__(self, parent=None): super(LevelsHistogram, self).__init__(parent=parent, title="", section="histogram") self.antialiased = False # a dict of dict : plot -> selected items -> HistogramItem self._tracked_items = {} self.curveparam = CurveParam(_("Curve"), icon="curve.png") self.curveparam.read_config(CONF, "histogram", "curve") self.histparam = HistogramParam(_("Histogram"), icon="histogram.png") self.histparam.logscale = False self.histparam.n_bins = 256 self.range = XRangeSelection(0, 1) self.range_mono_color = self.range.shapeparam.sel_line.color self.range_multi_color = CONF.get("histogram", "range/multi/color", "red") self.add_item(self.range, z=5) self.connect(self, SIG_RANGE_CHANGED, self.range_changed) self.set_active_item(self.range) self.setMinimumHeight(80) self.setAxisMaxMajor(self.Y_LEFT, 5) self.setAxisMaxMinor(self.Y_LEFT, 0) if parent is None: self.set_axis_title('bottom', 'Levels')
def setupStyleRtMarker(marker): linecolor = "#909090" edgeColor = "#005500" faceColor = "#005500" params = { "marker/cross/symbol/marker": "Rect", "marker/cross/symbol/size": 0, "marker/cross/symbol/edgecolor": edgeColor, "marker/cross/symbol/facecolor": faceColor, "marker/cross/line/color": linecolor, "marker/cross/line/width": 1.0, "marker/cross/line/style": "SolidLine", "marker/cross/sel_symbol/size": 0, "marker/cross/sel_line/color": linecolor, "marker/cross/sel_line/width": 1.0, "marker/cross/sel_line/style": "SolidLine", } CONF.update_defaults(dict(plot=params)) marker.markerparam.read_config(CONF, "plot", "marker/cross") marker.markerparam.update_marker(marker)
def setupStyleRtMarker(marker): linecolor = "#909090" edgeColor = "#005500" faceColor = "#005500" params = { "marker/cross/symbol/marker": "Rect", "marker/cross/symbol/size": 0, "marker/cross/symbol/edgecolor": edgeColor, "marker/cross/symbol/facecolor": faceColor, "marker/cross/line/color" : linecolor, "marker/cross/line/width": 1.0, "marker/cross/line/style": "SolidLine", "marker/cross/sel_symbol/size": 0, "marker/cross/sel_line/color" : linecolor, "marker/cross/sel_line/width": 1.0, "marker/cross/sel_line/style": "SolidLine", } CONF.update_defaults(dict(plot=params)) marker.markerparam.read_config(CONF, "plot", "marker/cross") marker.markerparam.update_marker(marker)
def start_tracking(self, filter, event): plot = filter.plot self.inside = False self.active = None self.handle = None self.first_pos = pos = event.pos() self.last_pos = QPoint(pos) selected = plot.get_active_item() distance = CONF.get("plot", "selection/distance", 6) (nearest, nearest_dist, nearest_handle, nearest_inside) = plot.get_nearest_object(pos, distance) if nearest is not None: # Is the nearest object the real deal? if not nearest.can_select() or nearest_dist >= distance: # Looking for the nearest object in z containing cursor position (nearest, nearest_dist, nearest_handle, nearest_inside) = plot.get_nearest_object_in_z(pos) # This will unselect active item only if it's not moved afterwards: self.unselection_pending = selected is nearest if selected and not self.multiselection: # An item is selected self.active = selected (dist, self.handle, self.inside, other_object) = self.active.hit_test(pos) if other_object is not None: # e.g. LegendBoxItem: 'other_object' is the selected curve plot.set_active_item(other_object) return if dist >= distance and not self.inside: # The following allows to move together selected items by # clicking inside any of them (instead of active item only) other_selitems = [ _it for _it in plot.get_selected_items() if _it is not self.active and _it.can_move() ] for selitem in other_selitems: dist, handle, inside, _other = selitem.hit_test(pos) if dist < distance or inside: self.inside = inside break else: self.__unselect_objects(filter) filter.set_state(self.start_state, event) return else: # No item is selected self.active = nearest self.handle = nearest_handle self.inside = nearest_inside dist = nearest_dist if nearest is not None: plot.set_active_item(nearest) if not nearest.selected: if not self.multiselection: plot.unselect_all() plot.select_item(nearest) # Eventually move or resize selected object: self.__move_or_resize_object(dist, distance, event, filter) plot.replot()
def save(): CONF.save()
import rrpam_wds import rrpam_wds.constants as c from rrpam_wds.gui import monkey_patch_guiqwt_guidata # there are some changes to the guiqwt classes to be done. It is not easy to do this by subclassing, as # we need to use make.* facotry. monkey_patch_guiqwt_guidata._patch_all() # show guiqwt where the images are. add_image_module_path("rrpam_wds.gui", "images") # this how we change an option # if there is not .config directory in the home directory, create it. configfile = os.path.join(c.HOMEDIR, '.config') if (os.path.isfile(configfile) and (not os.path.isdir(configfile))): os.unlink(configfile) if (not os.path.isdir(configfile)): os.mkdir(configfile) DEFAULTS = { 'plot': { "selection/distance": 10, } } CONF.update_defaults(DEFAULTS) CONF.set_application("rrpamwds", version=rrpam_wds.__version__) def save(): CONF.save()