Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEFrame.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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/****************************************************************************/
18// The Widget for add additional elements
19/****************************************************************************/
20
24#include <netedit/GNEViewNet.h>
29
30#include "GNEFrame.h"
31
32// ===========================================================================
33// static members
34// ===========================================================================
35
36FXFont* GNEFrame::myFrameHeaderFont = nullptr;
37
38// ===========================================================================
39// method definitions
40// ===========================================================================
41
42GNEFrame::GNEFrame(GNEViewParent* viewParent, GNEViewNet* viewNet, const std::string& frameLabel) :
43 FXVerticalFrame(viewParent->getFramesArea(), GUIDesignAuxiliarFrame),
44 myViewNet(viewNet) {
45
46 // fill myPredefinedTagsMML (to avoid repeating this fill during every element creation)
47 int i = 0;
49 int key = SUMOXMLDefinitions::attrs[i].key;
50 assert(key >= 0);
51 while (key >= (int)myPredefinedTagsMML.size()) {
52 myPredefinedTagsMML.push_back("");
53 }
55 i++;
56 }
57
58 // Create font only one time
59 if (myFrameHeaderFont == nullptr) {
60 myFrameHeaderFont = new FXFont(getApp(), "Arial", 14, FXFont::Bold);
61 }
62
63 // Create frame for header
64 myHeaderFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
65
66 // Create frame for left elements of header (By default unused)
68 myHeaderLeftFrame->hide();
69
70 // Create title frame
71 myFrameHeaderLabel = new FXLabel(myHeaderFrame, frameLabel.c_str(), nullptr, GUIDesignLabelFrameInformation);
72
73 // Create frame for right elements of header (By default unused)
75 myHeaderRightFrame->hide();
76
77 // Add separator
78 new FXHorizontalSeparator(this, GUIDesignHorizontalSeparator);
79
80 // Create scroll windows with fixed width for contents
81 myScrollWindowsContents = new FXScrollWindow(this, GUIDesignScrollWindowFixedWidth(10));
82
83 // Create frame for contents (in which GroupBox will be placed)
85
86 // Set font of header
88
89 // Hide Frame
90 FXVerticalFrame::hide();
91}
92
93
95 // delete frame header only one time
97 delete myFrameHeaderFont;
98 myFrameHeaderFont = nullptr;
99 }
100}
101
102
103void
107
108
109void
111 // show scroll window
112 FXVerticalFrame::show();
113 // Show and update Frame Area in which this GNEFrame is placed
115}
116
117
118void
120 // hide scroll window
121 FXVerticalFrame::hide();
122 // Hide Frame Area in which this GNEFrame is placed
124}
125
126
127void
128GNEFrame::setFrameWidth(const int newWidth) {
129 // set scroll windows size (minus MARGIN)
130 myScrollWindowsContents->setWidth(newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1);
131 // calculate new contentWidth
132 int contentWidth = (newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1 - 15);
133 // adjust contents frame
134 myContentFrame->setWidth(contentWidth);
135 // set size of all contents frame children
136 for (auto child = myContentFrame->getFirst(); child != nullptr; child = child->getNext()) {
137 child->setWidth(contentWidth);
138 }
139 // call frame width updated
141}
142
143
146 return myViewNet;
147}
148
149
150FXVerticalFrame*
152 return myContentFrame;
153}
154
155
156FXLabel*
160
161
162FXFont*
166
167
168int
170 if (myScrollWindowsContents->verticalScrollBar()->shown()) {
171 return myScrollWindowsContents->verticalScrollBar()->getWidth();
172 } else {
173 return 0;
174 }
175}
176
177
178void
180 // open help dialog with attributes of the given attribute carrier
182}
183
184
185void
187 // this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
188}
189
190
191void
193 // this function can be reimplemented in all child frames
194}
195
196// ---------------------------------------------------------------------------
197// GNEFrame - protected methods
198// ---------------------------------------------------------------------------
199
200void
202 // this function has to be reimplemented in all child frames that uses a GNETagSelector module
203}
204
205
206void
208 // this function has to be reimplemented in all child frames that uses a DemandElementSelector
209}
210
211
212bool
214 // this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
215 return false;
216}
217
218
219void
221 // this function has to be reimplemented in all child frames that uses a AttributeEditor module
222}
223
224
225void
227 // this function has to be reimplemented in all child frames that uses a GNEOverlappedInspection
228}
229
230
231bool
232GNEFrame::createPath(const bool /*useLastRoute*/) {
233 // this function has to be reimplemented in all child frames that uses a path or consecutiveLanePath
234 return false;
235}
236
237
238const std::vector<std::string>&
242
243
244FXLabel*
245GNEFrame::buildRainbow(FXComposite* parent) {
246 // create label for color information
247 FXLabel* label = new FXLabel(parent, TL("Scale: Min -> Max"), nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));
248 // create frame for color scale
249 FXHorizontalFrame* horizontalFrameColors = new FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame);
250 for (const auto& color : GNEViewNetHelper::getRainbowScaledColors()) {
251 FXLabel* colorLabel = new FXLabel(horizontalFrameColors, "", nullptr, GUIDesignLabel(JUSTIFY_LEFT));
252 colorLabel->setBackColor(MFXUtils::getFXColor(color));
253 }
254 return label;
255 // for whatever reason, sonar complains in the next line that horizontalFrameColors may leak, but fox does the cleanup
256} // NOSONAR
257
258/****************************************************************************/
#define GUIDesignFrameAreaMargin
right margin for frame area
Definition GUIDesigns.h:56
#define GUIDesignAuxiliarHorizontalFrameCenteredVertically
design for auxiliar (Without borders) horizontal frame used to pack another frames,...
Definition GUIDesigns.h:433
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:430
#define GUIDesignLabel(justify)
Definition GUIDesigns.h:245
#define GUIDesignAuxiliarFrameFixedWidth(width)
design for auxiliar (Without borders) frame with fixed width and extended height
Definition GUIDesigns.h:415
#define GUIDesignLabelThick(justify)
label extended over frame with thick and with text justify to left
Definition GUIDesigns.h:251
#define GUIDesignHorizontalSeparator
Definition GUIDesigns.h:494
#define GUIDesignScrollWindowFixedWidth(customWidth)
design for scroll windows extended over Y and fix width
Definition GUIDesigns.h:397
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
Definition GUIDesigns.h:409
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition GUIDesigns.h:281
#define TL(string)
Definition MsgHandler.h:304
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NOTHING
invalid attribute, must be the last one
FXHorizontalFrame * myHeaderRightFrame
fame for right header elements
Definition GNEFrame.h:134
int getScrollBarWidth() const
get scrollBar width (zero if is hidden)
Definition GNEFrame.cpp:169
virtual void attributeUpdated(SumoXMLAttr attribute)
function called after set a valid attribute in AttributeCreator/AttributeEditor/ParametersEditor/....
Definition GNEFrame.cpp:220
void setFrameWidth(const int newWidth)
set width of GNEFrame
Definition GNEFrame.cpp:128
void focusUpperElement()
focus upper element of frame
Definition GNEFrame.cpp:104
virtual void updateFrameAfterUndoRedo()
function called after undo/redo in the current frame (can be reimplemented in frame children)
Definition GNEFrame.cpp:186
static FXLabel * buildRainbow(FXComposite *parent)
build rainbow in frame modul
Definition GNEFrame.cpp:245
virtual void tagSelected()
Tag selected in GNETagSelector.
Definition GNEFrame.cpp:201
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:145
FXLabel * getFrameHeaderLabel() const
get the label for the frame's header
Definition GNEFrame.cpp:157
FXScrollWindow * myScrollWindowsContents
scroll windows that holds the content frame
Definition GNEFrame.h:144
virtual void demandElementSelected()
selected demand element in DemandElementSelector
Definition GNEFrame.cpp:207
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:122
FXFont * getFrameHeaderFont() const
get font of the header's frame
Definition GNEFrame.cpp:163
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition GNEFrame.h:125
FXHorizontalFrame * myHeaderFrame
fame for header elements
Definition GNEFrame.h:128
~GNEFrame()
destructor
Definition GNEFrame.cpp:94
virtual void show()
show Frame
Definition GNEFrame.cpp:110
virtual void hide()
hide Frame
Definition GNEFrame.cpp:119
GNEFrame(GNEViewParent *viewParent, GNEViewNet *viewNet, const std::string &frameLabel)
Constructor.
Definition GNEFrame.cpp:42
virtual void selectedOverlappedElement(GNEAttributeCarrier *AC)
open GNEAttributesCreator extended dialog
Definition GNEFrame.cpp:226
virtual void frameWidthUpdated()
function called after setting new width in current frame (can be reimplemented in frame children)
Definition GNEFrame.cpp:192
virtual bool shapeDrawed()
build a shaped element using the drawed shape
Definition GNEFrame.cpp:213
virtual bool createPath(const bool useLastRoute)
create path between two elements
Definition GNEFrame.cpp:232
void openHelpAttributesDialog(const GNEAttributeCarrier *AC) const
Open help attributes dialog.
Definition GNEFrame.cpp:179
std::vector< std::string > myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation (needed for SUMOSAXAttributesImpl_Cach...
Definition GNEFrame.h:153
FXLabel * myFrameHeaderLabel
the label for the frame's header
Definition GNEFrame.h:150
static FXFont * myFrameHeaderFont
static Font for the Header (it's common for all headers, then create only one time)
Definition GNEFrame.h:147
const std::vector< std::string > & getPredefinedTagsMML() const
get predefinedTagsMML
Definition GNEFrame.cpp:239
FXVerticalFrame * getContentFrame() const
get vertical frame that holds all widgets of frame
Definition GNEFrame.cpp:151
FXHorizontalFrame * myHeaderLeftFrame
fame for left header elements
Definition GNEFrame.h:131
GNEViewParent * getViewParent() const
get the net object
A single child window which contains a view of the simulation area.
void hideFramesArea()
hide frames area if all GNEFrames are hidden
void showFramesArea()
show frames area if at least a GNEFrame is showed
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:145
static SequentialStringBijection::Entry attrs[]
The names of SUMO-XML attributes (for passing to GenericSAXHandler)
static const std::vector< RGBColor > & getRainbowScaledColors()
get scaled rainbow colors
int key
const char * str