From: cvs Date: Thu, 7 Oct 1999 15:56:28 +0000 (+0000) Subject: Add ways to declare the parameters of output formats once and for all. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8884aa2104933afba4a974f5a2a0cbd8f6c4895;p=dealii-svn.git Add ways to declare the parameters of output formats once and for all. git-svn-id: https://svn.dealii.org/trunk@1748 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/data_out_base.h b/deal.II/base/include/base/data_out_base.h index 363b609c8c..79718a8539 100644 --- a/deal.II/base/include/base/data_out_base.h +++ b/deal.II/base/include/base/data_out_base.h @@ -5,6 +5,7 @@ /*---------------------------- data_out_base.h ---------------------------*/ +#include #include #include #include @@ -331,6 +332,24 @@ class DataOutBase * Constructor. */ UcdFlags (const bool write_preamble = true); + + /** + * Declare all flags with name + * and type as offered by this + * class, for use in input files. + */ + static void declare_parameters (ParameterHandler &prm); + + /** + * Read the parameters declared in + * #declare_parameters# and set the + * flags for this output format + * accordingly. + * + * The flags thus obtained overwrite + * all previous contents of this object. + */ + void parse_parameters (ParameterHandler &prm); }; /** @@ -350,6 +369,25 @@ class DataOutBase * #private# as well). */ int dummy; + + public: + /** + * Declare all flags with name + * and type as offered by this + * class, for use in input files. + */ + static void declare_parameters (ParameterHandler &prm); + + /** + * Read the parameters declared in + * #declare_parameters# and set the + * flags for this output format + * accordingly. + * + * The flags thus obtained overwrite + * all previous contents of this object. + */ + void parse_parameters (ParameterHandler &prm); }; /** @@ -369,6 +407,25 @@ class DataOutBase * #private# as well). */ int dummy; + + public: + /** + * Declare all flags with name + * and type as offered by this + * class, for use in input files. + */ + static void declare_parameters (ParameterHandler &prm); + + /** + * Read the parameters declared in + * #declare_parameters# and set the + * flags for this output format + * accordingly. + * + * The flags thus obtained overwrite + * all previous contents of this object. + */ + void parse_parameters (ParameterHandler &prm); }; @@ -606,6 +663,28 @@ class DataOutBase const bool draw_cells = true, const bool shade_cells = true, const ColorFunction color_function= &default_color_function); + + /** + * Declare all flags with name + * and type as offered by this + * class, for use in input files. + * + * For coloring, only the color + * functions declared in this + * class are offered. + */ + static void declare_parameters (ParameterHandler &prm); + + /** + * Read the parameters declared in + * #declare_parameters# and set the + * flags for this output format + * accordingly. + * + * The flags thus obtained overwrite + * all previous contents of this object. + */ + void parse_parameters (ParameterHandler &prm); }; /** @@ -625,6 +704,25 @@ class DataOutBase * #private# as well). */ int dummy; + + public: + /** + * Declare all flags with name + * and type as offered by this + * class, for use in input files. + */ + static void declare_parameters (ParameterHandler &prm); + + /** + * Read the parameters declared in + * #declare_parameters# and set the + * flags for this output format + * accordingly. + * + * The flags thus obtained overwrite + * all previous contents of this object. + */ + void parse_parameters (ParameterHandler &prm); }; /** @@ -966,6 +1064,44 @@ class DataOutInterface : private DataOutBase */ static string get_output_format_names (); + /** + * Declare parameters for all output + * formats by declaring subsections + * within the parameter file for each + * output format and call the + * respective #declare_parameters# + * functions of the flag classes for + * each output format. + * + * Some of the declared subsections + * may not contain entries, if the + * respective format does not + * export any flags. + * + * Note that the top-level parameters + * denoting the number of subdivisions + * per patch and the output format + * are not declared, since they are + * only passed to virtual functions + * and are not stored inside objects + * of this type. You have to + * declare them yourself. + */ + static void declare_parameters (ParameterHandler &prm); + + /** + * Read the parameters declared in + * #declare_parameters# and set the + * flags for the output formats + * accordingly. + * + * The flags thus obtained overwrite + * all previous contents of the flag + * objects as default-constructed or + * set by the #set_flags# function. + */ + void parse_parameters (ParameterHandler &prm); + /** * Exception */ diff --git a/deal.II/base/source/data_out_base.all_dimensions.cc b/deal.II/base/source/data_out_base.all_dimensions.cc index 926338d5e2..85107ef6ce 100644 --- a/deal.II/base/source/data_out_base.all_dimensions.cc +++ b/deal.II/base/source/data_out_base.all_dimensions.cc @@ -2,7 +2,7 @@ #include - +#include DataOutBase::UcdFlags::UcdFlags (const bool write_preamble) : @@ -10,6 +10,45 @@ DataOutBase::UcdFlags::UcdFlags (const bool write_preamble) : {}; + +void DataOutBase::UcdFlags::declare_parameters (ParameterHandler &prm) +{ + prm.declare_entry ("Write preamble", "true", Patterns::Bool()); +}; + + + +void DataOutBase::UcdFlags::parse_parameters (ParameterHandler &prm) +{ + write_preamble = prm.get_bool ("Write preamble"); +}; + + + +void DataOutBase::GnuplotFlags::declare_parameters (ParameterHandler &/*prm*/) +{ +}; + + + +void DataOutBase::GnuplotFlags::parse_parameters (ParameterHandler &/*prm*/) +{ +}; + + + +void DataOutBase::PovrayFlags::declare_parameters (ParameterHandler &/*prm*/) +{ +}; + + + +void DataOutBase::PovrayFlags::parse_parameters (ParameterHandler &/*prm*/) +{ +}; + + + DataOutBase::EpsFlags::EpsFlags (const unsigned int height_vector, const unsigned int color_vector, const SizeType size_type, @@ -147,4 +186,66 @@ bool DataOutBase::EpsCell2d::operator < (const EpsCell2d &e) const +void DataOutBase::EpsFlags::declare_parameters (ParameterHandler &prm) +{ + prm.declare_entry ("Index of vector for height", "0", + Patterns::Integer()); + prm.declare_entry ("Index of vector for color", "0", + Patterns::Integer()); + prm.declare_entry ("Scale to width or height", "width", + Patterns::Selection ("width|height")); + prm.declare_entry ("Size (width or height) in eps units", "300", + Patterns::Integer()); + prm.declare_entry ("Line widths in eps units", "0.5", + Patterns::Double()); + prm.declare_entry ("Azimut angle", "60", + Patterns::Double()); + prm.declare_entry ("Turn angle", "30", + Patterns::Double()); + prm.declare_entry ("Scaling for z-axis", "1", + Patterns::Double ()); + prm.declare_entry ("Draw mesh lines", "true", + Patterns::Bool()); + prm.declare_entry ("Fill interior of cells", "true", + Patterns::Bool()); + prm.declare_entry ("Color shading of interior of cells", "true", + Patterns::Bool()); + prm.declare_entry ("Color function", "default", + Patterns::Selection ("default|grey scale")); +}; + + +void DataOutBase::EpsFlags::parse_parameters (ParameterHandler &prm) +{ + height_vector = prm.get_integer ("Index of vector for height"); + color_vector = prm.get_integer ("Index of vector for color"); + if (prm.get ("Scale to width or height") == "width") + size_type = width; + else + size_type = height; + size = prm.get_integer ("Size (width or height) in eps units"); + line_width = prm.get_double ("Line widths in eps units"); + azimut_angle = prm.get_double ("Azimut angle"); + turn_angle = prm.get_double ("Turn angle"); + z_scaling = prm.get_double ("Scaling for z-axis"); + draw_mesh = prm.get_bool ("Draw mesh lines"); + draw_cells = prm.get_bool ("Fill interior of cells"); + shade_cells = prm.get_bool ("Color shading of interior of cells"); + if (prm.get("Color function") == "default") + color_function = &default_color_function; + else + color_function = &grey_scale_color_function; +}; + + + +void DataOutBase::GmvFlags::declare_parameters (ParameterHandler &/*prm*/) +{ +}; + + + +void DataOutBase::GmvFlags::parse_parameters (ParameterHandler &/*prm*/) +{ +}; diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc index ab403d4b57..13f8058e2a 100644 --- a/deal.II/base/source/data_out_base.cc +++ b/deal.II/base/source/data_out_base.cc @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -1562,6 +1563,58 @@ string DataOutInterface::get_output_format_names () { +template +void DataOutInterface::declare_parameters (ParameterHandler &prm) +{ + prm.enter_subsection ("UCD output parameters"); + UcdFlags::declare_parameters (prm); + prm.leave_subsection(); + + prm.enter_subsection ("Gnuplot output parameters"); + GnuplotFlags::declare_parameters (prm); + prm.leave_subsection(); + + prm.enter_subsection ("Povray output parameters"); + PovrayFlags::declare_parameters (prm); + prm.leave_subsection(); + + prm.enter_subsection ("Eps output parameters"); + EpsFlags::declare_parameters (prm); + prm.leave_subsection(); + + prm.enter_subsection ("Gmv output parameters"); + GmvFlags::declare_parameters (prm); + prm.leave_subsection(); +}; + + + +template +void DataOutInterface::parse_parameters (ParameterHandler &prm) +{ + prm.enter_subsection ("UCD output parameters"); + ucd_flags.parse_parameters (prm); + prm.leave_subsection(); + + prm.enter_subsection ("Gnuplot output parameters"); + gnuplot_flags.parse_parameters (prm); + prm.leave_subsection(); + + prm.enter_subsection ("Povray output parameters"); + povray_flags.parse_parameters (prm); + prm.leave_subsection(); + + prm.enter_subsection ("Eps output parameters"); + eps_flags.parse_parameters (prm); + prm.leave_subsection(); + + prm.enter_subsection ("Gmv output parameters"); + gmv_flags.parse_parameters (prm); + prm.leave_subsection(); +}; + + +