# subplot-commands.rb: commands for dealing with subplots # copyright (c) 2009 by Vincent Fourmond # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details (in the COPYING file). require 'ctioga2/utils' require 'ctioga2/log' module CTioga2 module Graphics # The group containing all commands linked to subplots and other # insets, frame margin selections... SubplotsGroup = CmdGroup.new('subplots', "Subplots and assimilated", "Subplots and assimilated", 31) SetFrameMarginsCommand = Cmd.new("frame-margins",nil,"--frame-margins", [ CmdArg.new('frame-margins'), ]) do |plotmaker, margins| plotmaker.root_object.current_plot.subframe = margins end SetFrameMarginsCommand.describe('Sets the margins of the current plot', < CmdArg.new('color'), 'transparency' => CmdArg.new('float'), 'reversed_color' => CmdArg.new('color'), 'reversed_transparency' => CmdArg.new('float'), } RegionCommand = Cmd.new("region",nil,"--region", [ ], RegionOptions) do |plotmaker, options| r = plotmaker.root_object.enter_region r.set_from_hash(options) end RegionCommand.describe('Starts a region with filling between curves', < CmdArg.new('text')}) do |plotmaker, scale, options| what = options['what'] || 'text' case what when /text/i Styles::PlotStyle.current_plot_style(plotmaker).text_scale = scale when /lines/i Styles::PlotStyle.current_plot_style(plotmaker).lines_scale = scale when /both/i Styles::PlotStyle.current_plot_style(plotmaker).text_scale = scale Styles::PlotStyle.current_plot_style(plotmaker).lines_scale = scale else CTioga2::Log::error { "Unkown 'what' option for plot-scale: #{what}" } end end RescaleCommand.describe('Rescales the current (sub)plot', <