~ubuntu-branches/ubuntu/utopic/ctioga2/utopic

« back to all changes in this revision

Viewing changes to lib/ctioga2/graphics/generator.rb

  • Committer: Package Import Robot
  • Author(s): Vincent Fourmond
  • Date: 2013-12-27 21:04:22 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131227210422-a3f0c7alorq6lwq2
Tags: 0.8-1
* New upstream release
* Updated URLs and debian/watch to follow its new location
* Already conforms to standards 3.9.5
* Finally updated VCS URLS

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
module CTioga2
23
23
 
24
 
  Version::register_svn_info('$Revision: 513 $', '$Date: 2013-09-19 00:43:28 +0200 (Thu, 19 Sep 2013) $')
25
 
 
26
24
  module Graphics
27
25
 
28
26
 
53
51
      # parametric plots.
54
52
      attr_accessor :xy_parametric_parameters
55
53
 
 
54
 
 
55
      # Style of histograms
 
56
      attr_accessor :histogram_parameters
 
57
 
 
58
 
56
59
      # Creates a CurveGenerator object.
57
60
      def initialize
58
61
        @legend_provider = Legends::LegendProvider.new
60
63
        @current_curves = :xy_plot
61
64
 
62
65
        @xy_parametric_parameters = Styles::ParametricPlotStyle.new
 
66
        @histogram_parameters = Styles::HistogramStyle.new
63
67
      end
64
68
 
65
69
      PlotOptions = { 
87
91
          CurveStyleFactory::PlotCommandOptions.key?(k)
88
92
        }
89
93
 
90
 
        curve = send(@current_curves, plot, dataset, options)
91
 
        curve.curve_style.target = curve
 
94
        begin
 
95
          legend = @legend_provider.dataset_legend(dataset)
 
96
          style = @style_factory.next(options)
 
97
          style.legend ||= legend # The legend specified as option to
 
98
                                  # the --plot command has precedence
 
99
                                  # over the one specified by
 
100
                                  # --legend.
 
101
          curve = send(@current_curves, dataset, style)
 
102
          curve.curve_style.target = curve
 
103
        end
92
104
        return curve
93
105
      end
94
106
 
96
108
      
97
109
      ## \name Available kinds of curves
98
110
      ##
99
 
      ## @todo All these are completely identical, there probably
100
 
      ## isn't need for separate code ?
101
 
      # 
102
 
      # @{
103
 
      # 
104
 
      # The "classical" 2D plots.
105
 
      def xy_plot(plot, dataset, options = {})
106
 
        legend = @legend_provider.dataset_legend(dataset)
107
 
        style = @style_factory.next(options)
108
 
        style.legend ||= legend # The legend specified as option to
109
 
                                # the --plot command has precedence
110
 
                                # over the one specified by --legend.
111
 
        curve = Graphics::Elements::Curve2D.new(dataset, style)
112
 
        return curve
 
111
      ## @{
 
112
 
 
113
 
 
114
      # The "classical" 2D plots.
 
115
      def xy_plot(dataset, style)
 
116
        return Graphics::Elements::Curve2D.new(dataset, style)
 
117
      end
 
118
 
 
119
      # The "classical" 2D plots.
 
120
      def histogram(dataset, style)
 
121
        return Graphics::Elements::Histogram.new(dataset, style, 
 
122
                                                 @histogram_parameters.dup)
113
123
      end
114
124
 
115
125
      # XYZ plots formerly known as "parametric plots"
116
 
      def xy_parametric(plot, dataset, options = {})
117
 
        legend = @legend_provider.dataset_legend(dataset)
118
 
        style = @style_factory.next(options)
119
 
        style.legend ||= legend # The legend specified as option to
120
 
                                # the --plot command has precedence
121
 
                                # over the one specified by --legend.
122
 
        curve = Graphics::Elements::Parametric2D.
 
126
      def xy_parametric(dataset, style)
 
127
        return Graphics::Elements::Parametric2D.
123
128
          new(dataset, style, @xy_parametric_parameters.dup)
124
 
        return curve
125
 
      end
126
 
 
127
 
      # XYZ maps
128
 
      def xyz_map(plot, dataset, options = {})
129
 
        legend = @legend_provider.dataset_legend(dataset)
130
 
        style = @style_factory.next(options)
131
 
        style.legend ||= legend # The legend specified as option to
132
 
                                # the --plot command has precedence
133
 
                                # over the one specified by --legend.
134
 
        style.legend = false    # No legend for XYZ maps
135
 
        curve = Graphics::Elements::XYZMap.new(dataset, style)
136
 
        return curve
137
 
      end
138
 
 
139
 
      # XYZ maps
140
 
      def xyz_contour(plot, dataset, options = {})
141
 
        legend = @legend_provider.dataset_legend(dataset)
142
 
        style = @style_factory.next(options)
143
 
        style.legend ||= legend # The legend specified as option to
144
 
                                # the --plot command has precedence
145
 
                                # over the one specified by --legend.
146
 
        style.legend = false    # No legend for XYZ maps
147
 
        curve = Graphics::Elements::XYZContour.new(dataset, style)
148
 
        return curve
 
129
      end
 
130
 
 
131
      # XYZ maps
 
132
      def xyz_map(dataset, style)
 
133
        style.legend = false    # No legend for XYZ maps
 
134
        return Graphics::Elements::XYZMap.new(dataset, style)
 
135
      end
 
136
 
 
137
      # XYZ maps
 
138
      def xyz_contour(dataset, style)
 
139
        style.legend = false    # No legend for XYZ contours
 
140
        return Graphics::Elements::XYZContour.new(dataset, style)
149
141
      end
150
142
 
151
143
 
176
168
are governed by one (or more ?) Z values.
177
169
EOH
178
170
 
 
171
    HistogramPlotCommand = 
 
172
      Cmd.new("histogram",nil,"--histogram", 
 
173
              [], Styles::HistogramStyle.options_hash) do |plotmaker, opts|
 
174
      plotmaker.curve_generator.current_curves = :histogram
 
175
      plotmaker.curve_generator.
 
176
        histogram_parameters.set_from_hash(opts)
 
177
    end
 
178
    
 
179
    HistogramPlotCommand.describe('select histogram plots', 
 
180
                                  <<EOH, PlotTypesGroup)
 
181
Switch to drawing histograms.
 
182
EOH
 
183
 
179
184
    ContourPlotCommand = 
180
185
      Cmd.new("contour",nil,"--contour") do |plotmaker|
181
186
      plotmaker.curve_generator.current_curves = :xyz_contour