LBAO Task 1.1: Tabular Series Slot Report: Option to exclude all NEAR-zero slots
- Phil's notes for Willard, 3-22-2017 (b) -- Hit Refresh
David's Notes (3-22-2017) ...
This is LBAO task 1.1:
This should be another very small task.
...
Omit slots:
(o) Having only NaN Values
(o) Having only NaN or 0.0 values (absolute)
(o) Having only NaN or 0.0 values (slot display values)
I could be convinced to just go with the third item and get rid of the existing 2nd item, (comparison to absolute zero). If they've said to show two digits in the slot, we show two digits in the report. If the value is 0.001 internally, but we show 0.00 in the slot, we shouldn't show it as 0.00 in the report even though it is non zero internally. |
Reference Screenshots
Ouptut Manager ... New Tabular Series Slot Report...

Tabular Series Slot Report (aka GREEN BOOK) ... Settings Tab:

Relevant Classes, Fields and Methods:
Tablular Series Slot Report (aka GREEN BOOK) configuration dialog:
- Q3GUI/GreenBookConfigPanel (a QWidget)
- Q3GUI/GreenBookConfigPanelWidgets.ui (Qt Designer file)
- QCheckBox* _ui._omitSlotsCheckBox
- QRadioButton* _ui._omitSlotsWithNanRadioButton
- QRadioButton* _ui._omitSlotsWithNorZRadioButton
- Add a third radio button
- method: void GreenBookConfigPanel::updateWidgets();
- method: char GreenBookConfigPanel::omitSlotsWhichChar() const
Data Model: Sim/GreenBookReportConfig:
- class GreenBookReportConfig : public ReportConfig
- bool _omitSlots;
- char _omitSlotsWhich; // 'n'-NaNs only, 'z'-NaNs or 0's only.
- bool omitSlots() const { return (_omitSlots); }
- char omitSlotsWhich() const { return (_omitSlotsWhich); }
- void setOmitSlots (bool);
- void setOmitSlotsWhich (char);
- class GreenBookReportConfig::SlotRec
- bool slotIsShown (const GreenBookReportConfig* cfg) const
- bool anyValidValues (const GreenBookReportConfig* cfg) const
- bool anyNonZeroValues (const GreenBookReportConfig* cfg) const
- Add similar method: bool anyNonNearZeroValues (...) const
... see implementation notes below!
For the -- bool GreenBookReportConfig::SlotRec::anyNonNearZeroValues() -- implementation, a quick (to code) algorithm is (1) convert the slot value (at the particular timestep Date_Time) to a string in user units and configured precision, (2) convert that string back to a double, (3) compare to 0.0. Note that SlotColRef is an alias for RootColRef ....
- BEFORE the time iteration:
- Construct a SlotColRef scRef from GreenBookReportConfig::SlotRec::locateSlot().
- Isolate the slot pointer and column:
- const Slot* slotPtr = scRef.slot()
- const int col = scRef.col();
- Return 'false' if the slotPtr is NULL.
- Obtain the slot's configured numeric formatting 'precision'.
- const NumDisplayAttribs& attbs = slotPtr->activeNumDisplayAttribs_prim (col);
- const int slotPrec = attbs.dispPrecision(); // fractional decimal digit count
- INSIDE the time (Date_Time when) iteration:
- Get user-units value: const double userVal = scRef.getUserPrimValue (when);
- If NaN, 'continue'. Otherwise ...
- Convert that value to a string (with the Unit Schme-based precision for that slot):
- QString numStringBuffer; // (but perhaps instantiate above the loop)
- static const char formatCh ('f');
- (void) cwFormat::cwFormatValue (userVal, formatCh, slotPrec, numStrBuffer);
- ... (2) convert numStrBuffer back to a double ... (3) compare to 0.0.
... This approach -- converting the numeric value to a string (using the slot's unit scheme precision) and then back to a double -- isn't the fastest way of performing this check, but it's simple, and, I believe, fast enough for "greenbook" generation time. Given this algorithm, the code outline above is very good. (I haven't actually compiled the code snippets above, but it's at least close).
--- (end) ---