General Purpose Geodetic Library
SgGuiLoggerConfig.cpp
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 
24 #include <SgGuiLoggerConfig.h>
25 
26 
27 
28 
29 #if QT_VERSION >= 0x050000
30 # include <QtWidgets/QBoxLayout>
31 # include <QtWidgets/QButtonGroup>
32 # include <QtWidgets/QCheckBox>
33 # include <QtWidgets/QComboBox>
34 # include <QtWidgets/QFrame>
35 # include <QtWidgets/QGroupBox>
36 # include <QtWidgets/QHeaderView>
37 # include <QtWidgets/QLabel>
38 # include <QtWidgets/QLineEdit>
39 # include <QtWidgets/QMessageBox>
40 # include <QtWidgets/QPushButton>
41 # include <QtWidgets/QSpinBox>
42 # include <QtWidgets/QRadioButton>
43 #else
44 # include <QtGui/QBoxLayout>
45 # include <QtGui/QButtonGroup>
46 # include <QtGui/QCheckBox>
47 # include <QtGui/QComboBox>
48 # include <QtGui/QFrame>
49 # include <QtGui/QGroupBox>
50 # include <QtGui/QHeaderView>
51 # include <QtGui/QLabel>
52 # include <QtGui/QLineEdit>
53 # include <QtGui/QMessageBox>
54 # include <QtGui/QPushButton>
55 # include <QtGui/QSpinBox>
56 # include <QtGui/QRadioButton>
57 #endif
58 
59 
60 
61 extern const QString facilityNames[];
62 extern const int numOfFacilities;
63 extern const QString levelNames[4];
64 extern const int logFacilities[32];
65 /*=======================================================================================================
66 *
67 * SgGuiTaskConfig's METHODS:
68 *
69 *======================================================================================================*/
70 //
71 SgGuiLoggerConfig::SgGuiLoggerConfig(QWidget* parent, Qt::WindowFlags f)
72  : QWidget(parent, f)
73 {
74  QGroupBox *gBox;
75  QBoxLayout *mainLayout;
76  QLabel *label;
77  QGridLayout *gridLayout;
78 
79  mainLayout = new QVBoxLayout(this);
80  mainLayout -> addStretch(1);
81 
82  gBox = new QGroupBox("Logger's Options", this);
83  gridLayout = new QGridLayout(gBox);
84 
85  eLogFileName_ = new QLineEdit(gBox);
86  eLogFileName_->setText(logger->getFileName());
87  label = new QLabel("Log file name:", gBox);
88  label->setMinimumSize(label->sizeHint());
89  eLogFileName_->setMinimumSize(eLogFileName_->sizeHint());
90 
91  gridLayout->addWidget(label, 0, 0);
92  gridLayout->addWidget(eLogFileName_, 0, 1);
93 
94  sLogCapacity_ = new QSpinBox(gBox);
95  sLogCapacity_ -> setSuffix(" lines");
96  label = new QLabel("Log capacity:", gBox);
97  label->setMinimumSize(label->sizeHint());
98  sLogCapacity_->setMinimumSize(sLogCapacity_->sizeHint());
99  sLogCapacity_->setMaximum(100000);
100  sLogCapacity_->setMinimum(100);
101  sLogCapacity_->setSingleStep(100);
102  sLogCapacity_->setValue(logger->getCapacity());
103  gridLayout->addWidget(label, 1, 0);
104  gridLayout->addWidget(sLogCapacity_, 1, 1);
105 
106  gridLayout->setColumnStretch( 2, 1);
107 
108  cbLogStoreInFile_ = new QCheckBox("Save log to the file", gBox);
109  cbLogTimeLabel_ = new QCheckBox("Put time stamps", gBox);
110  cbFullDate_ = new QCheckBox("Use full date format", gBox);
111  QCheckBox *cb=new QCheckBox("Reserved", gBox);
112  cb->setEnabled(false);
113  //
114  cbLogStoreInFile_->setMinimumSize(cbLogStoreInFile_->sizeHint());
115  cbLogTimeLabel_->setMinimumSize(cbLogTimeLabel_->sizeHint());
116  cbFullDate_->setMinimumSize(cbFullDate_->sizeHint());
117  cbLogStoreInFile_->setChecked(logger->getIsStoreInFile());
118  cbLogTimeLabel_->setChecked(logger->getIsNeedTimeMark());
119  cbFullDate_->setChecked(logger->getUseFullDateFormat());
120  gridLayout->addWidget(cbLogStoreInFile_, 0, 3);
121  gridLayout->addWidget(cbLogTimeLabel_ , 1, 3);
122  gridLayout->addWidget(cb, 0, 4);
123  gridLayout->addWidget(cbFullDate_ , 1, 4);
124 
125  gridLayout->activate();
126 
127  mainLayout->addWidget(gBox);
128  mainLayout->addStretch(1);
129  //---
130 
131 
132  gBox = new QGroupBox("Log Levels", this);
133  gridLayout = new QGridLayout(gBox);
134 
135  label = new QLabel("Er", gBox);
136  label -> setMinimumSize(label->sizeHint());
137  gridLayout -> addWidget(label, 0, 2);
138  label = new QLabel("Wn", gBox);
139  label -> setMinimumSize(label->sizeHint());
140  gridLayout -> addWidget(label, 0, 3);
141  label = new QLabel("In", gBox);
142  label -> setMinimumSize(label->sizeHint());
143  gridLayout -> addWidget(label, 0, 4);
144  label = new QLabel("Db", gBox);
145  label -> setMinimumSize(label->sizeHint());
146  gridLayout -> addWidget(label, 0, 5);
147  label = new QLabel("Er", gBox);
148  label -> setMinimumSize(label->sizeHint());
149  gridLayout -> addWidget(label, 0, 8);
150  label = new QLabel("Wn", gBox);
151  label -> setMinimumSize(label->sizeHint());
152  gridLayout -> addWidget(label, 0, 9);
153  label = new QLabel("In", gBox);
154  label -> setMinimumSize(label->sizeHint());
155  gridLayout -> addWidget(label, 0,10);
156  label = new QLabel("Db", gBox);
157  label -> setMinimumSize(label->sizeHint());
158  gridLayout -> addWidget(label, 0,11);
159 
160  gridLayout -> setRowStretch( 0, 2);
161  gridLayout -> setColumnStretch( 0, 2);
162  gridLayout -> setColumnStretch( 1, 1);
163 
164  for (int i=0; i<16; i++)
165  {
166  label= new QLabel(facilityNames[i], gBox);
167  label-> setMinimumSize(label->sizeHint());
168  gridLayout-> addWidget(label, 1+i, 1);
169  for (int j=0; j<4; j++)
170  {
171  cbLLevel_[j][i] = new QCheckBox(gBox);
172  cbLLevel_[j][i]->setMinimumSize(cbLLevel_[j][i]->sizeHint());
173 // QToolTip::add(cbLLevel_[j][i], levelNames[j]);
174  gridLayout -> addWidget(cbLLevel_[j][i], 1+i, 2+j);
175  };
176  };
177  gridLayout->setColumnStretch( 6, 7);
178  gridLayout->setColumnStretch( 7, 1);
179  gridLayout->setColumnMinimumWidth( 6, label->fontMetrics().width("WW"));
180  for (int i=0; i<16; i++)
181  {
182  label = new QLabel(facilityNames[16+i], gBox);
183  label->setMinimumSize(label->sizeHint());
184  gridLayout->addWidget(label, 1+i, 7);
185  for (int j=0; j<4; j++)
186  {
187  cbLLevel_[j][16+i] = new QCheckBox(gBox);
188  cbLLevel_[j][16+i]->setMinimumSize(cbLLevel_[j][16+i]->sizeHint());
189 // QToolTip::add(cbLLevel[j][16+i], levelNames[j]);
190  gridLayout->addWidget(cbLLevel_[j][16+i], 1+i, 8+j);
191  };
192  };
193  gridLayout->setColumnStretch( 12, 2);
194  gridLayout->activate();
195 
196  mainLayout->addWidget(gBox);
197  mainLayout->addStretch(2);
198 
199  // set up check boxes:
200  unsigned int mask[4];
201  mask[0] = logger->getLogFacility(SgLogger::ERR);
202  mask[1] = logger->getLogFacility(SgLogger::WRN);
203  mask[2] = logger->getLogFacility(SgLogger::INF);
204  mask[3] = logger->getLogFacility(SgLogger::DBG);
205  for (int i=0; i<4; i++)
206  for (int j=0; j<32; j++)
207  cbLLevel_[i][j]->setChecked(mask[i] & logFacilities[j]);
208 };
209 
210 
211 
212 //
214 {
215  logger->setFileName(eLogFileName_->text());
216  logger->setCapacity(sLogCapacity_->value());
219  logger->setUseFullDateFormat(cbFullDate_->isChecked());
220 
221  unsigned int mask[4]={0,0,0,0};
222  for (int i=0; i<4; i++)
223  for (int j=0; j<32; j++)
224  if (cbLLevel_[i][j]->isChecked())
225  mask[i] |= logFacilities[j];
226 
231 };
232 /*=====================================================================================================*/
233 
234 
235 
236 
237 
238 
239 
240 /*=====================================================================================================*/
241 const QString facilityNames[32]=
242 {
243  QString("IO: generic binary operations"), // SgLogger::IO_BIN,
244  QString("IO: generic text operations"), // SgLogger::IO_TXT,
245  QString("IO: NetCDF"), // SgLogger::IO_NCDF,
246  QString("IO: Database handler"), // SgLogger::IO_DBH,
247  QString("General matrices"), // SgLogger::MATRIX,
248  QString("3D Matrices"), // SgLogger::MATRIX3D,
249  QString("Data interpolation"), // SgLogger::INTERP,
250  QString("Tools: Reserved"), // SgLogger::MATH_RES_1,
251  QString("Data structures: observation"), // SgLogger::OBS,
252  QString("Data structures: station"), // SgLogger::STATION,
253  QString("Data structures: source"), // SgLogger::SOURCE,
254  QString("Data structures: session"), // SgLogger::SESSION,
255  QString("Reference frames"), // SgLogger::REF_FRAME,
256  QString("Time conversion, scales"), // SgLogger::TIME,
257  QString("Ionospheric correction"), // SgLogger::IONO,
258  QString("Tropospheric refraction"), // SgLogger::REFRACTION,
259  QString("Calculation of delay"), // SgLogger::DELAY,
260  QString("Calculation of rate"), // SgLogger::RATE,
261  QString("Applying flyby info"), // SgLogger::FLY_BY,
262  QString("Site displacements"), // SgLogger::DISLPACEMENT,
263  QString("Geo: Reserved"), // SgLogger::GEO_RES_1,
264  QString("Estimator"), // SgLogger::ESTIMATOR,
265  QString("Piecewise linear parameters"), // SgLogger::PWL,
266  QString("Stochastic parameters"), // SgLogger::STOCH,
267  QString("Config/Setup"), // SgLogger::CONFIG,
268  QString("Graphical User Interface"), // SgLogger::GUI,
269  QString("Report generator"), // SgLogger::REPORT,
270  QString("System resources"), // SgLogger::RESOURCE,
271  QString("Task manager"), // SgLogger::RUN,
272  QString("Preliminary processing"), // SgLogger::PREPROC,
273  QString("Reserved #1"), // SgLogger::RESERVED_1,
274  QString("Reserved #2") // SgLogger::RESERVED_2
275 };
276 
277 const int numOfFacilities=sizeof(facilityNames)/sizeof(const QString);
278 
279 const QString levelNames[4]=
280 {
281  QString("ERROR"),
282  QString("WARNING"),
283  QString("INFO"),
284  QString("DEBUG")
285 };
286 
287 const int logFacilities[32]=
288 {
321 };
322 
323 
324 /*=====================================================================================================*/
const int numOfFacilities
const QString facilityNames[]
const QString levelNames[4]
const int logFacilities[32]
SgLogger * logger
Definition: SgLogger.cpp:231
SgGuiLoggerConfig(QWidget *, Qt::WindowFlags=Qt::Widget)
QLineEdit * eLogFileName_
QCheckBox * cbLogStoreInFile_
QCheckBox * cbLogTimeLabel_
QCheckBox * cbFullDate_
QCheckBox * cbLLevel_[4][32]
QSpinBox * sLogCapacity_
bool getIsStoreInFile() const
Definition: SgLogger.h:137
void setIsStoreInFile(bool isStoreInFile)
Definition: SgLogger.h:127
void setLogFacility(LogLevel lvl, quint32 f)
Definition: SgLogger.h:131
void setFileName(const QString &fileName)
Definition: SgLogger.h:125
void setIsNeedTimeMark(bool isNeedTimeMark)
Definition: SgLogger.h:129
quint32 getLogFacility(LogLevel lvl) const
Definition: SgLogger.h:141
@ MATRIX
Definition: SgLogger.h:69
@ IO_NCDF
Definition: SgLogger.h:66
@ RESERVED_2
Definition: SgLogger.h:100
@ STOCH
Definition: SgLogger.h:92
@ ESTIMATOR
Definition: SgLogger.h:90
@ IO_TXT
Definition: SgLogger.h:65
@ DELAY
Definition: SgLogger.h:83
@ IO_BIN
Definition: SgLogger.h:64
@ TIME
Definition: SgLogger.h:80
@ GEO_RES_1
Definition: SgLogger.h:87
@ SOURCE
Definition: SgLogger.h:76
@ IO_DBH
Definition: SgLogger.h:67
@ MATRIX3D
Definition: SgLogger.h:70
@ INTERP
Definition: SgLogger.h:71
@ RATE
Definition: SgLogger.h:84
@ IONO
Definition: SgLogger.h:81
@ DISPLACEMENT
Definition: SgLogger.h:86
@ REPORT
Definition: SgLogger.h:95
@ STATION
Definition: SgLogger.h:75
@ PREPROC
Definition: SgLogger.h:98
@ SESSION
Definition: SgLogger.h:77
@ REF_FRAME
Definition: SgLogger.h:79
@ RESOURCE
Definition: SgLogger.h:96
@ REFRACTION
Definition: SgLogger.h:82
@ RESERVED_1
Definition: SgLogger.h:99
@ CONFIG
Definition: SgLogger.h:93
@ MATH_RES_1
Definition: SgLogger.h:72
@ FLY_BY
Definition: SgLogger.h:85
void setCapacity(int capacity)
Definition: SgLogger.h:126
bool getIsNeedTimeMark() const
Definition: SgLogger.h:139
const QString & getFileName() const
Definition: SgLogger.h:135
int getCapacity() const
Definition: SgLogger.h:136
bool getUseFullDateFormat() const
Definition: SgLogger.h:138
void setUseFullDateFormat(bool useFullDateFormat)
Definition: SgLogger.h:128