Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
23#include <netedit/GNEViewNet.h>
28
29#include "GNEFrame.h"
30
31// ===========================================================================
32// defines
33// ===========================================================================
34
35#define PADDINGFRAME 10 // (5+5)
36#define VERTICALSCROLLBARWIDTH 15
37
38// ===========================================================================
39// static members
40// ===========================================================================
41
42FXFont* GNEFrame::myFrameHeaderFont = nullptr;
43
44// ===========================================================================
45// method definitions
46// ===========================================================================
47
48GNEFrame::GNEFrame(GNEViewParent* viewParent, GNEViewNet* viewNet, const std::string& frameLabel) :
49 FXVerticalFrame(viewParent->getFramesArea(), GUIDesignAuxiliarFrame),
50 myViewNet(viewNet) {
51
52 // fill myPredefinedTagsMML (to avoid repeating this fill during every element creation)
53 int i = 0;
55 int key = SUMOXMLDefinitions::attrs[i].key;
56 assert(key >= 0);
57 while (key >= (int)myPredefinedTagsMML.size()) {
58 myPredefinedTagsMML.push_back("");
59 }
61 i++;
62 }
63
64 // Create font only one time
65 if (myFrameHeaderFont == nullptr) {
66 myFrameHeaderFont = new FXFont(getApp(), "Arial", 14, FXFont::Bold);
67 }
68
69 // Create frame for header
70 myHeaderFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
71
72 // Create frame for left elements of header (By default unused)
74 myHeaderLeftFrame->hide();
75
76 // Create title frame
77 myFrameHeaderLabel = new FXLabel(myHeaderFrame, frameLabel.c_str(), nullptr, GUIDesignLabelFrameInformation);
78
79 // Create frame for right elements of header (By default unused)
81 myHeaderRightFrame->hide();
82
83 // Add separator
84 new FXHorizontalSeparator(this, GUIDesignHorizontalSeparator);
85
86 // Create scroll windows with fixed width for contents
87 myScrollWindowsContents = new FXScrollWindow(this, GUIDesignScrollWindowFixed);
88
89 // Create frame for contents (in which GroupBox will be placed)
91
92 // Set font of header
94
95 // set initial width (will be changed in the first update
96 setWidth(10);
97
98 // Hide Frame
99 FXVerticalFrame::hide();
100}
101
102
104 // delete frame header only one time
105 if (myFrameHeaderFont) {
106 delete myFrameHeaderFont;
107 myFrameHeaderFont = nullptr;
108 }
109}
110
111
112void
116
117
118void
120 // show scroll window
121 FXVerticalFrame::show();
122 // Show and update Frame Area in which this GNEFrame is placed
124}
125
126
127void
129 // hide scroll window
130 FXVerticalFrame::hide();
131 // Hide Frame Area in which this GNEFrame is placed
133}
134
135
136void
137GNEFrame::setFrameWidth(const int newWidth) {
138 // set scroll windows size (minus MARGIN)
139 myScrollWindowsContents->setWidth(newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1);
140 // calculate new contentWidth
141 int contentWidth = (newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1 - 15);
142 // adjust contents frame
143 myContentFrame->setWidth(contentWidth);
144 // set size of all contents frame children
145 for (auto child = myContentFrame->getFirst(); child != nullptr; child = child->getNext()) {
146 child->setWidth(contentWidth);
147 }
148 // call frame width updated
150}
151
152
155 return myViewNet;
156}
157
158
159FXVerticalFrame*
161 return myContentFrame;
162}
163
164
165FXLabel*
169
170
171FXFont*
175
176
177int
179 if (myScrollWindowsContents->verticalScrollBar()->shown()) {
180 return myScrollWindowsContents->verticalScrollBar()->getWidth();
181 } else {
182 return 0;
183 }
184}
185
186
187void
189 FXDialogBox* attributesHelpDialog = new FXDialogBox(myScrollWindowsContents, (TL("Parameters of ") + AC->getTagStr()).c_str(), GUIDesignDialogBoxResizable, 0, 0, 0, 0, 10, 10, 10, 38, 4, 4);
190 // Create FXTable
191 FXTable* myTable = new FXTable(attributesHelpDialog, attributesHelpDialog, MID_TABLE, GUIDesignTableNotEditable);
192 attributesHelpDialog->setIcon(GUIIconSubSys::getIcon(GUIIcon::MODEINSPECT));
193 int sizeColumnDescription = 0;
194 int sizeColumnDefinitions = 0;
195 myTable->setVisibleRows((FXint)(AC->getTagProperty()->getNumberOfAttributes()));
196 myTable->setVisibleColumns(4);
197 myTable->setTableSize((FXint)(AC->getTagProperty()->getNumberOfAttributes()), 4);
198 myTable->setBackColor(FXRGB(255, 255, 255));
199 myTable->setColumnText(0, TL("Attribute"));
200 myTable->setColumnText(1, TL("Category"));
201 myTable->setColumnText(2, TL("Description"));
202 myTable->setColumnText(3, TL("Definition"));
203 myTable->getRowHeader()->setWidth(0);
204 myTable->setColumnHeaderHeight(GUIDesignHeight);
205 // Iterate over vector of additional parameters
206 int itemIndex = 0;
207 for (const auto& attrProperty : AC->getTagProperty()->getAttributeProperties()) {
208 // Set attribute
209 FXTableItem* attributeItem = new FXTableItem(attrProperty->getAttrStr().c_str());
210 attributeItem->setJustify(FXTableItem::CENTER_X);
211 myTable->setItem(itemIndex, 0, attributeItem);
212 // Set description of element
213 FXTableItem* categoryItem = new FXTableItem("");
214 categoryItem->setText(attrProperty->getCategory().c_str());
215 categoryItem->setJustify(FXTableItem::CENTER_X);
216 myTable->setItem(itemIndex, 1, categoryItem);
217 // Set description of element
218 FXTableItem* descriptionItem = new FXTableItem("");
219 descriptionItem->setText(attrProperty->getDescription().c_str());
220 sizeColumnDescription = MAX2(sizeColumnDescription, (int)attrProperty->getDescription().size());
221 descriptionItem->setJustify(FXTableItem::CENTER_X);
222 myTable->setItem(itemIndex, 2, descriptionItem);
223 // Set definition
224 FXTableItem* definitionItem = new FXTableItem(attrProperty->getDefinition().c_str());
225 definitionItem->setJustify(FXTableItem::LEFT);
226 myTable->setItem(itemIndex, 3, definitionItem);
227 sizeColumnDefinitions = MAX2(sizeColumnDefinitions, (int)attrProperty->getDefinition().size());
228 itemIndex++;
229 }
230 myTable->fitRowsToContents(0, itemIndex);
231 // set header
232 FXHeader* header = myTable->getColumnHeader();
233 header->setItemJustify(0, JUSTIFY_CENTER_X);
234 header->setItemSize(0, 120);
235 header->setItemJustify(0, JUSTIFY_CENTER_X);
236 header->setItemSize(1, 100);
237 header->setItemJustify(1, JUSTIFY_CENTER_X);
238 header->setItemSize(2, sizeColumnDescription * 8);
239 header->setItemJustify(2, JUSTIFY_CENTER_X);
240 header->setItemSize(3, sizeColumnDefinitions * 6);
241 // Create horizontal separator
242 new FXHorizontalSeparator(attributesHelpDialog, GUIDesignHorizontalSeparator);
243 // Create frame for OK Button
244 FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(attributesHelpDialog, GUIDesignAuxiliarHorizontalFrame);
245 // Create Button Close (And two more horizontal frames to center it)
246 new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
247 GUIDesigns::buildFXButton(myHorizontalFrameOKButton, TL("OK"), "", TL("close"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), attributesHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
248 new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
249 // create Dialog
250 attributesHelpDialog->create();
251 // show in the given position
252 attributesHelpDialog->show(PLACEMENT_CURSOR);
253 // refresh APP
254 getApp()->refresh();
255 // open as modal dialog (will block all windows until stop() or stopModal() is called)
256 getApp()->runModalFor(attributesHelpDialog);
257}
258
259
260void
262 // this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
263}
264
265
266void
268 // this function can be reimplemented in all child frames
269}
270
271// ---------------------------------------------------------------------------
272// GNEFrame - protected methods
273// ---------------------------------------------------------------------------
274
275void
277 // this function has to be reimplemented in all child frames that uses a GNETagSelector module
278}
279
280
281void
283 // this function has to be reimplemented in all child frames that uses a DemandElementSelector
284}
285
286
287bool
289 // this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
290 return false;
291}
292
293
294void
296 // this function has to be reimplemented in all child frames that uses a AttributeEditor module
297}
298
299
300void
302 // this function has to be reimplemented in all child frames that uses a GNEOverlappedInspection
303}
304
305
306bool
307GNEFrame::createPath(const bool /*useLastRoute*/) {
308 // this function has to be reimplemented in all child frames that uses a path or consecutiveLanePath
309 return false;
310}
311
312
313const std::vector<std::string>&
317
318
319FXLabel*
320GNEFrame::buildRainbow(FXComposite* parent) {
321 // create label for color information
322 FXLabel* label = new FXLabel(parent, TL("Scale: Min -> Max"), nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));
323 // create frame for color scale
324 FXHorizontalFrame* horizontalFrameColors = new FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame);
325 for (const auto& color : GNEViewNetHelper::getRainbowScaledColors()) {
326 FXLabel* colorLabel = new FXLabel(horizontalFrameColors, "", nullptr, GUIDesignLabel(JUSTIFY_LEFT));
327 colorLabel->setBackColor(MFXUtils::getFXColor(color));
328 }
329 return label;
330 // for whatever reason, sonar complains in the next line that horizontalFrameColors may leak, but fox does the cleanup
331} // NOSONAR
332
333/****************************************************************************/
@ MID_TABLE
The Table.
Definition GUIAppEnum.h:539
#define GUIDesignTableNotEditable
design for table extended over frame that cannot be edited
Definition GUIDesigns.h:628
#define GUIDesignDialogBoxResizable
design for standard dialog box (for example, about dialog)
Definition GUIDesigns.h:608
#define GUIDesignFrameAreaMargin
right margin for frame area
Definition GUIDesigns.h:41
#define GUIDesignAuxiliarHorizontalFrameCenteredVertically
design for auxiliar (Without borders) horizontal frame used to pack another frames,...
Definition GUIDesigns.h:402
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:399
#define GUIDesignLabel(justify)
Definition GUIDesigns.h:243
#define GUIDesignAuxiliarFrameFixedWidth(width)
design for auxiliar (Without borders) frame with fixed width and extended height
Definition GUIDesigns.h:396
#define GUIDesignButtonOK
Definition GUIDesigns.h:153
#define GUIDesignScrollWindowFixed
design for scroll windows extended over Y and fix width
Definition GUIDesigns.h:378
#define GUIDesignLabelThick(justify)
label extended over frame with thick and with text justify to left
Definition GUIDesigns.h:249
#define GUIDesignHorizontalSeparator
Definition GUIDesigns.h:463
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
Definition GUIDesigns.h:390
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition GUIDesigns.h:279
#define TL(string)
Definition MsgHandler.h:301
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NOTHING
invalid attribute, must be the last one
int GUIDesignHeight
the default size for GUI elements
Definition StdDefs.cpp:35
T MAX2(T a, T b)
Definition StdDefs.h:82
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
FXHorizontalFrame * myHeaderRightFrame
fame for right header elements
Definition GNEFrame.h:133
int getScrollBarWidth() const
get scrollBar width (zero if is hidden)
Definition GNEFrame.cpp:178
virtual void attributeUpdated(SumoXMLAttr attribute)
function called after set a valid attribute in AttributeCreator/AttributeEditor/ParametersEditor/....
Definition GNEFrame.cpp:295
void setFrameWidth(const int newWidth)
set width of GNEFrame
Definition GNEFrame.cpp:137
void focusUpperElement()
focus upper element of frame
Definition GNEFrame.cpp:113
virtual void updateFrameAfterUndoRedo()
function called after undo/redo in the current frame (can be reimplemented in frame children)
Definition GNEFrame.cpp:261
static FXLabel * buildRainbow(FXComposite *parent)
build rainbow in frame modul
Definition GNEFrame.cpp:320
virtual void tagSelected()
Tag selected in GNETagSelector.
Definition GNEFrame.cpp:276
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:154
FXLabel * getFrameHeaderLabel() const
get the label for the frame's header
Definition GNEFrame.cpp:166
FXScrollWindow * myScrollWindowsContents
scroll windows that holds the content frame
Definition GNEFrame.h:143
virtual void demandElementSelected()
selected demand element in DemandElementSelector
Definition GNEFrame.cpp:282
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:121
FXFont * getFrameHeaderFont() const
get font of the header's frame
Definition GNEFrame.cpp:172
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:103
virtual void show()
show Frame
Definition GNEFrame.cpp:119
virtual void hide()
hide Frame
Definition GNEFrame.cpp:128
GNEFrame(GNEViewParent *viewParent, GNEViewNet *viewNet, const std::string &frameLabel)
Constructor.
Definition GNEFrame.cpp:48
virtual void selectedOverlappedElement(GNEAttributeCarrier *AC)
open GNEAttributesCreator extended dialog
Definition GNEFrame.cpp:301
virtual void frameWidthUpdated()
function called after setting new width in current frame (can be reimplemented in frame children)
Definition GNEFrame.cpp:267
virtual bool shapeDrawed()
build a shaped element using the drawed shape
Definition GNEFrame.cpp:288
virtual bool createPath(const bool useLastRoute)
create path between two elements
Definition GNEFrame.cpp:307
void openHelpAttributesDialog(const GNEAttributeCarrier *AC) const
Open help attributes dialog.
Definition GNEFrame.cpp:188
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:314
FXVerticalFrame * getContentFrame() const
get vertical frame that holds all widgets of frame
Definition GNEFrame.cpp:160
FXHorizontalFrame * myHeaderLeftFrame
fame for left header elements
Definition GNEFrame.h:130
int getNumberOfAttributes() const
get number of attributes
const std::vector< const GNEAttributeProperties * > & getAttributeProperties() const
get all attribute properties
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
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
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