Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEHelpAttributesDialog.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// Help dialog used in netedit
19/****************************************************************************/
20
25
27
28// ===========================================================================
29// method definitions
30// ===========================================================================
31
33 GNEDialog(applicationWindow, TLF("Attributes of %", AC->getTagStr()).c_str(),
35 OpenType::MODAL, ResizeMode::RESIZABLE) {
36 // Create FXTable
37 FXTable* table = new FXTable(myContentFrame, this, MID_TABLE, GUIDesignTableNotEditable);
38 // configure table
39 int sizeColumnDescription = 0;
40 int sizeColumnDefinitions = 0;
41 table->setVisibleRows((FXint)(AC->getTagProperty()->getNumberOfAttributes()));
42 table->setVisibleColumns(4);
43 table->setTableSize((FXint)(AC->getTagProperty()->getNumberOfAttributes()), 4);
44 table->setBackColor(GUIDesignBackgroundColorWhite);
45 table->setColumnText(0, TL("Attribute"));
46 table->setColumnText(1, TL("Category"));
47 table->setColumnText(2, TL("Description"));
48 table->setColumnText(3, TL("Definition"));
49 table->getRowHeader()->setWidth(0);
50 table->setColumnHeaderHeight(GUIDesignHeight);
51 // Iterate over vector of additional parameters
52 int itemIndex = 0;
53 // add internal attributes
54 addAttributes(AC, table, itemIndex, sizeColumnDescription, sizeColumnDefinitions, false);
55 // add netedit attributes
56 addAttributes(AC, table, itemIndex, sizeColumnDescription, sizeColumnDefinitions, true);
57 table->fitRowsToContents(0, itemIndex);
58 // set header
59 FXHeader* header = table->getColumnHeader();
60 header->setItemJustify(0, JUSTIFY_CENTER_X);
61 header->setItemSize(0, 120);
62 header->setItemJustify(0, JUSTIFY_CENTER_X);
63 header->setItemSize(1, 100);
64 header->setItemJustify(1, JUSTIFY_CENTER_X);
65 header->setItemSize(2, sizeColumnDescription * 8);
66 header->setItemJustify(2, JUSTIFY_CENTER_X);
67 header->setItemSize(3, sizeColumnDefinitions * 6);
68 // open modal dialog
69 openDialog();
70}
71
72
75
76
77void
79 // nothing to do
80}
81
82
83void
84GNEHelpAttributesDialog::addAttributes(const GNEAttributeCarrier* AC, FXTable* table, int& itemIndex,
85 int& sizeColumnDescription, int& sizeColumnDefinitions, const bool neteditAttributes) {
86 for (const auto& attrProperty : AC->getTagProperty()->getAttributeProperties()) {
87 if (attrProperty->isNeteditEditor() == neteditAttributes) {
88 // Set attribute
89 FXTableItem* attributeItem = new FXTableItem(attrProperty->getAttrStr().c_str());
90 attributeItem->setJustify(FXTableItem::CENTER_X);
91 table->setItem(itemIndex, 0, attributeItem);
92 // Set description of element
93 FXTableItem* categoryItem = new FXTableItem("");
94 categoryItem->setText(attrProperty->getCategory().c_str());
95 categoryItem->setJustify(FXTableItem::CENTER_X);
96 table->setItem(itemIndex, 1, categoryItem);
97 // Set description of element
98 FXTableItem* descriptionItem = new FXTableItem("");
99 descriptionItem->setText(attrProperty->getDescription().c_str());
100 sizeColumnDescription = MAX2(sizeColumnDescription, (int)attrProperty->getDescription().size());
101 descriptionItem->setJustify(FXTableItem::CENTER_X);
102 table->setItem(itemIndex, 2, descriptionItem);
103 // Set definition
104 FXTableItem* definitionItem = new FXTableItem(attrProperty->getDefinition().c_str());
105 definitionItem->setJustify(FXTableItem::LEFT);
106 table->setItem(itemIndex, 3, definitionItem);
107 sizeColumnDefinitions = MAX2(sizeColumnDefinitions, (int)attrProperty->getDefinition().size());
108 itemIndex++;
109 }
110 }
111}
112
113/****************************************************************************/
DialogType
@ MID_TABLE
The Table.
Definition GUIAppEnum.h:541
#define GUIDesignTableNotEditable
design for table extended over frame that cannot be edited
Definition GUIDesigns.h:644
#define GUIDesignBackgroundColorWhite
white background color (for valid text)
Definition GUIDesigns.h:47
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
int GUIDesignHeight
the default height for GUI elements
Definition StdDefs.cpp:40
T MAX2(T a, T b)
Definition StdDefs.h:86
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:159
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
OpenType
Open dialog type.
Definition GNEDialog.h:58
void addAttributes(const GNEAttributeCarrier *AC, FXTable *table, int &itemIndex, int &sizeColumnDescription, int &sizeColumnDefinitions, const bool neteditAttributes)
add attributes
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
GNEHelpAttributesDialog(GNEApplicationWindow *applicationWindow, const GNEAttributeCarrier *AC)
Constructor.
int getNumberOfAttributes() const
get number of attributes
const std::vector< const GNEAttributeProperties * > & getAttributeProperties() const
get all attribute properties
dialog arguments, used for certain modal dialogs that can not be edited using tab