// $Id: RepGenSimObjHtml.cpp,v 1.10 2010/05/14 19:37:47 lynn Exp $ // // class RepGenSimObjHtml : public RepGenSimObj // //-- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- static const char* HeaderBackgroundColor ("#d8d8d8"); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- #ifndef RepGenSimObjHtmlINCLUDED #include "RepGenSimObjHtml.hpp" #endif #ifndef RwModelReportINCLUDED #include "RwModelReport.hpp" #endif #ifndef RepGenSlotHtmlINCLUDED #include "RepGenSlotHtml.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 cwSlistINCLUDED #include "cwSlist.hpp" #endif #ifndef cwfstreamINCLUDED #include "cwfstream.hpp" #endif #include "rwStr.hpp" //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- static const QString namedAnchorFmt (""); //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- RepGenSimObjHtml::RepGenSimObjHtml (RwModelReport* rep, SimObj* obj) : RepGenSimObj (rep, obj) { } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- RepGenSimObjHtml::~RepGenSimObjHtml() { } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // virtual from RepGenSimObj void RepGenSimObjHtml::writeObjSummary (cwofstream& os) { if (_simObj == NULL) return; //------------------------>> const QString objName (_simObj->getCompleteName()); const QString objDesc (_simObj->getLongTypeName(true)); // iconTag // ********************************** // *** SimObj HTML Named Anchor *** // ********************************** const QString objMunge = RepGen::reduceNameString (objName); const QString objAnchor = namedAnchorFmt.arg (objMunge); os << qPrintable (objAnchor) << endl; // ****************************************** // *** SimObj Type Icon and SimObj Name *** // ****************************************** const QString imgFileStr = typImgFileStr (true); // large const bool imgFileStrOk (!imgFileStr.isEmpty()); static const QString alignText (""); // no align attribute const QString htmlIcon = RepGen::html_icon (imgFileStr, QSize(40,40), 0, objDesc, alignText); static const QString simObjTitleTemplate ( "\n" " \n" " \n" " \n" " \n" " \n" "
%1   %2
" ); const QString simObjTitle = simObjTitleTemplate .arg (htmlIcon) .arg (objName); const QString boxedTitle = RepGen::htmlTableBox (0, simObjTitle); os << qPrintable (boxedTitle) << endl; // os << " 
" << endl; // ********************************************** // *** SimObj Report Document Section Links *** // ********************************************** static const QString contFmt ( "" ); static const QString contStr = contFmt .arg (RepGen_SectionAnchor_ObjMethods) .arg (RepGen_SectionAnchor_ScalarSlotList) .arg (RepGen_SectionAnchor_OtherSlotList) .arg (RepGen_SectionAnchor_SeriesSlotList) .arg (RepGen_SectionAnchor_SlotDetails); os << qPrintable (contStr) << endl; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // virtual from RepGenSimObj void RepGenSimObjHtml::writeMethodTable (cwofstream& os) { if (_simObj == NULL) return; //------------------------>> static const QString headerTextNoteFmt ( "

%1 (%2) -- Method categories \n" "with non-default method selections:

"); // Write Named Anchor for Section: Object Methods const QString sectAnchor = namedAnchorFmt.arg (RepGen_SectionAnchor_ObjMethods); os << qPrintable (sectAnchor) << endl; // ************************************** // *** Set up HTML Table Attributes *** // ************************************** static const QString cellPaddingFmt (" cellpadding=\"%1\""); static const QString cellSpacingFmt (" cellspacing=\"%2\""); static const QString borderPixFmt (" border=\"%3\""); const QString cellPadding (cellPaddingFmt .arg (4)); // PADDING const QString cellSpacing (cellSpacingFmt .arg (0)); // CELL SPACING const QString borderPix (borderPixFmt .arg (1)); // BORDER static const QString tableTag ( QString ("") .arg (cellPadding) .arg (cellSpacing) .arg (borderPix) ); // ***************************** // *** SimObj Method Table *** // ***************************** static const QString methodTableHeaderTrFmt ( " \n" " Method Category\n" // icon / category " Selected Method\n" // method " " ); static const QString methodTableDataTrFmt ( " \n" " %1\n" // simobj icon " %2\n" // category " %3\n" // method " " ); 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; //------------------------ const QString objName (obj->getCompleteName()); const QString objDesc (obj->getLongTypeName(true)); // Pre-Table Header Text Note const QString headerTextNote = headerTextNoteFmt .arg (objName) .arg (objDesc); os << qPrintable (headerTextNote) << endl; const IconHandle objIcon (obj, false); // not large const QString imgPath = RepGen::imgFileStr (objIcon, _modelReport); const QSize imgSize = RepGen::imgSize (objIcon); QString iconHtml = RepGen::html_icon (imgPath, imgSize, 0, objDesc, ""); if (obj == _simObj) { const QString objMunge = RepGen::reduceNameString (objName); const QString iconURL = QString ("#") + objMunge; iconHtml = RepGen::html_link (iconHtml, iconURL); } // Start HTML Table os << qPrintable (tableTag) << endl; const QString methodTableHeaderTr = methodTableHeaderTrFmt .arg (HeaderBackgroundColor); os << qPrintable (methodTableHeaderTr) << endl; QStringList catsList; QStringList methsList; getCatsMeths (obj, catsList, methsList, false); // don't include defaults const int catsListSize = catsList.size(); for (int catInx = 0; catInx < catsListSize; ++catInx) { const QString catName = catsList.value (catInx); const QString methName = methsList.value (catInx); const QString methodTableDataTr = methodTableDataTrFmt .arg (iconHtml) .arg (catName) .arg (methName); os << qPrintable (methodTableDataTr) << endl; } // End HTML Table os << "\n" << " 
" << endl; } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // virtual from RepGenSimObj void RepGenSimObjHtml::writeSlotLists (cwofstream& os) { if (_simObj == NULL) return; //------------------------>> const QString objName (_simObj->getCompleteName()); const RunType ctlType (RT_SIMULATION); cwDlist slotList; _simObj->getSlotsInUse (slotList, ctlType); // ************************************** // *** Set up HTML Table Attributes *** // ************************************** static const QString cellPaddingFmt (" cellpadding=\"%1\""); static const QString cellSpacingFmt (" cellspacing=\"%2\""); static const QString borderPixFmt (" border=\"%3\""); const QString cellPadding (cellPaddingFmt .arg (4)); // PADDING const QString cellSpacing (cellSpacingFmt .arg (0)); // CELL SPACING const QString borderPix (borderPixFmt .arg (1)); // BORDER static const QString tableTag ( QString ("") .arg (cellPadding) .arg (cellSpacing) .arg (borderPix) ); // ************************** // *** Scalar Slot List *** // ************************** // Write Named Anchor for Section: Scalar Slots const QString scalarAnch = namedAnchorFmt.arg (RepGen_SectionAnchor_ScalarSlotList); os << qPrintable (scalarAnch) << endl; RepGenSlotHtml dummyRepGenSlot (_modelReport, (Slot*) NULL); // Start HTML Table os << qPrintable (tableTag) << endl; // Header Table-Row dummyRepGenSlot.writeSlotListHeader (RepGenSlot::SlotList_Scalar, "Scalar Slots", 1, 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; if (!SlotGUIUtils::isScalarLikeSlot (slotPtr)) continue; //------------------------------------------------------ RepGenSlotHtml repSlot (_modelReport, slotPtr); repSlot.writeSlotListRow (RepGenSlot::SlotList_Scalar, 1, os); // indentLevel } os << "\n" << " 
" << endl; // ************************************ // *** Other Non-Series Slot List *** // ************************************ // Write Named Anchor for Section: Other Slots const QString otherAnch = namedAnchorFmt.arg (RepGen_SectionAnchor_OtherSlotList); os << qPrintable (otherAnch) << endl; // Start HTML Table os << qPrintable (tableTag) << endl; // Header Table-Row dummyRepGenSlot.writeSlotListHeader (RepGenSlot::SlotList_Other, "Other Non-Series Slots", 1, os); // Slot Table-Rows for (slotIter = slotList.first(); slotIter; slotIter = slotList.next (slotIter)) { const Slot* slotPtr = slotList.elem (slotIter); if (slotPtr == NULL) continue; if (SlotGUIUtils::isScalarLikeSlot (slotPtr)) continue; if (SlotGUIUtils::hasSeries (slotPtr)) continue; //---------------------------------------------- RepGenSlotHtml repSlot (_modelReport, slotPtr); repSlot.writeSlotListRow (RepGenSlot::SlotList_Other, 1, os); // indentLevel } os << "\n" << " 
" << endl; // ************************** // *** Series Slot List *** // ************************** // Write Named Anchor for Section: Series Slots const QString seriesAnch = namedAnchorFmt.arg (RepGen_SectionAnchor_SeriesSlotList); os << qPrintable (seriesAnch) << endl; // Start HTML Table os << qPrintable (tableTag) << endl; // Header Table-Row dummyRepGenSlot.writeSlotListHeader (RepGenSlot::SlotList_Series, "Series Slots", 1, os); // Slot Table-Rows for (slotIter = slotList.first(); slotIter; slotIter = slotList.next (slotIter)) { const Slot* slotPtr = slotList.elem (slotIter); if (slotPtr == NULL) continue; if (!SlotGUIUtils::hasSeries (slotPtr)) continue; //----------------------------------------------- RepGenSlotHtml repSlot (_modelReport, slotPtr); repSlot.writeSlotListRow (RepGenSlot::SlotList_Series, 1, os); // indentLevel } os << "\n" << " 
" << endl; // Write Named Anchor for Section: Slot Details const QString detailAnch = namedAnchorFmt.arg (RepGen_SectionAnchor_SlotDetails); os << qPrintable (detailAnch) << endl; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // private QString RepGenSimObjHtml::typImgFileStr (bool large) const { if (_simObj) { const IconHandle objIcon (_simObj, large); const QString filename = RepGen::imgFileStr (objIcon, _modelReport); return (filename); //------------->> } return (""); } //--- (end RepGenSimObjHtml.cpp) ---