SUMO - Simulation of Urban MObility
GNEAdditionalFrame.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // The Widget for add additional elements
18 /****************************************************************************/
19 #ifndef GNEAdditionalFrame_h
20 #define GNEAdditionalFrame_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include "GNEFrame.h"
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
38 class GNENetElement;
39 class GNEAdditional;
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
48 class GNEAdditionalFrame : public GNEFrame {
50  FXDECLARE(GNEAdditionalFrame)
51 
52 public:
53 
56  ADDADDITIONAL_INVALID_ARGUMENTS, // Parameters of additionals are invalid
57  ADDADDITIONAL_INVALID_PARENT, // NetElement parent is invalid
58  ADDADDITIONAL_SUCCESS // additional was successfully created
59  };
60 
61  // ===========================================================================
62  // class AdditionalAttributeSingle
63  // ===========================================================================
64 
65  class AdditionalAttributeSingle : public FXHorizontalFrame {
68 
69  public:
71  AdditionalAttributeSingle(FXComposite* parent);
72 
75 
77  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, std::string value);
78 
80  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, int value);
81 
83  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, double value);
84 
86  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, bool value);
87 
89  void hideParameter();
90 
92  SumoXMLTag getTag() const;
93 
95  SumoXMLAttr getAttr() const;
96 
98  std::string getValue() const;
99 
101  const std::string& isAttributeValid() const;
102 
106  long onCmdSetAttribute(FXObject*, FXSelector, void*);
107 
109  long onCmdSetBooleanAttribute(FXObject*, FXSelector, void*);
111 
112  protected:
115 
116  private:
119 
122 
124  FXLabel* myLabel;
125 
127  FXTextField* myTextFieldInt;
128 
130  FXTextField* myTextFieldReal;
131 
133  FXTextField* myTextFieldStrings;
134 
136  FXCheckButton* myBoolCheckButton;
137 
139  std::string myInvalidValue;
140  };
141 
142  // ===========================================================================
143  // class AdditionalAttributeList
144  // ===========================================================================
145 
146  class AdditionalAttributeList : public FXVerticalFrame {
149 
150  public:
152  AdditionalAttributeList(FXComposite* parent);
153 
156 
158  void showListParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, std::vector<int> value);
159 
161  void showListParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, std::vector<double> value, bool isTime = false);
162 
164  void showListParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, std::vector<bool> value);
165 
167  void showListParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, std::vector<std::string> value);
168 
170  void hideParameter();
171 
173  SumoXMLTag getTag() const;
174 
176  SumoXMLAttr getAttr() const;
177 
179  std::string getListValues();
180 
182  bool isCurrentListValid() const;
183 
187  long onCmdAddRow(FXObject*, FXSelector, void*);
188 
190  long onCmdRemoveRow(FXObject*, FXSelector, void*);
192 
193  protected:
196 
197  private:
200 
203 
205  std::vector<FXHorizontalFrame*>myHorizontalFrames;
206 
208  std::vector<FXLabel*> myLabels;
209 
211  std::vector<FXTextField*> myTextFields;
212 
214  FXHorizontalFrame* myHorizontalFrameButtons;
215 
217  FXButton* myAddButton;
218 
220  FXButton* myRemoveButton;
221 
224 
227  };
228 
229  // ===========================================================================
230  // class AdditionalAttributes
231  // ===========================================================================
232 
233  class AdditionalAttributes : public FXGroupBox {
236 
237  public:
239  AdditionalAttributes(GNEViewNet* viewNet, FXComposite* parent);
240 
243 
245  void clearAttributes();
246 
248  void addAttribute(SumoXMLTag additionalTag, SumoXMLAttr AdditionalAttributeSingle);
249 
251  void showAdditionalParameters();
252 
254  void hideAdditionalParameters();
255 
257  std::map<SumoXMLAttr, std::string> getAttributesAndValues() const;
258 
260  bool areValuesValid() const;
261 
263  void showWarningMessage(std::string extra = "") const;
264 
266  int getNumberOfAddedAttributes() const;
267 
271  long onCmdHelp(FXObject*, FXSelector, void*);
273 
274  protected:
277 
278  private:
281 
284 
286  std::vector<AdditionalAttributeSingle*> myVectorOfsingleAdditionalParameter;
287 
290 
292  std::vector<AdditionalAttributeList*> myVectorOfsingleAdditionalParameterList;
293 
296 
299 
302 
304  FXButton* helpAdditional;
305  };
306 
307  // ===========================================================================
308  // class NeteditAttributes
309  // ===========================================================================
310 
311  class NeteditAttributes : public FXGroupBox {
314 
315  public:
321  GNE_ADDITIONALREFERENCEPOINT_INVALID
322  };
323 
325  NeteditAttributes(FXComposite* parent);
326 
329 
331  void showLengthFieldAndReferecePoint();
332 
334  void hideLengthFieldAndReferecePoint();
335 
337  additionalReferencePoint getActualReferencePoint() const;
338 
340  double getLength() const;
341 
343  bool isBlockEnabled() const;
344 
346  bool isCurrentLengthValid() const;
347 
351  long onCmdSetLength(FXObject*, FXSelector, void*);
352 
354  long onCmdSelectReferencePoint(FXObject*, FXSelector, void*);
355 
357  long onCmdSetBlocking(FXObject*, FXSelector, void*);
358 
360  long onCmdHelp(FXObject*, FXSelector, void*);
362 
363  protected:
366 
367  private:
370 
373 
376 
378  FXLabel* myLengthLabel;
379 
381  FXTextField* myLengthTextField;
382 
384  FXLabel* myBlockLabel;
385 
388 
391  };
392 
393  // ===========================================================================
394  // class SelectorParentAdditional
395  // ===========================================================================
396 
397  class SelectorParentAdditional : public FXGroupBox {
400 
401  public:
403  SelectorParentAdditional(FXComposite* parent, GNEViewNet* viewNet);
404 
407 
409  std::string getIdSelected() const;
410 
412  void showListOfAdditionals(SumoXMLTag type, bool uniqueSelection);
413 
415  void hideListOfAdditionals();
416 
420  long onCmdSelectAdditionalParent(FXObject*, FXSelector, void*);
421 
423  long onCmdHelp(FXObject*, FXSelector, void*);
425 
426  protected:
429 
430  private:
431 
433  FXList* myList;
434 
436  FXLabel* mySetLabel;
437 
440 
443 
446  };
447 
448  // ===========================================================================
449  // class SelectorParentEdges
450  // ===========================================================================
451 
452  class SelectorParentEdges : public FXGroupBox {
455 
456  public:
458  SelectorParentEdges(FXComposite* parent, GNEViewNet* viewNet);
459 
462 
464  std::string getIdsSelected() const;
465 
467  void showList(std::string search = "");
468 
470  void hideList();
471 
473  void updateUseSelectedEdges();
474 
476  bool isUseSelectedEdgesEnable() const;
477 
481  long onCmdUseSelectedEdges(FXObject*, FXSelector, void*);
482 
484  long onCmdTypeInSearchBox(FXObject*, FXSelector, void*);
485 
487  long onCmdSelectEdge(FXObject*, FXSelector, void*);
488 
490  long onCmdClearSelection(FXObject*, FXSelector, void*);
491 
493  long onCmdInvertSelection(FXObject*, FXSelector, void*);
494 
496  long onCmdHelp(FXObject*, FXSelector, void*);
498 
499  protected:
502 
503  private:
506 
508  FXList* myList;
509 
511  FXTextField* myEdgesSearch;
512 
515 
518 
521 
524  };
525 
526  // ===========================================================================
527  // class SelectorParentLanes
528  // ===========================================================================
529 
530  class SelectorParentLanes : public FXGroupBox {
533 
534  public:
536  SelectorParentLanes(FXComposite* parent, GNEViewNet* viewNet);
537 
540 
542  std::string getIdsSelected() const;
543 
545  void showList(std::string search = "");
546 
548  void hideList();
549 
550  // @brief Update use selectedLanes
551  void updateUseSelectedLanes();
552 
554  bool isUseSelectedLanesEnable() const;
555 
559  long onCmdUseSelectedLanes(FXObject*, FXSelector, void*);
560 
562  long onCmdTypeInSearchBox(FXObject*, FXSelector, void*);
563 
565  long onCmdSelectLane(FXObject*, FXSelector, void*);
566 
568  long onCmdClearSelection(FXObject*, FXSelector, void*);
569 
571  long onCmdInvertSelection(FXObject*, FXSelector, void*);
572 
574  long onCmdHelp(FXObject*, FXSelector, void*);
576 
577  protected:
580 
581  private:
584 
586  FXList* myList;
587 
589  FXTextField* myLanesSearch;
590 
592  FXButton* helpLanes;
593 
596 
599 
602  };
603 
608  GNEAdditionalFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
609 
612 
618  AddAdditionalResult addAdditional(GNENetElement* netElement, GUISUMOAbstractView* abstractViewParent);
619 
623  void removeAdditional(GNEAdditional* additional);
624 
628  long onCmdSelectAdditional(FXObject*, FXSelector, void*);
630 
632  void show();
633 
635  static std::string getIdsSelected(const FXList* list);
636 
637 protected:
640 
641 private:
643  void setParametersOfAdditional(SumoXMLTag actualAdditionalType);
644 
646  std::string generateID(GNENetElement* netElement) const;
647 
649  double setStartPosition(double positionOfTheMouseOverLane, double lengthOfAdditional);
650 
652  double setEndPosition(double laneLength, double positionOfTheMouseOverLane, double lengthOfAdditional);
653 
656 
658  FXComboBox* myAdditionalMatchBox;
659 
662 
665 
668 
671 
674 
677 };
678 
679 
680 #endif
681 
682 /****************************************************************************/
double setStartPosition(double positionOfTheMouseOverLane, double lengthOfAdditional)
obtain the Start position values of StoppingPlaces and E2 detector over the lane
int maxNumberOfListParameters
max number of parameters (Defined in constructor)
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr myAdditionalAttr
current XML attribute
additionalReferencePoint myActualAdditionalReferencePoint
actual additional reference point selected in the match Box
AddAdditionalResult addAdditional(GNENetElement *netElement, GUISUMOAbstractView *abstractViewParent)
add additional element
int maxNumberOfParameters
max number of parameters (Defined in constructor)
GNEViewNet * myViewNet
pointer to viewNet
FXCheckButton * myUseSelectedLanesCheckButton
CheckBox for selected lanes.
FXButton * myRemoveButton
Button to decrease the number of textFields.
GNEAdditionalFrame::AdditionalAttributes * myadditionalParameters
additional internal attributes
int myNumberOfVisibleTextfields
number of visible text fields
FXList * myList
List of additional sets.
FXTextField * myTextFieldStrings
textField to modify the default value of string parameters
FXComboBox * myReferencePointMatchBox
match box with the list of reference points
double setEndPosition(double laneLength, double positionOfTheMouseOverLane, double lengthOfAdditional)
obtain the End position values of StoppingPlaces and E2 detector over the lane
FXCheckButton * myBoolCheckButton
check button to enable/disable the value of boolean parameters
FXButton * myClearEdgesSelection
button for clear selection
std::string myInvalidValue
string which indicates the reason due current value is invalid
long onCmdSelectAdditional(FXObject *, FXSelector, void *)
int myIndexParameter
Index for myVectorOfsingleAdditionalParameter.
FXTextField * myLengthTextField
textField for length
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
GNEViewNet * myViewNet
viewNet associated to GNEAdditionalFrame
void setParametersOfAdditional(SumoXMLTag actualAdditionalType)
set parameters depending of the new additionalType
bool myCurrentLengthValid
Flag to check if current length is valid.
FXTextField * myEdgesSearch
text field for search edge IDs
FXButton * myInvertEdgesSelection
button for invert selection
FXCheckButton * myUseSelectedEdgesCheckButton
CheckBox for selected edges.
FXButton * clearLanesSelection
button for clear selection
FXLabel * myLengthLabel
Label for length.
long onCmdSetAttribute(FXObject *, FXSelector, void *)
FXList * myList
List of SelectorParentLanes.
std::vector< FXLabel * > myLabels
vector with with the name of every parameter
int myIndexParameterList
index for myIndexParameterList
SumoXMLTag myActualAdditionalType
actual additional type selected in the match Box
FXButton * myHelpAdditionalParentSelector
button for help
void removeAdditional(GNEAdditional *additional)
remove an additional element previously added
SumoXMLAttr myAdditionalAttr
current XML attribute
~GNEAdditionalFrame()
Destructor.
FXLabel * myBlockLabel
Label for block movement.
FXComboBox * myAdditionalMatchBox
combo box with the list of additional elements
FXTextField * myLanesSearch
text field for search lane IDs
GNEAdditionalFrame::NeteditAttributes * myEditorParameters
Netedit parameter.
std::vector< FXTextField * > myTextFields
vector textField to modify the value of parameter
FXButton * myAddButton
Button to increase the number of textFields.
FXGroupBox * myGroupBoxForMyAdditionalMatchBox
groupBox for Match Box of additionals
GNEAdditionalFrame::SelectorParentLanes * mylaneParentsSelector
list of SelectorParentLanes
GNEAdditionalFrame::SelectorParentEdges * myedgeParentsSelector
list of SelectorParentEdges
FXList * myList
List of SelectorParentEdges.
SumoXMLTag myAdditionalTag
current XML attribute
FXLabel * myLabel
lael with the name of the parameter
AddAdditionalResult
FOX-declaration.
SumoXMLTag myAdditionalTag
current additional tag
GNEAdditionalFrame()
FOX needs this.
FXLabel * mySetLabel
Label with the name of additional.
void show()
show additional frame and update use selected edges/lanes
void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, std::string value)
show name and value of attribute of type string
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:59
GNEViewNet * myViewNet
viewNet associated to GNEAdditionalFrame
bool myUniqueSelection
flag to check if only a single parent is allowed
long onCmdSetBooleanAttribute(FXObject *, FXSelector, void *)
called when user change the value of myBoolCheckButton
std::string generateID(GNENetElement *netElement) const
generate a ID for an additiona element
const std::string & isAttributeValid() const
returns a empty string if current value is valid, a string with information about invalid value in ot...
FXButton * invertLanesSelection
button for invert selection
GNEAdditionalFrame::SelectorParentAdditional * myAdditionalParentSelector
list of additional Set
FXTextField * myTextFieldInt
textField to modify the default value of int/float/string parameters
static std::string getIdsSelected(const FXList *list)
get list of selecte id&#39;s in string format
FXHorizontalFrame * myHorizontalFrameButtons
horizontal frame for buttons
std::vector< FXHorizontalFrame * > myHorizontalFrames
Vector with HorizontalFrames.
int myMaxNumberOfValuesInParameterList
Number max of values in a parameter of type list.
GNEViewNet * myViewNet
viewNet associated to GNEAdditionalFrame
std::vector< AdditionalAttributeSingle * > myVectorOfsingleAdditionalParameter
vector with the additional parameters
std::vector< AdditionalAttributeList * > myVectorOfsingleAdditionalParameterList
vector with the additional parameters of type list
FXCheckButton * myBlockMovementCheckButton
checkBox for block movement
FXTextField * myTextFieldReal
textField to modify the default value of real/times parameters
FXButton * helpReferencePoint
Button for help about the reference point.
FXButton * myHelpedgeParentsSelector
button for help