GemaCoreLib
The GeMA Core library
gmPrintUtils.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_PRINT_UTILS_H_
25 #define _GEMA_PRINT_UTILS_H_
26 
27 #include "gmLog.h"
28 
29 class GmValueInfo;
30 class GmValueAccessor;
31 class GmCellAccessor;
32 class GmGaussAccessor;
33 class GmCellMesh;
34 class GmElementMesh;
35 
36 struct lua_State;
37 class LuaTable;
38 class Unit;
39 
42 {
43  GM_PRINT_UNITS = 0x00001,
46  GM_PRINT_DEF_AS_NIL = 0x00008,
49  GM_PRINT_CELL_TYPE = 0x00040,
50  GM_PRINT_CELL_NODES = 0x00080,
55  GM_PRINT_NODE_GHOST = 0x01000,
58  GM_PRINT_TRAILLER = 0x08000,
59  GM_PRINT_ACTIVEONLY = 0x10000,
60  GM_PRINT_CONSTMAP = 0x20000,
61 
62  // -----
64  GM_PRINT_USER = 0x40000,
65 
66  // ----- DO not add entries AFTER this line
71 };
72 
73 
76 {
77 public:
80  : _logger(logger), _level(level), _options(opt), _firstGhostIndex(-1) {}
81 
83  void setOption(GmPrintUtilsFlags opt, bool mode) { _options = mode ? (_options | opt) : (_options & ~opt); }
84 
86  void setOptions(int options) { _options = options; }
87 
94  void setFirstGhostIndex(int index) { _firstGhostIndex = index; }
95 
96  GmValueAccessor* valueAccessorForStringColumn(QString title, const QStringList& data, int width);
97 
98  void printValueTable(const QList<GmValueAccessor*>& dataList, QString title = "", const QList<int>& columnWidths = QList<int>());
99  void printCellTable (const GmCellMesh* mesh, const QList<GmCellAccessor* >& dataList, QString title = "",
100  const QList<int>& columnWidths = QList<int>(), int ip = -1);
101  void printGaussTable(const GmElementMesh* mesh, const QList<GmGaussAccessor* >& dataList, QString title = "",
102  const QList<int>& columnWidths = QList<int>());
103 
104 
105  static bool parseValueIds (lua_State* L, int index, QString fname, QStringList& valueList, QList<Unit>& unitList);
106  static QList<int> parseColumnWidths(lua_State* L, int index, QString fname, int ncol);
107  static void parsePrintOptions(lua_State* L, int index, QString fname, int& options, int* state);
108 
109  static void progressBar(int i, int size, int& mark, const GmLogCategory& logger, int freq = 10);
110 
111 protected:
112  template <class A> GMC_API_EXPORT void addDataColumnSizes (const QList<A*>& dataList, const QList<int>& colWidths, QList<int>& sizes);
113  template <class A> GMC_API_EXPORT int printColumnHeaders (QString title, const QStringList& extraCols, const QList<A*>& dataList,
114  const QList<int>& colWidths);
115  template <class A> GMC_API_EXPORT void buildReverseConstMaps(const QList<A*>& dataList, QList<QMap<double, QString> >& revConstMapList);
116 
117  static void checkOption(LuaTable& table, const char* field, int& options, int flag);
118 
119  QString center(QString val, int size);
120 
123  int _options;
125 };
126 
127 #endif
128 
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
void setOptions(int options)
Sets all printing options.
Definition: gmPrintUtils.h:86
Should we print units in the header in a separate line? Default = false.
Definition: gmPrintUtils.h:44
GmPrintUtilsFlags
Set of combinable options controlling the behaviour of print functions.
Definition: gmPrintUtils.h:41
Should we mark line numbers (with a '|' prefix) in printValueTable() or cell node numbers in printCel...
Definition: gmPrintUtils.h:56
Groups utilitary routines for pretty printing data.
Definition: gmPrintUtils.h:75
Should we print a title in the header, for the entire table? Default = false.
Definition: gmPrintUtils.h:57
A mark to set the first 'user' option available. This value should be updated whenever adding options...
Definition: gmPrintUtils.h:64
The GmGaussAccessor class is a proxy object to a value accesor implementing a more convenient interfa...
Definition: gmGaussAccessor.h:38
Should we add a column telling if the cell is active or not for cell meshes? Default = false.
Definition: gmPrintUtils.h:53
void setFirstGhostIndex(int index)
Informs the printer about the border between normal and ghost nodes.
Definition: gmPrintUtils.h:94
GmLogLevel _level
The log level used to print messages.
Definition: gmPrintUtils.h:122
Extended information. Probably more than you wanted.
Definition: gmLog.h:39
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
Should we add a node column for cell meshes? Default = true.
Definition: gmPrintUtils.h:50
Should we add a evaluation point column when EVAL_FUNCTIONS = true for cell meshes or for Gauss Attri...
Definition: gmPrintUtils.h:52
Should we print only active cells? Default = true.
Definition: gmPrintUtils.h:59
Should we print line numbers on the left margin? Default = true.
Definition: gmPrintUtils.h:47
The GmCellAccessor class is a proxy object to a value accesor implementing a more convenient interfac...
Definition: gmCellAccessor.h:66
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
Should we print default values as 'nil'? Default = false.
Definition: gmPrintUtils.h:46
Should we clip column titles when the user gave us a width and the title is bigger than that?...
Definition: gmPrintUtils.h:48
Should we add a columns with property names for cell meshes? Default = true.
Definition: gmPrintUtils.h:51
Should we add a closing trailler line to the table? Default = false.
Definition: gmPrintUtils.h:58
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
Should we print ghost nodes? When false, filters rows in printValueTable() or cell nodes in printCell...
Definition: gmPrintUtils.h:55
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
Should we print common geometry nodes? When false, filters rows in printValueTable() or cell nodes in...
Definition: gmPrintUtils.h:54
Base interface for FEM (finite element) meshes.
Definition: gmElementMesh.h:40
int _firstGhostIndex
Index used by printValueTable() to identify which table lines, if any, refer to ghost nodes....
Definition: gmPrintUtils.h:124
Should we try to translate values back to strings when a scalar data column has an associated const m...
Definition: gmPrintUtils.h:60
Should we print units in column title? Default = true.
Definition: gmPrintUtils.h:43
void setOption(GmPrintUtilsFlags opt, bool mode)
Enable or desable a printing option.
Definition: gmPrintUtils.h:83
int _options
Print options, stores a bit field with PrintFlags options that are turned on.
Definition: gmPrintUtils.h:123
GmPrintUtils(const GmLogCategory &logger, GmLogLevel level=GM_EXT_INFO, int opt=GM_PRINT_DEFAULT)
Constructor receiving the logger and level used to print data, along with print options.
Definition: gmPrintUtils.h:79
Should we evaluate functions or do we print its name? Default = false.
Definition: gmPrintUtils.h:45
const GmLogCategory & _logger
The logger used to print messages.
Definition: gmPrintUtils.h:121
Should we add a type column for cell meshes / Gauss attributes? Deafult = true.
Definition: gmPrintUtils.h:49
A tag to request that the options should be filled with the default.
Definition: gmPrintUtils.h:68
Declaration of support functions and macros for information logging.