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
23#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, GUIDesignScrollWindowFixed);
89
90 // Create frame for contents (in which GroupBox will be placed)
92
93 // Set font of header
95
96 // set initial width (will be changed in the first update
97 setWidth(10);
98
99 // Hide Frame
100 FXVerticalFrame::hide();
101}
102
103
105 // delete frame header only one time
106 if (myFrameHeaderFont) {
107 delete myFrameHeaderFont;
108 myFrameHeaderFont = nullptr;
109 }
110}
111
112
113void
117
118
119void
121 // show scroll window
122 FXVerticalFrame::show();
123 // Show and update Frame Area in which this GNEFrame is placed
125}
126
127
128void
130 // hide scroll window
131 FXVerticalFrame::hide();
132 // Hide Frame Area in which this GNEFrame is placed
134}
135
136
137void
138GNEFrame::setFrameWidth(const int newWidth) {
139 // set scroll windows size (minus MARGIN)
140 myScrollWindowsContents->setWidth(newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1);
141 // calculate new contentWidth
142 int contentWidth = (newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1 - 15);
143 // adjust contents frame
144 myContentFrame->setWidth(contentWidth);
145 // set size of all contents frame children
146 for (auto child = myContentFrame->getFirst(); child != nullptr; child = child->getNext()) {
147 child->setWidth(contentWidth);
148 }
149 // call frame width updated
151}
152
153
156 return myViewNet;
157}
158
159
160FXVerticalFrame*
162 return myContentFrame;
163}
164
165
166FXLabel*
170
171
172FXFont*
176
177
178int
180 if (myScrollWindowsContents->verticalScrollBar()->shown()) {
181 return myScrollWindowsContents->verticalScrollBar()->getWidth();
182 } else {
183 return 0;
184 }
185}
186
187
188void
190 MFXDialogBox* attributesHelpDialog = new MFXDialogBox(myScrollWindowsContents, (TL("Parameters of ") + AC->getTagStr()).c_str(), GUIDesignDialogBoxResizable, 0, 0, 0, 0, 10, 10, 10, 38, 4, 4);
191 // Create FXTable
192 FXTable* myTable = new FXTable(attributesHelpDialog, attributesHelpDialog, MID_TABLE, GUIDesignTableNotEditable);
193 attributesHelpDialog->setIcon(GUIIconSubSys::getIcon(GUIIcon::MODEINSPECT));
194 int sizeColumnDescription = 0;
195 int sizeColumnDefinitions = 0;
196 myTable->setVisibleRows((FXint)(AC->getTagProperty()->getNumberOfAttributes()));
197 myTable->setVisibleColumns(4);
198 myTable->setTableSize((FXint)(AC->getTagProperty()->getNumberOfAttributes()), 4);
199 myTable->setBackColor(FXRGB(255, 255, 255));
200 myTable->setColumnText(0, TL("Attribute"));
201 myTable->setColumnText(1, TL("Category"));
202 myTable->setColumnText(2, TL("Description"));
203 myTable->setColumnText(3, TL("Definition"));
204 myTable->getRowHeader()->setWidth(0);
205 myTable->setColumnHeaderHeight(GUIDesignHeight);
206 // Iterate over vector of additional parameters
207 int itemIndex = 0;
208 for (const auto& attrProperty : AC->getTagProperty()->getAttributeProperties()) {
209 // Set attribute
210 FXTableItem* attributeItem = new FXTableItem(attrProperty->getAttrStr().c_str());
211 attributeItem->setJustify(FXTableItem::CENTER_X);
212 myTable->setItem(itemIndex, 0, attributeItem);
213 // Set description of element
214 FXTableItem* categoryItem = new FXTableItem("");
215 categoryItem->setText(attrProperty->getCategory().c_str());
216 categoryItem->setJustify(FXTableItem::CENTER_X);
217 myTable->setItem(itemIndex, 1, categoryItem);
218 // Set description of element
219 FXTableItem* descriptionItem = new FXTableItem("");
220 descriptionItem->setText(attrProperty->getDescription().c_str());
221 sizeColumnDescription = MAX2(sizeColumnDescription, (int)attrProperty->getDescription().size());
222 descriptionItem->setJustify(FXTableItem::CENTER_X);
223 myTable->setItem(itemIndex, 2, descriptionItem);
224 // Set definition
225 FXTableItem* definitionItem = new FXTableItem(attrProperty->getDefinition().c_str());
226 definitionItem->setJustify(FXTableItem::LEFT);
227 myTable->setItem(itemIndex, 3, definitionItem);
228 sizeColumnDefinitions = MAX2(sizeColumnDefinitions, (int)attrProperty->getDefinition().size());
229 itemIndex++;
230 }
231 myTable->fitRowsToContents(0, itemIndex);
232 // set header
233 FXHeader* header = myTable->getColumnHeader();
234 header->setItemJustify(0, JUSTIFY_CENTER_X);
235 header->setItemSize(0, 120);
236 header->setItemJustify(0, JUSTIFY_CENTER_X);
237 header->setItemSize(1, 100);
238 header->setItemJustify(1, JUSTIFY_CENTER_X);
239 header->setItemSize(2, sizeColumnDescription * 8);
240 header->setItemJustify(2, JUSTIFY_CENTER_X);
241 header->setItemSize(3, sizeColumnDefinitions * 6);
242 // Create horizontal separator
243 new FXHorizontalSeparator(attributesHelpDialog, GUIDesignHorizontalSeparator);
244 // Create frame for OK Button
245 FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(attributesHelpDialog, GUIDesignAuxiliarHorizontalFrame);
246 // Create Button Close (And two more horizontal frames to center it)
247 new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
248 GUIDesigns::buildFXButton(myHorizontalFrameOKButton, TL("OK"), "", TL("close"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), attributesHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
249 new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
250 // create Dialog
251 attributesHelpDialog->create();
252 // show in the given position
253 attributesHelpDialog->show(PLACEMENT_CURSOR);
254 // refresh APP
255 getApp()->refresh();
256 // open as modal dialog (will block all windows until stop() or stopModal() is called)
257 getApp()->runModalFor(attributesHelpDialog);
258}
259
260
261void
263 // this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
264}
265
266
267void
269 // this function can be reimplemented in all child frames
270}
271
272// ---------------------------------------------------------------------------
273// GNEFrame - protected methods
274// ---------------------------------------------------------------------------
275
276void
278 // this function has to be reimplemented in all child frames that uses a GNETagSelector module
279}
280
281
282void
284 // this function has to be reimplemented in all child frames that uses a DemandElementSelector
285}
286
287
288bool
290 // this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
291 return false;
292}
293
294
295void
297 // this function has to be reimplemented in all child frames that uses a AttributeEditor module
298}
299
300
301void
303 // this function has to be reimplemented in all child frames that uses a GNEOverlappedInspection
304}
305
306
307bool
308GNEFrame::createPath(const bool /*useLastRoute*/) {
309 // this function has to be reimplemented in all child frames that uses a path or consecutiveLanePath
310 return false;
311}
312
313
314const std::vector<std::string>&
318
319
320FXLabel*
321GNEFrame::buildRainbow(FXComposite* parent) {
322 // create label for color information
323 FXLabel* label = new FXLabel(parent, TL("Scale: Min -> Max"), nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));
324 // create frame for color scale
325 FXHorizontalFrame* horizontalFrameColors = new FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame);
326 for (const auto& color : GNEViewNetHelper::getRainbowScaledColors()) {
327 FXLabel* colorLabel = new FXLabel(horizontalFrameColors, "", nullptr, GUIDesignLabel(JUSTIFY_LEFT));
328 colorLabel->setBackColor(MFXUtils::getFXColor(color));
329 }
330 return label;
331 // for whatever reason, sonar complains in the next line that horizontalFrameColors may leak, but fox does the cleanup
332} // NOSONAR
333
334/****************************************************************************/
@ 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:305
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:36
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:179
virtual void attributeUpdated(SumoXMLAttr attribute)
function called after set a valid attribute in AttributeCreator/AttributeEditor/ParametersEditor/....
Definition GNEFrame.cpp:296
void setFrameWidth(const int newWidth)
set width of GNEFrame
Definition GNEFrame.cpp:138
void focusUpperElement()
focus upper element of frame
Definition GNEFrame.cpp:114
virtual void updateFrameAfterUndoRedo()
function called after undo/redo in the current frame (can be reimplemented in frame children)
Definition GNEFrame.cpp:262
static FXLabel * buildRainbow(FXComposite *parent)
build rainbow in frame modul
Definition GNEFrame.cpp:321
virtual void tagSelected()
Tag selected in GNETagSelector.
Definition GNEFrame.cpp:277
GNEViewNet * getViewNet() const
get view net
Definition GNEFrame.cpp:155
FXLabel * getFrameHeaderLabel() const
get the label for the frame's header
Definition GNEFrame.cpp:167
FXScrollWindow * myScrollWindowsContents
scroll windows that holds the content frame
Definition GNEFrame.h:143
virtual void demandElementSelected()
selected demand element in DemandElementSelector
Definition GNEFrame.cpp:283
GNEViewNet * myViewNet
FOX need this.
Definition GNEFrame.h:121
FXFont * getFrameHeaderFont() const
get font of the header's frame
Definition GNEFrame.cpp:173
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:104
virtual void show()
show Frame
Definition GNEFrame.cpp:120
virtual void hide()
hide Frame
Definition GNEFrame.cpp:129
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:302
virtual void frameWidthUpdated()
function called after setting new width in current frame (can be reimplemented in frame children)
Definition GNEFrame.cpp:268
virtual bool shapeDrawed()
build a shaped element using the drawed shape
Definition GNEFrame.cpp:289
virtual bool createPath(const bool useLastRoute)
create path between two elements
Definition GNEFrame.cpp:308
void openHelpAttributesDialog(const GNEAttributeCarrier *AC) const
Open help attributes dialog.
Definition GNEFrame.cpp:189
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:315
FXVerticalFrame * getContentFrame() const
get vertical frame that holds all widgets of frame
Definition GNEFrame.cpp:161
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