* the formats presently implemented. User programs need therefore not
* be changed whenever a new format is implemented.
*
+ * Additionally, objects of this class have a default format, which
+ * can be set by the parameter "Output format" of the parameter
+ * file. Within a program, this can be changed by the member function
+ * #set_format#. Using this default format, it is possible to leave
+ * the format selection completely to the parameter file. A suitable
+ * suffic for the output file name can be obtained by #default_suffix#
+ * without arguments.
*
* @author Wolfgang Bangerth, 1999
*/
* Provide a data type specifying the
* presently supported output formats.
*/
- enum OutputFormat { ucd, gnuplot, povray, eps, gmv };
+ enum OutputFormat { nil, ucd, gnuplot, povray, eps, gmv };
/**
* Obtain data through the #get_patches#
* Write data and grid to #out# according
* to the given data format. This function
* simply calls the appropriate
- * #write_*# function.
+ * #write_*# function. If no output format is
+ * requested, the #default_format# is written.
+ *
+ * An error occurs if no format is provided and
+ * the default format is #nil#.
*/
- void write (ostream &out, const OutputFormat output_format) const;
-
+ void write (ostream &out, const OutputFormat output_format = nil) const;
+
+ /**
+ * Set the default format. The value set here
+ * is used anytime, output for format #nil# is
+ * requested.
+ */
+ void set_format(const OutputFormat default_format);
+
/**
* Set the flags to be used for output
* in UCD format.
* \item #gmv#: #.gmv#.
* \end{itemize}
*
- * Since this function does not need data
- * from this object, it is static and can
- * thus be called without creating an
- * object of this class.
+ * If this function is called
+ * with no argument or #nil#, the
+ * suffix for the
+ * #default_format# is returned.
*/
- static string default_suffix (const OutputFormat output_format);
+ string default_suffix (const OutputFormat output_format = nil);
/**
* Return the #OutputFormat# value
virtual vector<string> get_dataset_names () const = 0;
private:
+ /**
+ * Standard output format.
+ * Use this format, if output format nil is
+ * requested. It can be changed by the #set_format#
+ * function or in a parameter file.
+ */
+ OutputFormat default_format;
+
/**
* Flags to be used upon output of UCD
* data. Can be changed by using the
template <int dim>
void DataOutInterface<dim>::write (ostream &out,
- const OutputFormat output_format) const {
+ OutputFormat output_format) const
+{
+ if (output_format == nil)
+ output_format = default_format;
+
switch (output_format)
{
case ucd:
};
};
+template <int dim>
+void DataOutInterface<dim>::set_format(OutputFormat fmt)
+{
+ default_format = fmt;
+}
template <int dim>
template <int dim>
-string DataOutInterface<dim>::default_suffix (const OutputFormat output_format)
+string DataOutInterface<dim>::default_suffix (OutputFormat output_format)
{
+ if (output_format == nil)
+ output_format = default_format;
+
switch (output_format)
{
case ucd:
template <int dim>
-string DataOutInterface<dim>::get_output_format_names () {
+string DataOutInterface<dim>::get_output_format_names ()
+{
return "ucd|gnuplot|povray|eps|gmv";
-};
+}
template <int dim>
void DataOutInterface<dim>::declare_parameters (ParameterHandler &prm)
{
+ prm.declare_entry ("Output format", "gnuplot",
+ Patterns::Selection (get_output_format_names ()));
+
prm.enter_subsection ("UCD output parameters");
UcdFlags::declare_parameters (prm);
- prm.leave_subsection();
+ prm.leave_subsection ();
prm.enter_subsection ("Gnuplot output parameters");
GnuplotFlags::declare_parameters (prm);
- prm.leave_subsection();
+ prm.leave_subsection ();
prm.enter_subsection ("Povray output parameters");
PovrayFlags::declare_parameters (prm);
- prm.leave_subsection();
+ prm.leave_subsection ();
prm.enter_subsection ("Eps output parameters");
EpsFlags::declare_parameters (prm);
- prm.leave_subsection();
+ prm.leave_subsection ();
prm.enter_subsection ("Gmv output parameters");
GmvFlags::declare_parameters (prm);
- prm.leave_subsection();
-};
+ prm.leave_subsection ();
+}
template <int dim>
void DataOutInterface<dim>::parse_parameters (ParameterHandler &prm)
{
+ const string& output_name = prm.get ("Output format");
+ default_format = parse_output_format (output_name);
+
prm.enter_subsection ("UCD output parameters");
ucd_flags.parse_parameters (prm);
- prm.leave_subsection();
+ prm.leave_subsection ();
prm.enter_subsection ("Gnuplot output parameters");
gnuplot_flags.parse_parameters (prm);
- prm.leave_subsection();
+ prm.leave_subsection ();
prm.enter_subsection ("Povray output parameters");
povray_flags.parse_parameters (prm);
- prm.leave_subsection();
+ prm.leave_subsection ();
prm.enter_subsection ("Eps output parameters");
eps_flags.parse_parameters (prm);
- prm.leave_subsection();
+ prm.leave_subsection ();
prm.enter_subsection ("Gmv output parameters");
gmv_flags.parse_parameters (prm);
- prm.leave_subsection();
-};
-
-
-
+ prm.leave_subsection ();
+}