lib/ctioga2/graphics/styles/curve.rb in ctioga2-0.0 vs lib/ctioga2/graphics/styles/curve.rb in ctioga2-0.1

- old
+ new

@@ -15,19 +15,19 @@ require 'ctioga2/log' # This module contains all the classes used by ctioga module CTioga2 - Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $') + Version::register_svn_info('$Revision: 198 $', '$Date: 2010-11-30 00:48:23 +0100 (Tue, 30 Nov 2010) $') module Graphics module Styles # A class holding all the styles for a curve. # - # TODO: maybe for objects different than Curve2D, a subclass of + # \todo maybe for objects different than Curve2D, a subclass of # CurveStyle could be used ? This way, we could have clearly # separated legends and the like ? class CurveStyle # The style of the line that is drawn, as a StrokeStyle. @@ -37,10 +37,52 @@ attr_accessor :marker # The text of the legend, if there is one. attr_accessor :legend + # The style of the error bars when needed, as a ErrorBarStyle. + attr_accessor :error_bar + + # Filling of the curve, if applicable + attr_accessor :fill + + # Details of the location of the curve, a LocationStyle object. + attr_accessor :location + + # Whether in a region plot, the curve should be above or below + # the filled region. + attr_accessor :region_position + + # A path style. + # + # @todo Ideas for a path tyle include + # - plain lines + # - impulses ? + # - splines + # See gnuplot help for "plot with" for inspiration. + attr_accessor :path_style + + # A colormap for strokes (only for XYZ data) + # + # @todo There should be a very clear way to mark curve style + # elements which are specific to certain kinds of plots (and + # warn the user about misuses ?) + attr_accessor :color_map + + # The name of an axis to create to use for the display of the + # Z scale. + # + # @todo specify the behaviour when the axis exists. + attr_accessor :zaxis + + # A colormap for markers (only for XYZ data) + attr_accessor :marker_color_map + + # Whether the XY display should split on NaN values (wherever) + attr_accessor :split_on_nan + + # True if a line should be drawn. def has_line? return @line && @line.style end @@ -57,16 +99,34 @@ # Sets the values of the different sub-objects from a 'flat' # _hash_. Keys have the following meaning: # * 'line_...': a StrokeStyle for the drawing the line # * 'marker_...': a MarkerStyle for the drawing of markers # * 'legend': the legend of the curve + # * '[xy]axis': the name of the axis the curve should be + # plotted onto # - # TODO: make @legend another object derived from BasicStyle ? + # \todo make #legend another object derived from BasicStyle ? def set_from_hash(hash) @line = StrokeStyle.from_hash(hash, 'line_%s') @marker = MarkerStyle.from_hash(hash, 'marker_%s') + @error_bar = ErrorBarStyle.from_hash(hash, 'error_bar_%s') + @location = LocationStyle.from_hash(hash, 'location_%s') + @fill = CurveFillStyle.from_hash(hash, 'fill_%s') + + @region_position = hash['region_position'] + @legend = hash['legend'] + + @path_style = hash['style'] + + @color_map = hash['color_map'] + + @marker_color_map = hash['marker_color_map'] + + @split_on_nan = hash['split_on_nan'] + + @zaxis = hash['zaxis'] end # Creates a CurveStyle object straight from a hash # description. See #set_from_hash for more information. def self.from_hash(hash) @@ -77,10 +137,10 @@ # Draws a legend pictogram that fills up the whole current # frame. # - # TODO: add more elements to the pictogram in case of more + # \todo add more elements to the pictogram in case of more # complex things. def draw_legend_pictogram(t) t.context do if has_line? @line.set_stroke_style(t)