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// defines
34// ===========================================================================
35
36#define PADDINGFRAME 10 // (5+5)
37#define VERTICALSCROLLBARWIDTH 15
38
39// ===========================================================================
40// static members
41// ===========================================================================
42
43FXFont* GNEFrame::myFrameHeaderFont = nullptr;
44
45// ===========================================================================
46// method definitions
47// ===========================================================================
48
49GNEFrame::GNEFrame(GNEViewParent* viewParent, GNEViewNet* viewNet, const std::string& frameLabel) :
50 FXVerticalFrame(viewParent->getFramesArea(), GUIDesignAuxiliarFrame),
51 myViewNet(viewNet) {
52
53 // fill myPredefinedTagsMML (to avoid repeating this fill during every element creation)
54 int i = 0;
56 int key = SUMOXMLDefinitions::attrs[i].key;
57 assert(key >= 0);
58 while (key >= (int)myPredefinedTagsMML.size()) {
59 myPredefinedTagsMML.push_back("");
60 }
62 i++;
63 }
64
65 // Create font only one time
66 if (myFrameHeaderFont == nullptr) {
67 myFrameHeaderFont = new FXFont(getApp(), "Arial", 14, FXFont::Bold);
68 }
69
70 // Create frame for header
71 myHeaderFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
72
73 // Create frame for left elements of header (By default unused)
75 myHeaderLeftFrame->hide();
76
77 // Create title frame
78 myFrameHeaderLabel = new FXLabel(myHeaderFrame, frameLabel.c_str(), nullptr, GUIDesignLabelFrameInformation);
79
80 // Create frame for right elements of header (By default unused)
82 myHeaderRightFrame->hide();
83
84 // Add separator
85 new FXHorizontalSeparator(this, GUIDesignHorizontalSeparator);
86
87 // Create scroll windows with fixed width for contents
88 myScrollWindowsContents = new FXScrollWindow(this, GUIDesignScrollWindowFixedWidth(10));
89
90 // Create frame for contents (in which GroupBox will be placed)
92
93 // Set font of header
95
96 // Hide Frame
97 FXVerticalFrame::hide();
98}
99
100
102 // delete frame header only one time
103 if (myFrameHeaderFont) {
104 delete myFrameHeaderFont;
105 myFrameHeaderFont = nullptr;
106 }
107}
108
109
110void
114
115
116void
118 // show scroll window
119 FXVerticalFrame::show();
120 // Show and update Frame Area in which this GNEFrame is placed
122}
123
124
125void
127 // hide scroll window
128 FXVerticalFrame::hide();
129 // Hide Frame Area in which this GNEFrame is placed
131}
132
133
134void
135GNEFrame::setFrameWidth(const int newWidth) {
136 // set scroll windows size (minus MARGIN)
137 myScrollWindowsContents->setWidth(newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1);
138 // calculate new contentWidth
139 int contentWidth = (newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1 - 15);
140 // adjust contents frame
141 myContentFrame->setWidth(contentWidth);
142 // set size of all contents frame children
143 for (auto child = myContentFrame->getFirst(); child != nullptr; child = child->getNext()) {
144 child->setWidth(contentWidth);
145 }
146 // call frame width updated
148}
149
150
153 return myViewNet;
154}
155
156
157FXVerticalFrame*
159 return myContentFrame;
160}
161
162
163FXLabel*
167
168
169FXFont*
173
174
175int
177 if (myScrollWindowsContents->verticalScrollBar()->shown()) {
178 return myScrollWindowsContents->verticalScrollBar()->getWidth();
179 } else {
180 return 0;
181 }
182}
183
184
185void
187 // open help dialog with attributes of the given attribute carrier
189}
190
191
192void
194 // this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
195}
196
197
198void
200 // this function can be reimplemented in all child frames
201}
202
203// ---------------------------------------------------------------------------
204// GNEFrame - protected methods
205// ---------------------------------------------------------------------------
206
207void
209 // this function has to be reimplemented in all child frames that uses a GNETagSelector module
210}
211
212
213void
215 // this function has to be reimplemented in all child frames that uses a DemandElementSelector
216}
217
218
219bool
221 // this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
222 return false;
223}
224
225
226void
228 // this function has to be reimplemented in all child frames that uses a AttributeEditor module
229}
230
231
232void
234 // this function has to be reimplemented in all child frames that uses a GNEOverlappedInspection
235}
236
237
238bool
239GNEFrame::createPath(const bool /*useLastRoute*/) {
240 // this function has to be reimplemented in all child frames that uses a path or consecutiveLanePath
241 return false;
242}
243
244
245const std::vector<std::string>&
249
250
251FXLabel*
252GNEFrame::buildRainbow(FXComposite* parent) {
253 // create label for color information
254 FXLabel* label = new FXLabel(parent, TL("Scale: Min -> Max"), nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));
255 // create frame for color scale
256 FXHorizontalFrame* horizontalFrameColors = new FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame);
257 for (const auto& color : GNEViewNetHelper::getRainbowScaledColors()) {
258 FXLabel* colorLabel = new FXLabel(horizontalFrameColors, "", nullptr, GUIDesignLabel(JUSTIFY_LEFT));
259 colorLabel->setBackColor(MFXUtils::getFXColor(color));
260 }
261 return label;
262 // for whatever reason, sonar complains in the next line that horizontalFrameColors may leak, but fox does the cleanup
263} // NOSONAR
264
265/****************************************************************************/
#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:133
int getScrollBarWidth() const
get scrollBar width (zero if is hidden)
Definition GNEFrame.cpp:176
virtual void attributeUpdated(SumoXMLAttr attribute)
function called after set a valid attribute in AttributeCreator/AttributeEditor/ParametersEditor/....
Definition GNEFrame.cpp:227
void setFrameWidth(const int newWidth)
set width of GNEFrame
Definition GNEFrame.cpp:135
void focusUpperElement()
focus upper element of frame
Definition GNEFrame.cpp:111
virtual void updateFrameAfterUndoRedo()
function called after undo/redo in the current frame (can be reimplemented in frame children)
Definition GNEFrame.cpp:193
static FXLabel * buildRainbow(FXComposite *parent)
build rainbow in frame modul
Definition GNEFrame.cpp:252
virtual void tagSelected()
Tag selected in GNETagSelector.
Definition GNEFrame.cpp:208
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:152
FXLabel * getFrameHeaderLabel() const
get the label for the frame's header
Definition GNEFrame.cpp:164
FXScrollWindow * myScrollWindowsContents
scroll windows that holds the content frame
Definition GNEFrame.h:143
virtual void demandElementSelected()
selected demand element in DemandElementSelector
Definition GNEFrame.cpp:214
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:121
FXFont * getFrameHeaderFont() const
get font of the header's frame
Definition GNEFrame.cpp:170
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition GNEFrame.h:124
FXHorizontalFrame * myHeaderFrame
fame for header elements
Definition GNEFrame.h:127
~GNEFrame()
destructor
Definition GNEFrame.cpp:101
virtual void show()
show Frame
Definition GNEFrame.cpp:117
virtual void hide()
hide Frame
Definition GNEFrame.cpp:126
GNEFrame(GNEViewParent *viewParent, GNEViewNet *viewNet, const std::string &frameLabel)
Constructor.
Definition GNEFrame.cpp:49
virtual void selectedOverlappedElement(GNEAttributeCarrier *AC)
open GNEAttributesCreator extended dialog
Definition GNEFrame.cpp:233
virtual void frameWidthUpdated()
function called after setting new width in current frame (can be reimplemented in frame children)
Definition GNEFrame.cpp:199
virtual bool shapeDrawed()
build a shaped element using the drawed shape
Definition GNEFrame.cpp:220
virtual bool createPath(const bool useLastRoute)
create path between two elements
Definition GNEFrame.cpp:239
void openHelpAttributesDialog(const GNEAttributeCarrier *AC) const
Open help attributes dialog.
Definition GNEFrame.cpp:186
std::vector< std::string > myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation (needed for SUMOSAXAttributesImpl_Cach...
Definition GNEFrame.h:152
FXLabel * myFrameHeaderLabel
the label for the frame's header
Definition GNEFrame.h:149
static FXFont * myFrameHeaderFont
static Font for the Header (it's common for all headers, then create only one time)
Definition GNEFrame.h:146
const std::vector< std::string > & getPredefinedTagsMML() const
get predefinedTagsMML
Definition GNEFrame.cpp:246
FXVerticalFrame * getContentFrame() const
get vertical frame that holds all widgets of frame
Definition GNEFrame.cpp:158
FXHorizontalFrame * myHeaderLeftFrame
fame for left header elements
Definition GNEFrame.h:130
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