Path: blob/main/src/utils/gui/tracker/GUIParameterTracker.h
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GUIParameterTracker.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date Sept 200218///19// A window which displays the time line of one (or more) value(s)20/****************************************************************************/21#pragma once22#include <config.h>2324#include <vector>25#include <utils/foxtools/MFXComboBoxIcon.h>26// fx3d includes windows.h so we need to guard against macro pollution27#ifdef WIN3228#define NOMINMAX29#endif30#include <fx3d.h>31#ifdef WIN3232#undef NOMINMAX33#endif34#include <utils/gui/globjects/GUIGlObject.h>35#include <utils/gui/div/GLObjectValuePassConnector.h>36#include "TrackerValueDesc.h"373839// ===========================================================================40// class definitions41// ===========================================================================42/** @class GUIParameterTracker43* @brief A window which displays the time line of one (or more) value(s)44*/45class GUIParameterTracker : public FXMainWindow {46FXDECLARE(GUIParameterTracker)47public:48/// @brief callback-enumerations49enum {50/// @brief Change aggregation interval51MID_AGGREGATIONINTERVAL = FXMainWindow::ID_LAST,52/// @brief Save the current values53MID_SAVE,54/// @brief toggle multiplot55MID_MULTIPLOT,56/// @brief end-of-enum57ID_LAST58};596061/** @brief Constructor (the tracker is empty)62* @param[in] app The main application window63* @param[in] name The title of the tracker64*/65GUIParameterTracker(GUIMainWindow& app, const std::string& name);666768/// @brief Destructor69~GUIParameterTracker();707172/// @brief Creates the window73void create();747576/** @brief Adds a further time line to display77* @param[in] o The object to get values from78* @param[in] src The value source of the object79* @param[in] newTracked The description of the tracked value80*/81void addTracked(GUIGlObject& o, ValueSource<double>* src,82TrackerValueDesc* newTracked);838485/// @name FOX-callbacks86/// @{8788/// @brief Called on window resizing89long onConfigure(FXObject*, FXSelector, void*);9091/// @brief Called if the window shall be repainted92long onPaint(FXObject*, FXSelector, void*);9394/// @brief Called on a simulation step95long onSimStep(FXObject*, FXSelector, void*);9697/// @brief Called on a simulation step98long onMultiPlot(FXObject*, FXSelector, void*);99100/// @brief Called when the aggregation interval (combo) has been changed101long onCmdChangeAggregation(FXObject*, FXSelector, void*);102103/// @brief Called when the data shall be saved104long onCmdSave(FXObject*, FXSelector, void*);105/// @}106107108/// @brief all value source to multiplot trackers109static bool addTrackedMultiplot(GUIGlObject& o, ValueSource<double>* src, TrackerValueDesc* newTracked);110111public:112/**113* @class GUIParameterTrackerPanel114* This panel lies within the GUIParameterTracker being the main widget.115* It is the widget responsible for displaying the information while116* GUIParameterTracker only provides window-facilities.117*/118class GUIParameterTrackerPanel : public FXGLCanvas {119FXDECLARE(GUIParameterTrackerPanel)120public:121/** @brief Constructor122* @param[in] c The parent composite123* @param[in] app The main window124* @param[in] parent The parent tracker window this view belongs to125*/126GUIParameterTrackerPanel(FXComposite* c, GUIMainWindow& app,127GUIParameterTracker& parent);128129/// @brief Destructor130~GUIParameterTrackerPanel();131132/// @brief needed to update133friend class GUIParameterTracker;134135136/// @name FOX-callbacks137/// @{138139/// Called on window resizing140long onConfigure(FXObject*, FXSelector, void*);141142/// Called if the window shall be repainted143long onPaint(FXObject*, FXSelector, void*);144145/// @brief called on mouse movement (for updating moused value)146long onMouseMove(FXObject*, FXSelector, void*);147148/// @}149150151private:152/** @brief Draws all values153*/154void drawValues();155156/** @brief Draws a single value157* @param[in] desc The tracked values to draw158* @param[in] index Mulitplot index159*/160void drawValue(TrackerValueDesc& desc, const RGBColor& col, int index);161162private:163/// @brief The parent window164GUIParameterTracker* myParent;165166/// @brief the sizes of the window167int myWidthInPixels, myHeightInPixels;168169/// @brief latest mouse position170double myMouseX;171172protected:173FOX_CONSTRUCTOR(GUIParameterTrackerPanel)174};175176public:177/// @brief the panel may change some things178friend class GUIParameterTrackerPanel;179180private:181/// @brief Builds the tool bar182void buildToolBar();183184protected:185/// @brief The main application186GUIMainWindow* myApplication;187188/// @brief The list of tracked values189std::vector<TrackerValueDesc*> myTracked;190191/// @brief The panel to display the values in192GUIParameterTrackerPanel* myPanel;193194/// @brief The value sources195std::vector<GLObjectValuePassConnector<double>*> myValuePassers;196197/// @brief for some menu detaching fun198FXToolBarShell* myToolBarDrag;199200/// @brief A combo box to select an aggregation interval201MFXComboBoxIcon* myAggregationInterval;202203/// @brief The simulation delay204FXdouble myAggregationDelay;205206/// @brief The tracker tool bar207FXToolBar* myToolBar;208209/// @brief Whether phase names shall be printed instead of indices210FXCheckButton* myMultiPlot;211212/// @brief all trackers that are opened for plotting multiple values213static std::set<GUIParameterTracker*> myMultiPlots;214static std::vector<RGBColor> myColors;215216protected:217FOX_CONSTRUCTOR(GUIParameterTracker)218219};220221222