// $Id: RepGenUtils.hpp,v 1.15 2011/08/02 22:04:23 nwilson Exp $ // RiverWare Model Report Generation -- Utilities. #ifndef RepGenUtilsINCLUDED #define RepGenUtilsINCLUDED #ifndef cwNumINCLUDED #include "cwNum.hpp" #endif #include #include #include class RwModelReport; class cwofstream; class SimObj; class Slot; class IconHandle; class QStringList; // ****************************** // *** Configuration Values *** // ****************************** extern const char* RepGen_SectionAnchor_ObjMethods; extern const char* RepGen_SectionAnchor_ScalarSlotList; extern const char* RepGen_SectionAnchor_OtherSlotList; extern const char* RepGen_SectionAnchor_SeriesSlotList; extern const char* RepGen_SectionAnchor_SlotDetails; namespace RepGen { // ************************************ // *** Column Configuration Class *** // ************************************ class ColDat { private: int _width; // [characters] bool _alignRight; // (default: no). int _maxFootnoteDigs; int _sumValCntAll; int _sumValCntValid; double _userSum; double _userMin; double _userMax; double _userFirst; double _userLast; public: ColDat() : _width (0), _alignRight (false), _maxFootnoteDigs (0), _sumValCntAll (0), _sumValCntValid (0), _userSum (0.0), _userMin (INVALIDVALUE), _userMax (INVALIDVALUE), _userFirst (INVALIDVALUE), _userLast (INVALIDVALUE) {} void setMinimumWidth (int); void setMinimumWidth (const QString&); void setWidth (int newWidth) { _width = newWidth; } int width() const { return (_width); } void setAlignRight (bool ar) { _alignRight = ar; } bool alignRight() const { return (_alignRight); } void trackMaxFootnoteDigits (const QString& newFootnoteStr); void clearMaxFootnoteDigits() { _maxFootnoteDigs = 0; } int maxFootnoteDigits() const { return _maxFootnoteDigs; } void clearSummaryValues(); void processValueForSummary (double userVal); int getSumValCntAll() const { return (_sumValCntAll); } int getSumValCntValid() const { return (_sumValCntValid); } double getUserSum() const { return (_userSum); } double getUserMin() const { return (_userMin); } double getUserMax() const { return (_userMax); } double getUserFirst() const { return (_userFirst); } double getUserLast() const { return (_userLast); } }; // ******************************** // *** General HTML Utilities *** // ******************************** // Note: Some of the utilities in Rpl/DocumentInfo may be useful. // Those are simple enough. It's better to copy them here rather // than introduce a dependency on that module. // Remove non-AlphaNums (incl. spaces); Camel case if non-AlphaNumbs exist. QString reduceNameString (const QString& inStr); QString html_link (const QString& val, const QString& link); QString html_icon (const QString& imgPath, const QSize& imgSize, const int border, const QString& altText, const QString& alignText); QString htmlTableBox (int ind, const QString& htmlContent, int margin=10); QString htmlTableRow (char rowTyp, // 'h'-head, 'd'-dat, 's'-summary const QString& firstColCssClass, const QString& otherColCssClass, const QString& noteCssClass, const QString& firstColBgColorStr, const QString& otherColBgColorStr, const QString& noteBgColorStr, const QVector& colDatVec, const QStringList& cellStrings, const QStringList* cellNotes); // may be NULL // ******************************************* // *** RiverWare Specific HTML Utilities *** // ******************************************* QString localSimObjUrl (const SimObj*, bool quoted=true); QString localSlotUrl (const Slot*, bool quoted=true); // ****************************** // *** IconHandle Utilities *** // ****************************** QString imgFileStr (const IconHandle&, RwModelReport*); QSize imgSize (const IconHandle&); // ****************************** // *** ASCII TEXT Utilities *** // ****************************** QString textBox (const QStringList& contentLineStrs); QString textBox (const QString& contentStr); QString textTableLine (const QVector& colDatVec, char vertDivChar, char horzDivChar); QString textTableLine (const QVector& colDatVec, const QStringList& cellStrings, const QStringList* cellNotes=NULL); } #endif // RepGenUtilsINCLUDED //--- (end RepGenUtils.hpp) ---