Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIPropertySchemeStorage.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21//
22/****************************************************************************/
23#pragma once
24#include <config.h>
25
26#include <vector>
31#include "GUIPropertyScheme.h"
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class OutputDevice;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
48template<class T>
50public:
53
56
59 for (const auto& scheme : mySchemes) {
60 cb.appendIconItem(scheme.getTranslatedName().c_str(),
61 scheme.getIcon() == GUIIcon::EMPTY ? nullptr : GUIIconSubSys::getIcon(scheme.getIcon()),
62 MFXUtils::getFXColor(scheme.getBackgroundColor()));
63 }
65 }
66
67 void setActive(int scheme) {
68 if (scheme < (int)mySchemes.size()) {
69 myActiveScheme = scheme;
70 }
71 }
72
73 int getActive() const {
74 return myActiveScheme;
75 }
76
77 T& getScheme() {
79 }
80
81 const T& getScheme() const {
83 }
84
85 const std::vector<T>& getSchemes() const {
86 return mySchemes;
87 }
88
89 T* getSchemeByName(std::string name) {
90 for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
91 if ((*i).getName() == name) {
92 return &(*i);
93 }
94 }
95 return 0;
96 }
97
98 void setSchemeByName(std::string name) {
99 for (int i = 0; i < (int)mySchemes.size(); i++) {
100 if (mySchemes[i].getName() == name) {
101 myActiveScheme = i;
102 break;
103 }
104 }
105 }
106
107 void save(OutputDevice& dev, const std::string& prefix = "") const {
108 for (typename std::vector<T>::const_iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
109 i->save(dev, prefix);
110 }
111 }
112
115 }
116
117
118 void addScheme(T scheme) {
119 mySchemes.push_back(scheme);
120 }
121
122 int size() const {
123 return (int)mySchemes.size();
124 }
125
126
127protected:
129 std::vector<T> mySchemes;
130
131};
132
GUIPropertySchemeStorage< GUIColorScheme > GUIColorer
GUIPropertySchemeStorage< GUIScaleScheme > GUIScaler
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Base class for coloring. Allows changing the used colors and sets the used color in dependence to a v...
const std::vector< T > & getSchemes() const
virtual ~GUIPropertySchemeStorage()
Destructor.
void setSchemeByName(std::string name)
bool operator==(const GUIPropertySchemeStorage &c) const
void save(OutputDevice &dev, const std::string &prefix="") const
void fill(MFXComboBoxIcon &cb)
Fills the given combobox with the names of available colorings.
T * getSchemeByName(std::string name)
ComboBox with icon.
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:112
Static storage of an output device and its base (abstract) implementation.