Module: CTioga::Debug
- Includes:
- Log, Tioga::FigureConstants
- Included in:
- LegendItem, LegendStyle, PlotMaker, PlotStyle, TiogaElement, TiogaPrimitiveMaker
- Defined in:
- lib/CTioga/debug.rb
Overview
This module contains code to be included by PlotMaker for debugging. Even if it doesn’t deserve a real module of it’s own, it makes sense to have it separated anyway.
Constant Summary collapse
- @@debug =
These variables are scoped at the module level so that they are shared among all bits of code - as they can only be set in one place.
false
- @@debug_indent =
0
- @@debug_indent_string =
" "
Instance Method Summary collapse
-
#debug_figmaker(t) ⇒ Object
A function using the hooks defined by Bill to display what is happenning inside Tioga.
- #debug_patterns(t) ⇒ Object
-
#debug_puts(str) ⇒ Object
The function to use to display debugging information.
-
#figmaker_options(t) ⇒ Object
Returns a string representing the ‘options’ of the FigureMaker object given.
-
#test_pattern(t) ⇒ Object
This function is taken from Tioga; it is used to check the alignements of the TeX text and PDF image.
-
#test_pattern_right(t) ⇒ Object
This function is taken from Tioga; it is used to check the alignements of the TeX text and PDF image.
Methods included from Log
#identify, #init_logger, #logger, #logger_options, #spawn
Instance Method Details
#debug_figmaker(t) ⇒ Object
A function using the hooks defined by Bill to display what is happenning inside Tioga
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 |
# File 'lib/CTioga/debug.rb', line 47 def debug_figmaker(t) t.def_enter_context_function { debug_puts "Tioga: enter new context\t" + frames_str(t) @@debug_indent += 1 } t.def_exit_context_function { @@debug_indent -=1 debug_puts "Tioga: exit context\t" + frames_str(t) } t.def_enter_show_plot_function { |bounds| debug_puts "Tioga: enter show_plot #{bounds[0]} #{bounds[1]} " + "#{bounds[2]} #{bounds[3]}" @@debug_indent += 1 } t.def_exit_show_plot_function { |bounds| @@debug_indent -=1 debug_puts "Tioga: exit show_plot #{bounds[0]} #{bounds[1]} " + "#{bounds[2]} #{bounds[3]}" } t.def_enter_subfigure_function { |margins| debug_puts "Tioga: enter subfigure #{margins[0]} #{margins[1]} " + "#{margins[2]} #{margins[3]}" debug_puts "Tioga: frames " + frames_str(t) } t.def_enter_subplot_function { |margins| debug_puts "Tioga: enter subplot #{margins[0]} #{margins[1]} " + "#{margins[2]} #{margins[3]}" debug_puts "Tioga: frames " + frames_str(t) } end |
#debug_patterns(t) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/CTioga/debug.rb', line 83 def debug_patterns(t) t.def_figure('Test_patterns') { setup_real_size_bop(t) test_pattern(t) } t.make_preview_pdf(t.figure_index('Test_patterns')) t.def_figure('Test_patterns_right') { setup_real_size_bop(t) test_pattern_right(t) } t.make_preview_pdf(t.figure_index('Test_patterns_right')) end |
#debug_puts(str) ⇒ Object
The function to use to display debugging information. Checks if we are in debug mode.
38 39 40 41 42 43 |
# File 'lib/CTioga/debug.rb', line 38 def debug_puts(str) if @@debug debug @@debug_indent_string * @@debug_indent + str end end |
#figmaker_options(t) ⇒ Object
Returns a string representing the ‘options’ of the FigureMaker object given.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/CTioga/debug.rb', line 182 def (t) return '' unless @@debug s = "" for meth in t.methods.sort if t.respond_to?((meth + '=').to_sym) begin s += "\n#{meth}: " + t.send(meth).to_s rescue # In case the method did need some arguments... end end end return s end |
#test_pattern(t) ⇒ Object
This function is taken from Tioga; it is used to check the alignements of the TeX text and PDF image.
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 |
# File 'lib/CTioga/debug.rb', line 99 def test_pattern(t) t.line_width = 1 t.stroke_frame # we make it asymmetric to catch other kinds of problems t.set_subframe('left' => 0.1 , 'right' => 0.05, 'top' => 0.05, 'bottom' => 0.1) centerx = t.bounds_xmin + 0.5 * t.bounds_width chr_ht = t.default_text_height_dy t.stroke_color = Red t.line_width = 0.2 t.stroke_line(t.bounds_xmax, t.bounds_ymin, t.bounds_xmax, t.bounds_ymax) t.stroke_line(centerx, t.bounds_ymin, centerx, t.bounds_ymax) t.stroke_line(t.bounds_xmin, t.bounds_ymin, t.bounds_xmin, t.bounds_ymax) y = t.bounds_ymin; dy = t.bounds_height / 10 scale = 0.85; 10.times do t.stroke_line(t.bounds_xmin, y, t.bounds_xmax, y) t.show_text('text'=>"Left", 'x'=> t.bounds_xmin, 'y' => y, 'scale'=>0.5+scale, 'justification' => LEFT_JUSTIFIED) t.show_text('text'=>"Center", 'x'=> centerx, 'y' => y, 'scale'=>1.8-scale, 'justification' => CENTERED) t.show_text('text'=>"Right", 'x'=> t.bounds_xmax, 'y' => y, 'scale'=>0.5+scale, 'justification' => RIGHT_JUSTIFIED) scale = scale - 0.1 y = y + dy end t.stroke_line(t.bounds_xmin, t.bounds_ymax, t.bounds_xmax, t.bounds_ymax) t.justification = CENTERED t.show_text('text'=>"TeX and PDF Alignment Test Pattern", 'side'=> TOP, 'pos' => 0.5, 'shift'=>0.3) t.show_text('text'=>"Check for Proper Registration of Text and Graphics", 'side'=>BOTTOM, 'pos' => 0.5, 'shift'=> 1.6, 'scale'=>0.4) t.show_text( 'text'=>'If needed, adjust by changing ' + '{\sffamily FigureMaker.tex\_xoffset} ' + 'and {\sffamily FigureMaker.tex\_yoffset}.', 'side'=>BOTTOM, 'pos' => 0.5, 'shift'=> 3.9, 'scale'=>0.3) end |
#test_pattern_right(t) ⇒ Object
This function is taken from Tioga; it is used to check the alignements of the TeX text and PDF image.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/CTioga/debug.rb', line 140 def test_pattern_right(t) t.line_width = 1 # t.stroke_frame margin = 0.1 # we make it asymmetric to catch other kinds of problems t.set_subframe('left' => 0.1 , 'right' => 0.05, 'top' => 0.05, 'bottom' => 0.1) centerx = t.bounds_xmin + 0.5 * t.bounds_width chr_ht = t.default_text_height_dy t.stroke_color = Red t.line_width = 1 t.stroke_line(t.bounds_xmax, t.bounds_ymin, t.bounds_xmax, t.bounds_ymax) t.stroke_line(centerx, t.bounds_ymin, centerx, t.bounds_ymax) y = t.bounds_ymin; dy = t.bounds_height / 10 scale = 0.85; 10.times do t.stroke_line(centerx, y, t.bounds_xmax, y) t.show_text('text'=>"Left", 'x'=> t.bounds_xmin, 'y' => y, 'scale'=>0.5+scale, 'justification' => LEFT_JUSTIFIED) t.show_text('text'=>"Center", 'x'=> centerx, 'y' => y, 'scale'=>1.8-scale, 'justification' => CENTERED) t.show_text('text'=>"Right", 'x'=> t.bounds_xmax, 'y' => y, 'scale'=>0.5+scale, 'justification' => RIGHT_JUSTIFIED) scale = scale - 0.1 y = y + dy end t.stroke_line(centerx, t.bounds_ymax, t.bounds_xmax, t.bounds_ymax) t.justification = CENTERED t.show_text('text'=>"TeX and PDF Alignment Test Pattern", 'side'=> TOP, 'pos' => 0.5, 'shift'=>0.3) t.show_text('text'=>"Check for Proper Registration of Text and Graphics", 'side'=>BOTTOM, 'pos' => 0.5, 'shift'=> 1.6, 'scale'=>0.4) t.show_text( 'text'=>'If needed, adjust by changing ' + '{\sffamily FigureMaker.tex\_xoffset} ' + 'and {\sffamily FigureMaker.tex\_yoffset}.', 'side'=>BOTTOM, 'pos' => 0.5, 'shift'=> 3.9, 'scale'=>0.3) end |