Eclipse SUMO - Simulation of Urban MObility
GNEFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // The Widget for add additional elements
15 /****************************************************************************/
16 
17 // ===========================================================================
18 // included modules
19 // ===========================================================================
20 
21 #include <config.h>
22 
23 #include <netedit/GNEViewNet.h>
24 #include <netedit/GNEViewParent.h>
27 
28 #include "GNEFrame.h"
29 
30 
31 // ===========================================================================
32 // static members
33 // ===========================================================================
34 
35 FXFont* GNEFrame::myFrameHeaderFont = nullptr;
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
40 
41 GNEFrame::GNEFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet, const std::string& frameLabel) :
42  FXVerticalFrame(horizontalFrameParent, GUIDesignAuxiliarFrame),
43  myViewNet(viewNet),
44  myEdgeCandidateColor(RGBColor(0, 64, 0, 255)),
45  myEdgeCandidateSelectedColor(RGBColor::GREEN) {
46 
47  // fill myPredefinedTagsMML (to avoid repeating this fill during every element creation)
48  int i = 0;
52  i++;
53  }
54 
55  // Create font only one time
56  if (myFrameHeaderFont == nullptr) {
57  myFrameHeaderFont = new FXFont(getApp(), "Arial", 14, FXFont::Bold);
58  }
59 
60  // Create frame for header
61  myHeaderFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
62 
63  // Create frame for left elements of header (By default unused)
65  myHeaderLeftFrame->hide();
66 
67  // Create titel frame
68  myFrameHeaderLabel = new FXLabel(myHeaderFrame, frameLabel.c_str(), nullptr, GUIDesignLabelFrameInformation);
69 
70  // Create frame for right elements of header (By default unused)
72  myHeaderRightFrame->hide();
73 
74  // Add separator
75  new FXHorizontalSeparator(this, GUIDesignHorizontalSeparator);
76 
77  // Create frame for contents
78  myScrollWindowsContents = new FXScrollWindow(this, GUIDesignContentsScrollWindow);
79 
80  // Create frame for contents
82 
83  // Set font of header
85 
86  // Hide Frame
87  FXVerticalFrame::hide();
88 }
89 
90 
92  // delete frame header only one time
93  if (myFrameHeaderFont) {
94  delete myFrameHeaderFont;
95  myFrameHeaderFont = nullptr;
96  }
97 }
98 
99 
100 void
102  myFrameHeaderLabel->setFocus();
103 }
104 
105 
106 void
108  // show scroll window
109  FXVerticalFrame::show();
110  // Show and update Frame Area in which this GNEFrame is placed
112 }
113 
114 
115 void
117  // hide scroll window
118  FXVerticalFrame::hide();
119  // Hide Frame Area in which this GNEFrame is placed
121 }
122 
123 
124 void
125 GNEFrame::setFrameWidth(int newWidth) {
126  setWidth(newWidth);
127  myScrollWindowsContents->setWidth(newWidth);
128 }
129 
130 
131 GNEViewNet*
133  return myViewNet;
134 }
135 
136 
137 FXLabel*
139  return myFrameHeaderLabel;
140 }
141 
142 
143 FXFont*
145  return myFrameHeaderFont;
146 }
147 
148 
149 void
151  // this function has to be reimplemente in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
152 }
153 
154 // ---------------------------------------------------------------------------
155 // GNEFrame - protected methods
156 // ---------------------------------------------------------------------------
157 
158 void
160  // this function has to be reimplemente in all child frames that uses a TagSelector modul
161 }
162 
163 
164 void
166  // this function has to be reimplemente in all child frames that uses a DemandElementSelector
167 }
168 
169 
170 void
172  // this function has to be reimplemente in all child frames that uses a EdgePathCreator
173 }
174 
175 
176 bool
178  // this function has to be reimplemente in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)
179  return false;
180 }
181 
182 
183 void
185  // this function has to be reimplemente in all child frames that uses a TagSelector modul
186 }
187 
188 
189 void
191  // this function has to be reimplemente in all child frames that uses a AttributesCreator editor with extended attributes
192 }
193 
194 
195 void
197  // this function has to be reimplemente in all child frames that uses a OverlappedInspection
198 }
199 
200 
201 void
203  FXDialogBox* attributesHelpDialog = new FXDialogBox(myScrollWindowsContents, ("Parameters of " + tagProperties.getTagStr()).c_str(), GUIDesignDialogBoxResizable, 0, 0, 0, 0, 10, 10, 10, 38, 4, 4);
204  // Create FXTable
205  FXTable* myTable = new FXTable(attributesHelpDialog, attributesHelpDialog, MID_TABLE, GUIDesignTableNotEditable);
206  attributesHelpDialog->setIcon(GUIIconSubSys::getIcon(ICON_MODEINSPECT));
207  int sizeColumnDescription = 0;
208  int sizeColumnDefinitions = 0;
209  myTable->setVisibleRows((FXint)(tagProperties.getNumberOfAttributes()));
210  myTable->setVisibleColumns(3);
211  myTable->setTableSize((FXint)(tagProperties.getNumberOfAttributes()), 3);
212  myTable->setBackColor(FXRGB(255, 255, 255));
213  myTable->setColumnText(0, "Attribute");
214  myTable->setColumnText(1, "Description");
215  myTable->setColumnText(2, "Definition");
216  myTable->getRowHeader()->setWidth(0);
217  // Iterate over vector of additional parameters
218  int itemIndex = 0;
219  for (const auto& i : tagProperties) {
220  // Set attribute
221  FXTableItem* attribute = new FXTableItem(i.getAttrStr().c_str());
222  attribute->setJustify(FXTableItem::CENTER_X);
223  myTable->setItem(itemIndex, 0, attribute);
224  // Set description of element
225  FXTableItem* type = new FXTableItem("");
226  type->setText(i.getDescription().c_str());
227  sizeColumnDescription = MAX2(sizeColumnDescription, (int)i.getDescription().size());
228  type->setJustify(FXTableItem::CENTER_X);
229  myTable->setItem(itemIndex, 1, type);
230  // Set definition
231  FXTableItem* definition = new FXTableItem(i.getDefinition().c_str());
232  definition->setJustify(FXTableItem::LEFT);
233  myTable->setItem(itemIndex, 2, definition);
234  sizeColumnDefinitions = MAX2(sizeColumnDefinitions, (int)i.getDefinition().size());
235  itemIndex++;
236  }
237  // set header
238  FXHeader* header = myTable->getColumnHeader();
239  header->setItemJustify(0, JUSTIFY_CENTER_X);
240  header->setItemSize(0, 120);
241  header->setItemJustify(1, JUSTIFY_CENTER_X);
242  header->setItemSize(1, sizeColumnDescription * 7);
243  header->setItemJustify(2, JUSTIFY_CENTER_X);
244  header->setItemSize(2, sizeColumnDefinitions * 6);
245  // Create horizontal separator
246  new FXHorizontalSeparator(attributesHelpDialog, GUIDesignHorizontalSeparator);
247  // Create frame for OK Button
248  FXHorizontalFrame* myHorizontalFrameOKButton = new FXHorizontalFrame(attributesHelpDialog, GUIDesignAuxiliarHorizontalFrame);
249  // Create Button Close (And two more horizontal frames to center it)
250  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
251  new FXButton(myHorizontalFrameOKButton, "OK\t\tclose", GUIIconSubSys::getIcon(ICON_ACCEPT), attributesHelpDialog, FXDialogBox::ID_ACCEPT, GUIDesignButtonOK);
252  new FXHorizontalFrame(myHorizontalFrameOKButton, GUIDesignAuxiliarHorizontalFrame);
253  // Write Warning in console if we're in testing mode
254  WRITE_DEBUG("Opening HelpAttributes dialog for tag '" + tagProperties.getTagStr() + "' showing " + toString(tagProperties.getNumberOfAttributes()) + " attributes");
255  // create Dialog
256  attributesHelpDialog->create();
257  // show in the given position
258  attributesHelpDialog->show(PLACEMENT_CURSOR);
259  // refresh APP
260  getApp()->refresh();
261  // open as modal dialog (will block all windows until stop() or stopModal() is called)
262  getApp()->runModalFor(attributesHelpDialog);
263  // Write Warning in console if we're in testing mode
264  WRITE_DEBUG("Closing HelpAttributes dialog for tag '" + tagProperties.getTagStr() + "'");
265 }
266 
267 
268 const RGBColor&
270  return myEdgeCandidateColor;
271 }
272 
273 
274 const RGBColor&
277 }
278 
279 
280 const std::map<int, std::string>&
282  return myPredefinedTagsMML;
283 }
284 
285 /****************************************************************************/
GUIDesignAuxiliarHorizontalFrame
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:273
GNEFrame::myFrameHeaderFont
static FXFont * myFrameHeaderFont
static Font for the Header (it's common for all headers, then create only one time)
Definition: GNEFrame.h:140
ICON_ACCEPT
Definition: GUIIcons.h:386
GNEFrame::myScrollWindowsContents
FXScrollWindow * myScrollWindowsContents
scroll windows that holds the content frame
Definition: GNEFrame.h:137
GNEFrame::attributeUpdated
virtual void attributeUpdated()
function called after set a valid attribute in AttributeCreator/AttributeEditor/ParametersEditor/....
Definition: GNEFrame.cpp:184
GNEFrame::getFrameHeaderFont
FXFont * getFrameHeaderFont() const
get font of the header's frame
Definition: GNEFrame.cpp:144
GNEAttributeCarrier::TagProperties
struct with the attribute Properties
Definition: GNEAttributeCarrier.h:317
GNEFrame::updateFrameAfterUndoRedo
virtual void updateFrameAfterUndoRedo()
function called after undo/redo in the current frame (can be reimplemented in frame children)
Definition: GNEFrame.cpp:150
GNEAttributeCarrier::TagProperties::getTagStr
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
Definition: GNEAttributeCarrier.cpp:529
GNEFrame::GNEFrame
GNEFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet, const std::string &frameLabel)
Constructor.
Definition: GNEFrame.cpp:41
GNEFrame::edgePathCreated
virtual void edgePathCreated()
finish edge path creation
Definition: GNEFrame.cpp:171
GNEFrame::demandElementSelected
virtual void demandElementSelected()
selected demand element in DemandElementSelector
Definition: GNEFrame.cpp:165
MID_TABLE
The Table.
Definition: GUIAppEnum.h:454
GNEFrame::tagSelected
virtual void tagSelected()
Tag selected in TagSelector.
Definition: GNEFrame.cpp:159
GNEFrame::myHeaderLeftFrame
FXHorizontalFrame * myHeaderLeftFrame
fame for left header elements
Definition: GNEFrame.h:130
GNEFrame::getViewNet
GNEViewNet * getViewNet() const
get view net
Definition: GNEFrame.cpp:132
GUIDesignButtonOK
#define GUIDesignButtonOK
Definition: GUIDesigns.h:98
GNEViewNet
Definition: GNEViewNet.h:42
GUIDesignTableNotEditable
#define GUIDesignTableNotEditable
design for table extended over frame that cannot be edited
Definition: GUIDesigns.h:458
GNEViewParent::hideFramesArea
void hideFramesArea()
hide frames area if all GNEFrames are hidden
Definition: GNEViewParent.cpp:298
GUIDesigns.h
GUIIconSubSys::getIcon
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Definition: GUIIconSubSys.cpp:609
GNEFrame::myContentFrame
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
Definition: GNEFrame.h:124
GUIDesignContentsScrollWindow
#define GUIDesignContentsScrollWindow
design for the content frame of every frame
Definition: GUIDesigns.h:267
GNEFrame::myHeaderRightFrame
FXHorizontalFrame * myHeaderRightFrame
fame for right header elements
Definition: GNEFrame.h:133
GNEFrame::attributesEditorExtendedDialogOpened
virtual void attributesEditorExtendedDialogOpened()
open AttributesCreator extended dialog (can be reimplemented in frame children)
Definition: GNEFrame.cpp:190
GUIAppEnum.h
GNEFrame::myFrameHeaderLabel
FXLabel * myFrameHeaderLabel
the label for the frame's header
Definition: GNEFrame.h:143
GNEViewParent::showFramesArea
void showFramesArea()
show frames area if at least a GNEFrame is showed
Definition: GNEViewParent.cpp:288
GUIDesignLabelFrameInformation
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
Definition: GUIDesigns.h:194
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
GNEFrame::getEdgeCandidateSelectedColor
const RGBColor & getEdgeCandidateSelectedColor() const
get selected color
Definition: GNEFrame.cpp:275
GUIDesignContentsFrame
#define GUIDesignContentsFrame
design for the main content frame of every frame/dialog
Definition: GUIDesigns.h:282
RGBColor
Definition: RGBColor.h:39
SUMOXMLDefinitions::attrs
static StringBijection< int >::Entry attrs[]
The names of SUMO-XML attributes (for passing to GenericSAXHandler)
Definition: SUMOXMLDefinitions.h:1356
GNEFrame::focusUpperElement
void focusUpperElement()
focus upper element of frame
Definition: GNEFrame.cpp:101
GUIDesignHorizontalSeparator
#define GUIDesignHorizontalSeparator
Definition: GUIDesigns.h:321
GNEFrame::myEdgeCandidateColor
RGBColor myEdgeCandidateColor
edge candidate color (used by some modulds to mark edges)
Definition: GNEFrame.h:146
SUMO_ATTR_NOTHING
invalid attribute
Definition: SUMOXMLDefinitions.h:374
GNEFrame::myHeaderFrame
FXHorizontalFrame * myHeaderFrame
fame for header elements
Definition: GNEFrame.h:127
GNEViewNet.h
GNEFrame::myEdgeCandidateSelectedColor
RGBColor myEdgeCandidateSelectedColor
selected edge candidate color (used by some modulds to selected mark edges)
Definition: GNEFrame.h:149
GNEFrame::myViewNet
GNEViewNet * myViewNet
View Net.
Definition: GNEFrame.h:121
GNEFrame::getPredefinedTagsMML
const std::map< int, std::string > & getPredefinedTagsMML() const
get predefinedTagsMML
Definition: GNEFrame.cpp:281
GNEFrame::openHelpAttributesDialog
void openHelpAttributesDialog(const GNEAttributeCarrier::TagProperties &tagProperties) const
Open help attributes dialog.
Definition: GNEFrame.cpp:202
GNEViewParent.h
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
GNEFrame::selectedOverlappedElement
virtual void selectedOverlappedElement(GNEAttributeCarrier *AC)
open AttributesCreator extended dialog (can be reimplemented in frame children)
Definition: GNEFrame.cpp:196
GUIDesignDialogBoxResizable
#define GUIDesignDialogBoxResizable
design for standard dialog box (for example, about dialog)
Definition: GUIDesigns.h:442
GNEFrame::~GNEFrame
~GNEFrame()
destructor
Definition: GNEFrame.cpp:91
GNEFrame::setFrameWidth
void setFrameWidth(int newWidth)
set width of GNEFrame
Definition: GNEFrame.cpp:125
GUIDesignAuxiliarFrame
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:270
GNEFrame::shapeDrawed
virtual bool shapeDrawed()
build a shaped element using the drawed shape (can be reimplemented in frame children)
Definition: GNEFrame.cpp:177
ICON_MODEINSPECT
Definition: GUIIcons.h:226
GNEFrame::getEdgeCandidateColor
const RGBColor & getEdgeCandidateColor() const
get edge candidate color
Definition: GNEFrame.cpp:269
config.h
GNEFrame::myPredefinedTagsMML
std::map< int, std::string > myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation (needed for SUMOSAXAttributesImpl_Cach...
Definition: GNEFrame.h:152
GNEFrame.h
GNEFrame::show
virtual void show()
show Frame
Definition: GNEFrame.cpp:107
WRITE_DEBUG
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:284
GNEAttributeCarrier
Definition: GNEAttributeCarrier.h:54
GNEFrame::getFrameHeaderLabel
FXLabel * getFrameHeaderLabel() const
get the label for the frame's header
Definition: GNEFrame.cpp:138
GNEFrame::hide
virtual void hide()
hide Frame
Definition: GNEFrame.cpp:116
GNEViewNet::getViewParent
GNEViewParent * getViewParent() const
get the net object
Definition: GNEViewNet.cpp:1008
GNEAttributeCarrier::TagProperties::getNumberOfAttributes
int getNumberOfAttributes() const
get number of attributes
Definition: GNEAttributeCarrier.cpp:648