| 1 | ## Xmgrace.pm is a sub-module of Graph.pm. It has all the subroutines | ||||||||||||||||||||||||||||
| 2 | ## needed for the gnuplot part of the package. | ||||||||||||||||||||||||||||
| 3 | ## | ||||||||||||||||||||||||||||
| 4 | ## $Id: Xmgrace.pm,v 1.34 2006/06/07 21:09:33 emile Exp $ $Name: $ | ||||||||||||||||||||||||||||
| 5 | ## | ||||||||||||||||||||||||||||
| 6 | ## This software product is developed by Esmond Lee and David Moore, | ||||||||||||||||||||||||||||
| 7 | ## and copyrighted(C) 1998 by the University of California, San Diego | ||||||||||||||||||||||||||||
| 8 | ## (UCSD), with all rights reserved. UCSD administers the CAIDA grant, | ||||||||||||||||||||||||||||
| 9 | ## NCR-9711092, under which part of this code was developed. | ||||||||||||||||||||||||||||
| 10 | ## | ||||||||||||||||||||||||||||
| 11 | ## There is no charge for this software. You can redistribute it and/or | ||||||||||||||||||||||||||||
| 12 | ## modify it under the terms of the GNU General Public License, v. 2 dated | ||||||||||||||||||||||||||||
| 13 | ## June 1991 which is incorporated by reference herein. This software is | ||||||||||||||||||||||||||||
| 14 | ## distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF MERCHANTABILITY | ||||||||||||||||||||||||||||
| 15 | ## OR FITNESS FOR A PARTICULAR PURPOSE or that the use of it will not | ||||||||||||||||||||||||||||
| 16 | ## infringe on any third party's intellectual property rights. | ||||||||||||||||||||||||||||
| 17 | ## | ||||||||||||||||||||||||||||
| 18 | ## You should have received a copy of the GNU GPL along with this program. | ||||||||||||||||||||||||||||
| 19 | ## | ||||||||||||||||||||||||||||
| 20 | ## | ||||||||||||||||||||||||||||
| 21 | ## IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY | ||||||||||||||||||||||||||||
| 22 | ## PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL | ||||||||||||||||||||||||||||
| 23 | ## DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS | ||||||||||||||||||||||||||||
| 24 | ## SOFTWARE, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF | ||||||||||||||||||||||||||||
| 25 | ## THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 26 | ## | ||||||||||||||||||||||||||||
| 27 | ## THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE | ||||||||||||||||||||||||||||
| 28 | ## UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, | ||||||||||||||||||||||||||||
| 29 | ## SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY | ||||||||||||||||||||||||||||
| 30 | ## OF CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES | ||||||||||||||||||||||||||||
| 31 | ## OF ANY KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED | ||||||||||||||||||||||||||||
| 32 | ## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A | ||||||||||||||||||||||||||||
| 33 | ## PARTICULAR PURPOSE, OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE | ||||||||||||||||||||||||||||
| 34 | ## ANY PATENT, TRADEMARK OR OTHER RIGHTS. | ||||||||||||||||||||||||||||
| 35 | ## | ||||||||||||||||||||||||||||
| 36 | ## | ||||||||||||||||||||||||||||
| 37 | ## Contact: graph-dev@caida.org | ||||||||||||||||||||||||||||
| 38 | ## | ||||||||||||||||||||||||||||
| 39 | ## | ||||||||||||||||||||||||||||
| 40 | package Chart::Graph::Xmgrace; | ||||||||||||||||||||||||||||
| 41 | 4 | ▶ | use Exporter(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 4 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 44 | 4 | @EXPORT = qw(); | |||||||||||||||||||||||||||
| 45 | 4 | @EXPORT_OK = qw(&xmgrace); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 4 | ▶ | use Carp; # for carp() and croak() | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 4 | ▶ | use Chart::Graph::Utils qw(:UTILS); # get global subs and variable | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 4 | ▶ | use Chart::Graph::XrtUtils qw(:UTILS); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | 4 | ▶ | use Chart::Graph::Xmgrace::Grace; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | 4 | ▶ | use Chart::Graph::Xmgrace::Graph_Presentation_Type; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | 4 | ▶ | use Chart::Graph::Xmgrace::Dataset; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 4 | ▶ | use FileHandle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 4 | $cvs_Id = '$Id: Xmgrace.pm,v 1.34 2006/06/07 21:09:33 emile Exp $'; | |||||||||||||||||||||||||||
| 56 | 4 | $cvs_Author = '$Author: emile $'; | |||||||||||||||||||||||||||
| 57 | 4 | $cvs_Name = '$Name: $'; | |||||||||||||||||||||||||||
| 58 | 4 | $cvs_Revision = '$Revision: 1.34 $'; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 4 | $VERSION = 3.2; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | #for debugging purposes. | ||||||||||||||||||||||||||||
| 65 | 4 | my $stdout = 0; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # these variables hold default options for xmgrace | ||||||||||||||||||||||||||||
| 68 | 4 | my %def_xmgrace_global_opts = ( | |||||||||||||||||||||||||||
| 69 | "title" => "untitled", # @description | ||||||||||||||||||||||||||||
| 70 | "subtitle" => "", | ||||||||||||||||||||||||||||
| 71 | "type of graph" => "XY graph", # XY graph, XY chart, Polar Graph, Smith Chart, Fixed | ||||||||||||||||||||||||||||
| 72 | "output type" => "PNG", # png, jpeg, ps | ||||||||||||||||||||||||||||
| 73 | "output file" => "untitled-grace", | ||||||||||||||||||||||||||||
| 74 | "grace output file" => "untitled-grace.agr", | ||||||||||||||||||||||||||||
| 75 | "xrange" => undef, | ||||||||||||||||||||||||||||
| 76 | "yrange" => undef, | ||||||||||||||||||||||||||||
| 77 | "x-axis label" => "x-axis", | ||||||||||||||||||||||||||||
| 78 | "y-axis label" => "y-axis", | ||||||||||||||||||||||||||||
| 79 | "alt x-axis label" => undef, | ||||||||||||||||||||||||||||
| 80 | "alt y-axis label" => undef, | ||||||||||||||||||||||||||||
| 81 | "logscale x" => undef, | ||||||||||||||||||||||||||||
| 82 | "logscale y" => undef, | ||||||||||||||||||||||||||||
| 83 | "xtics" => undef, | ||||||||||||||||||||||||||||
| 84 | "ytics" => undef, | ||||||||||||||||||||||||||||
| 85 | "alt xtics" => undef, | ||||||||||||||||||||||||||||
| 86 | "alt ytics" => undef, | ||||||||||||||||||||||||||||
| 87 | "stacked" => "false", | ||||||||||||||||||||||||||||
| 88 | "extra opts" => undef, | ||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 4 | my $def_graph_appearance = new Chart::Graph::Xmgrace::Graph_Presentation_Type; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | my %def_xmgrace_data_opts = ( | ||||||||||||||||||||||||||||
| 95 | "set presentation" => "XY", | ||||||||||||||||||||||||||||
| 96 | 4 | "options" => $def_graph_appearance->{"XY graph"}, | |||||||||||||||||||||||||||
| 97 | "title" => "untitled data set", # comment, legend | ||||||||||||||||||||||||||||
| 98 | "data format" => undef, # columns, matrix, or file | ||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # New Hash of array references to hold list of options that might need to | ||||||||||||||||||||||||||||
| 102 | # be checked against options. If Xmgrace program changes. Update here | ||||||||||||||||||||||||||||
| 103 | 4 | my %def_xmgrace_available_options = | |||||||||||||||||||||||||||
| 104 | ( "type of graph" => ["XY graph", "XY chart", "Bar chart", | ||||||||||||||||||||||||||||
| 105 | "Polar graph", "Smith chart", "Fixed", | ||||||||||||||||||||||||||||
| 106 | # "Pie Chart", # Not yet implemented | ||||||||||||||||||||||||||||
| 107 | ], | ||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # | ||||||||||||||||||||||||||||
| 112 | # | ||||||||||||||||||||||||||||
| 113 | # Subroutine: xmgrace() | ||||||||||||||||||||||||||||
| 114 | # | ||||||||||||||||||||||||||||
| 115 | # Description: this is the main function you will be calling from | ||||||||||||||||||||||||||||
| 116 | # our scripts. please see | ||||||||||||||||||||||||||||
| 117 | # www.caida.org/Tools/Graph/graph_xmgrace.html for a | ||||||||||||||||||||||||||||
| 118 | # full description and how-to of this subroutine | ||||||||||||||||||||||||||||
| 119 | # | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 3 | ▶ | sub xmgrace { | ||||||||||||||||||||||||||
|
Subroutine
xmgrace: called CC=61 SCAR=56.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 122 | 3 | my ($user_global_opts_ref, @data_sets) = @_; | |||||||||||||||||||||||||||
| 123 | 3 | my (%data_opts, %global_opts,); | |||||||||||||||||||||||||||
| 124 | 3 | my ($plottype, $output_file, $plot_file, $output_type, $data_set_ref); | |||||||||||||||||||||||||||
| 125 | #my $autoscale = 1; # by default use autoscale | ||||||||||||||||||||||||||||
| 126 | #my ($xscale, $yscale) = (0,0); | ||||||||||||||||||||||||||||
| 127 | 3 | my $autoscale = ""; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | # create a new filehandle to be used throughout package | ||||||||||||||||||||||||||||
| 130 | 3 | my $handle = new FileHandle; | |||||||||||||||||||||||||||
| 131 | 3 | my $grace_output_file; | |||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 3 | my $grace = new Chart::Graph::Xmgrace::Grace("g0"); | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # create tmpdir | ||||||||||||||||||||||||||||
| 136 | 3 | _make_tmpdir("_Xmgrace_"); # grace files should be saved for user tweaking | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | # set paths for external programs | ||||||||||||||||||||||||||||
| 139 | 3 | ▶ | if (not _set_xmgrace_paths()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 2 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 141 | 2 | return 0; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | # check first arg for hash | ||||||||||||||||||||||||||||
| 145 | 1 | ▶ | if (ref($user_global_opts_ref) ne "HASH") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | carp "Global options must be a hash"; | |||||||||||||||||||||||||||
| 147 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 148 | 0 | return 0; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | # check for data sets | ||||||||||||||||||||||||||||
| 152 | 1 | ▶ | if (not @data_sets) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 0 | carp "no data sets"; | |||||||||||||||||||||||||||
| 154 | 0 | $handle->close; | |||||||||||||||||||||||||||
| 155 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 156 | 0 | return 0; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 1 | my $command_file = _make_tmpfile("command", "agr"); | |||||||||||||||||||||||||||
| 160 | # remember to close the file if we return | ||||||||||||||||||||||||||||
| 161 | 1 | ▶ | if (not $handle->open(">$command_file")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | carp "could not open file: $command_file"; | |||||||||||||||||||||||||||
| 163 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 164 | 0 | return 0; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | # process global options | ||||||||||||||||||||||||||||
| 168 | # call to combine user options with default options | ||||||||||||||||||||||||||||
| 169 | 1 | %global_opts = _mesh_opts($user_global_opts_ref, \%def_xmgrace_global_opts); | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | # crunch on the global options | ||||||||||||||||||||||||||||
| 172 | 1 | ▶ | while (my ($key, $value) = each %global_opts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 20 | ▶ | if ($key eq "title") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 1 | $grace->title_options->title($value); | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 20 | ▶ | if ($key eq "subtitle") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 1 | $grace->subtitle_options->title($value); | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 20 | ▶ | if ($key eq "type of graph") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 1 | ▶ | unless(_is_available_option($key, $value, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | \%def_xmgrace_available_options)) { | ||||||||||||||||||||||||||||
| 185 | 0 | carp "Not a valid Xmgrace graph type"; | |||||||||||||||||||||||||||
| 186 | 0 | $handle->close(); | |||||||||||||||||||||||||||
| 187 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 188 | 0 | return 0; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 1 | ▶ | if ($value =~ "graph") { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 191 | 0 | $grace->graph_global_options->type("XY"); | |||||||||||||||||||||||||||
| 192 | } elsif ($value =~ "chart") { | ||||||||||||||||||||||||||||
| 193 | 1 | $grace->graph_global_options->type("Chart"); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 20 | ▶ | if ($key eq "stacked") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 1 | ▶ | if ($value eq "true" || $value eq "false") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$value eq "true" or $value eq "false"
MC/DC0%0/2
$value eq "true" or $value eq "false"
$value eq "true"
$value eq "false"
Truth table33%1/3
A or B
A= $value eq "true"B= $value eq "false"
| |||||||||||||||||||||||||||||
| 199 | 1 | $grace->graph_global_options->stacked("$value"); | |||||||||||||||||||||||||||
| 200 | } else { # anything else is considered "false" | ||||||||||||||||||||||||||||
| 201 | 0 | carp join ('', | |||||||||||||||||||||||||||
| 202 | "Warning: ambiguous setting for stacking", | ||||||||||||||||||||||||||||
| 203 | "bar chart\nAssuming no stacking" | ||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||
| 205 | 0 | $grace->graph_global_options->stacked("false"); | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 20 | ▶ | if ($key eq "x-axis label") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | 1 | $grace->axes_options->xaxis->label_options->label($value); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 20 | ▶ | if ($key eq "y-axis label") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 1 | $grace->axes_options->yaxis->label_options->label($value); | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 20 | ▶ | if ($key eq "alt x-axis label") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 0 | $grace->axes_options->altxaxis->status("on"); | |||||||||||||||||||||||||||
| 220 | 0 | $grace->axes_options->altxaxis->label_options->label($value); | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | # else altxaxis off | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 20 | ▶ | if ($key eq "alt y-axis label") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | $grace->axes_options->altyaxis->status("on"); | |||||||||||||||||||||||||||
| 228 | 0 | $grace->axes_options->altyaxis->label_options->label($value); | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | # else altyaxis off | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 20 | ▶ | if ($key eq "xrange") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if (ref($value) ne "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 0 | carp "xrange values must be an ARRAY\n"; | |||||||||||||||||||||||||||
| 238 | 0 | $handle->close(); | |||||||||||||||||||||||||||
| 239 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 240 | 0 | return 0; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | 0 | $grace->world_options->xmin($value->[0]); | |||||||||||||||||||||||||||
| 243 | 0 | $grace->world_options->xmax($value->[1]); | |||||||||||||||||||||||||||
| 244 | 0 | $autoscale = "x"; | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 20 | ▶ | if ($key eq "yrange") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 249 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if (ref($value) ne "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 0 | carp "yrange values must be an ARRAY\n"; | |||||||||||||||||||||||||||
| 252 | 0 | $handle->close(); | |||||||||||||||||||||||||||
| 253 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 254 | 0 | return 0; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 0 | $grace->world_options->ymin($value->[0]); | |||||||||||||||||||||||||||
| 257 | 0 | $grace->world_options->ymax($value->[1]); | |||||||||||||||||||||||||||
| 258 | 0 | $autoscale = "y"; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 20 | ▶ | if ($key eq "xtics") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | $grace->axes_options->xaxis->tick_options->type("spec"); | |||||||||||||||||||||||||||
| 265 | 0 | $grace->axes_options->xaxis->ticklabel_options->type("spec"); | |||||||||||||||||||||||||||
| 266 | 0 | $grace->axes_options->xaxis->ticklabel_options->ticklabels($value); | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 20 | ▶ | if ($key eq "ytics") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 273 | 0 | $grace->axes_options->yaxis->tick_options->type("spec"); | |||||||||||||||||||||||||||
| 274 | 0 | $grace->axes_options->yaxis->ticklabel_options->type("spec"); | |||||||||||||||||||||||||||
| 275 | 0 | $grace->axes_options->yaxis->ticklabel_options->ticklabels($value); | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 20 | ▶ | if ($key eq "alt xtics") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | 0 | $grace->axes_options->altxaxis->tick_options->type("spec"); | |||||||||||||||||||||||||||
| 282 | 0 | $grace->axes_options->altxaxis->ticklabel_options->type("spec"); | |||||||||||||||||||||||||||
| 283 | 0 | $grace->axes_options->altxaxis->ticklabel_options->ticklabels($value); | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 20 | ▶ | if ($key eq "alt ytics") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 0 | $grace->axes_options->altyaxis->tick_options->type("spec"); | |||||||||||||||||||||||||||
| 291 | 0 | $grace->axes_options->altyaxis->ticklabel_options->type("spec"); | |||||||||||||||||||||||||||
| 292 | 0 | $grace->axes_options->altyaxis->ticklabel_options->ticklabels($value); | |||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 20 | ▶ | if ($key eq "logscale x") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 297 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | 0 | $grace->axes_options->xaxes->scale("Logarithmic"); | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 20 | ▶ | if ($key eq "logscale y") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 303 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 304 | 0 | $grace->axes_options->yaxes->scale("Logarithmic"); | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 20 | ▶ | if ($key eq "output type") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 1 | $output_type = uc($value); | |||||||||||||||||||||||||||
| 310 | 1 | ▶ | if (not _check_output_type($output_type)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 0 | $output_type = $def_xmgrace_global_opts{"output type"}; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | #print "output type = $value\n"; | ||||||||||||||||||||||||||||
| 314 | 1 | $grace->output_type($output_type); | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 20 | ▶ | if ($key eq "output file") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | #print "output file = $value\n"; | ||||||||||||||||||||||||||||
| 319 | 1 | $grace->output_file($value); | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 20 | ▶ | if ($key eq "grace output file") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 1 | $grace->grace_output_file(_make_gracefile("$value")); | |||||||||||||||||||||||||||
| 325 | #print "grace output file = $value\n"; | ||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 20 | ▶ | if ($key eq "extra opts") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | 1 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 0 | $grace->extra_options->extras($value); | |||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | # process data sets | ||||||||||||||||||||||||||||
| 337 | 1 | my @cum_data_set_objects; | |||||||||||||||||||||||||||
| 338 | 1 | my $dataset_count = 0; | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 1 | ▶ | while (@data_sets) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 11 | $data_set_ref = shift @data_sets; | |||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 11 | ▶ | if (ref($data_set_ref) ne "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 344 | 0 | carp "Data set must be an array"; | |||||||||||||||||||||||||||
| 345 | 0 | $handle->close(); | |||||||||||||||||||||||||||
| 346 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 347 | 0 | return 0; | |||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | # create a new Dataset object with each new datase | ||||||||||||||||||||||||||||
| 351 | 11 | my $data_set_object = new Chart::Graph::Xmgrace::Dataset; | |||||||||||||||||||||||||||
| 352 | 11 | my ($user_data_opts_ref, @data) = @{$data_set_ref}; | |||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | # set values in the dataset object | ||||||||||||||||||||||||||||
| 355 | 11 | $data_set_object->set_number($dataset_count); | |||||||||||||||||||||||||||
| 356 | 11 | $data_set_object->data(\@data); | |||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | # process data | ||||||||||||||||||||||||||||
| 359 | 11 | $data_set_object->data_format($user_data_opts_ref->{"data format"}); | |||||||||||||||||||||||||||
| 360 | 11 | my $formatted_data = _xmgrace_data_set($data_set_object); | |||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 11 | ▶ | if (not $formatted_data) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 363 | # error message already printed | ||||||||||||||||||||||||||||
| 364 | 0 | $handle->close(); | |||||||||||||||||||||||||||
| 365 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 366 | 0 | return 0; | |||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | # stick formatted data back in the dataset object | ||||||||||||||||||||||||||||
| 370 | 11 | $data_set_object->data($formatted_data); | |||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | # set set_type | ||||||||||||||||||||||||||||
| 373 | 11 | my $tog = $global_opts{"type of graph"}; # type of graph | |||||||||||||||||||||||||||
| 374 | 11 | ▶ | if ($tog =~ "XY") { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 375 | 0 | $data_set_object->set_type("XY"); | |||||||||||||||||||||||||||
| 376 | } elsif ($tog =~ m/BAR/i) { | ||||||||||||||||||||||||||||
| 377 | 11 | $data_set_object->set_type("BAR"); | |||||||||||||||||||||||||||
| 378 | } else { | ||||||||||||||||||||||||||||
| 379 | 0 | carp "Untrapped graph type - Xmgrace.pm internal error"; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | # need to create a new Presentation Type object for each dataset | ||||||||||||||||||||||||||||
| 383 | 11 | my $gpt = new Chart::Graph::Xmgrace::Graph_Presentation_Type($dataset_count); | |||||||||||||||||||||||||||
| 384 | 11 | my $graph_appearance = $gpt->{$global_opts{"type of graph"}}; | |||||||||||||||||||||||||||
| 385 | 11 | $def_xmgrace_data_opts{options} = $graph_appearance; | |||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | # mesh data options | ||||||||||||||||||||||||||||
| 388 | 11 | my $data_options_ref = _mesh_xmgrace_opts($user_data_opts_ref, | |||||||||||||||||||||||||||
| 389 | \%def_xmgrace_data_opts); | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | 11 | ▶ | if (not $data_options_ref) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | # error message already printed | ||||||||||||||||||||||||||||
| 393 | 0 | $handle->close(); | |||||||||||||||||||||||||||
| 394 | 0 | _cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 395 | 0 | return 0; | |||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | # change the "title" into "comment" and "legend" | ||||||||||||||||||||||||||||
| 399 | 11 | _set_title($data_options_ref); | |||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | # set data options in the dataset object | ||||||||||||||||||||||||||||
| 402 | 11 | $data_set_object->options($data_options_ref); | |||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | # create new set presention for each data set | ||||||||||||||||||||||||||||
| 405 | 11 | my $sp = $user_data_opts_ref->{"set presentation"}; | |||||||||||||||||||||||||||
| 406 | 11 | ▶ | if ($sp) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ($sp eq "XY") { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 408 | 0 | _set_XY($data_set_object); | |||||||||||||||||||||||||||
| 409 | } elsif ($sp =~ m/BAR/i) { | ||||||||||||||||||||||||||||
| 410 | 0 | _set_BAR($data_set_object); | |||||||||||||||||||||||||||
| 411 | } else { | ||||||||||||||||||||||||||||
| 412 | 0 | carp "Untrapped graph type - Xmgrace.pm internal error"; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | # process data | ||||||||||||||||||||||||||||
| 417 | # accumulate data objects into an array. | ||||||||||||||||||||||||||||
| 418 | 11 | push @cum_data_set_objects, $data_set_object; | |||||||||||||||||||||||||||
| 419 | 11 | $dataset_count++; | |||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | # print commandfile | ||||||||||||||||||||||||||||
| 423 | 1 | ▶ | if ($stdout) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 0 | $handle = \*STDOUT; | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | 1 | $grace->print($handle); | |||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | # we're done crunching on the data now print something! | ||||||||||||||||||||||||||||
| 429 | # print data options | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | 1 | foreach my $set_object (@cum_data_set_objects) { | |||||||||||||||||||||||||||
| 433 | # XXX This code breaks under Perl 5.6 - not sure why XXX | ||||||||||||||||||||||||||||
| 434 | # $set_object->{options}->{options}->print($handle,"s" . | ||||||||||||||||||||||||||||
| 435 | # "$set_object->{set_number}"); | ||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | # print data sets | ||||||||||||||||||||||||||||
| 439 | 1 | foreach my $set_object (@cum_data_set_objects) { | |||||||||||||||||||||||||||
| 440 | 11 | _printline($handle, "target G0.S$set_object->{\"set_number\"}\n"); | |||||||||||||||||||||||||||
| 441 | 11 | _printline($handle, "type $set_object->{\"set_type\"}\n"); | |||||||||||||||||||||||||||
| 442 | 11 | ▶ | if (not _print_data_set($handle, $set_object)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | # already printed error message | ||||||||||||||||||||||||||||
| 444 | 0 | return 0; | |||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | # commandfile successfully completed | ||||||||||||||||||||||||||||
| 449 | 1 | ▶ | $handle->close unless ($stdout); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | # if user chooses to, can save the .agr file | ||||||||||||||||||||||||||||
| 452 | 1 | ▶ | if (defined $grace->{grace_output_file}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 453 | 1 | _copy_commandfile($command_file, $grace->{grace_output_file}); | |||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | # run xmgrace with commandline args to create the specified graph type | ||||||||||||||||||||||||||||
| 457 | # $xmgrace needs to be defined in the user's script | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | 1 | _exec_xmgrace($command_file, $grace, $autoscale); # could probably put the autoscale flag inside the grace object | |||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | } # end of xmgrace() | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | ############################################################ | ||||||||||||||||||||||||||||
| 466 | # | ||||||||||||||||||||||||||||
| 467 | # The following functions are internal functions used by this package. The | ||||||||||||||||||||||||||||
| 468 | # user won't know about these functions. | ||||||||||||||||||||||||||||
| 469 | # | ||||||||||||||||||||||||||||
| 470 | ############################################################ | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | # | ||||||||||||||||||||||||||||
| 473 | # | ||||||||||||||||||||||||||||
| 474 | # Subroutine _is_available_option($$$) | ||||||||||||||||||||||||||||
| 475 | # | ||||||||||||||||||||||||||||
| 476 | # Description: Modest helper subroutine to loop through available | ||||||||||||||||||||||||||||
| 477 | # options for more complex Xmgrace options and return | ||||||||||||||||||||||||||||
| 478 | # true if a match is found. | ||||||||||||||||||||||||||||
| 479 | # | ||||||||||||||||||||||||||||
| 480 | # | ||||||||||||||||||||||||||||
| 481 | 1 | ▶ | sub _is_available_option($$$) { | ||||||||||||||||||||||||||
|
Subroutine
_is_available_option: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 482 | 1 | my $key = shift; | |||||||||||||||||||||||||||
| 483 | 1 | my $to_match = shift; | |||||||||||||||||||||||||||
| 484 | 1 | my $avail_options_ref = shift; | |||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | 1 | ▶ | if (exists($avail_options_ref->{$key})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 487 | 1 | foreach my $option (@{$avail_options_ref->{$key}}) { | |||||||||||||||||||||||||||
| 488 | 3 | ▶ | if ($to_match =~ m/$option/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 489 | 1 | return($option); | |||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | 0 | return(undef); | |||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 1 | ▶ | sub _exec_xmgrace ($$$) { | ||||||||||||||||||||||||||
|
Subroutine
_exec_xmgrace: called CC=9 SCAR=37.7
| |||||||||||||||||||||||||||||
| 499 | 1 | my ($command_file, $grace, $autoscale) = @_; | |||||||||||||||||||||||||||
| 500 | 1 | my ($childpid, $port); | |||||||||||||||||||||||||||
| 501 | 1 | my $display_env = $ENV{DISPLAY}; | |||||||||||||||||||||||||||
| 502 | 1 | my $status; | |||||||||||||||||||||||||||
| 503 | my $framebuffer; | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | #if ($Chart::Graph::use_xvfb) { | ||||||||||||||||||||||||||||
| 506 | # start the virtual X server | ||||||||||||||||||||||||||||
| 507 | #($childpid, $port) = _exec_xvfb(); | ||||||||||||||||||||||||||||
| 508 | # $status = system("$xmgrace -display :$port.0 < $command_file"); | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | #} else { | ||||||||||||||||||||||||||||
| 511 | # use the local X server | ||||||||||||||||||||||||||||
| 512 | # warning: colors might be messed up | ||||||||||||||||||||||||||||
| 513 | # depending on your current setup | ||||||||||||||||||||||||||||
| 514 | #$status = system("$Chart::Graph::xrt3d -display $display_env < $command_file"); | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | #} | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | #my $status = system("$xrt -display :$port.0 < $command_file"); | ||||||||||||||||||||||||||||
| 519 | #if (not _chk_status($status)) { | ||||||||||||||||||||||||||||
| 520 | # return 0; | ||||||||||||||||||||||||||||
| 521 | # } | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | #if ($Chart::Graph::use_xvfb) { | ||||||||||||||||||||||||||||
| 524 | # kill('KILL', $childpid); | ||||||||||||||||||||||||||||
| 525 | # } | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | 1 | ▶ | if ($autoscale eq "") { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 529 | 1 | ▶ | _run_app("$xmgrace", "-hardcopy -hdevice $grace->{output_type}", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 530 | "-printfile $grace->{output_file} $command_file -pexec autoscale") unless $stdout; | ||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if ($Chart::Graph::debug) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 532 | 0 | print STDERR "$xmgrace -hardcopy -hdevice $grace->{output_type} -printfile $grace->{output_file} $command_file -pexec autoscale\n"; | |||||||||||||||||||||||||||
| 533 | 0 | print STDERR "done.\n"; | |||||||||||||||||||||||||||
| 534 | ### fill in tmp files... | ||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | 0 | 1; | |||||||||||||||||||||||||||
| 537 | } elsif ($autoscale eq "x") { | ||||||||||||||||||||||||||||
| 538 | 0 | ▶ | _run_app("$xmgrace", "-autoscale y", "-hardcopy -hdevice $grace->{output_type}", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 539 | "-printfile $grace->{output_file} $command_file -pexec autoscale") unless $stdout; | ||||||||||||||||||||||||||||
| 540 | 0 | print STDERR "xscale\n"; | |||||||||||||||||||||||||||
| 541 | } elsif ($autoscale eq "y") { | ||||||||||||||||||||||||||||
| 542 | 0 | ▶ | _run_app("$xmgrace", "-autoscale x", "-hardcopy -hdevice $grace->{output_type}", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 543 | "-printfile $grace->{output_file} $command_file -autoscale") unless $stdout; | ||||||||||||||||||||||||||||
| 544 | 0 | print STDERR "yscale\n"; | |||||||||||||||||||||||||||
| 545 | } else { | ||||||||||||||||||||||||||||
| 546 | 0 | ▶ | _run_app("$xmgrace", "-autoscale xy", "-hardcopy -hdevice $grace->{output_type}", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 547 | "-printfile $grace->{output_file} $command_file -autoscale") unless $stdout; | ||||||||||||||||||||||||||||
| 548 | 0 | print STDERR "both\n"; | |||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | # | ||||||||||||||||||||||||||||
| 554 | # Subroutine: set_xmgrace_paths() | ||||||||||||||||||||||||||||
| 555 | # | ||||||||||||||||||||||||||||
| 556 | # Description: set paths for external programs required by gnuplot() | ||||||||||||||||||||||||||||
| 557 | # if they are not defined already | ||||||||||||||||||||||||||||
| 558 | # | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | 3 | ▶ | sub _set_xmgrace_paths { | ||||||||||||||||||||||||||
|
Subroutine
_set_xmgrace_paths: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | 3 | ▶ | if (not defined($xmgrace)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 563 | 1 | ▶ | if (not $xmgrace = _get_path("xmgrace")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 564 | 1 | return 0; | |||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | 2 | ▶ | if (not defined($xvfb)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 569 | 1 | ▶ | if (not $xvfb = _get_path("Xvfb")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 570 | 1 | return 0; | |||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | # make sure /usr/dt/lib is in the library path | ||||||||||||||||||||||||||||
| 575 | 1 | _set_ldpath("/usr/dt/lib"); # defined in Xrtutils.pm | |||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | 1 | return 1; | |||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | # | ||||||||||||||||||||||||||||
| 582 | # Subroutine: _xmgrace_data_set() | ||||||||||||||||||||||||||||
| 583 | # | ||||||||||||||||||||||||||||
| 584 | # Description: this function sets up the data sets into a columns format | ||||||||||||||||||||||||||||
| 585 | # and returns a formatted data reference | ||||||||||||||||||||||||||||
| 586 | # | ||||||||||||||||||||||||||||
| 587 | # | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | 11 | ▶ | sub _xmgrace_data_set { | ||||||||||||||||||||||||||
|
Subroutine
_xmgrace_data_set: called CC=5 SCAR=23.2
| |||||||||||||||||||||||||||||
| 590 | 11 | my $data_set_object = shift; | |||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | 11 | my $data_format = $data_set_object->{"data_format"}; | |||||||||||||||||||||||||||
| 593 | 11 | my @data = @{$data_set_object->data}; | |||||||||||||||||||||||||||
| 594 | 11 | my $formatted_data_ref; | |||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | # we give the user 3 formats for supplying the data set | ||||||||||||||||||||||||||||
| 597 | # 1) matrix | ||||||||||||||||||||||||||||
| 598 | # 2) column | ||||||||||||||||||||||||||||
| 599 | # 3) file | ||||||||||||||||||||||||||||
| 600 | # please see the online docs for a description of these | ||||||||||||||||||||||||||||
| 601 | # formats | ||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | 11 | ▶ | if ($data_format eq "matrix") { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 604 | 11 | $formatted_data_ref = _matrix_to_columns(@data); | |||||||||||||||||||||||||||
| 605 | } elsif ($data_format eq "columns") { | ||||||||||||||||||||||||||||
| 606 | 0 | $formatted_data_ref = _columns_to_columns(@data); | |||||||||||||||||||||||||||
| 607 | } elsif ($data_format eq "file") { | ||||||||||||||||||||||||||||
| 608 | 0 | $formatted_data_ref = _file_to_columns(@data); # single item list (filename) | |||||||||||||||||||||||||||
| 609 | } elsif ($data_format eq "") { | ||||||||||||||||||||||||||||
| 610 | 0 | carp "Need to specify data set type"; | |||||||||||||||||||||||||||
| 611 | 0 | return 0; | |||||||||||||||||||||||||||
| 612 | } else { | ||||||||||||||||||||||||||||
| 613 | 0 | carp "Illegal data format: $data_format"; | |||||||||||||||||||||||||||
| 614 | 0 | return 0; | |||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||
| 616 | 11 | return $formatted_data_ref; | |||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | # | ||||||||||||||||||||||||||||
| 620 | # | ||||||||||||||||||||||||||||
| 621 | # Subroutine: matrix_to_columns() | ||||||||||||||||||||||||||||
| 622 | # | ||||||||||||||||||||||||||||
| 623 | # Description: converts the matrix data input into a an array | ||||||||||||||||||||||||||||
| 624 | # of pairs of input. See www for the specific on | ||||||||||||||||||||||||||||
| 625 | # the matrix format | ||||||||||||||||||||||||||||
| 626 | # | ||||||||||||||||||||||||||||
| 627 | # | ||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||
| 629 | 11 | ▶ | sub _matrix_to_columns (\@ ) { | ||||||||||||||||||||||||||
|
Subroutine
_matrix_to_columns: called CC=5 SCAR=17.2
| |||||||||||||||||||||||||||||
| 630 | 11 | my ($matrix_ref) = @_; | |||||||||||||||||||||||||||
| 631 | 11 | my $entry_ref; | |||||||||||||||||||||||||||
| 632 | my $matrix_len; | ||||||||||||||||||||||||||||
| 633 | 11 | my @pairs = (); | |||||||||||||||||||||||||||
| 634 | 11 | my $single_pair = ""; | |||||||||||||||||||||||||||
| 635 | 11 | my (@x_col, @y_col); | |||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | 11 | ▶ | if (ref($matrix_ref) ne "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 638 | 0 | carp "Matrix data must be a reference to an array"; | |||||||||||||||||||||||||||
| 639 | 0 | return 0; | |||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | 11 | $matrix_len = @{$matrix_ref}; | |||||||||||||||||||||||||||
| 643 | 11 | ▶ | for (my $i = 0; $i < $matrix_len; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 644 | 99 | $entry_ref = $matrix_ref->[$i]; | |||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | 99 | ▶ | if (ref($entry_ref) ne "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 647 | 0 | carp "Matrix entry must be a reference to an array"; | |||||||||||||||||||||||||||
| 648 | 0 | return 0; | |||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | # check that each entry ONLY has two entries | ||||||||||||||||||||||||||||
| 652 | 99 | ▶ | if (@{$entry_ref} != 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 653 | 0 | carp "Each entry must be an array of size 2"; | |||||||||||||||||||||||||||
| 654 | 0 | return 0; | |||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | 99 | push @x_col, $entry_ref->[0]; | |||||||||||||||||||||||||||
| 658 | 99 | push @y_col, $entry_ref->[1]; | |||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | 99 | @pairs = (\@x_col, \@y_col); | |||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | 11 | return \@pairs; | |||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | # | ||||||||||||||||||||||||||||
| 667 | # | ||||||||||||||||||||||||||||
| 668 | # Subroutine: columns_to_columns() | ||||||||||||||||||||||||||||
| 669 | # | ||||||||||||||||||||||||||||
| 670 | # Description: converts the column data input into a the gnuplot | ||||||||||||||||||||||||||||
| 671 | # data file format. please see www page for specifics | ||||||||||||||||||||||||||||
| 672 | # on this format. | ||||||||||||||||||||||||||||
| 673 | # | ||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | 0 | ▶ | sub _columns_to_columns (\@ ) { | ||||||||||||||||||||||||||
|
Subroutine
_columns_to_columns: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 676 | 0 | my ($x_col, $y_col) = @{$_[0]}; | |||||||||||||||||||||||||||
| 677 | 0 | my ($x_len, $y_len); | |||||||||||||||||||||||||||
| 678 | 0 | my @pairs = (); | |||||||||||||||||||||||||||
| 679 | 0 | my $single_pair = ""; | |||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | 0 | ▶ | if ((ref($x_col) ne "ARRAY") or (ref($y_col) ne "ARRAY")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $x_col ne "ARRAY" or ref $y_col ne "ARRAY"
MC/DC0%0/2
ref $x_col ne "ARRAY" or ref $y_col ne "ARRAY"
ref $x_col ne "ARRAY"
ref $y_col ne "ARRAY"
Truth table0%0/3
A or B
A= ref $x_col ne "ARRAY"B= ref $y_col ne "ARRAY"
| |||||||||||||||||||||||||||||
| 682 | 0 | ▶ | unless($x_col) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 683 | 0 | carp "No data in X column"; | |||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||
| 685 | 0 | ▶ | unless($y_col) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 686 | 0 | carp "No data in Y column"; | |||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||
| 688 | 0 | carp "Column data must be a reference to an array"; | |||||||||||||||||||||||||||
| 689 | 0 | return 0; | |||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | 0 | $x_len = @{$x_col}; | |||||||||||||||||||||||||||
| 693 | 0 | $y_len = @{$y_col}; | |||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | 0 | ▶ | if ($x_len != $y_len) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 696 | 0 | carp "x and y columns must be of same length"; | |||||||||||||||||||||||||||
| 697 | 0 | return 0; | |||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | 0 | ▶ | if ($x_len == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 701 | 0 | carp "Warning: x column has no data"; | |||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | 0 | ▶ | if ($y_len == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 705 | 0 | carp "Warning: y column has no data"; | |||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | 0 | @pairs = ($x_col, $y_col); | |||||||||||||||||||||||||||
| 709 | 0 | return \@pairs; | |||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | # | ||||||||||||||||||||||||||||
| 713 | # Subroutine: file_to_columns() | ||||||||||||||||||||||||||||
| 714 | # | ||||||||||||||||||||||||||||
| 715 | # Description: If a gnuplot data set was given in | ||||||||||||||||||||||||||||
| 716 | # file format, we simply copy the data | ||||||||||||||||||||||||||||
| 717 | # and read it into | ||||||||||||||||||||||||||||
| 718 | # | ||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | 0 | ▶ | sub _file_to_columns (\@ ) { | ||||||||||||||||||||||||||
|
Subroutine
_file_to_columns: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 721 | 0 | my ($file_in) = @_; | |||||||||||||||||||||||||||
| 722 | 0 | my $single_pair = ""; | |||||||||||||||||||||||||||
| 723 | 0 | my @pairs = (); | |||||||||||||||||||||||||||
| 724 | 0 | my (@x_col, @y_col); | |||||||||||||||||||||||||||
| 725 | 0 | my ($x_len, $y_len); | |||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||
| 727 | 0 | ▶ | if (not $file_in) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 728 | 0 | carp "File data format selected but data set file missing"; | |||||||||||||||||||||||||||
| 729 | 0 | return 0; | |||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||
| 732 | 0 | ▶ | if (not -f $file_in) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 733 | 0 | carp "Data set file, '$file_in', does not exist."; | |||||||||||||||||||||||||||
| 734 | 0 | return 0; | |||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||
| 737 | 0 | my $fh = new FileHandle; | |||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||
| 739 | 0 | ▶ | if (not $fh->open("<$file_in")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 740 | 0 | carp "Could not open file: '$file_in'"; | |||||||||||||||||||||||||||
| 741 | 0 | cleanup_tmpdir(); | |||||||||||||||||||||||||||
| 742 | 0 | return 0; | |||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||
| 745 | 0 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 746 | 0 | chomp; | |||||||||||||||||||||||||||
| 747 | 0 | my @data = split /\s+/; | |||||||||||||||||||||||||||
| 748 | 0 | push @x_col, $data[0]; | |||||||||||||||||||||||||||
| 749 | 0 | push @y_col, $data[1]; | |||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||
| 752 | 0 | $x_len = @x_col; | |||||||||||||||||||||||||||
| 753 | 0 | $y_len = @y_col; | |||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||
| 755 | 0 | ▶ | if ($x_len != $y_len) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 756 | 0 | carp "x and y columns must be of same length"; | |||||||||||||||||||||||||||
| 757 | 0 | return 0; | |||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||
| 760 | 0 | ▶ | if ($x_len == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 761 | 0 | carp "Warning: x column has no data"; | |||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||
| 764 | 0 | ▶ | if ($y_len == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 765 | 0 | carp "Warning: y column has no data"; | |||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||
| 768 | 0 | @pairs = (\@x_col, \@y_col); | |||||||||||||||||||||||||||
| 769 | 0 | $fh->close; | |||||||||||||||||||||||||||
| 770 | 0 | return \@pairs; | |||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||
| 773 | # | ||||||||||||||||||||||||||||
| 774 | # Subroutine: _printline() | ||||||||||||||||||||||||||||
| 775 | # | ||||||||||||||||||||||||||||
| 776 | # Description: prints out an Xmgrace formatted line | ||||||||||||||||||||||||||||
| 777 | # | ||||||||||||||||||||||||||||
| 778 | # | ||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||
| 780 | 22 | ▶ | sub _printline ($$$ ) { | ||||||||||||||||||||||||||
|
Subroutine
_printline: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 781 | 22 | my ($handle, $string, $length) = @_; | |||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||
| 783 | 22 | ▶ | unless ($length) {$length = 1;} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 784 | 22 | print $handle "@"; | |||||||||||||||||||||||||||
| 785 | 22 | print $handle ' ' x $length; | |||||||||||||||||||||||||||
| 786 | 22 | print $handle "$string"; | |||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||
| 788 | 22 | return 1; # just for fun | |||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||
| 792 | # | ||||||||||||||||||||||||||||
| 793 | # Subroutine: _copy_commandfile() | ||||||||||||||||||||||||||||
| 794 | # | ||||||||||||||||||||||||||||
| 795 | # Description: copies the temp commandfile into a grace | ||||||||||||||||||||||||||||
| 796 | # output file (.agr) | ||||||||||||||||||||||||||||
| 797 | # | ||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||
| 799 | 1 | ▶ | sub _copy_commandfile ($$ ) { | ||||||||||||||||||||||||||
|
Subroutine
_copy_commandfile: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||
| 801 | 1 | my ($commandfile, $grace_output_file) = @_; | |||||||||||||||||||||||||||
| 802 | 1 | my $status = system("cp", "$commandfile", "$grace_output_file"); | |||||||||||||||||||||||||||
| 803 | 1 | ▶ | if (not _chk_status($status)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 804 | 0 | return 0; | |||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||
| 808 | # | ||||||||||||||||||||||||||||
| 809 | # Subroutine: _make_gracefile() | ||||||||||||||||||||||||||||
| 810 | # | ||||||||||||||||||||||||||||
| 811 | # Description: constructs the gracefile.agr name | ||||||||||||||||||||||||||||
| 812 | # | ||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | 1 | ▶ | sub _make_gracefile ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_make_gracefile: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||
| 816 | 1 | my $file = shift; | |||||||||||||||||||||||||||
| 817 | 1 | my $ext = ".agr"; | |||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||
| 819 | 1 | ▶ | if ($file !~ m|\.agr$|) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 820 | 0 | return "$file$ext"; | |||||||||||||||||||||||||||
| 821 | } else { | ||||||||||||||||||||||||||||
| 822 | 1 | return "$file"; | |||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||
| 826 | # | ||||||||||||||||||||||||||||
| 827 | # Subroutine: _check_output_type() | ||||||||||||||||||||||||||||
| 828 | # | ||||||||||||||||||||||||||||
| 829 | # Description: checks user output type to known output types. | ||||||||||||||||||||||||||||
| 830 | # | ||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||
| 832 | 1 | ▶ | sub _check_output_type ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_check_output_type: called CC=4 SCAR=14.8
| |||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||
| 834 | 1 | my $user_type = shift; | |||||||||||||||||||||||||||
| 835 | 1 | my @types = ("PNG", "PS", "JPEG", "PNM"); | |||||||||||||||||||||||||||
| 836 | 1 | my $seen = 0; | |||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||
| 838 | 1 | foreach my $known_type (@types) { | |||||||||||||||||||||||||||
| 839 | 1 | ▶ | if ($user_type =~ m|$known_type|i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 840 | 1 | $seen = 1; | |||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||
| 842 | 1 | ▶ | if ($seen) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 843 | 1 | return 1; | |||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||
| 846 | 0 | carp "Unknown output type: \'$user_type\'\nUsing default output type: \'PNG\'"; | |||||||||||||||||||||||||||
| 847 | 0 | return 0; | |||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||
| 851 | # | ||||||||||||||||||||||||||||
| 852 | # Subroutine: _run_app() | ||||||||||||||||||||||||||||
| 853 | # | ||||||||||||||||||||||||||||
| 854 | # Description: to simplify calls to external applications | ||||||||||||||||||||||||||||
| 855 | # | ||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||
| 857 | 1 | ▶ | sub _run_app($@ ) { | ||||||||||||||||||||||||||
|
Subroutine
_run_app: called CC=3 SCAR=14.8
| |||||||||||||||||||||||||||||
| 858 | 1 | my $application = shift; | |||||||||||||||||||||||||||
| 859 | 1 | my @arguments = @_; | |||||||||||||||||||||||||||
| 860 | 1 | my $command_str; | |||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||
| 862 | # Run application | ||||||||||||||||||||||||||||
| 863 | # Test if an executable file exists as specified location | ||||||||||||||||||||||||||||
| 864 | 1 | ▶ | if (-x "$application") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 865 | # Try to run application. Quit if that fails. | ||||||||||||||||||||||||||||
| 866 | 0 | $command_str = join(' ', $application, @arguments); | |||||||||||||||||||||||||||
| 867 | 0 | my $rc = 0xffff & system ($command_str); | |||||||||||||||||||||||||||
| 868 | 0 | ▶ | if ($rc != 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 869 | 0 | die "Execution error: $application"; | |||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||
| 871 | } else { | ||||||||||||||||||||||||||||
| 872 | 1 | die "No such application: $application"; | |||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||
| 876 | # | ||||||||||||||||||||||||||||
| 877 | # Subroutine: _mesh_xmgrace_opts | ||||||||||||||||||||||||||||
| 878 | # | ||||||||||||||||||||||||||||
| 879 | # Description: meshes the user's data_options with the default | ||||||||||||||||||||||||||||
| 880 | # data options these "options" include: title, set | ||||||||||||||||||||||||||||
| 881 | # presentation, options, and data format | ||||||||||||||||||||||||||||
| 882 | # | ||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||
| 884 | 11 | ▶ | sub _mesh_xmgrace_opts { | ||||||||||||||||||||||||||
|
Subroutine
_mesh_xmgrace_opts: called CC=6 SCAR=18.4
| |||||||||||||||||||||||||||||
| 885 | 11 | my ($user_opts_ref, $default_opts_ref) = @_; | |||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||
| 887 | 11 | my %user_opts = %{$user_opts_ref}; | |||||||||||||||||||||||||||
| 888 | 11 | my %default_opts = %{$default_opts_ref}; | |||||||||||||||||||||||||||
| 889 | 11 | my %opts; | |||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||
| 891 | # check user opts against defaults and mesh | ||||||||||||||||||||||||||||
| 892 | # the basic algorithm here is to override the | ||||||||||||||||||||||||||||
| 893 | # the default options against the ones that | ||||||||||||||||||||||||||||
| 894 | # the user has passed in. | ||||||||||||||||||||||||||||
| 895 | 11 | ▶ | while (my ($key, $value) = each %default_opts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||
| 897 | 44 | ▶ | if ($key eq "options") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 898 | 11 | my $opts_obj = $def_xmgrace_data_opts{options}; | |||||||||||||||||||||||||||
| 899 | 11 | my $def_options = $opts_obj->{options}; | |||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||
| 901 | 11 | ▶ | if (defined($user_opts{options})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 902 | # if user provides options for the datasets we mesh them | ||||||||||||||||||||||||||||
| 903 | my $data_options_obj = _mesh_option_opts($user_opts_ref->{options}, | ||||||||||||||||||||||||||||
| 904 | 0 | $def_options); | |||||||||||||||||||||||||||
| 905 | 0 | $opts_obj->{options} = $data_options_obj; | |||||||||||||||||||||||||||
| 906 | 0 | $opts{options} = $opts_obj; | |||||||||||||||||||||||||||
| 907 | 0 | delete $user_opts{$key}; # remove options | |||||||||||||||||||||||||||
| 908 | } else { | ||||||||||||||||||||||||||||
| 909 | 11 | $opts_obj->{options} = $def_options; | |||||||||||||||||||||||||||
| 910 | 11 | $opts{options} = $opts_obj; | |||||||||||||||||||||||||||
| 911 | } | ||||||||||||||||||||||||||||
| 912 | } else { | ||||||||||||||||||||||||||||
| 913 | 33 | ▶ | if (defined($user_opts{$key})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 914 | 22 | $opts{$key} = $user_opts{$key}; | |||||||||||||||||||||||||||
| 915 | 22 | delete $user_opts{$key}; # remove options | |||||||||||||||||||||||||||
| 916 | # that are matching | ||||||||||||||||||||||||||||
| 917 | } else { | ||||||||||||||||||||||||||||
| 918 | 11 | $opts{$key} = $default_opts{$key}; | |||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||
| 923 | # any left over options in the table are unknown | ||||||||||||||||||||||||||||
| 924 | # if the user passes in illegal options then we | ||||||||||||||||||||||||||||
| 925 | # warn them with an error message but still | ||||||||||||||||||||||||||||
| 926 | # proceed. | ||||||||||||||||||||||||||||
| 927 | 11 | ▶ | while (my ($key, $value) = each %user_opts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 928 | 0 | carp "unknown option: $key"; | |||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||
| 931 | 11 | return \%opts; | |||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||
| 934 | # | ||||||||||||||||||||||||||||
| 935 | # Name: _mesh_option_opts | ||||||||||||||||||||||||||||
| 936 | # | ||||||||||||||||||||||||||||
| 937 | # Description: if the user introduces a "option" in their dataset | ||||||||||||||||||||||||||||
| 938 | # hash, we use this function to mesh those options | ||||||||||||||||||||||||||||
| 939 | # with the default options of a particular dataset. | ||||||||||||||||||||||||||||
| 940 | # note: default options depend on the type of | ||||||||||||||||||||||||||||
| 941 | # graph | ||||||||||||||||||||||||||||
| 942 | # | ||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||
| 944 | 0 | ▶ | sub _mesh_option_opts { | ||||||||||||||||||||||||||
|
Subroutine
_mesh_option_opts: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 945 | 0 | my ($user_opts_ref, $default_opts_ref) = @_; | |||||||||||||||||||||||||||
| 946 | 0 | my %user_opts = %{$user_opts_ref}; | |||||||||||||||||||||||||||
| 947 | 0 | my %def_options = %{$default_opts_ref}; | |||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||
| 949 | # check user opts against defaults and mesh | ||||||||||||||||||||||||||||
| 950 | # the basic algorithm here is to override the | ||||||||||||||||||||||||||||
| 951 | # the default options against the ones that | ||||||||||||||||||||||||||||
| 952 | # the user has passed in. | ||||||||||||||||||||||||||||
| 953 | 0 | ▶ | while (my ($key, $value) = each %def_options) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 954 | 0 | ▶ | if (defined($user_opts{$key})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||
| 956 | 0 | ▶ | if (!ref($value)) { # scalar | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 957 | 0 | $def_options{$key} = $user_opts{$key}; | |||||||||||||||||||||||||||
| 958 | 0 | delete $user_opts{$key}; # remove options | |||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||
| 961 | else { # blessed object | ||||||||||||||||||||||||||||
| 962 | 0 | my $return_obj; | |||||||||||||||||||||||||||
| 963 | 0 | my $class = ref($def_options{$key}); | |||||||||||||||||||||||||||
| 964 | $return_obj = _mesh_option_opts($user_opts_ref->{$key}, | ||||||||||||||||||||||||||||
| 965 | 0 | $def_options{$key}->{options}); | |||||||||||||||||||||||||||
| 966 | 0 | bless($return_obj, $class); | |||||||||||||||||||||||||||
| 967 | 0 | $def_options{$key}->{options} = $return_obj; | |||||||||||||||||||||||||||
| 968 | 0 | delete $user_opts{$key}; | |||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||
| 973 | # any left over options in the table are unknown | ||||||||||||||||||||||||||||
| 974 | # if the user passes in illegal options then we | ||||||||||||||||||||||||||||
| 975 | # warn them with an error message but still | ||||||||||||||||||||||||||||
| 976 | # proceed. | ||||||||||||||||||||||||||||
| 977 | 0 | ▶ | while (my ($key, $value) = each %user_opts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 978 | 0 | carp "unknown option: $key"; | |||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||
| 981 | 0 | my $ret_obj = \%def_options; | |||||||||||||||||||||||||||
| 982 | 0 | return $ret_obj; | |||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||
| 985 | # | ||||||||||||||||||||||||||||
| 986 | # Name: _print_data_set | ||||||||||||||||||||||||||||
| 987 | # | ||||||||||||||||||||||||||||
| 988 | # Description: used to print out the data in the dataset in a | ||||||||||||||||||||||||||||
| 989 | # formatted manner | ||||||||||||||||||||||||||||
| 990 | # | ||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||
| 992 | 11 | ▶ | sub _print_data_set ($\@ ) { | ||||||||||||||||||||||||||
|
Subroutine
_print_data_set: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||
| 993 | 11 | my ($handle, $set_object) = @_; | |||||||||||||||||||||||||||
| 994 | 11 | my ($x_col, $y_col); | |||||||||||||||||||||||||||
| 995 | 11 | my $length; | |||||||||||||||||||||||||||
| 996 | 11 | my $i; | |||||||||||||||||||||||||||
| 997 | 11 | my $delimeter = "\t\t"; # set to 15 spaces, nice one xmgrace! | |||||||||||||||||||||||||||
| 998 | 11 | my $pairs = $set_object->data; | |||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||
| 1000 | 11 | ($x_col, $y_col) = ($pairs->[0], $pairs->[1]); | |||||||||||||||||||||||||||
| 1001 | 11 | $length = $#{$x_col}; | |||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||
| 1003 | # | ||||||||||||||||||||||||||||
| 1004 | # data set format | ||||||||||||||||||||||||||||
| 1005 | # @target G<graph #>.S<set #> | ||||||||||||||||||||||||||||
| 1006 | # @type $type_of_graph | ||||||||||||||||||||||||||||
| 1007 | # x1 y1 | ||||||||||||||||||||||||||||
| 1008 | # . . | ||||||||||||||||||||||||||||
| 1009 | # . . | ||||||||||||||||||||||||||||
| 1010 | # xn yn | ||||||||||||||||||||||||||||
| 1011 | # & | ||||||||||||||||||||||||||||
| 1012 | # | ||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||
| 1014 | # we don't print out the hidden data set | ||||||||||||||||||||||||||||
| 1015 | # XXX Protection against trying to access nonexistentant | ||||||||||||||||||||||||||||
| 1016 | # XXX accessor function or OVERLOADED function? | ||||||||||||||||||||||||||||
| 1017 | 11 | ▶ | if (exists($set_object->{options}->{options}->{hidden})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1018 | # This statement now breaks in 5.6 - unblessed reference. | ||||||||||||||||||||||||||||
| 1019 | 0 | ▶ | if ($set_object->{options}->{options}->hidden eq "true") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1020 | 0 | return 1; | |||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||
| 1024 | 11 | ▶ | for ($i = 0; $i <= $length; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1025 | 99 | print $handle "$delimeter", "$x_col->[$i]", "$delimeter", | |||||||||||||||||||||||||||
| 1026 | "$y_col->[$i]\n"; | ||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||
| 1029 | # each data set is separated by a "&" | ||||||||||||||||||||||||||||
| 1030 | 11 | print $handle "&\n"; | |||||||||||||||||||||||||||
| 1031 | 11 | return 1; | |||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||
| 1035 | # | ||||||||||||||||||||||||||||
| 1036 | # Name: _set_BAR | ||||||||||||||||||||||||||||
| 1037 | # | ||||||||||||||||||||||||||||
| 1038 | # Description: sets up the necessary characteristics of a BAR | ||||||||||||||||||||||||||||
| 1039 | # dataset type | ||||||||||||||||||||||||||||
| 1040 | # | ||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||
| 1042 | 0 | ▶ | sub _set_BAR ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_set_BAR: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 1043 | 0 | my $ds_object = shift; | |||||||||||||||||||||||||||
| 1044 | 0 | my $data_options_ref = $ds_object->{options}; | |||||||||||||||||||||||||||
| 1045 | 0 | $ds_object->set_type("BAR"); | |||||||||||||||||||||||||||
| 1046 | 0 | $data_options_ref->{options}->type("BAR"); | |||||||||||||||||||||||||||
| 1047 | 0 | $data_options_ref->{options}->symbol->fill_pattern("1"); | |||||||||||||||||||||||||||
| 1048 | 0 | $data_options_ref->{options}->symbol->color("1"); | |||||||||||||||||||||||||||
| 1049 | 0 | $data_options_ref->{options}->line->type("0"); | |||||||||||||||||||||||||||
| 1050 | 0 | return 1; | |||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||
| 1053 | # | ||||||||||||||||||||||||||||
| 1054 | # Name: _set_XY | ||||||||||||||||||||||||||||
| 1055 | # | ||||||||||||||||||||||||||||
| 1056 | # Description: sets up the necessary characteristics of an XY | ||||||||||||||||||||||||||||
| 1057 | # dataset type | ||||||||||||||||||||||||||||
| 1058 | # | ||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||
| 1060 | 0 | ▶ | sub _set_XY ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_set_XY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 1061 | 0 | my $ds_object = shift; | |||||||||||||||||||||||||||
| 1062 | 0 | my $data_options_ref = $ds_object->{options}; | |||||||||||||||||||||||||||
| 1063 | 0 | $ds_object->set_type("XY"); | |||||||||||||||||||||||||||
| 1064 | 0 | $data_options_ref->{options}->type("XY"); | |||||||||||||||||||||||||||
| 1065 | 0 | $data_options_ref->{options}->symbol->fill_pattern("0"); | |||||||||||||||||||||||||||
| 1066 | 0 | $data_options_ref->{options}->line->type("1"); | |||||||||||||||||||||||||||
| 1067 | 0 | return 1; | |||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||
| 1070 | # Name: _set_title | ||||||||||||||||||||||||||||
| 1071 | # | ||||||||||||||||||||||||||||
| 1072 | # Description: sets up the necessary characteristics for the | ||||||||||||||||||||||||||||
| 1073 | # title of the graph | ||||||||||||||||||||||||||||
| 1074 | # | ||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||
| 1076 | 11 | ▶ | sub _set_title ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_set_title: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1077 | 11 | my $ds_ref = shift; | |||||||||||||||||||||||||||
| 1078 | 11 | my $title = $ds_ref->{title}; | |||||||||||||||||||||||||||
| 1079 | 11 | $ds_ref->{options}->{options}->{comment} = $title; | |||||||||||||||||||||||||||
| 1080 | 11 | $ds_ref->{options}->{options}->{legend} = $title; | |||||||||||||||||||||||||||
| 1081 | 11 | return 1; | |||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||
| 1084 | #################################################################### | ||||||||||||||||||||||||||||
| 1085 | # | ||||||||||||||||||||||||||||
| 1086 | # The following functions are used to map an option value from | ||||||||||||||||||||||||||||
| 1087 | # prose to it's corresponding number value which grace understands | ||||||||||||||||||||||||||||
| 1088 | # Note: these routines are not used in the current version. the user | ||||||||||||||||||||||||||||
| 1089 | # must use numbers (NOT prose) for now. | ||||||||||||||||||||||||||||
| 1090 | # | ||||||||||||||||||||||||||||
| 1091 | ################################################################### | ||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||
| 1094 | # | ||||||||||||||||||||||||||||
| 1095 | # Subroutine: _get_color() | ||||||||||||||||||||||||||||
| 1096 | # | ||||||||||||||||||||||||||||
| 1097 | # Description: simply looks up a hash table and returns | ||||||||||||||||||||||||||||
| 1098 | # a number that xmgrace understands that | ||||||||||||||||||||||||||||
| 1099 | # corresponds to the color | ||||||||||||||||||||||||||||
| 1100 | # | ||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||
| 1102 | 0 | ▶ | sub _get_color ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_get_color: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 1103 | 0 | my $color = shift; | |||||||||||||||||||||||||||
| 1104 | 0 | my %colortable = ( | |||||||||||||||||||||||||||
| 1105 | "white" => "0", | ||||||||||||||||||||||||||||
| 1106 | "black" => "1", | ||||||||||||||||||||||||||||
| 1107 | "red" => "2", | ||||||||||||||||||||||||||||
| 1108 | "green" => "3", | ||||||||||||||||||||||||||||
| 1109 | "blue" => "4", | ||||||||||||||||||||||||||||
| 1110 | "yellow" => "5", | ||||||||||||||||||||||||||||
| 1111 | "brown" => "6", | ||||||||||||||||||||||||||||
| 1112 | "grey" => "7", | ||||||||||||||||||||||||||||
| 1113 | "violet" => "8", | ||||||||||||||||||||||||||||
| 1114 | "cyan" => "9", | ||||||||||||||||||||||||||||
| 1115 | "magenta" => "10", | ||||||||||||||||||||||||||||
| 1116 | "orange" => "11", | ||||||||||||||||||||||||||||
| 1117 | "indigo" => "12", | ||||||||||||||||||||||||||||
| 1118 | "maroon" => "13", | ||||||||||||||||||||||||||||
| 1119 | "turquoise" => "14", | ||||||||||||||||||||||||||||
| 1120 | "green4" => "15", | ||||||||||||||||||||||||||||
| 1121 | ); | ||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||
| 1123 | 0 | $color = lc($color); | |||||||||||||||||||||||||||
| 1124 | # "\L$color\E" | ||||||||||||||||||||||||||||
| 1125 | #color =~ y/A-Z/a-z/; | ||||||||||||||||||||||||||||
| 1126 | 0 | my $retval = $colortable{$color}; | |||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||
| 1128 | 0 | ▶ | if ($retval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1129 | 0 | return $retval; | |||||||||||||||||||||||||||
| 1130 | } else { | ||||||||||||||||||||||||||||
| 1131 | 0 | return 0; | |||||||||||||||||||||||||||
| 1132 | } | ||||||||||||||||||||||||||||
| 1133 | } | ||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||
| 1135 | # | ||||||||||||||||||||||||||||
| 1136 | # Subroutine: _get_symbol() | ||||||||||||||||||||||||||||
| 1137 | # | ||||||||||||||||||||||||||||
| 1138 | # Description: simply looks up a hash table and returns | ||||||||||||||||||||||||||||
| 1139 | # a number that xmgrace understands that | ||||||||||||||||||||||||||||
| 1140 | # corresponds to the symbol | ||||||||||||||||||||||||||||
| 1141 | # | ||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||
| 1143 | 0 | ▶ | sub _get_symbol ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_get_symbol: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 1144 | 0 | my $symbol = shift; | |||||||||||||||||||||||||||
| 1145 | 0 | my %symtab = ( | |||||||||||||||||||||||||||
| 1146 | "none" => "0", | ||||||||||||||||||||||||||||
| 1147 | "circle" => "1", | ||||||||||||||||||||||||||||
| 1148 | "square" => "2", | ||||||||||||||||||||||||||||
| 1149 | "diamond" => "3", | ||||||||||||||||||||||||||||
| 1150 | "triangle up" => "4", | ||||||||||||||||||||||||||||
| 1151 | "triangle left" => "5", | ||||||||||||||||||||||||||||
| 1152 | "triangle down" => "6", | ||||||||||||||||||||||||||||
| 1153 | "triangle right" => "7", | ||||||||||||||||||||||||||||
| 1154 | "plus" => "8", | ||||||||||||||||||||||||||||
| 1155 | "x" => "9", | ||||||||||||||||||||||||||||
| 1156 | "star" => "10", | ||||||||||||||||||||||||||||
| 1157 | "char" => "11", | ||||||||||||||||||||||||||||
| 1158 | ); | ||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||
| 1160 | 0 | $symbol = lc($symbol); | |||||||||||||||||||||||||||
| 1161 | 0 | my $retval = $symtab{$symbol}; | |||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | if ($retval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1164 | 0 | return $retval; | |||||||||||||||||||||||||||
| 1165 | } else { | ||||||||||||||||||||||||||||
| 1166 | 0 | return 0; | |||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||
| 1171 | # | ||||||||||||||||||||||||||||
| 1172 | # Subroutine: _get_linetype() | ||||||||||||||||||||||||||||
| 1173 | # | ||||||||||||||||||||||||||||
| 1174 | # Description: simply looks up a hash table and returns | ||||||||||||||||||||||||||||
| 1175 | # a number that xmgrace understands that | ||||||||||||||||||||||||||||
| 1176 | # corresponds to the linetype | ||||||||||||||||||||||||||||
| 1177 | # | ||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | sub _get_linetype ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_get_linetype: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 1180 | 0 | my $linetype = shift; | |||||||||||||||||||||||||||
| 1181 | 0 | my %linetypetab = ( | |||||||||||||||||||||||||||
| 1182 | "none" => "0", | ||||||||||||||||||||||||||||
| 1183 | "straight" => "1", | ||||||||||||||||||||||||||||
| 1184 | "left stairs" => "2", | ||||||||||||||||||||||||||||
| 1185 | "right stairs" => "3", | ||||||||||||||||||||||||||||
| 1186 | "segments" => "4", | ||||||||||||||||||||||||||||
| 1187 | "3-segments" => "5", | ||||||||||||||||||||||||||||
| 1188 | ); | ||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||
| 1190 | 0 | $linetype = lc($linetype); | |||||||||||||||||||||||||||
| 1191 | 0 | my $retval = $linetypetab{$linetype}; | |||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||
| 1193 | 0 | ▶ | if ($retval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1194 | 0 | return $retval; | |||||||||||||||||||||||||||
| 1195 | } else { | ||||||||||||||||||||||||||||
| 1196 | 0 | return 0; | |||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||
| 1200 | # | ||||||||||||||||||||||||||||
| 1201 | # Subroutine: _get_linestyle() | ||||||||||||||||||||||||||||
| 1202 | # | ||||||||||||||||||||||||||||
| 1203 | # Description: simply looks up a hash table and returns | ||||||||||||||||||||||||||||
| 1204 | # a number that xmgrace understands that | ||||||||||||||||||||||||||||
| 1205 | # corresponds to the linestyle | ||||||||||||||||||||||||||||
| 1206 | # | ||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||
| 1208 | 0 | ▶ | sub _get_linestyle ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_get_linestyle: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 1209 | 0 | my $linestyle = shift; | |||||||||||||||||||||||||||
| 1210 | 0 | my %linestyletab = ( | |||||||||||||||||||||||||||
| 1211 | "none" => "0", | ||||||||||||||||||||||||||||
| 1212 | "solid" => "1", | ||||||||||||||||||||||||||||
| 1213 | "dotted" => "2", | ||||||||||||||||||||||||||||
| 1214 | "en dash" => "3", | ||||||||||||||||||||||||||||
| 1215 | "em dash" => "4", | ||||||||||||||||||||||||||||
| 1216 | "dot-en dash" => "5", | ||||||||||||||||||||||||||||
| 1217 | "dot-em dash" => "6", | ||||||||||||||||||||||||||||
| 1218 | "dot-en-dot dash" => "7", | ||||||||||||||||||||||||||||
| 1219 | "en-dot-en dash" => "8", | ||||||||||||||||||||||||||||
| 1220 | ); | ||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||
| 1222 | 0 | $linestyle = lc($linestyle); | |||||||||||||||||||||||||||
| 1223 | 0 | my $retval = $linestyletab{$linestyle}; | |||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||
| 1225 | 0 | ▶ | if ($retval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1226 | 0 | return $retval; | |||||||||||||||||||||||||||
| 1227 | } else { | ||||||||||||||||||||||||||||
| 1228 | 0 | return 0; | |||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||
| 1232 | # | ||||||||||||||||||||||||||||
| 1233 | # Subroutine: _get_baselinetype() | ||||||||||||||||||||||||||||
| 1234 | # | ||||||||||||||||||||||||||||
| 1235 | # Description: simply looks up a hash table and returns | ||||||||||||||||||||||||||||
| 1236 | # a number that xmgrace understands that | ||||||||||||||||||||||||||||
| 1237 | # corresponds to the baselinetype | ||||||||||||||||||||||||||||
| 1238 | # | ||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||
| 1240 | 0 | ▶ | sub _get_baselinetype ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_get_baselinetype: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 1241 | 0 | my $baselinetype = shift; | |||||||||||||||||||||||||||
| 1242 | 0 | my %baselinetypetab = ( | |||||||||||||||||||||||||||
| 1243 | "zero" => "0", | ||||||||||||||||||||||||||||
| 1244 | "set min" => "1", | ||||||||||||||||||||||||||||
| 1245 | "set max" => "2", | ||||||||||||||||||||||||||||
| 1246 | "graph min" => "3", | ||||||||||||||||||||||||||||
| 1247 | "graph max" => "4", | ||||||||||||||||||||||||||||
| 1248 | ); | ||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||
| 1250 | 0 | $baselinetype = lc($baselinetype); | |||||||||||||||||||||||||||
| 1251 | 0 | my $retval = $baselinetypetab{$baselinetype}; | |||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||
| 1253 | 0 | ▶ | if ($retval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1254 | 0 | return $retval; | |||||||||||||||||||||||||||
| 1255 | } else { | ||||||||||||||||||||||||||||
| 1256 | 0 | return 0; | |||||||||||||||||||||||||||
| 1257 | } | ||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||
| 1261 | # | ||||||||||||||||||||||||||||
| 1262 | # Subroutine: _get_filltype() | ||||||||||||||||||||||||||||
| 1263 | # | ||||||||||||||||||||||||||||
| 1264 | # Description: simply looks up a hash table and returns | ||||||||||||||||||||||||||||
| 1265 | # a number that xmgrace understands that | ||||||||||||||||||||||||||||
| 1266 | # corresponds to the filltype | ||||||||||||||||||||||||||||
| 1267 | # | ||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||
| 1269 | 0 | ▶ | sub _get_filltype ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_get_filltype: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 1270 | 0 | my $filltype = shift; | |||||||||||||||||||||||||||
| 1271 | 0 | my %filltypetab = ( | |||||||||||||||||||||||||||
| 1272 | "none" => "0", | ||||||||||||||||||||||||||||
| 1273 | "as polygon" => "1", | ||||||||||||||||||||||||||||
| 1274 | "to baseline" => "2", | ||||||||||||||||||||||||||||
| 1275 | ); | ||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||
| 1277 | 0 | $filltype = lc($filltype); | |||||||||||||||||||||||||||
| 1278 | 0 | my $retval = $filltypetab{$filltype}; | |||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||
| 1280 | 0 | ▶ | if ($retval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1281 | 0 | return $retval; | |||||||||||||||||||||||||||
| 1282 | } else { | ||||||||||||||||||||||||||||
| 1283 | 0 | return 0; | |||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||
| 1287 | # | ||||||||||||||||||||||||||||
| 1288 | # Subroutine: _get_avaluetype() | ||||||||||||||||||||||||||||
| 1289 | # | ||||||||||||||||||||||||||||
| 1290 | # Description: simply looks up a hash table and returns | ||||||||||||||||||||||||||||
| 1291 | # a number that xmgrace understands that | ||||||||||||||||||||||||||||
| 1292 | # corresponds to the avaluetype | ||||||||||||||||||||||||||||
| 1293 | # | ||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||
| 1295 | 0 | ▶ | sub _get_avaluetype ($ ) { | ||||||||||||||||||||||||||
|
Subroutine
_get_avaluetype: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 1296 | 0 | my $avaluetype = shift; | |||||||||||||||||||||||||||
| 1297 | 0 | my %avaluetypetab = ( | |||||||||||||||||||||||||||
| 1298 | "none" => "0", | ||||||||||||||||||||||||||||
| 1299 | "x" => "1", | ||||||||||||||||||||||||||||
| 1300 | "y" => "2", | ||||||||||||||||||||||||||||
| 1301 | "xy" => "3", | ||||||||||||||||||||||||||||
| 1302 | "string" => "4", | ||||||||||||||||||||||||||||
| 1303 | "z" => "5", | ||||||||||||||||||||||||||||
| 1304 | ); | ||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||
| 1306 | 0 | $avaluetype = lc($avaluetype); | |||||||||||||||||||||||||||
| 1307 | 0 | my $retval = $avaluetypetab{$avaluetype}; | |||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||
| 1309 | 0 | ▶ | if ($retval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1310 | 0 | return $retval; | |||||||||||||||||||||||||||
| 1311 | } else { | ||||||||||||||||||||||||||||
| 1312 | 0 | return 0; | |||||||||||||||||||||||||||
| 1313 | } | ||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||
| 1317 | 4 | 1; | |||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||
| 1319 | __END__ | ||||||||||||||||||||||||||||