GUIParameterTracker Class Reference

#include <GUIParameterTracker.h>

Inheritance diagram for GUIParameterTracker:

FXMainWindow

Detailed Description

Definition at line 51 of file GUIParameterTracker.h.


Public Types

enum  { MID_AGGREGATIONINTERVAL = FXMainWindow::ID_LAST, MID_SAVE, ID_LAST }

Public Member Functions

void addTracked (GUIGlObject &o, ValueSource< SUMOReal > *src, TrackerValueDesc *newTracked)
 Adds a further time line to display.
void create ()
 Creates the window.
 GUIParameterTracker (GUIMainWindow &app, const std::string &name)
 Constructor (the tracker is empty).
 GUIParameterTracker (GUIMainWindow &app, const std::string &name, GUIGlObject &o, int xpos, int ypos)
 Constructor (one value is defined).
long onCmdChangeAggregation (FXObject *, FXSelector, void *)
 Called when the aggregation interval (combo) has been changed.
long onCmdSave (FXObject *, FXSelector, void *)
 Called when the data shall be saved.
long onConfigure (FXObject *, FXSelector, void *)
 Called on window resizing.
long onPaint (FXObject *, FXSelector, void *)
 Called if the window shall be repainted.
long onSimStep (FXObject *, FXSelector, void *)
 Called on a simulation step.
 ~GUIParameterTracker ()
 Destructor.

Protected Types

typedef std::vector
< TrackerValueDesc * > 
TrackedVarsVector
 Definition of the container for logged values.
typedef std::vector
< GLObjectValuePassConnector
< SUMOReal > * > 
ValuePasserVector
 Definition of a list of value passing objects.

Protected Member Functions

void addVariable (GUIGlObject *o, const std::string &name, size_t recordBegin)
 Adds a further variable to display.
 GUIParameterTracker ()
 Fox needs this.

Protected Attributes

FXdouble myAggregationDelay
 The simulation delay.
FXComboBox * myAggregationInterval
 A combo box to select an aggregation interval.
GUIMainWindowmyApplication
 The main application.
GUIParameterTrackerPanelmyPanel
 The panel to display the values in.
FXToolBar * myToolBar
 The tracker tool bar.
FXToolBarShell * myToolBarDrag
 for some menu detaching fun
TrackedVarsVector myTracked
 The list of tracked values.
ValuePasserVector myValuePassers
 The value sources.

Private Member Functions

void buildToolBar ()
 Builds the tool bar.

Friends

class GUIParameterTrackerPanel
 the panel may change some things

Data Structures

class  GUIParameterTrackerPanel

Member Typedef Documentation

typedef std::vector<TrackerValueDesc*> GUIParameterTracker::TrackedVarsVector [protected]

Definition of the container for logged values.

Definition at line 164 of file GUIParameterTracker.h.

typedef std::vector<GLObjectValuePassConnector<SUMOReal>*> GUIParameterTracker::ValuePasserVector [protected]

Definition of a list of value passing objects.

Definition at line 173 of file GUIParameterTracker.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
MID_AGGREGATIONINTERVAL 
MID_SAVE 
ID_LAST 

Definition at line 54 of file GUIParameterTracker.h.

00054          {
00055         MID_AGGREGATIONINTERVAL = FXMainWindow::ID_LAST,
00056         MID_SAVE,
00057         ID_LAST
00058     };


Constructor & Destructor Documentation

GUIParameterTracker::GUIParameterTracker ( GUIMainWindow app,
const std::string &  name,
GUIGlObject o,
int  xpos,
int  ypos 
)

Constructor (one value is defined).

Definition at line 92 of file GUIParameterTracker.cpp.

References GUIMainWindow::addChild(), buildToolBar(), GUIIconSubSys::getIcon(), GUIParameterTrackerPanel, ICON_APP_TRACKER, myApplication, and myPanel.

00096         : FXMainWindow(app.getApp(),"Tracker",NULL,NULL,DECOR_ALL,20, 20,300,200),
00097         myApplication(&app) {
00098     buildToolBar();
00099     app.addChild(this, true);
00100     FXVerticalFrame *glcanvasFrame =
00101         new FXVerticalFrame(this,
00102                             FRAME_SUNKEN|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y,
00103                             0,0,0,0,0,0,0,0);
00104     myPanel = new GUIParameterTrackerPanel(glcanvasFrame,
00105                                            *myApplication, *this);
00106     setTitle(name.c_str());
00107     setIcon(GUIIconSubSys::getIcon(ICON_APP_TRACKER));
00108 }

GUIParameterTracker::GUIParameterTracker ( GUIMainWindow app,
const std::string &  name 
)

Constructor (the tracker is empty).

GUIParameterTracker::~GUIParameterTracker (  ) 

Destructor.

Definition at line 111 of file GUIParameterTracker.cpp.

References myApplication, myToolBar, myToolBarDrag, myTracked, myValuePassers, and GUIMainWindow::removeChild().

00111                                           {
00112     myApplication->removeChild(this);
00113     for (TrackedVarsVector::iterator i1=myTracked.begin(); i1!=myTracked.end(); i1++) {
00114         delete(*i1);
00115     }
00116     // deleted by GUINet
00117     for (ValuePasserVector::iterator i2=myValuePassers.begin(); i2!=myValuePassers.end(); i2++) {
00118         delete(*i2);
00119     }
00120     delete myToolBarDrag;
00121     delete myToolBar;
00122 }

GUIParameterTracker::GUIParameterTracker (  )  [inline, protected]

Fox needs this.

Definition at line 192 of file GUIParameterTracker.h.

00192 { }


Member Function Documentation

void GUIParameterTracker::addTracked ( GUIGlObject o,
ValueSource< SUMOReal > *  src,
TrackerValueDesc newTracked 
)

Adds a further time line to display.

Definition at line 165 of file GUIParameterTracker.cpp.

References myTracked, and myValuePassers.

Referenced by GUIParam_PopupMenuInterface::onCmdOpenTracker().

00167                                                               {
00168     myTracked.push_back(newTracked);
00169     // build connection (is automatically set into an execution map)
00170     myValuePassers.push_back(new GLObjectValuePassConnector<SUMOReal>(o,
00171                              src, newTracked));
00172 }

void GUIParameterTracker::addVariable ( GUIGlObject o,
const std::string &  name,
size_t  recordBegin 
) [protected]

Adds a further variable to display.

Definition at line 133 of file GUIParameterTracker.cpp.

References myTracked.

00134                                                      {
00135     TrackerValueDesc *newTracked =
00136         new TrackerValueDesc(name, RGBColor(0, 0, 0), o, recordBegin);
00137     myTracked.push_back(newTracked);
00138 }

void GUIParameterTracker::buildToolBar (  )  [private]

Builds the tool bar.

Definition at line 142 of file GUIParameterTracker.cpp.

References GUIIconSubSys::getIcon(), ICON_SAVE, MID_AGGREGATIONINTERVAL, MID_SAVE, myAggregationInterval, myToolBar, and myToolBarDrag.

Referenced by GUIParameterTracker().

00142                                   {
00143     myToolBarDrag = new FXToolBarShell(this,FRAME_NORMAL);
00144     myToolBar = new FXToolBar(this,myToolBarDrag, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
00145     new FXToolBarGrip(myToolBar, myToolBar, FXToolBar::ID_TOOLBARGRIP, TOOLBARGRIP_DOUBLE);
00146     // save button
00147     new FXButton(myToolBar,"\t\tSave the data...",
00148                  GUIIconSubSys::getIcon(ICON_SAVE), this, GUIParameterTracker::MID_SAVE,
00149                  ICON_ABOVE_TEXT|BUTTON_TOOLBAR|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT);
00150     // aggregation interval combo
00151     myAggregationInterval =
00152         new FXComboBox(myToolBar, 8, this, MID_AGGREGATIONINTERVAL,
00153                        FRAME_SUNKEN|LAYOUT_LEFT|LAYOUT_TOP|COMBOBOX_STATIC);
00154     myAggregationInterval->appendItem("1s");
00155     myAggregationInterval->appendItem("1min");
00156     myAggregationInterval->appendItem("5min");
00157     myAggregationInterval->appendItem("15min");
00158     myAggregationInterval->appendItem("30min");
00159     myAggregationInterval->appendItem("60min");
00160     myAggregationInterval->setNumVisible(6);
00161 }

void GUIParameterTracker::create (  ) 

Creates the window.

Definition at line 126 of file GUIParameterTracker.cpp.

References myToolBarDrag.

Referenced by GUIParam_PopupMenuInterface::onCmdOpenTracker().

00126                             {
00127     FXMainWindow::create();
00128     myToolBarDrag->create();
00129 }

long GUIParameterTracker::onCmdChangeAggregation ( FXObject ,
FXSelector  ,
void *   
)

Called when the aggregation interval (combo) has been changed.

Definition at line 197 of file GUIParameterTracker.cpp.

References myAggregationInterval, and myTracked.

00197                                                                       {
00198     int index = myAggregationInterval->getCurrentItem();
00199     size_t aggInt = 0;
00200     switch (index) {
00201     case 0:
00202         aggInt = 1;
00203         break;
00204     case 1:
00205         aggInt = 60;
00206         break;
00207     case 2:
00208         aggInt = 60 * 5;
00209         break;
00210     case 3:
00211         aggInt = 60 * 15;
00212         break;
00213     case 4:
00214         aggInt = 60 * 30;
00215         break;
00216     case 5:
00217         aggInt = 60 * 60;
00218         break;
00219     default:
00220         throw 1;
00221         break;
00222     }
00223     TrackedVarsVector::iterator i1;
00224     for (i1=myTracked.begin(); i1!=myTracked.end(); i1++) {
00225         (*i1)->setAggregationSpan(aggInt);
00226     }
00227     return 1;
00228 }

long GUIParameterTracker::onCmdSave ( FXObject ,
FXSelector  ,
void *   
)

Called when the data shall be saved.

Definition at line 232 of file GUIParameterTracker.cpp.

References OutputDevice::close(), gCurrentFolder, TrackerValueDesc::getAggregatedValues(), OutputDevice::getDevice(), MFXUtils::getFilename2Write(), GUIIconSubSys::getIcon(), TrackerValueDesc::getName(), ICON_EMPTY, max, myTracked, and TrackerValueDesc::unlockValues().

00232                                                          {
00233     FXString file = MFXUtils::getFilename2Write(this, "Save Data", ".csv", GUIIconSubSys::getIcon(ICON_EMPTY), gCurrentFolder);
00234     if (file=="") {
00235         return 1;
00236     }
00237     try {
00238         OutputDevice &dev = OutputDevice::getDevice(file.text());
00239         // write header
00240         TrackedVarsVector::iterator i;
00241         dev << "# ";
00242         for (i=myTracked.begin(); i!=myTracked.end(); ++i) {
00243             if (i!=myTracked.begin()) {
00244                 dev << ';';
00245             }
00246             TrackerValueDesc *tvd = *i;
00247             dev << tvd->getName();
00248         }
00249         dev << '\n';
00250         // count entries
00251         size_t max = 0;
00252         for (i=myTracked.begin(); i!=myTracked.end(); ++i) {
00253             TrackerValueDesc *tvd = *i;
00254             size_t sizei = tvd->getAggregatedValues().size();
00255             if (max<sizei) {
00256                 max = sizei;
00257             }
00258             tvd->unlockValues();
00259         }
00260         // write entries
00261         for (unsigned int j=0; j<max; j++) {
00262             for (i=myTracked.begin(); i!=myTracked.end(); ++i) {
00263                 if (i!=myTracked.begin()) {
00264                     dev << ';';
00265                 }
00266                 TrackerValueDesc *tvd = *i;
00267                 dev << tvd->getAggregatedValues()[j];
00268                 tvd->unlockValues();
00269             }
00270             dev << '\n';
00271         }
00272         dev.close();
00273     } catch (IOError &e) {
00274         FXMessageBox::error(this, MBOX_OK, "Storing failed!", e.what());
00275     }
00276     return 1;
00277 }

long GUIParameterTracker::onConfigure ( FXObject sender,
FXSelector  sel,
void *  data 
)

Called on window resizing.

Definition at line 176 of file GUIParameterTracker.cpp.

References myPanel, and GUIParameterTracker::GUIParameterTrackerPanel::onConfigure().

00176                                                                              {
00177     myPanel->onConfigure(sender, sel, data);
00178     return FXMainWindow::onConfigure(sender, sel, data);
00179 }

long GUIParameterTracker::onPaint ( FXObject sender,
FXSelector  sel,
void *  data 
)

Called if the window shall be repainted.

Definition at line 183 of file GUIParameterTracker.cpp.

References myPanel, and GUIParameterTracker::GUIParameterTrackerPanel::onPaint().

00183                                                                          {
00184     myPanel->onPaint(sender, sel, data);
00185     return FXMainWindow::onPaint(sender, sel, data);
00186 }

long GUIParameterTracker::onSimStep ( FXObject ,
FXSelector  ,
void *   
)

Called on a simulation step.

Definition at line 190 of file GUIParameterTracker.cpp.

00190                                                          {
00191     update();
00192     return 1;
00193 }


Friends And Related Function Documentation

friend class GUIParameterTrackerPanel [friend]

the panel may change some things

Definition at line 152 of file GUIParameterTracker.h.

Referenced by GUIParameterTracker().


Field Documentation

The simulation delay.

Definition at line 185 of file GUIParameterTracker.h.

A combo box to select an aggregation interval.

Definition at line 182 of file GUIParameterTracker.h.

Referenced by buildToolBar(), and onCmdChangeAggregation().

The main application.

Definition at line 161 of file GUIParameterTracker.h.

Referenced by GUIParameterTracker(), and ~GUIParameterTracker().

The panel to display the values in.

Definition at line 170 of file GUIParameterTracker.h.

Referenced by GUIParameterTracker(), onConfigure(), and onPaint().

FXToolBar* GUIParameterTracker::myToolBar [protected]

The tracker tool bar.

Definition at line 188 of file GUIParameterTracker.h.

Referenced by buildToolBar(), and ~GUIParameterTracker().

FXToolBarShell* GUIParameterTracker::myToolBarDrag [protected]

for some menu detaching fun

Definition at line 179 of file GUIParameterTracker.h.

Referenced by buildToolBar(), create(), and ~GUIParameterTracker().

The value sources.

Definition at line 176 of file GUIParameterTracker.h.

Referenced by addTracked(), and ~GUIParameterTracker().


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

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