Class: CTioga2::Graphics::Styles::CurveStyle

Inherits:
Object
  • Object
show all
Defined in:
lib/ctioga2/graphics/styles/curve.rb

Overview

TODO:

This should probably be a subclass of basicStyle, to

A class holding all the styles for a curve.

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 ?

handle style sheets.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#color_mapObject

TODO:

There should be a very clear way to mark curve style

A colormap for strokes (only for XYZ data)

elements which are specific to certain kinds of plots (and warn the user about misuses ?)



72
73
74
# File 'lib/ctioga2/graphics/styles/curve.rb', line 72

def color_map
  @color_map
end

#error_barObject

The style of the error bars when needed, as a ErrorBarStyle.



46
47
48
# File 'lib/ctioga2/graphics/styles/curve.rb', line 46

def error_bar
  @error_bar
end

#fillObject

Filling of the curve, if applicable



49
50
51
# File 'lib/ctioga2/graphics/styles/curve.rb', line 49

def fill
  @fill
end

#legendObject

The text of the legend, if there is one.



43
44
45
# File 'lib/ctioga2/graphics/styles/curve.rb', line 43

def legend
  @legend
end

#lineObject

The style of the line that is drawn, as a StrokeStyle.



37
38
39
# File 'lib/ctioga2/graphics/styles/curve.rb', line 37

def line
  @line
end

#locationObject

Details of the location of the curve, a LocationStyle object.



52
53
54
# File 'lib/ctioga2/graphics/styles/curve.rb', line 52

def location
  @location
end

#markerObject

The style of markers that should be drawn, as a MarkerStyle.



40
41
42
# File 'lib/ctioga2/graphics/styles/curve.rb', line 40

def marker
  @marker
end

#marker_color_mapObject

A colormap for markers (only for XYZ data)



81
82
83
# File 'lib/ctioga2/graphics/styles/curve.rb', line 81

def marker_color_map
  @marker_color_map
end

#path_styleObject

TODO:

Ideas for a path tyle include

A path style.

  • plain lines

  • impulses ?

  • splines

See gnuplot help for “plot with” for inspiration.



65
66
67
# File 'lib/ctioga2/graphics/styles/curve.rb', line 65

def path_style
  @path_style
end

#region_positionObject

Whether in a region plot, the curve should be above or below the filled region.



56
57
58
# File 'lib/ctioga2/graphics/styles/curve.rb', line 56

def region_position
  @region_position
end

#split_on_nanObject

Whether the XY display should split on NaN values (wherever)



84
85
86
# File 'lib/ctioga2/graphics/styles/curve.rb', line 84

def split_on_nan
  @split_on_nan
end

#zaxisObject

TODO:

specify the behaviour when the axis exists.

The name of an axis to create to use for the display of the Z scale.



78
79
80
# File 'lib/ctioga2/graphics/styles/curve.rb', line 78

def zaxis
  @zaxis
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates a CurveStyle object straight from a hash description. See #set_from_hash for more information.



138
139
140
141
142
# File 'lib/ctioga2/graphics/styles/curve.rb', line 138

def self.from_hash(hash)
  a = CurveStyle.new
  a.set_from_hash(hash)
  return a
end

Instance Method Details

#draw_legend_pictogram(t) ⇒ Object

Draws a legend pictogram that fills up the whole current frame.

todo add more elements to the pictogram in case of more complex things.



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/ctioga2/graphics/styles/curve.rb', line 150

def draw_legend_pictogram(t)
  t.context do
    if has_line?
      @line.set_stroke_style(t)
      t.stroke_line(0.0, 0.5, 1.0, 0.5)
    end
    if has_marker?
      @marker.draw_markers_at(t, [0.5], [0.5])
    end
  end
end

#has_legend?Boolean

True if there is one legend to be drawn for this object.

Returns:

  • (Boolean)


98
99
100
# File 'lib/ctioga2/graphics/styles/curve.rb', line 98

def has_legend?
  return @legend
end

#has_line?Boolean

True if a line should be drawn.

Returns:

  • (Boolean)


88
89
90
# File 'lib/ctioga2/graphics/styles/curve.rb', line 88

def has_line?
  return @line && @line.style
end

#has_marker?Boolean

True if markers should be drawn

Returns:

  • (Boolean)


93
94
95
# File 'lib/ctioga2/graphics/styles/curve.rb', line 93

def has_marker?
  return @marker && @marker.marker
end

#set_from_hash(hash) ⇒ Object

TODO:

This function should essentially disappear if we make

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 ?

this derive from BasicStyle.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/ctioga2/graphics/styles/curve.rb', line 114

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