GUISettingsHandler Class Reference

#include <GUISettingsHandler.h>

Inheritance diagram for GUISettingsHandler:

SUMOSAXHandler GenericSAXHandler

Detailed Description

An XML-handler for visualisation schemes.

Definition at line 43 of file GUISettingsHandler.h.


Public Member Functions

std::string addSettings (GUISUMOAbstractView *view=0) const throw ()
 Adds the parsed settings to the global list of settings.
void characters (const XMLCh *const chars, const XERCES3_SIZE_t length)
 The inherited method called when characters occured.
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
 The inherited method called when a tag is being closed.
const std::vector
< GUISUMOAbstractView::Decal > & 
getDecals () const throw ()
 Returns the parsed decals.
SUMOReal getDelay () const throw ()
 Returns the parsed delay.
const std::string & getFileName () const throw ()
 returns the current file name
 GUISettingsHandler (const std::string &content, bool isFile=true) throw ()
 Constructor.
bool hasDecals () const throw ()
 Returns whether any decals have been parsed.
void registerParent (const SumoXMLTag tag, GenericSAXHandler *handler)
 Assigning a parent handler which is enabled when the specified tag is closed.
void setFileName (const std::string &name) throw ()
 Sets the current file name.
void setSnapshots (GUISUMOAbstractView *view) const throw ()
 Makes a snapshot if it has been parsed.
void setViewport (SUMOReal &zoom, SUMOReal &xoff, SUMOReal &yoff) const throw ()
 Sets the viewport which has been parsed.
void setViewport (GUISUMOAbstractView *view) const throw ()
 Sets the viewport which has been parsed.
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
 The inherited method called when a new tag opens.
 ~GUISettingsHandler () throw ()
 Destructor.
SAX ErrorHandler callbacks
void error (const SAXParseException &exception) throw (ProcessError)
 Handler for XML-errors.
void fatalError (const SAXParseException &exception) throw (ProcessError)
 Handler for XML-errors.
void warning (const SAXParseException &exception) throw ()
 Handler for XML-warnings.
inherited from GenericSAXHandler
void myStartElement (SumoXMLTag element, const SUMOSAXAttributes &attrs) throw (ProcessError)
 Called on the opening of a tag.

Protected Member Functions

std::string buildErrorMessage (const SAXParseException &exception) throw ()
 Builds an error message.
virtual void myCharacters (SumoXMLTag element, const std::string &chars) throw (ProcessError)
 Callback method for characters to implement by derived classes.
virtual void myEndElement (SumoXMLTag element) throw (ProcessError)
 Callback method for a closing tag to implement by derived classes.

Private Attributes

SumoXMLTag myCurrentColorer
 The last color scheme category (edges or vehicles).
GUIColorSchememyCurrentScheme
 The current color scheme.
std::vector
< GUISUMOAbstractView::Decal
myDecals
 The decals list to fill.
SUMOReal myDelay
 The delay loaded.
GUIVisualizationSettings mySettings
 The settings to fill.
std::map< SUMOTime, std::string > mySnapshots
 mappig of time steps to filenames for potential snapshots
SUMOReal myXPos
SUMOReal myYPos
SUMOReal myZoom
 The viewport loaded.

Constructor & Destructor Documentation

GUISettingsHandler::GUISettingsHandler ( const std::string &  content,
bool  isFile = true 
) throw ()

Constructor.

Parameters:
[in] file the file to parse

Definition at line 50 of file GUISettingsHandler.cpp.

References XMLSubSys::getSAXReader(), and XMLSubSys::runParser().

00051         : SUMOSAXHandler(content), myDelay(-1), myZoom(-1), myXPos(-1), myYPos(-1), myCurrentColorer(SUMO_TAG_NOTHING), myCurrentScheme(0) {
00052     if (isFile) {
00053         XMLSubSys::runParser(*this, content);
00054     } else {
00055         setFileName("registrySettings");
00056         SAX2XMLReader *reader = XMLSubSys::getSAXReader(*this);
00057         MemBufInputSource memBufIS((const XMLByte*)content.c_str(),content.size(),"registrySettings");
00058         reader->parse(memBufIS);
00059         delete reader;
00060     }
00061 }

GUISettingsHandler::~GUISettingsHandler (  )  throw ()

Destructor.

Definition at line 64 of file GUISettingsHandler.cpp.

00064                                                 {
00065 }


Member Function Documentation

std::string GUISettingsHandler::addSettings ( GUISUMOAbstractView view = 0  )  const throw ()

Adds the parsed settings to the global list of settings.

Returns:
the name of the parsed settings

Definition at line 219 of file GUISettingsHandler.cpp.

References GUICompleteSchemeStorage::add(), gSchemeStorage, mySettings, and GUIVisualizationSettings::name.

Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), GUICompleteSchemeStorage::init(), and GUIDialog_ViewSettings::loadSettings().

00219                                                                        {
00220     if (mySettings.name != "") {
00221         gSchemeStorage.add(mySettings);
00222         if (view) {
00223             size_t index = view->getColoringSchemesCombo().appendItem(mySettings.name.c_str());
00224             view->getColoringSchemesCombo().setCurrentItem(index);
00225             view->setColorScheme(mySettings.name);
00226         }
00227     }
00228     return mySettings.name;
00229 }

std::string SUMOSAXHandler::buildErrorMessage ( const SAXParseException &  exception  )  throw () [protected, inherited]

Builds an error message.

The error message includes the file name and the line/column information as supported by the given SAXParseException

Parameters:
[in] exception The name of the currently processed file
Returns:
A string describing the given exception

Definition at line 55 of file SUMOSAXHandler.cpp.

References GenericSAXHandler::getFileName().

Referenced by SUMOSAXHandler::error(), SUMOSAXHandler::fatalError(), and SUMOSAXHandler::warning().

00055                                                                             {
00056     std::ostringstream buf;
00057     char *pMsg = XMLString::transcode(exception.getMessage());
00058     buf << pMsg << std::endl;
00059     buf << " In file '" << getFileName() << "'" << std::endl;
00060     buf << " At line/column " << exception.getLineNumber()+1
00061     << '/' << exception.getColumnNumber() << "." << std::endl;
00062     XMLString::release(&pMsg);
00063     return buf.str();
00064 }

void GenericSAXHandler::characters ( const XMLCh *const   chars,
const XERCES3_SIZE_t  length 
) [inherited]

The inherited method called when characters occured.

The retrieved characters are converted into a string and appended into a private buffer. They are reported as soon as the element ends.

Todo:
recheck/describe what happens with characters when a new element is opened
Todo:
describe characters processing in the class' head

Definition at line 168 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myCharactersVector.

00169                                                            {
00170     myCharactersVector.push_back(TplConvert<XMLCh>::_2str(chars, length));
00171 }

void GenericSAXHandler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const   qname 
) [inherited]

The inherited method called when a tag is being closed.

This method calls the user-implemented methods myCharacters with the previously collected and converted characters.

Then, myEndElement is called, supplying it the qname converted to its enum- and string-representations.

Todo:
recheck/describe encoding of the string-representation
Todo:
do not generate and report the string-representation

Definition at line 118 of file GenericSAXHandler.cpp.

References TplConvert< E >::_2str(), GenericSAXHandler::convertTag(), GenericSAXHandler::myCharacters(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myEndElement(), GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, XMLSubSys::setHandler(), SUMO_TAG_INCLUDE, and SUMO_TAG_NOTHING.

00120                                                         {
00121     std::string name = TplConvert<XMLCh>::_2str(qname);
00122     SumoXMLTag element = convertTag(name);
00123     // collect characters
00124     if (myCharactersVector.size()!=0) {
00125         size_t len = 0;
00126         unsigned i;
00127         for (i=0; i<myCharactersVector.size(); ++i) {
00128             len += myCharactersVector[i].length();
00129         }
00130         char *buf = new char[len+1];
00131         size_t pos = 0;
00132         for (i=0; i<myCharactersVector.size(); ++i) {
00133             memcpy((unsigned char*) buf+pos, (unsigned char*) myCharactersVector[i].c_str(),
00134                    sizeof(char)*myCharactersVector[i].length());
00135             pos += myCharactersVector[i].length();
00136         }
00137         buf[pos] = 0;
00138 
00139         // call user handler
00140         try {
00141             myCharacters(element, buf);
00142         } catch (std::runtime_error &) {
00143             delete[] buf;
00144             throw;
00145         }
00146         delete[] buf;
00147     }
00148     if (element != SUMO_TAG_INCLUDE) {
00149         myEndElement(element);
00150         if (myParentHandler && myParentIndicator == element) {
00151             XMLSubSys::setHandler(*myParentHandler);
00152             myParentIndicator = SUMO_TAG_NOTHING;
00153             myParentHandler = 0;
00154         }
00155     }
00156 }

void SUMOSAXHandler::error ( const SAXParseException &  exception  )  throw (ProcessError) [inherited]

Handler for XML-errors.

The message is built using buildErrorMessage and thrown within a ProcessError.

Parameters:
[in] exception The occured exception to process
Exceptions:
ProcessError On any call

Definition at line 74 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage().

00074                                                                             {
00075     throw ProcessError(buildErrorMessage(exception));
00076 }

void SUMOSAXHandler::fatalError ( const SAXParseException &  exception  )  throw (ProcessError) [inherited]

Handler for XML-errors.

The message is built using buildErrorMessage and thrown within a ProcessError.

Exceptions:
ProcessError On any call
Parameters:
[in] exception The occured exception to process

Definition at line 80 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage().

00080                                                                                  {
00081     throw ProcessError(buildErrorMessage(exception));
00082 }

const std::vector< GUISUMOAbstractView::Decal > & GUISettingsHandler::getDecals (  )  const throw ()

Returns the parsed decals.

Returns:
the parsed decals

Definition at line 263 of file GUISettingsHandler.cpp.

References myDecals.

Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded(), and GUIDialog_ViewSettings::loadDecals().

00263                                             {
00264     return myDecals;
00265 }

SUMOReal GUISettingsHandler::getDelay (  )  const throw ()

Returns the parsed delay.

Returns:
the parsed delay

Definition at line 269 of file GUISettingsHandler.cpp.

References myDelay.

Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded().

00269                                            {
00270     return myDelay;
00271 }

const std::string & GenericSAXHandler::getFileName (  )  const throw () [inherited]

bool GUISettingsHandler::hasDecals (  )  const throw ()

Returns whether any decals have been parsed.

Returns:
whether decals have been parsed

Definition at line 257 of file GUISettingsHandler.cpp.

References myDecals.

Referenced by GUIDialog_ViewSettings::loadDecals().

00257                                             {
00258     return !myDecals.empty();
00259 }

void GenericSAXHandler::myCharacters ( SumoXMLTag  element,
const std::string &  chars 
) throw (ProcessError) [protected, virtual, inherited]

Callback method for characters to implement by derived classes.

Called by "endElement" (see there).

Parameters:
[in] element The opened element, given as a SumoXMLTag
[in] chars The complete embedded character string ProcessError These method may throw a ProcessError if something fails

Reimplemented in ROJTRTurnDefLoader, MSRouteHandler, NIImporter_OpenDrive, NIImporter_SUMO, NLHandler, PCLoaderXML, PCNetProjectionLoader, and RORDLoader_SUMOBase.

Definition at line 189 of file GenericSAXHandler.cpp.

Referenced by GenericSAXHandler::endElement().

00189 {}

void GenericSAXHandler::myEndElement ( SumoXMLTag  element  )  throw (ProcessError) [protected, virtual, inherited]

Callback method for a closing tag to implement by derived classes.

Called by "endElement" (see there).

Parameters:
[in] element The closed element, given as a SumoXMLTag ProcessError These method may throw a ProcessError if something fails

Reimplemented in MSRouteHandler, MSLaneSpeedTrigger, MSTriggeredRerouter, NIImporter_OpenDrive, NIImporter_OpenStreetMap::NodesHandler, NIImporter_OpenStreetMap::EdgesHandler, NIImporter_SUMO, NIXMLEdgesHandler, NLHandler, ODDistrictHandler, PCLoaderOSM::NodesHandler, PCLoaderOSM::EdgesHandler, RORDGenerator_ODAmounts, RORDLoader_SUMOBase, RORDLoader_TripDefs, traci::TraCIHandler, and SAXWeightsHandler.

Definition at line 193 of file GenericSAXHandler.cpp.

Referenced by GenericSAXHandler::endElement().

00193 {}

void GUISettingsHandler::myStartElement ( SumoXMLTag  element,
const SUMOSAXAttributes attrs 
) throw (ProcessError) [virtual]

Called on the opening of a tag.

Parameters:
[in] element ID of the currently opened element
[in] attrs Attributes within the currently opened element
Exceptions:
ProcessError If something fails
See also:
GenericSAXHandler::myStartElement

Reimplemented from GenericSAXHandler.

Definition at line 69 of file GUISettingsHandler.cpp.

References TplConvert< E >::_2bool(), TplConvert< E >::_2int(), TplConvert< E >::_2SUMOReal(), GUIColorScheme::addColor(), GUIVisualizationSettings::addExaggeration, GUIVisualizationSettings::addMode, GUIVisualizationSettings::addNameSize, GUIVisualizationSettings::antialiase, GUIVisualizationSettings::backgroundColor, GUISUMOAbstractView::Decal::centerX, GUISUMOAbstractView::Decal::centerY, GUIColorScheme::clear(), GUICompleteSchemeStorage::contains(), GUIVisualizationSettings::dither, GUIVisualizationSettings::drawAddName, GUIVisualizationSettings::drawEdgeName, GUIVisualizationSettings::drawInternalEdgeName, GUIVisualizationSettings::drawJunctionName, GUIVisualizationSettings::drawLinkJunctionIndex, GUIVisualizationSettings::drawLinkTLIndex, GUIVisualizationSettings::drawPOIName, GUIVisualizationSettings::drawVehicleName, GUIVisualizationSettings::edgeNameColor, GUIVisualizationSettings::edgeNameSize, GUISUMOAbstractView::Decal::filename, GUICompleteSchemeStorage::get(), FileHelpers::getConfigurationRelative(), GenericSAXHandler::getFileName(), GUIColorer< T >::getSchemeByName(), GUIVisualizationSettings::gridXSize, GUIVisualizationSettings::gridYSize, gSchemeStorage, GUISUMOAbstractView::Decal::height, GUIVisualizationSettings::hideConnectors, GUISUMOAbstractView::Decal::initialised, GUIVisualizationSettings::internalEdgeNameColor, GUIVisualizationSettings::internalEdgeNameSize, FileHelpers::isAbsolute(), GUIColorScheme::isFixed(), GUIVisualizationSettings::junctionMode, GUIVisualizationSettings::junctionNameColor, GUIVisualizationSettings::junctionNameSize, GUIVisualizationSettings::laneColorer, GUIVisualizationSettings::laneShowBorders, GUIVisualizationSettings::minAddSize, GUIVisualizationSettings::minPOISize, GUIVisualizationSettings::minVehicleSize, myCurrentColorer, myCurrentScheme, myDecals, myDelay, mySettings, mySnapshots, myXPos, myYPos, myZoom, GUIVisualizationSettings::name, RGBColor::parseColorReporting(), GUIVisualizationSettings::poiExaggeration, GUIVisualizationSettings::poiNameColor, GUIVisualizationSettings::poiNameSize, GUISUMOAbstractView::Decal::rot, GUIColorer< T >::setActive(), GUIColorScheme::setColor(), GUIColorScheme::setInterpolated(), GUIVisualizationSettings::showBlinker, GUIVisualizationSettings::showGrid, GUIVisualizationSettings::showLane2Lane, GUIVisualizationSettings::showLinkDecals, GUIVisualizationSettings::showRails, GUIVisualizationSettings::showSizeLegend, SUMO_ATTR_COLOR, SUMO_ATTR_FILE, SUMO_ATTR_INTERPOLATED, SUMO_ATTR_NAME, SUMO_ATTR_THRESHOLD, SUMO_ATTR_TIME, SUMO_ATTR_VALUE, SUMO_ATTR_X, SUMO_ATTR_Y, SUMO_ATTR_ZOOM, SUMO_TAG_COLORSCHEME, SUMO_TAG_DELAY, SUMO_TAG_ENTRY, SUMO_TAG_SNAPSHOT, SUMO_TAG_VIEWPORT, SUMO_TAG_VIEWSETTINGS_ADDITIONALS, SUMO_TAG_VIEWSETTINGS_BACKGROUND, SUMO_TAG_VIEWSETTINGS_DECAL, SUMO_TAG_VIEWSETTINGS_EDGES, SUMO_TAG_VIEWSETTINGS_JUNCTIONS, SUMO_TAG_VIEWSETTINGS_LEGEND, SUMO_TAG_VIEWSETTINGS_OPENGL, SUMO_TAG_VIEWSETTINGS_POIS, SUMO_TAG_VIEWSETTINGS_SCHEME, SUMO_TAG_VIEWSETTINGS_VEHICLES, toString(), GUIVisualizationSettings::vehicleColorer, GUIVisualizationSettings::vehicleExaggeration, GUIVisualizationSettings::vehicleNameColor, GUIVisualizationSettings::vehicleNameSize, GUIVisualizationSettings::vehicleQuality, and GUISUMOAbstractView::Decal::width.

00070                                                                                        {
00071     bool ok = true;
00072     switch (element) {
00073     case SUMO_TAG_DELAY:
00074         myDelay = attrs.getOptSUMORealReporting(SUMO_ATTR_VALUE, "delay", 0, ok, myDelay);
00075         break;
00076     case SUMO_TAG_VIEWPORT:
00077         myZoom = attrs.getOptSUMORealReporting(SUMO_ATTR_ZOOM, "viewport", 0, ok, myZoom);
00078         myXPos = attrs.getOptSUMORealReporting(SUMO_ATTR_X, "viewport", 0, ok, myXPos);
00079         myYPos = attrs.getOptSUMORealReporting(SUMO_ATTR_Y, "viewport", 0, ok, myYPos);
00080         break;
00081     case SUMO_TAG_SNAPSHOT: {
00082         bool ok = true;
00083         std::string file = attrs.getStringReporting(SUMO_ATTR_FILE, "snapshot", 0, ok);
00084         if (file != "" && !FileHelpers::isAbsolute(file)) {
00085             file = FileHelpers::getConfigurationRelative(getFileName(), file);
00086         }
00087         mySnapshots[attrs.getOptSUMOTimeReporting(SUMO_ATTR_TIME, "snapshot", file.c_str(), ok, 0)] = file;
00088     }
00089     break;
00090     case SUMO_TAG_VIEWSETTINGS_SCHEME: {
00091         bool ok = true;
00092         mySettings.name = attrs.getOptStringReporting(SUMO_ATTR_NAME, 0, 0, ok, mySettings.name);
00093         if (gSchemeStorage.contains(mySettings.name)) {
00094             mySettings = gSchemeStorage.get(mySettings.name);
00095         }
00096     }
00097     break;
00098     case SUMO_TAG_VIEWSETTINGS_OPENGL:
00099         mySettings.antialiase = TplConvert<char>::_2bool(attrs.getStringSecure("antialiase", toString(mySettings.antialiase)).c_str());
00100         mySettings.dither = TplConvert<char>::_2bool(attrs.getStringSecure("dither", toString(mySettings.dither)).c_str());
00101         break;
00102     case SUMO_TAG_VIEWSETTINGS_BACKGROUND: {
00103         bool ok = true;
00104         mySettings.backgroundColor = RGBColor::parseColorReporting(attrs.getStringSecure("backgroundColor", toString(mySettings.backgroundColor)), "background", 0, true, ok);
00105         mySettings.showGrid = TplConvert<char>::_2bool(attrs.getStringSecure("showGrid", toString(mySettings.showGrid)).c_str());
00106         mySettings.gridXSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("gridXSize", toString(mySettings.gridXSize)).c_str());
00107         mySettings.gridYSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("gridYSize", toString(mySettings.gridYSize)).c_str());
00108     }
00109     break;
00110     case SUMO_TAG_VIEWSETTINGS_EDGES: {
00111         bool ok = true;
00112         int laneEdgeMode = TplConvert<char>::_2int(attrs.getStringSecure("laneEdgeMode", "0").c_str());
00113         mySettings.laneShowBorders = TplConvert<char>::_2bool(attrs.getStringSecure("laneShowBorders", toString(mySettings.laneShowBorders)).c_str());
00114         mySettings.showLinkDecals = TplConvert<char>::_2bool(attrs.getStringSecure("showLinkDecals", toString(mySettings.showLinkDecals)).c_str());
00115         mySettings.showRails = TplConvert<char>::_2bool(attrs.getStringSecure("showRails", toString(mySettings.showRails)).c_str());
00116         mySettings.drawEdgeName = TplConvert<char>::_2bool(attrs.getStringSecure("drawEdgeName", toString(mySettings.drawEdgeName)).c_str());
00117         mySettings.edgeNameSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("edgeNameSize", toString(mySettings.edgeNameSize)).c_str());
00118         mySettings.edgeNameColor = RGBColor::parseColorReporting(attrs.getStringSecure("edgeNameColor", toString(mySettings.edgeNameColor)), "edges", 0, true, ok);
00119         mySettings.drawInternalEdgeName = TplConvert<char>::_2bool(attrs.getStringSecure("drawInternalEdgeName", toString(mySettings.drawInternalEdgeName)).c_str());
00120         mySettings.internalEdgeNameSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("internalEdgeNameSize", toString(mySettings.internalEdgeNameSize)).c_str());
00121         mySettings.internalEdgeNameColor = RGBColor::parseColorReporting(attrs.getStringSecure("internalEdgeNameColor", toString(mySettings.internalEdgeNameColor)), "edges", 0, true, ok);
00122         mySettings.hideConnectors = TplConvert<char>::_2bool(attrs.getStringSecure("hideConnectors", toString(mySettings.hideConnectors)).c_str());
00123         myCurrentColorer = element;
00124 #ifdef HAVE_MESOSIM
00125         mySettings.edgeColorer.setActive(laneEdgeMode);
00126 #endif
00127         mySettings.laneColorer.setActive(laneEdgeMode);
00128     }
00129     break;
00130     case SUMO_TAG_COLORSCHEME:
00131         myCurrentScheme = 0;
00132         if (myCurrentColorer == SUMO_TAG_VIEWSETTINGS_EDGES) {
00133             myCurrentScheme = mySettings.laneColorer.getSchemeByName(attrs.getStringSecure(SUMO_ATTR_NAME, ""));
00134 #ifdef HAVE_MESOSIM
00135             if (myCurrentScheme == 0) {
00136                 myCurrentScheme = mySettings.edgeColorer.getSchemeByName(attrs.getStringSecure(SUMO_ATTR_NAME, ""));
00137             }
00138 #endif
00139         }
00140         if (myCurrentColorer == SUMO_TAG_VIEWSETTINGS_VEHICLES) {
00141             myCurrentScheme = mySettings.vehicleColorer.getSchemeByName(attrs.getStringSecure(SUMO_ATTR_NAME, ""));
00142         }
00143         if (myCurrentScheme && !myCurrentScheme->isFixed()) {
00144             bool ok = true;
00145             myCurrentScheme->setInterpolated(attrs.getOptBoolReporting(SUMO_ATTR_INTERPOLATED, "colorScheme", 0, ok, false));
00146             myCurrentScheme->clear();
00147         }
00148         break;
00149     case SUMO_TAG_ENTRY:
00150         if (myCurrentScheme) {
00151             bool ok = true;
00152             std::string colorStr = attrs.getStringReporting(SUMO_ATTR_COLOR, "entry", 0, ok);
00153             RGBColor color = RGBColor::parseColorReporting(colorStr, "edgeColoring", 0, true, ok);
00154             if (myCurrentScheme->isFixed()) {
00155                 myCurrentScheme->setColor(attrs.getStringSecure(SUMO_ATTR_NAME, ""), color);
00156             } else {
00157                 myCurrentScheme->addColor(color,
00158                                           attrs.getSUMORealReporting(SUMO_ATTR_THRESHOLD, "entry", 0, ok));
00159             }
00160         }
00161         break;
00162     case SUMO_TAG_VIEWSETTINGS_VEHICLES:
00163         mySettings.vehicleColorer.setActive(TplConvert<char>::_2int(attrs.getStringSecure("vehicleMode", "0").c_str()));
00164         mySettings.vehicleQuality = TplConvert<char>::_2int(attrs.getStringSecure("vehicleQuality", toString(mySettings.vehicleQuality)).c_str());
00165         mySettings.minVehicleSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("minVehicleSize", toString(mySettings.minVehicleSize)).c_str());
00166         mySettings.vehicleExaggeration = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("vehicleExaggeration", toString(mySettings.vehicleExaggeration)).c_str());
00167         mySettings.showBlinker = TplConvert<char>::_2bool(attrs.getStringSecure("showBlinker", toString(mySettings.showBlinker)).c_str());
00168         mySettings.drawVehicleName = TplConvert<char>::_2bool(attrs.getStringSecure("drawVehicleName", toString(mySettings.drawVehicleName)).c_str());
00169         mySettings.vehicleNameSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("vehicleNameSize", toString(mySettings.vehicleNameSize)).c_str());
00170         mySettings.vehicleNameColor = RGBColor::parseColorReporting(attrs.getStringSecure("vehicleNameColor", toString(mySettings.vehicleNameColor)), "vehicles", 0, true, ok);
00171         myCurrentColorer = element;
00172         break;
00173     case SUMO_TAG_VIEWSETTINGS_JUNCTIONS:
00174         mySettings.junctionMode = TplConvert<char>::_2int(attrs.getStringSecure("junctionMode", toString(mySettings.junctionMode)).c_str());
00175         mySettings.drawLinkTLIndex = TplConvert<char>::_2bool(attrs.getStringSecure("drawLinkTLIndex", toString(mySettings.drawLinkTLIndex)).c_str());
00176         mySettings.drawLinkJunctionIndex = TplConvert<char>::_2bool(attrs.getStringSecure("drawLinkJunctionIndex", toString(mySettings.drawLinkJunctionIndex)).c_str());
00177         mySettings.drawJunctionName = TplConvert<char>::_2bool(attrs.getStringSecure("drawJunctionName", toString(mySettings.drawJunctionName)).c_str());
00178         mySettings.junctionNameSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("junctionNameSize", toString(mySettings.junctionNameSize)).c_str());
00179         mySettings.junctionNameColor = RGBColor::parseColorReporting(attrs.getStringSecure("junctionNameColor", toString(mySettings.junctionNameColor)), "junctions", 0, true, ok);
00180         mySettings.showLane2Lane = TplConvert<char>::_2bool(attrs.getStringSecure("showLane2Lane", toString(mySettings.showLane2Lane)).c_str());
00181         break;
00182     case SUMO_TAG_VIEWSETTINGS_ADDITIONALS:
00183         mySettings.addMode = TplConvert<char>::_2int(attrs.getStringSecure("addMode", toString(mySettings.addMode)).c_str());
00184         mySettings.minAddSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("minAddSize", toString(mySettings.minAddSize)).c_str());
00185         mySettings.addExaggeration = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("addExaggeration", toString(mySettings.addExaggeration)).c_str());
00186         mySettings.drawAddName = TplConvert<char>::_2bool(attrs.getStringSecure("drawAddName", toString(mySettings.drawAddName)).c_str());
00187         mySettings.addNameSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("addNameSize", toString(mySettings.addNameSize)).c_str());
00188         break;
00189     case SUMO_TAG_VIEWSETTINGS_POIS:
00190         mySettings.poiExaggeration = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("poiExaggeration", toString(mySettings.poiExaggeration)).c_str());
00191         mySettings.minPOISize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("minPOISize", toString(mySettings.minPOISize)).c_str());
00192         mySettings.drawPOIName = TplConvert<char>::_2bool(attrs.getStringSecure("drawPOIName", toString(mySettings.drawPOIName)).c_str());
00193         mySettings.poiNameSize = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("poiNameSize", toString(mySettings.poiNameSize)).c_str());
00194         mySettings.poiNameColor = RGBColor::parseColorReporting(attrs.getStringSecure("poiNameColor", toString(mySettings.poiNameColor)), "pois", 0, true, ok);
00195         break;
00196     case SUMO_TAG_VIEWSETTINGS_LEGEND:
00197         mySettings.showSizeLegend = TplConvert<char>::_2bool(attrs.getStringSecure("showSizeLegend", toString(mySettings.showSizeLegend)).c_str());
00198         break;
00199     case SUMO_TAG_VIEWSETTINGS_DECAL: {
00200         GUISUMOAbstractView::Decal d;
00201         d.filename = attrs.getStringSecure("filename", d.filename);
00202         if (d.filename != "" && !FileHelpers::isAbsolute(d.filename)) {
00203             d.filename = FileHelpers::getConfigurationRelative(getFileName(), d.filename);
00204         }
00205         d.centerX = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("centerX", toString(d.centerX)).c_str());
00206         d.centerY = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("centerY", toString(d.centerY)).c_str());
00207         d.width = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("width", toString(d.width)).c_str());
00208         d.height = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("height", toString(d.height)).c_str());
00209         d.rot = TplConvert<char>::_2SUMOReal(attrs.getStringSecure("rotation", toString(d.rot)).c_str());
00210         d.initialised = false;
00211         myDecals.push_back(d);
00212     }
00213     break;
00214     }
00215 }

void GenericSAXHandler::registerParent ( const SumoXMLTag  tag,
GenericSAXHandler handler 
) [inherited]

Assigning a parent handler which is enabled when the specified tag is closed.

Definition at line 160 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, and XMLSubSys::setHandler().

Referenced by NLTriggerBuilder::parseAndBuildLaneSpeedTrigger().

00160                                                                                   {
00161     myParentHandler = handler;
00162     myParentIndicator = tag;
00163     XMLSubSys::setHandler(*this);
00164 }

void GenericSAXHandler::setFileName ( const std::string &  name  )  throw () [inherited]

Sets the current file name.

Parameters:
[in] name The name of the currently processed file
Todo:
Hmmm - this is as unsafe as having a direct access to the variable; recheck

Definition at line 72 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myFileName.

Referenced by PCNetProjectionLoader::loadIfSet(), ROLoader::loadNet(), NIImporter_OpenStreetMap::loadNetwork(), NILoader::loadXMLType(), and traci::TraCIServer::TraCIServer().

00072                                                             {
00073     myFileName = name;
00074 }

void GUISettingsHandler::setSnapshots ( GUISUMOAbstractView view  )  const throw ()

Makes a snapshot if it has been parsed.

Parameters:
[in] parent the view which needs to be shot

Definition at line 249 of file GUISettingsHandler.cpp.

References mySnapshots.

Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded().

00249                                                                         {
00250     if (!mySnapshots.empty()) {
00251         view->setSnapshots(mySnapshots);
00252     }
00253 }

void GUISettingsHandler::setViewport ( SUMOReal &  zoom,
SUMOReal &  xoff,
SUMOReal &  yoff 
) const throw ()

Sets the viewport which has been parsed.

Parameters:
[out] zoom Variable to store the loaded zoom into
[out] xoff Variable to store the loaded x-offset into
[out] yoff Variable to store the loaded y-offset into

Definition at line 241 of file GUISettingsHandler.cpp.

References myXPos, myYPos, and myZoom.

00241                                                                                             {
00242     zoom = myZoom;
00243     xoff = myXPos;
00244     yoff = myYPos;
00245 }

void GUISettingsHandler::setViewport ( GUISUMOAbstractView view  )  const throw ()

Sets the viewport which has been parsed.

Parameters:
[in] parent the view for which the viewport has to be set

Definition at line 233 of file GUISettingsHandler.cpp.

References myXPos, myYPos, and myZoom.

Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded().

00233                                                                        {
00234     if (myZoom > 0) {
00235         view->setViewport(myZoom, myXPos, myYPos);
00236     }
00237 }

void GenericSAXHandler::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const   qname,
const Attributes &  attrs 
) [inherited]

The inherited method called when a new tag opens.

The method parses the supplied XMLCh*-qname using the internal name/enum-map to obtain the enum representation of the attribute name.

Then, "myStartElement" is called supplying the enumeration value, the string-representation of the name and the attributes.

Todo:
recheck/describe encoding of the string-representation
Todo:
do not generate and report the string-representation

Definition at line 97 of file GenericSAXHandler.cpp.

References TplConvert< E >::_2str(), GenericSAXHandler::convertTag(), FileHelpers::getConfigurationRelative(), GenericSAXHandler::getFileName(), SUMOSAXAttributesImpl_Xerces::getString(), FileHelpers::isAbsolute(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myPredefinedTags, GenericSAXHandler::myPredefinedTagsMML, GenericSAXHandler::myStartElement(), XMLSubSys::runParser(), SUMO_ATTR_HREF, and SUMO_TAG_INCLUDE.

00100                                                          {
00101     std::string name = TplConvert<XMLCh>::_2str(qname);
00102     SumoXMLTag element = convertTag(name);
00103     myCharactersVector.clear();
00104     SUMOSAXAttributesImpl_Xerces na(attrs, myPredefinedTags, myPredefinedTagsMML);
00105     if (element == SUMO_TAG_INCLUDE) {
00106         std::string file = na.getString(SUMO_ATTR_HREF);
00107         if (!FileHelpers::isAbsolute(file)) {
00108             file = FileHelpers::getConfigurationRelative(getFileName(), file);
00109         }
00110         XMLSubSys::runParser(*this, file);
00111     } else {
00112         myStartElement(element, na);
00113     }
00114 }

void SUMOSAXHandler::warning ( const SAXParseException &  exception  )  throw () [inherited]

Handler for XML-warnings.

The message is built using buildErrorMessage and reported to the warning-instance of the MsgHandler.

Parameters:
[in] exception The occured exception to process

Definition at line 68 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage(), MsgHandler::getWarningInstance(), and MsgHandler::inform().


Field Documentation

The last color scheme category (edges or vehicles).

Definition at line 131 of file GUISettingsHandler.h.

Referenced by myStartElement().

The current color scheme.

Definition at line 134 of file GUISettingsHandler.h.

Referenced by myStartElement().

The decals list to fill.

Definition at line 128 of file GUISettingsHandler.h.

Referenced by getDecals(), hasDecals(), and myStartElement().

SUMOReal GUISettingsHandler::myDelay [private]

The delay loaded.

Definition at line 119 of file GUISettingsHandler.h.

Referenced by getDelay(), and myStartElement().

The settings to fill.

Definition at line 116 of file GUISettingsHandler.h.

Referenced by addSettings(), and myStartElement().

std::map<SUMOTime, std::string> GUISettingsHandler::mySnapshots [private]

mappig of time steps to filenames for potential snapshots

Definition at line 125 of file GUISettingsHandler.h.

Referenced by myStartElement(), and setSnapshots().

SUMOReal GUISettingsHandler::myXPos [private]

Definition at line 122 of file GUISettingsHandler.h.

Referenced by myStartElement(), and setViewport().

SUMOReal GUISettingsHandler::myYPos [private]

Definition at line 122 of file GUISettingsHandler.h.

Referenced by myStartElement(), and setViewport().

SUMOReal GUISettingsHandler::myZoom [private]

The viewport loaded.

Definition at line 122 of file GUISettingsHandler.h.

Referenced by myStartElement(), and setViewport().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:45 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6