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