#include <GUICompleteSchemeStorage.h>
Definition at line 46 of file GUICompleteSchemeStorage.h.
Public Member Functions | |
| void | add (const GUIVisualizationSettings &scheme) throw () |
| Adds a visualization scheme. | |
| bool | contains (const std::string &name) const throw () |
| Returns the information whether a setting with the given name is stored. | |
| GUIVisualizationSettings & | get (const std::string &name) throw () |
| Returns the named scheme. | |
| GUIVisualizationSettings & | getDefault () throw () |
| Returns the default scheme. | |
| const std::vector< std::string > & | getNames () const throw () |
| Returns a list of stored settings names. | |
| unsigned int | getNumInitialSettings () const throw () |
| Returns the number of initial settings. | |
| GUICompleteSchemeStorage () throw () | |
| Constructor. | |
| void | init (FXApp *app) throw () |
| Initialises the storage with some default settings. | |
| void | remove (const std::string &name) throw () |
| Removes the setting with the given name. | |
| void | saveViewport (const SUMOReal x, const SUMOReal y, const SUMOReal zoom) throw () |
| Makes the given viewport the default. | |
| void | setDefault (const std::string &name) throw () |
| Makes the scheme with the given name the default. | |
| void | setViewport (GUISUMOAbstractView *view) throw () |
| Sets the default viewport. | |
| void | writeSettings (FXApp *app) throw () |
| Writes the current scheme into the registry. | |
| ~GUICompleteSchemeStorage () throw () | |
| Destructor. | |
Protected Attributes | |
| std::string | myDefaultSettingName |
| Name of the default setting. | |
| unsigned int | myNumInitialSettings |
| The number of settings which were present at startup. | |
| std::map< std::string, GUIVisualizationSettings > | mySettings |
| A map of settings referenced by their names. | |
| std::vector< std::string > | mySortedSchemeNames |
| List of known setting names. | |
| SUMOReal | myX |
| The default viewport. | |
| SUMOReal | myY |
| SUMOReal | myZoom |
| GUICompleteSchemeStorage::GUICompleteSchemeStorage | ( | ) | throw () |
| GUICompleteSchemeStorage::~GUICompleteSchemeStorage | ( | ) | throw () |
| void GUICompleteSchemeStorage::add | ( | const GUIVisualizationSettings & | scheme | ) | throw () |
Adds a visualization scheme.
| [in] | scheme | The visualization scheme to add |
Definition at line 60 of file GUICompleteSchemeStorage.cpp.
References mySettings, and mySortedSchemeNames.
Referenced by GUISettingsHandler::addSettings(), init(), GUIDialog_ViewSettings::onCmdColorChange(), and GUIDialog_ViewSettings::onCmdSaveSetting().
00060 { 00061 std::string name = scheme.name; 00062 if (std::find(mySortedSchemeNames.begin(), mySortedSchemeNames.end(), name)==mySortedSchemeNames.end()) { 00063 mySortedSchemeNames.push_back(name); 00064 } 00065 mySettings[name] = scheme; 00066 }
| bool GUICompleteSchemeStorage::contains | ( | const std::string & | name | ) | const throw () |
Returns the information whether a setting with the given name is stored.
| [in] | name | The name of regarded scheme |
Definition at line 82 of file GUICompleteSchemeStorage.cpp.
References mySettings.
Referenced by GUISettingsHandler::myStartElement(), remove(), and setDefault().
00082 { 00083 return mySettings.find(name)!=mySettings.end(); 00084 }
| GUIVisualizationSettings & GUICompleteSchemeStorage::get | ( | const std::string & | name | ) | throw () |
Returns the named scheme.
| [in] | name | The name of the visualization scheme to return |
Definition at line 70 of file GUICompleteSchemeStorage.cpp.
References mySettings.
Referenced by GUIDialog_ViewSettings::loadSettings(), GUISettingsHandler::myStartElement(), GUIDialog_ViewSettings::onCmdColorChange(), GUIDialog_ViewSettings::onCmdNameChange(), GUIDialog_ViewSettings::onCmdSaveSetting(), and GUIViewTraffic::setColorScheme().
00070 { 00071 return mySettings.find(name)->second; 00072 }
| GUIVisualizationSettings & GUICompleteSchemeStorage::getDefault | ( | ) | throw () |
Returns the default scheme.
Definition at line 76 of file GUICompleteSchemeStorage.cpp.
References myDefaultSettingName, and mySettings.
Referenced by FXIMPLEMENT_ABSTRACT().
00076 { 00077 return mySettings.find(myDefaultSettingName)->second; 00078 }
| const std::vector< std::string > & GUICompleteSchemeStorage::getNames | ( | ) | const throw () |
Returns a list of stored settings names.
Definition at line 107 of file GUICompleteSchemeStorage.cpp.
References mySortedSchemeNames.
Referenced by GUIViewTraffic::buildViewToolBars(), FXIMPLEMENT(), and writeSettings().
00107 { 00108 return mySortedSchemeNames; 00109 }
| unsigned int GUICompleteSchemeStorage::getNumInitialSettings | ( | ) | const throw () |
Returns the number of initial settings.
Definition at line 113 of file GUICompleteSchemeStorage.cpp.
References myNumInitialSettings.
Referenced by GUIDialog_ViewSettings::onCmdColorChange(), GUIDialog_ViewSettings::onCmdDeleteSetting(), GUIDialog_ViewSettings::onCmdSaveSetting(), GUIDialog_ViewSettings::onUpdDeleteSetting(), GUIDialog_ViewSettings::onUpdExportSetting(), and GUIDialog_ViewSettings::onUpdSaveSetting().
00113 { 00114 return myNumInitialSettings; 00115 }
| void GUICompleteSchemeStorage::init | ( | FXApp * | app | ) | throw () |
Initialises the storage with some default settings.
| [in] | app | The application |
Definition at line 128 of file GUICompleteSchemeStorage.cpp.
References add(), GUISettingsHandler::addSettings(), GUIVisualizationSettings::backgroundColor, GUIVisualizationSettings::hideConnectors, GUIVisualizationSettings::laneShowBorders, GUIVisualizationSettings::minVehicleSize, myDefaultSettingName, myNumInitialSettings, mySortedSchemeNames, myX, myY, myZoom, GUIVisualizationSettings::name, GUIVisualizationSettings::showLinkDecals, GUIVisualizationSettings::showRails, SUMOReal, toString(), and GUIVisualizationSettings::vehicleQuality.
Referenced by main().
00128 { 00129 { 00130 GUIVisualizationSettings vs; 00131 vs.name = "standard"; 00132 gSchemeStorage.add(vs); 00133 } 00134 { 00135 GUIVisualizationSettings vs; 00136 vs.name = "faster standard"; 00137 vs.showLinkDecals = false; 00138 vs.showRails = false; 00139 gSchemeStorage.add(vs); 00140 } 00141 { 00142 GUIVisualizationSettings vs; 00143 vs.name = "real world"; 00144 vs.vehicleQuality = 2; 00145 vs.backgroundColor = RGBColor((SUMOReal) .2, (SUMOReal) .5, (SUMOReal) .2); 00146 vs.laneShowBorders = true; 00147 vs.hideConnectors = true; 00148 vs.minVehicleSize = 0; 00149 gSchemeStorage.add(vs); 00150 } 00151 myNumInitialSettings = (unsigned int) mySortedSchemeNames.size(); 00152 // add saved settings 00153 int noSaved = app->reg().readIntEntry("VisualizationSettings", "settingNo", 0); 00154 for (int i=0; i<noSaved; ++i) { 00155 std::string name = "visset#" + toString(i); 00156 std::string setting = app->reg().readStringEntry("VisualizationSettings",name.c_str(), ""); 00157 if (setting!="") { 00158 GUIVisualizationSettings vs; 00159 00160 vs.name = setting; 00161 app->reg().readStringEntry("VisualizationSettings",name.c_str(), ""); 00162 00163 // add saved xml setting 00164 int xmlSize = app->reg().readIntEntry(name.c_str(), "xmlSize", 0); 00165 std::string content = ""; 00166 int index = 0; 00167 while (xmlSize > 0) { 00168 std::string part = app->reg().readStringEntry(name.c_str(), ("xml"+toString(index)).c_str(), ""); 00169 if (part == "") { 00170 break; 00171 } 00172 content += part; 00173 xmlSize -= (int) part.size(); 00174 index++; 00175 } 00176 if (content != "" && xmlSize == 0) { 00177 GUISettingsHandler handler(content, false); 00178 handler.addSettings(); 00179 } 00180 } 00181 } 00182 myDefaultSettingName = mySortedSchemeNames[0]; 00183 myX = myY = myZoom = 0; 00184 }
| void GUICompleteSchemeStorage::remove | ( | const std::string & | name | ) | throw () |
Removes the setting with the given name.
| [in] | name | The name of the scheme to remove |
Definition at line 88 of file GUICompleteSchemeStorage.cpp.
References contains(), mySettings, and mySortedSchemeNames.
Referenced by GUIDialog_ViewSettings::onCmdDeleteSetting(), and GUIDialog_ViewSettings::onCmdSaveSetting().
00088 { 00089 if (!contains(name)) { 00090 return; 00091 } 00092 mySortedSchemeNames.erase(find(mySortedSchemeNames.begin(), mySortedSchemeNames.end(), name)); 00093 mySettings.erase(mySettings.find(name)); 00094 }
| void GUICompleteSchemeStorage::saveViewport | ( | const SUMOReal | x, | |
| const SUMOReal | y, | |||
| const SUMOReal | zoom | |||
| ) | throw () |
Makes the given viewport the default.
| [in] | x | The x-offset |
| [in] | y | The y-offset |
| [in] | zoom | The zoom |
Definition at line 211 of file GUICompleteSchemeStorage.cpp.
References myX, myY, and myZoom.
Referenced by GUIApplicationWindow::load(), and GUISUMOAbstractView::~GUISUMOAbstractView().
| void GUICompleteSchemeStorage::setDefault | ( | const std::string & | name | ) | throw () |
Makes the scheme with the given name the default.
| [in] | name | The name of the scheme to marks as default |
Definition at line 98 of file GUICompleteSchemeStorage.cpp.
References contains(), and myDefaultSettingName.
Referenced by GUISUMOAbstractView::~GUISUMOAbstractView().
00098 { 00099 if (!contains(name)) { 00100 return; 00101 } 00102 myDefaultSettingName = name; 00103 }
| void GUICompleteSchemeStorage::setViewport | ( | GUISUMOAbstractView * | view | ) | throw () |
Sets the default viewport.
| [in] | parent | the view for which the viewport has to be set |
Definition at line 219 of file GUICompleteSchemeStorage.cpp.
References myX, myY, and myZoom.
Referenced by FXIMPLEMENT_ABSTRACT().
00219 { 00220 if (myZoom > 0) { 00221 view->setViewport(myZoom, myX, myY); 00222 } 00223 }
| void GUICompleteSchemeStorage::writeSettings | ( | FXApp * | app | ) | throw () |
Writes the current scheme into the registry.
| [in] | app | The application |
Definition at line 188 of file GUICompleteSchemeStorage.cpp.
References getNames(), OutputDevice_String::getString(), myNumInitialSettings, mySettings, GUIVisualizationSettings::name, GUIVisualizationSettings::save(), and toString().
Referenced by GUIDialog_ViewSettings::onCmdDeleteSetting(), and GUIDialog_ViewSettings::onCmdSaveSetting().
00188 { 00189 const std::vector<std::string> &names = getNames(); 00190 app->reg().writeIntEntry("VisualizationSettings", "settingNo", (FXint) names.size()-myNumInitialSettings); 00191 size_t gidx = 0; 00192 for (std::vector<std::string>::const_iterator i=names.begin()+myNumInitialSettings; i!=names.end(); ++i, ++gidx) { 00193 const GUIVisualizationSettings &item = mySettings.find(*i)->second; 00194 std::string sname = "visset#" + toString(gidx); 00195 00196 app->reg().writeStringEntry("VisualizationSettings", sname.c_str(), item.name.c_str()); 00197 OutputDevice_String dev; 00198 item.save(dev); 00199 std::string content = dev.getString(); 00200 app->reg().writeIntEntry(sname.c_str(), "xmlSize", content.size()); 00201 const unsigned maxSize = 1500; // this is a fox limitation for registry entries 00202 for (unsigned int i = 0; i < content.size(); i+=maxSize) { 00203 const std::string b = content.substr(i, maxSize); 00204 app->reg().writeStringEntry(sname.c_str(), ("xml" + toString(i/maxSize)).c_str(), b.c_str()); 00205 } 00206 } 00207 }
std::string GUICompleteSchemeStorage::myDefaultSettingName [protected] |
Name of the default setting.
Definition at line 140 of file GUICompleteSchemeStorage.h.
Referenced by getDefault(), init(), and setDefault().
unsigned int GUICompleteSchemeStorage::myNumInitialSettings [protected] |
The number of settings which were present at startup.
Definition at line 143 of file GUICompleteSchemeStorage.h.
Referenced by getNumInitialSettings(), init(), and writeSettings().
std::map<std::string, GUIVisualizationSettings> GUICompleteSchemeStorage::mySettings [protected] |
A map of settings referenced by their names.
Definition at line 134 of file GUICompleteSchemeStorage.h.
Referenced by add(), contains(), get(), getDefault(), remove(), and writeSettings().
std::vector<std::string> GUICompleteSchemeStorage::mySortedSchemeNames [protected] |
List of known setting names.
Definition at line 137 of file GUICompleteSchemeStorage.h.
Referenced by add(), getNames(), init(), and remove().
SUMOReal GUICompleteSchemeStorage::myX [protected] |
The default viewport.
Definition at line 146 of file GUICompleteSchemeStorage.h.
Referenced by init(), saveViewport(), and setViewport().
SUMOReal GUICompleteSchemeStorage::myY [protected] |
Definition at line 146 of file GUICompleteSchemeStorage.h.
Referenced by init(), saveViewport(), and setViewport().
SUMOReal GUICompleteSchemeStorage::myZoom [protected] |
Definition at line 146 of file GUICompleteSchemeStorage.h.
Referenced by init(), saveViewport(), and setViewport().
1.5.6