Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/GNEHelpAttributesDialog.cpp
193674 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 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
/****************************************************************************/
14
/// @file GNEHelpAttributesDialog.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Jul 2025
17
///
18
// Help dialog used in netedit
19
/****************************************************************************/
20
21
#include <netedit/GNETagProperties.h>
22
#include <netedit/elements/GNEAttributeCarrier.h>
23
#include <utils/gui/div/GUIDesigns.h>
24
#include <utils/gui/windows/GUIAppEnum.h>
25
26
#include "GNEHelpAttributesDialog.h"
27
28
// ===========================================================================
29
// method definitions
30
// ===========================================================================
31
32
GNEHelpAttributesDialog::GNEHelpAttributesDialog(GNEApplicationWindow* applicationWindow, const GNEAttributeCarrier* AC) :
33
GNEDialog(applicationWindow, TLF("Attributes of %", AC->getTagStr()).c_str(),
34
GUIIcon::MODEINSPECT, DialogType::BASIC_HELP, GNEDialog::Buttons::OK,
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
73
GNEHelpAttributesDialog::~GNEHelpAttributesDialog() {
74
}
75
76
77
void
78
GNEHelpAttributesDialog::runInternalTest(const InternalTestStep::DialogArgument* /*dialogArgument*/) {
79
// nothing to do
80
}
81
82
83
void
84
GNEHelpAttributesDialog::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
/****************************************************************************/
114
115