]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add flag for scientific or fixed point notation
authorhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 3 Jan 2000 17:09:44 +0000 (17:09 +0000)
committerhartmann <hartmann@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 3 Jan 2000 17:09:44 +0000 (17:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@2156 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/table_handler.h
deal.II/base/source/table_handler.cc

index cf3fc1a7428012246808fc6b75c681929c7217c8..ac7af6fbf8bb72d9c48ea9dcb24df8ff33ad5fe8 100644 (file)
@@ -226,6 +226,14 @@ class TableHandler
     void set_precision (const string &key,
                        const unsigned int precision);
 
+                                    /**
+                                     * Sets the #scientific_flag#. True means
+                                     * scientific, false means fixed point
+                                     * notation.
+                                     */
+    void set_scientific (const string &key,
+                        bool scientific);
+
                                     /**
                                      * Sets the caption of the column #key#
                                      * for tex output. You may want to chose
@@ -366,6 +374,12 @@ class TableHandler
                                          */
        unsigned int precision;
 
+                                        /**
+                                         * #scientific#=false means fixed
+                                         * point notation.
+                                         */
+       bool scientific;
+
                                         /**
                                          * Flag that may be used by derived 
                                          * classes for arbitrary purposes.
index 3d5f3aebce78246cf0fba1101dbe88fe2b34dd3e..fbf8b694f84be636302382b5b27bb7d7e2be797b 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <base/table_handler.h>
 
+#include <iostream>
 #include <iomanip>
 
 
@@ -53,6 +54,7 @@ TableHandler::Column::Column(const string &tex_caption):
                tex_caption(tex_caption),
                tex_format("c"),
                precision(4),
+               scientific(0),
                flag(0)  
 {}
 
@@ -61,6 +63,7 @@ TableHandler::Column::Column():
                tex_caption(),
                tex_format("c"),
                precision(4),
+               scientific(0),
                flag(0)  
 {}
 
@@ -192,6 +195,15 @@ void TableHandler::set_precision (const string &key,
 
 
 
+void TableHandler::set_scientific (const string &key,
+                                  bool scientific)
+{
+  Assert(columns.count(key), ExcColumnNotExistent(key));
+  columns[key].scientific=scientific;
+}
+
+
+
 void TableHandler::write_text(ostream &out) const
 {
   vector<string> sel_columns;
@@ -235,6 +247,11 @@ void TableHandler::write_text(ostream &out) const
          const Column &column=col_iter->second;
          
          out << setprecision(column.precision);
+
+         if (col_iter->second.scientific)
+           out.setf(ios::scientific, ios::floatfield);
+         else
+           out.setf(ios::fixed, ios::floatfield);
          column.entries[i]->write_tex(out);
          
          if (j<n_cols-1)
@@ -337,6 +354,12 @@ void TableHandler::write_tex(ofstream &out) const
          const Column &column=col_iter->second;
          
          out << setprecision(column.precision);
+
+         if (col_iter->second.scientific)
+           out.setf(ios::scientific, ios::floatfield);
+         else
+           out.setf(ios::fixed, ios::floatfield);
+         
          column.entries[i]->write_tex(out);
          
          if (j<n_cols-1)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.