// $Id: RepGenSimObjText.cpp,v 1.9 2010/05/14 19:37:47 lynn Exp $ // // class RepGenSimObjText : public RepGenSimObj // // STUB ... in progress. // //-- #ifndef RepGenSimObjTextINCLUDED #include "RepGenSimObjText.hpp" #endif #ifndef RwModelReportINCLUDED #include "RwModelReport.hpp" #endif #ifndef RepGenSlotTextINCLUDED #include "RepGenSlotText.hpp" #endif #ifndef RepGenUtilsINCLUDED #include "RepGenUtils.hpp" #endif #ifndef RunTypeINCLUDED #include "RunType.hpp" #endif #ifndef SimObjINCLUDED #include "SimObj.hpp" #endif #ifndef SlotINCLUDED #include "Slot.hpp" #endif #ifndef SlotGUIUtilsINCLUDED #include "SlotGUIUtils.hpp" #endif #ifndef cwfstreamINCLUDED #include "cwfstream.hpp" #endif #include "rwStr.hpp" //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- RepGenSimObjText::RepGenSimObjText (RwModelReport* rep, SimObj* obj) : RepGenSimObj (rep, obj) { } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- RepGenSimObjText::~RepGenSimObjText() { } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // virtual from RepGenSimObj void RepGenSimObjText::writeObjSummary (cwofstream& os) { if (_simObj == NULL) return; //------------------------>> // ************************************* // *** SimObj Type and SimObj Name *** // ************************************* const QString objName (_simObj->getCompleteName()); const QString objDesc (_simObj->getLongTypeName(true)); // iconTag const QString objNameFmt ("Simulation Object: %1"); const QString objDescFmt ("SimObj Type: %1"); QStringList summaryStrList; summaryStrList << objNameFmt.arg (objName) << objDescFmt.arg (objDesc); const QString summaryBox = RepGen::textBox (summaryStrList); os << qPrintable (summaryBox) << endl; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // virtual from RepGenSimObj void RepGenSimObjText::writeMethodTable (cwofstream& os) { if (_simObj == NULL) return; //------------------------>> cwSlist objList; buildCompSimObjList (_simObj, objList); cwIterator objIter; for (objIter = objList.first(); objIter; objIter = objList.next (objIter)) { const SimObj* obj = objList.elem (objIter); if (obj == NULL) continue; //------------------------ QVector colDatVec; writeMethodList (obj, true, colDatVec, os); // MEASURE writeMethodList (obj, false, colDatVec, os); // WRITE os << endl; } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // virtual from RepGenSimObj void RepGenSimObjText::writeSlotLists (cwofstream& os) { if (_simObj == NULL) return; //------------------------>> const QString objName (_simObj->getCompleteName()); const QString objDesc (_simObj->getLongTypeName(true)); // iconTag const RunType ctlType (RT_SIMULATION); cwDlist slotList; _simObj->getSlotsInUse (slotList, ctlType); const QString titlePrefix = QString ("%1 (%2) ") .arg (objName) .arg (objDesc); // ************************** // *** Scalar Slot List *** // ************************** RepGenSlotText dummyRepGenSlot (_modelReport, (Slot*) NULL); // Start Table ... QVector colConfigVec; // (1) Measure writeSlotList (true, // measureOnly colConfigVec, RepGenSlot::SlotList_Scalar, titlePrefix + "Scalar Slots", slotList, os); // (2) Write writeSlotList (false, // measureOnly colConfigVec, RepGenSlot::SlotList_Scalar, titlePrefix + "Scalar Slots", slotList, os); // ************************************ // *** Other Non-Series Slot List *** // ************************************ // Start Table ... colConfigVec.clear(); // (1) Measure writeSlotList (true, // measureOnly colConfigVec, RepGenSlot::SlotList_Other, titlePrefix + "Other Non-Series Slots", slotList, os); // (2) Write writeSlotList (false, // measureOnly colConfigVec, RepGenSlot::SlotList_Other, titlePrefix + "Other Non-Series Slots", slotList, os); // ************************** // *** Series Slot List *** // ************************** // Start Table ... colConfigVec.clear(); // (1) Measure writeSlotList (true, // measureOnly colConfigVec, RepGenSlot::SlotList_Series, titlePrefix + "Series Slots", slotList, os); // (2) Write writeSlotList (false, // measureOnly colConfigVec, RepGenSlot::SlotList_Series, titlePrefix + "Series Slots", slotList, os); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // private, static void RepGenSimObjText::writeMethodList (const SimObj* obj, bool measureOnly, QVector& colDatVec, cwofstream& os) { if (obj == NULL) return; //-------------------->> const QString objName (obj->getCompleteName()); const QString objType (obj->getType()); if (!measureOnly) { const QString listTitle = objName + " -- Non-Default Method Selections"; const QString titleBox = RepGen::textBox (listTitle); os << qPrintable (titleBox) << endl; } if (colDatVec.size() < 3) { colDatVec.resize (3); } QStringList catsList; QStringList methsList; getCatsMeths (obj, catsList, methsList, false); // don't include defaults QStringList colHdrStrList; colHdrStrList << "SimObj Type" << "Method Category" << "Selected Method"; if (measureOnly) { colDatVec [0] .setMinimumWidth (colHdrStrList .value (0)); colDatVec [1] .setMinimumWidth (colHdrStrList .value (1)); colDatVec [2] .setMinimumWidth (colHdrStrList .value (2)); } else // (not measureOnly) { const QString line1 (RepGen::textTableLine (colDatVec, '+', '-')); const QString line2 (RepGen::textTableLine (colDatVec, colHdrStrList)); const QString line3 (RepGen::textTableLine (colDatVec, '|', '=')); os << qPrintable (line1) << "\n" << qPrintable (line2) << "\n" << qPrintable (line3) << endl; } const int catsListSize = catsList.size(); for (int catInx = 0; catInx < catsListSize; ++catInx) { const QString catName = catsList.value (catInx); const QString methName = methsList.value (catInx); if (measureOnly) { colDatVec [0] .setMinimumWidth (objType); colDatVec [1] .setMinimumWidth (catName); colDatVec [2] .setMinimumWidth (methName); } else // (not measureOnly) { QStringList rowCellStrList; rowCellStrList << objType << catName << methName; const QString catLine = RepGen::textTableLine (colDatVec, rowCellStrList); os << qPrintable (catLine) << endl; } } if (!measureOnly) { const QString botLine (RepGen::textTableLine (colDatVec, '+', '-')); os << qPrintable (botLine) << endl; } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // private void RepGenSimObjText::writeSlotList (bool measureOnly, QVector& colConfigVec, RepGenSlot::SlotListType slotListType, const QString& listTitle, const cwDlist& slotList, cwofstream& os) { // Header Table-Row RepGenSlotText dummyRepGenSlot (_modelReport, (Slot*) NULL); dummyRepGenSlot.writeSlotListHeader (measureOnly, colConfigVec, slotListType, listTitle, os); // Slot Table-Rows cwIterator slotIter; for (slotIter = slotList.first(); slotIter; slotIter = slotList.next (slotIter)) { const Slot* slotPtr = slotList.elem (slotIter); if (slotPtr == NULL) continue; //---------------------------- switch (slotListType) { case RepGenSlot::SlotList_Scalar: { if (!SlotGUIUtils::isScalarLikeSlot (slotPtr)) continue; break; //-------- } case RepGenSlot::SlotList_Other: { if (SlotGUIUtils::isScalarLikeSlot (slotPtr)) continue; if (SlotGUIUtils::hasSeries (slotPtr)) continue; break; //-------- } case RepGenSlot::SlotList_Series: { if (!SlotGUIUtils::hasSeries (slotPtr)) continue; break; //-------- } } RepGenSlotText repSlot (_modelReport, slotPtr); repSlot.writeSlotListRow (measureOnly, colConfigVec, slotListType, os); } // End Table if (!measureOnly) { const QString botLine (RepGen::textTableLine (colConfigVec, '+', '-')); os << qPrintable (botLine) << "\n" << endl; } } //--- (end RepGenSimObjText.cpp) ---