This file is indexed.

/usr/lib/ruby/vendor_ruby/ctioga2/graphics/styles/contour.rb is in ctioga2 0.10-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# contour.rb: the style of a contour plot
# copyright (c) 2009 by Vincent Fourmond
  
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
  
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details (in the COPYING file).

require 'ctioga2/utils'
require 'ctioga2/log'


# This module contains all the classes used by ctioga
module CTioga2

  module Graphics

    module Styles


      # The base for a contour plot
      class BaseContourStyle < BasicStyle
        
        # Whether or not to use conrec for the contour computation
        typed_attribute :conrec, 'boolean'

        def make_contour(table, level, opts = {})
          if @conrec && (! opts.key? 'method')
            opts['method'] = 'conrec'
          end
          return table.make_contour(level, opts)
        end
        
      end


      # This class expands on the previous one to provide for
      # mechanisms to draw many related contour plots.
      class ContoursStyle < BaseContourStyle

        # The overall number of ticks (including minor ticks when
        # there is). May be approximative
        typed_attribute :number, 'integer'

        # Whether or not to "stick" to natural numbers for the 
        typed_attribute :use_naturals, 'boolean'

        # Number of subticks
        typed_attribute :minor_number, 'integer'

        # Relative scale of the minor ticks. Used if the absolute
        # width is not specified.
        typed_attribute :minor_scale, 'float'

        # Line style of minor ticks.
        sub_style :minor, LineStyle

        def initialize()
          @number = 20
          @use_naturals = true
          @minor_number = 4
          @minor_scale = 0.6
        end

        # Computes and plots the contours according to the style,
        # using the given color map.
        def plot_contours(t, table, zmin, zmax, color_map)

          ticks = []
          minor_ticks = []

          if @use_naturals
            bdz = (zmax - zmin)*@minor_number/@number
            bdz = Utils.closest_subdivision(bdz)

            zb = ((zmin/bdz).ceil) * bdz
            z = zb
            i = 0
            while z < zmax
              ticks << z
              z = zb + i*bdz
              i += 1
            end

            sbdz = bdz/@minor_number
            sbdz = Utils.closest_subdivision(sbdz, false)

            zb = ((zmin/sbdz).ceil) * sbdz
            z = zb
            i = 0
            idx = 0
            while z < zmax
              if ticks[idx] == z
                idx += 1
              else
                minor_ticks << z
              end
              i += 1
              z = zb + i*sbdz
            end
          else
            dz = (zmax - zmin)/@number
            @number.times do |i|
              ticks << zmin + (i + 0.5) * dz
            end
          end

          for lvl in ticks
            t.context do
              t.stroke_color = color_map.z_color(lvl, zmin, zmax)
              contour = make_contour(table, lvl)
              t.append_points_with_gaps_to_path(*contour)
              t.stroke
            end
          end

          # Minor ticks, when applicable !
          t.context do 
            t.line_width = t.line_width * @minor_scale
            @minor.set_stroke_style(t) if @minor
            for lvl in minor_ticks
              t.stroke_color = color_map.z_color(lvl, zmin, zmax)
              contour = make_contour(table, lvl)
              t.append_points_with_gaps_to_path(*contour)
              t.stroke
            end
          end

        end
      end
    end
  end
end