FEDEM Solver  R8.0
Source code of the dynamics solver
FFaMsg.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
13 #ifndef FFA_MSG_H
14 #define FFA_MSG_H
15 
16 #include <string>
17 #include <vector>
18 
19 // The symbol ERROR might have already been defined if, e.g., windows.h
20 // is included before this header file. To avoid compiler problems due to name
21 // conflict with the FFaDialogType enum value below, it must be undefined here.
22 // TODO: Rename FFaMsg::ERROR to something else?
23 #ifdef ERROR
24 #undef ERROR
25 #endif
26 
33 #define ListUI FFaMsg::getMessager()
34 
35 class FaVec3;
36 
37 
42 class FFaMsg
43 {
44 public:
46  FFaMsg() {}
48  virtual ~FFaMsg() {}
49 
51  static void setMessager(FFaMsg* messager = NULL);
53  static FFaMsg& getMessager();
55  static bool usingDefault();
56 
59  {
65  OK,
77  GENERIC
78  };
79 
81  static void resetToAllAnswer(const FFaDialogType type = _ALL_);
82 
84  // User feedback methods.
85  // These will be routed to the messager provided, or to the default one.
86 
88  static int dialog(const std::string& message,
90  const char** genericButtons = (const char**)NULL);
91 
93  static int dialog(int& returnedSelectionIdx, const std::string& message,
94  const FFaDialogType type,
95  const std::vector<std::string>& buttonTexts,
96  const std::vector<std::string>& selectionList);
97 
99  static void list(const std::string& str, bool onScreen = false);
101  static void tip (const std::string& str);
102 
104  static void setStatus (const std::string& statusText);
106  static void changeStatus(const std::string& statusText);
108  static void pushStatus (const std::string& statusText);
110  static void popStatus ();
111 
113  static void enableSubSteps (int steps);
115  static void setSubStep (int step);
117  static void disableSubSteps();
118 
120  static void displayTime(int hour, int min, int sec);
122  static void clearTime ();
123 
125  static void setSubTask(const std::string& taskText);
126 
128  static void enableProgress (int nSteps);
130  static void setProgress (int progressStep);
132  static void disableProgress();
133 
135  // Global stream-like operators for easy printing of messages to output list.
136  // Typically used with the ListUI macro (see above).
137  friend FFaMsg& operator<< (FFaMsg&, const std::string&);
138  friend FFaMsg& operator<< (FFaMsg&, const char*);
139  friend FFaMsg& operator<< (FFaMsg&, const FaVec3&);
140  friend FFaMsg& operator<< (FFaMsg&, double);
141  friend FFaMsg& operator<< (FFaMsg&, char);
142  friend FFaMsg& operator<< (FFaMsg&, int);
143  friend FFaMsg& operator<< (FFaMsg&, long long int);
144  friend FFaMsg& operator<< (FFaMsg&, size_t);
146 
148  virtual bool openListFile(const char* = NULL, bool = false) { return true; }
150  virtual void closeListFile() {}
151 
152 protected:
153 
154  // Virtual methods reimplemented to make real GUI meaning
155 
157  virtual int dialogVt(const std::string& message,
158  const FFaDialogType type,
159  const char** genericButtons);
161  virtual int dialogVt(const std::string& message,
162  const FFaDialogType type,
163  const std::vector<std::string>& buttonTexts);
165  virtual int dialogVt(int& returnedSelectionIdx,
166  const std::string& message,
167  const FFaDialogType type,
168  const std::vector<std::string>& buttonTexts,
169  const std::vector<std::string>& selectionList);
170 
172  virtual void listVt(const std::string& str, bool onScreen = false);
174  virtual void tipVt (const std::string& str);
175 
177  virtual void setStatusVt (const std::string&) {}
179  virtual void changeStatusVt(const std::string&) {}
181  virtual void pushStatusVt (const std::string&) {}
183  virtual void popStatusVt () {}
184 
186  virtual void enableSubStepsVt (int) {}
188  virtual void setSubStepVt (int) {}
190  virtual void disableSubStepsVt() {}
191 
193  virtual void displayTimeVt(int, int, int) {}
195  virtual void clearTimeVt () {}
196 
198  virtual void setSubTaskVt(const std::string&) {}
199 
201  virtual void enableProgressVt (int) {}
203  virtual void setProgressVt (int) {}
205  virtual void disableProgressVt() {}
206 };
207 
208 #endif
Interface class for various user feedback.
Definition: FFaMsg.H:43
virtual void popStatusVt()
GUI interface for popping the status message stack.
Definition: FFaMsg.H:183
virtual void disableProgressVt()
GUI interface for clearing the progress counter.
Definition: FFaMsg.H:205
FFaDialogType
Enums defining various dialog box types.
Definition: FFaMsg.H:59
@ YES_NO_CANCEL
Modal info dialog with yes/no and cancel options.
Definition: FFaMsg.H:68
@ _ALL_
Separator for the "to all" dialog types.
Definition: FFaMsg.H:69
@ OK_CANCEL
Modal info dialog with cancel option.
Definition: FFaMsg.H:66
@ ERROR
Modal error dialog.
Definition: FFaMsg.H:64
@ OK
Modal info dialog.
Definition: FFaMsg.H:65
@ GENERIC
Generic modal dialog with user-provided button texts.
Definition: FFaMsg.H:77
@ DISMISS_ERROR
Non-modal error dialog.
Definition: FFaMsg.H:61
@ YES_ALL_NO_ALL
Yes or no to all similar queries.
Definition: FFaMsg.H:72
@ DISMISS_WARNING
Non-modal warning dialog.
Definition: FFaMsg.H:60
@ YES_NO_ALL_CANCEL
Yes to this or no to all similar queries, or cancel.
Definition: FFaMsg.H:76
@ YES_NO_ALL
Yes to this or no to all similar queries.
Definition: FFaMsg.H:75
@ YES_ALL_NO_ALL_CANCEL
Yes or no to all similar queries, or cancel.
Definition: FFaMsg.H:74
@ YES_ALL_NO_CANCEL
Yes to all similar queries, or no for this or cancel.
Definition: FFaMsg.H:73
@ OK_ALL_CANCEL
Ok to all similar queries, or cancel the operation.
Definition: FFaMsg.H:70
@ WARNING
Modal warning dialog.
Definition: FFaMsg.H:63
@ YES_NO
Modal info dialog with yes/no options.
Definition: FFaMsg.H:67
@ YES_ALL_NO
Yes to all similar queries, or no for this only.
Definition: FFaMsg.H:71
@ DISMISS_INFO
Non-modal information dialog.
Definition: FFaMsg.H:62
static int dialog(const std::string &message, const FFaDialogType type=DISMISS_WARNING, const char **genericButtons=(const char **) NULL)
Shows a dialog according to the dialog type.
Definition: FFaMsg.C:69
FFaMsg()
Default constructor.
Definition: FFaMsg.H:46
virtual void disableSubStepsVt()
GUI interface for clearing the substep counter.
Definition: FFaMsg.H:190
virtual void setProgressVt(int)
GUI interface for updating the progress counter.
Definition: FFaMsg.H:203
static void disableProgress()
Clears the progress counter.
Definition: FFaMsg.C:248
virtual void displayTimeVt(int, int, int)
GUI interface for displaying the elapsed time of a solver process.
Definition: FFaMsg.H:193
static void clearTime()
Clears the elapsed time display.
Definition: FFaMsg.C:227
virtual void setSubTaskVt(const std::string &)
GUI interface for setting the subtask message.
Definition: FFaMsg.H:198
virtual void setSubStepVt(int)
GUI interface for assigning the substep counter.
Definition: FFaMsg.H:188
static void setSubStep(int step)
Assigns the substep counter.
Definition: FFaMsg.C:211
virtual void enableSubStepsVt(int)
GUI interface for enabling substep counting.
Definition: FFaMsg.H:186
static FFaMsg & getMessager()
Returns the current messager object.
Definition: FFaMsg.C:36
static void setProgress(int progressStep)
Updates the progress counter.
Definition: FFaMsg.C:243
static void enableSubSteps(int steps)
Enables substep counting in the GUI, in the range 1 to steps.
Definition: FFaMsg.C:206
virtual ~FFaMsg()
Empty destructor.
Definition: FFaMsg.H:48
static void tip(const std::string &str)
Updates the tip message in the GUI (or prints it to console).
Definition: FFaMsg.C:177
virtual void changeStatusVt(const std::string &)
GUI interface for changing the status message.
Definition: FFaMsg.H:179
static void pushStatus(const std::string &statusText)
Pushes a new message to the status stack.
Definition: FFaMsg.C:195
static void resetToAllAnswer(const FFaDialogType type=_ALL_)
Clears the multiple query answer given dialog type or all.
Definition: FFaMsg.C:52
virtual void enableProgressVt(int)
GUI interface for enabling the progress bar.
Definition: FFaMsg.H:201
static void setMessager(FFaMsg *messager=NULL)
Sets the real messager object to be used.
Definition: FFaMsg.C:30
static bool usingDefault()
Returns true if we are using the default messager.
Definition: FFaMsg.C:46
virtual void setStatusVt(const std::string &)
GUI interface for setting the status message.
Definition: FFaMsg.H:177
virtual void clearTimeVt()
GUI interface for clearing the elapsed time display.
Definition: FFaMsg.H:195
virtual void listVt(const std::string &str, bool onScreen=false)
Prints a message to the console.
Definition: FFaMsg.C:359
virtual void pushStatusVt(const std::string &)
GUI interface for pushing a new status message.
Definition: FFaMsg.H:181
static void disableSubSteps()
Clears the substep counter.
Definition: FFaMsg.C:216
static void setStatus(const std::string &statusText)
Sets the status message, but only the the status stack is empty.
Definition: FFaMsg.C:183
static void enableProgress(int nSteps)
Enables a progress bar in the GUI, in range 1 to nSteps.
Definition: FFaMsg.C:238
static void displayTime(int hour, int min, int sec)
Displays the elapsed time of a solver process in the GUI.
Definition: FFaMsg.C:222
static void popStatus()
Pops the status stack such that the previous message appears.
Definition: FFaMsg.C:200
virtual void closeListFile()
Closes the list file.
Definition: FFaMsg.H:150
static void changeStatus(const std::string &statusText)
Replaces the top message of the status stack.
Definition: FFaMsg.C:189
static void list(const std::string &str, bool onScreen=false)
Prints a message to the Output List GUI (or console).
Definition: FFaMsg.C:171
virtual bool openListFile(const char *=NULL, bool=false)
Opens a list file containing a copy of the output list window.
Definition: FFaMsg.H:148
static void setSubTask(const std::string &taskText)
Sets the subtask message in the GUI.
Definition: FFaMsg.C:232
virtual int dialogVt(const std::string &message, const FFaDialogType type, const char **genericButtons)
Shows a dialog according to the dialog type.
Definition: FFaMsg.C:316
virtual void tipVt(const std::string &str)
Prints tip message to the console.
Definition: FFaMsg.C:365
Class for point vectors in 3D space.
Definition: FFaVec3.H:40
character(len=40) type
Function type flag.
Definition: initiateFunctionTypeModule.f90:33
std::ostream & operator<<(std::ostream &os, const Case &c)
Global stream operator to print out a Case instance.
Definition: test_solver.C:70