From 3d1d5a9840ebc0d9990336fc6243cbc915b6331e Mon Sep 17 00:00:00 2001
From: Wolfgang Bangerth
Date: Wed, 6 Jul 2005 02:53:32 +0000
Subject: [PATCH] Allow to query the number of entries in a subsection and its
children. Use this to suppress output for completely empty subsections when
printing.
git-svn-id: https://svn.dealii.org/trunk@11075 0785d39b-7218-0410-832d-ea1e28bc413d
---
deal.II/base/source/parameter_handler.cc | 132 ++++++++++++++---------
deal.II/doc/news/changes.html | 9 ++
2 files changed, 88 insertions(+), 53 deletions(-)
diff --git a/deal.II/base/source/parameter_handler.cc b/deal.II/base/source/parameter_handler.cc
index a0ecc7d7a6..30d2a6657f 100644
--- a/deal.II/base/source/parameter_handler.cc
+++ b/deal.II/base/source/parameter_handler.cc
@@ -981,65 +981,73 @@ ParameterHandler::print_parameters_section (std::ostream &out,
}
- // if there was text before and
- // there are sections to come, put
- // two newlines between the last
- // entry and the first subsection
+ // if there was text before and there are
+ // sections to come, put two newlines
+ // between the last entry and the first
+ // subsection; also make sure that the
+ // subsections will be printed at all
+ // (i.e. at least one of them is non-empty)
if ((pd->entries.size() != 0)
&&
- (pd->subsections.size() != 0))
+ (pd->subsections.size() != 0)
+ &&
+ (pd->accumulated_no_of_entries() != pd->entries.size()))
out << std::endl << std::endl;
- // now transverse subsections tree
+ // now transverse subsections tree; only
+ // plot a subsection, if it has at least
+ // one entry somewhere in it
std::map::const_iterator ptrss;
- for (ptrss = pd->subsections.begin(); ptrss != pd->subsections.end(); ++ptrss)
- {
- switch (style)
- {
- case Text:
- out << std::setw(indent_level*2) << ""
- << "subsection " << ptrss->first << std::endl;
- break;
- case LaTeX:
- out << std::endl
- << "\\item {\\bf "
- << "Subsection " << ptrss->first
- << "}" << std::endl
- << "\\begin{itemize}"
- << std::endl;
- break;
- default:
- Assert (false, ExcNotImplemented());
- };
- enter_subsection (ptrss->first);
- print_parameters_section (out, style, indent_level+1);
- leave_subsection ();
- switch (style)
- {
- case Text:
- // write end of
- // subsection. one
- // blank line after
- // each subsection
- out << std::setw(indent_level*2) << ""
- << "end" << std::endl
- << std::endl;
-
- // if this is a toplevel
- // subsection, then have two
- // newlines
- if (indent_level == 0)
- out << std::endl;
+ for (ptrss = pd->subsections.begin();
+ ptrss != pd->subsections.end(); ++ptrss)
+ if (ptrss->second->accumulated_no_of_entries() != 0)
+ {
+ switch (style)
+ {
+ case Text:
+ out << std::setw(indent_level*2) << ""
+ << "subsection " << ptrss->first << std::endl;
+ break;
+ case LaTeX:
+ out << std::endl
+ << "\\item {\\bf "
+ << "Subsection " << ptrss->first
+ << "}" << std::endl
+ << "\\begin{itemize}"
+ << std::endl;
+ break;
+ default:
+ Assert (false, ExcNotImplemented());
+ };
+ enter_subsection (ptrss->first);
+ print_parameters_section (out, style, indent_level+1);
+ leave_subsection ();
+ switch (style)
+ {
+ case Text:
+ // write end of
+ // subsection. one
+ // blank line after
+ // each subsection
+ out << std::setw(indent_level*2) << ""
+ << "end" << std::endl
+ << std::endl;
+
+ // if this is a toplevel
+ // subsection, then have two
+ // newlines
+ if (indent_level == 0)
+ out << std::endl;
- break;
- case LaTeX:
- out << "\\end{itemize}"
- << std::endl;
- break;
- default:
- Assert (false, ExcNotImplemented());
- };
- };
+ break;
+ case LaTeX:
+ out << "\\end{itemize}"
+ << std::endl;
+ break;
+ default:
+ Assert (false, ExcNotImplemented());
+ }
+ }
}
@@ -1331,6 +1339,24 @@ ParameterHandler::Section::~Section ()
+unsigned int
+ParameterHandler::Section::
+accumulated_no_of_entries () const
+{
+ // number of entries in this section
+ unsigned int n = entries.size();
+
+ // then accumulate over all children
+ for (std::map::const_iterator
+ s = subsections.begin();
+ s != subsections.end(); ++s)
+ n += s->second->accumulated_no_of_entries();
+
+ return n;
+}
+
+
+
unsigned int
ParameterHandler::Section::memory_consumption () const
{
diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html
index 7d1b867a11..16abfc7836 100644
--- a/deal.II/doc/news/changes.html
+++ b/deal.II/doc/news/changes.html
@@ -225,6 +225,15 @@ inconvenience this causes.
(WB, 2005/07/05)
+
+ Changed: The ParameterHandler::print_parameters
+ function now omits printing subsections if they and the contained
+ sub-subsections contain no entries.
+
+ (WB, 2005/07/05)
+
+
Changed: Some of the dimension independent functions in the DataOutInterface
class have been moved into the
--
2.39.5