Eclipse SUMO - Simulation of Urban MObility
GNEFrameAttributesModuls.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-2020 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 // Auxiliar class for GNEFrame Moduls (only for attributes edition)
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
26 
27 // ===========================================================================
28 // class declaration
29 // ===========================================================================
30 
31 class GNEFrame;
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
36 
38 
39 public:
40  // ===========================================================================
41  // class declaration
42  // ===========================================================================
43 
44  class AttributesCreator;
45  class AttributesEditor;
48 
49  // ===========================================================================
50  // class AttributesCreatorRow
51  // ===========================================================================
52 
53  class AttributesCreatorRow : public FXHorizontalFrame {
56 
57  public:
59  AttributesCreatorRow(AttributesCreator* AttributesCreatorParent, const GNEAttributeProperties& attrProperties);
60 
62  void destroy();
63 
66 
68  std::string getValue() const;
69 
71  bool getAttributeCheckButtonCheck() const;
72 
74  void setAttributeCheckButtonCheck(bool value);
75 
78 
81 
83  bool isAttributesCreatorRowEnabled() const;
84 
86  void refreshRow() const;
87 
89  const std::string& isAttributeValid() const;
90 
93 
97  long onCmdSetAttribute(FXObject*, FXSelector, void*);
98 
100  long onCmdSelectCheckButton(FXObject*, FXSelector, void*);
101 
103  long onCmdSelectColorButton(FXObject*, FXSelector, void*);
105 
106  protected:
107  FOX_CONSTRUCTOR(AttributesCreatorRow)
108 
109 
110  std::string checkComplexAttribute(const std::string& value);
111 
113  std::string generateID() const;
114 
116  bool isValidID() const;
117 
118  private:
121 
124 
126  std::string myInvalidValue;
127 
129  FXLabel* myAttributeLabel = nullptr;
130 
132  FXCheckButton* myAttributeCheckButton = nullptr;
133 
135  FXButton* myAttributeColorButton = nullptr;
136 
138  FXTextField* myValueTextField = nullptr;
139 
141  FXCheckButton* myValueCheckButton = nullptr;
142  };
143 
144  // ===========================================================================
145  // class AttributesCreator
146  // ===========================================================================
147 
148  class AttributesCreator : public FXGroupBox {
151 
152  // declare friend class
153  friend class Row;
154 
155  public:
157  AttributesCreator(GNEFrame* frameParent);
158 
161 
166  void showAttributesCreatorModul(const GNETagProperties& tagProperties, const std::vector<SumoXMLAttr>& hiddenAttributes);
167 
170 
172  GNEFrame* getFrameParent() const;
173 
175  std::map<SumoXMLAttr, std::string> getAttributesAndValues(bool includeAll) const;
176 
179 
181  bool areValuesValid() const;
182 
184  void showWarningMessage(std::string extra = "") const;
185 
189  long onCmdHelp(FXObject*, FXSelector, void*);
191 
193  void refreshRows();
194 
195  protected:
197 
198  private:
201 
204 
207 
210 
212  FXButton* myHelpButton = nullptr;
213  };
214 
215  // ===========================================================================
216  // class AttributesCreatorFlow
217  // ===========================================================================
218 
219  class AttributesCreatorFlow : public FXGroupBox {
222 
223  public:
225  AttributesCreatorFlow(AttributesCreator* attributesCreatorParent);
226 
229 
231  void showAttributesCreatorFlowModul(const bool persons);
232 
234  void hideAttributesCreatorFlowModul();
235 
237  void refreshAttributesCreatorFlow();
238 
240  void setFlowParameters(std::map<SumoXMLAttr, std::string>& parameters);
241 
243  bool areValuesValid() const;
244 
246  void showWarningMessage(std::string extra = "") const;
247 
251  long onCmdSetFlowAttribute(FXObject*, FXSelector, void*);
252 
254  long onCmdSelectFlowRadioButton(FXObject*, FXSelector, void*);
256 
257  protected:
259 
260  private:
263 
265  FXRadioButton* myAttributeEndRadioButton = nullptr;
266 
268  FXTextField* myValueEndTextField = nullptr;
269 
271  FXRadioButton* myAttributeNumberRadioButton = nullptr;
272 
274  FXTextField* myValueNumberTextField = nullptr;
275 
277  FXRadioButton* myAttributeVehsPerHourRadioButton = nullptr;
278 
280  FXTextField* myValueVehsPerHourTextField = nullptr;
281 
283  FXRadioButton* myAttributePeriodRadioButton = nullptr;
284 
286  FXTextField* myValuePeriodTextField = nullptr;
287 
289  FXRadioButton* myAttributeProbabilityRadioButton = nullptr;
290 
292  FXTextField* myValueProbabilityTextField = nullptr;
293 
296  };
297 
298  // ===========================================================================
299  // class AttributesEditorRow
300  // ===========================================================================
301 
302  class AttributesEditorRow : protected FXHorizontalFrame {
305 
306  public:
308  AttributesEditorRow(AttributesEditor* attributeEditorParent, const GNEAttributeProperties& ACAttr, const std::string& value, bool attributeEnabled);
309 
311  void destroy();
312 
314  void refreshAttributesEditorRow(const std::string& value, bool forceRefresh, bool attributeEnabled);
315 
317  bool isAttributesEditorRowValid() const;
318 
321 
323  long onCmdSetAttribute(FXObject*, FXSelector, void*);
324 
326  long onCmdSelectCheckButton(FXObject*, FXSelector, void*);
327 
329  long onCmdOpenAttributeDialog(FXObject*, FXSelector, void*);
331 
332  protected:
334 
336  std::string stripWhitespaceAfterComma(const std::string& stringValue);
337 
338  private:
340  AttributesEditor* myAttributesEditorParent = nullptr;
341 
344 
346  const bool myMultiple;
347 
349  FXLabel* myAttributeLabel = nullptr;
350 
352  FXCheckButton* myAttributeCheckButton = nullptr;
353 
355  FXButton* myAttributeButtonCombinableChoices = nullptr;
356 
358  FXButton* myAttributeColorButton = nullptr;
359 
361  FXTextField* myValueTextField = nullptr;
362 
364  FXComboBox* myValueComboBoxChoices = nullptr;
365 
367  FXCheckButton* myValueCheckButton = nullptr;
368  };
369 
370  // ===========================================================================
371  // class AttributesEditor
372  // ===========================================================================
373 
374  class AttributesEditor : public FXGroupBox {
377 
378  public:
380  AttributesEditor(GNEFrame* inspectorFrameParent);
381 
383  void showAttributeEditorModul(bool includeExtended, bool forceAttributeEnabled);
384 
386  void hideAttributesEditorModul();
387 
389  void refreshAttributeEditor(bool forceRefreshShape, bool forceRefreshPosition);
390 
392  GNEFrame* getFrameParent() const;
393 
397  long onCmdAttributesEditorHelp(FXObject*, FXSelector, void*);
399 
400  protected:
402 
403  private:
406 
408  AttributesEditorFlow* myAttributesEditorFlow = nullptr;
409 
411  std::vector<AttributesEditorRow*> myAttributesEditorRows;
412 
414  FXButton* myHelpButton = nullptr;
415 
418  };
419 
420  // ===========================================================================
421  // class AttributesEditorFlow
422  // ===========================================================================
423 
424  class AttributesEditorFlow : protected FXGroupBox {
427 
428  public:
430  AttributesEditorFlow(AttributesEditor* attributesEditorParent);
431 
433  void showAttributeEditorFlowModul();
434 
436  void hideAttributesEditorFlowModul();
437 
439  bool isAttributesEditorFlowModulShown() const;
440 
442  void refreshAttributeEditorFlow();
443 
447  long onCmdSetFlowAttribute(FXObject*, FXSelector, void*);
448 
450  long onCmdSelectFlowRadioButton(FXObject*, FXSelector, void*);
452 
453  protected:
455 
456 
457  void refreshEnd();
458 
460  void refreshNumber();
461 
463  void refreshVehsPerHour();
464 
466  void refreshPeriod();
467 
469  void refreshProbability();
470 
471  private:
473  AttributesEditor* myAttributesEditorParent = nullptr;
474 
476  FXRadioButton* myAttributeEndRadioButton = nullptr;
477 
479  FXTextField* myValueEndTextField = nullptr;
480 
482  FXRadioButton* myAttributeNumberRadioButton = nullptr;
483 
485  FXTextField* myValueNumberTextField = nullptr;
486 
488  FXRadioButton* myAttributeVehsPerHourRadioButton = nullptr;
489 
491  FXTextField* myValueVehsPerHourTextField = nullptr;
492 
494  FXRadioButton* myAttributePeriodRadioButton = nullptr;
495 
497  FXTextField* myValuePeriodTextField = nullptr;
498 
500  FXRadioButton* myAttributeProbabilityRadioButton = nullptr;
501 
503  FXTextField* myValueProbabilityTextField = nullptr;
504  };
505 
506  // ===========================================================================
507  // class AttributesEditorExtended
508  // ===========================================================================
509 
510  class AttributesEditorExtended : protected FXGroupBox {
513 
514  public:
516  AttributesEditorExtended(GNEFrame* frameParent);
517 
520 
522  void showAttributesEditorExtendedModul();
523 
525  void hideAttributesEditorExtendedModul();
526 
530  long onCmdOpenDialog(FXObject*, FXSelector, void*);
532 
533  protected:
535 
536  private:
539  };
540 
541  // ===========================================================================
542  // class ParametersEditorCreator
543  // ===========================================================================
544 
545  class ParametersEditorCreator : private FXGroupBox {
548 
549  public:
551  ParametersEditorCreator(GNEFrame* frameParent);
552 
555 
557  void showParametersEditorCreator();
558 
560  void hideParametersEditorCreator();
561 
563  void refreshParametersEditorCreator();
564 
566  const std::map<std::string, std::string>& getParametersMap() const;
567 
569  std::string getParametersStr() const;
570 
572  std::vector<std::pair<std::string, std::string> > getParameters() const;
573 
575  void setParameters(const std::vector<std::pair<std::string, std::string> >& parameters);
576 
578  GNEFrame* getFrameParent() const;
579 
581  Parameterised::ParameterisedAttrType getAttrType() const;
582 
586  long onCmdEditParameters(FXObject*, FXSelector, void*);
587 
589  long onCmdSetParameters(FXObject*, FXSelector, void*);
591 
592  protected:
594 
595  private:
598 
601 
603  std::map<std::string, std::string> myParameters;
604 
606  FXTextField* myTextFieldParameters = nullptr;
607 
609  FXButton* myButtonEditParameters = nullptr;
610  };
611 
612  // ===========================================================================
613  // class DrawingShape
614  // ===========================================================================
615 
616  class DrawingShape : private FXGroupBox {
619 
620  public:
622  DrawingShape(GNEFrame* frameParent);
623 
625  ~DrawingShape();
626 
628  void showDrawingShape();
629 
631  void hideDrawingShape();
632 
634  void startDrawing();
635 
637  void stopDrawing();
638 
640  void abortDrawing();
641 
643  void addNewPoint(const Position& P);
644 
646  void removeLastPoint();
647 
649  const PositionVector& getTemporalShape() const;
650 
652  bool isDrawing() const;
653 
655  void setDeleteLastCreatedPoint(bool value);
656 
658  bool getDeleteLastCreatedPoint();
659 
663  long onCmdStartDrawing(FXObject*, FXSelector, void*);
664 
666  long onCmdStopDrawing(FXObject*, FXSelector, void*);
667 
669  long onCmdAbortDrawing(FXObject*, FXSelector, void*);
671 
672  protected:
674 
675  private:
678 
681 
684 
687 
690 
693 
696  };
697 
698  // ===========================================================================
699  // class NeteditAttributes
700  // ===========================================================================
701 
702  class NeteditAttributes : protected FXGroupBox {
705 
706  public:
708  NeteditAttributes(GNEFrame* frameParent);
709 
712 
714  void showNeteditAttributesModul(const GNETagProperties& tagValue);
715 
717  void hideNeteditAttributesModul();
718 
720  bool getNeteditAttributesAndValues(std::map<SumoXMLAttr, std::string>& valuesMap, const GNELane* lane) const;
721 
725  long onCmdSetNeteditAttribute(FXObject*, FXSelector, void*);
726 
728  long onCmdHelp(FXObject*, FXSelector, void*);
730 
731  protected:
733 
734  private:
740  GNE_ADDITIONALREFERENCEPOINT_INVALID
741  };
742 
744  double setStartPosition(double positionOfTheMouseOverLane, double lengthOfAdditional) const;
745 
747  double setEndPosition(double positionOfTheMouseOverLane, double lengthOfAdditional) const;
748 
751 
754 
756  FXHorizontalFrame* myLengthFrame;
757 
759  FXTextField* myLengthTextField;
760 
762  FXHorizontalFrame* myBlockMovementFrame;
763 
766 
768  FXHorizontalFrame* myBlockShapeFrame;
769 
771  FXCheckButton* myBlockShapeCheckButton;
772 
774  FXHorizontalFrame* myCloseShapeFrame;
775 
777  FXCheckButton* myCloseShapeCheckButton;
778 
780  FXHorizontalFrame* myCenterViewAfterCreationFrame;
781 
784 
787 
790 
793  };
794 
796  static bool isSupermodeValid(const GNEViewNet* viewNet, const GNEAttributeCarrier* AC);
797 
799  static bool isSupermodeValid(const GNEViewNet* viewNet, const GNEAttributeProperties& ACAttr);
800 };
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
AttributesCreator * myAttributesCreatorParent
pointer to Attributes Creator Parent
int myFlowParameters
variable used to save current flow configuration
long onCmdHelp(FXObject *, FXSelector, void *)
GNEFrame * getFrameParent() const
return frame parent
void refreshRows()
refresh rows (called after creating an element)
void showAttributesCreatorModul(const GNETagProperties &tagProperties, const std::vector< SumoXMLAttr > &hiddenAttributes)
show AttributesCreator modul
std::map< SumoXMLAttr, std::string > getAttributesAndValues(bool includeAll) const
get attributes and their values
std::vector< AttributesCreatorRow * > myAttributesCreatorRows
vector with the AttributesCreatorRow
GNEFrame * myFrameParent
pointer to Frame Parent
AttributesCreatorFlow * myAttributesCreatorFlow
pointer to myAttributesCreatorFlow
bool areValuesValid() const
check if parameters of attributes are valid
void showWarningMessage(std::string extra="") const
show warning message with information about non-valid attributes
GNETagProperties getCurrentTagProperties() const
get current edited Tag Properties
GNETagProperties myTagProperties
current edited Tag Properties
AttributesCreator * getAttributesCreatorParent() const
get AttributesCreator parent
AttributesCreatorRow(AttributesCreator *AttributesCreatorParent, const GNEAttributeProperties &attrProperties)
FOX-declaration.
long onCmdSelectCheckButton(FXObject *, FXSelector, void *)
called when user press a check button
FXTextField * myValueTextField
textField to modify the default value of string parameters
bool isAttributesCreatorRowEnabled() const
check if row is enabled
std::string myInvalidValue
string which indicates the reason due current value is invalid
FXCheckButton * myAttributeCheckButton
check button to enable/disable Label attribute
long onCmdSelectColorButton(FXObject *, FXSelector, void *)
called when user press the "Color" button
bool isValidID() const
check if current ID placed in myValueTextField is valid
FXButton * myAttributeColorButton
Button for open color editor.
void setAttributeCheckButtonCheck(bool value)
enable or disable label checkbox button for optional attributes
const std::string & isAttributeValid() const
returns a empty string if current value is valid, a string with information about invalid value in ot...
FXCheckButton * myValueCheckButton
check button to enable/disable the value of boolean parameters
const GNEAttributeProperties & getAttrProperties() const
return Attr
long onCmdSetAttribute(FXObject *, FXSelector, void *)
std::string checkComplexAttribute(const std::string &value)
check if given complex attribute is valid
FXLabel * myAttributeLabel
Label with the name of the attribute.
AttributesCreator * myAttributesCreatorParent
pointer to AttributesCreator
const GNEAttributeProperties myAttrProperties
attribute properties
void destroy()
destroy AttributesCreatorRow (but don't delete)
bool getAttributeCheckButtonCheck() const
return status of label checkbox button
std::vector< AttributesEditorRow * > myAttributesEditorRows
list of Attribute editor rows
bool myIncludeExtended
flag used to mark if current edited ACs are bein edited including extended attribute
const GNEAttributeProperties myACAttr
current AC Attribute
const bool myMultiple
flag to check if input element contains multiple values
FXButton * myStartDrawingButton
button for start drawing
PositionVector myTemporalShapeShape
current drawed shape
FXLabel * myInformationLabel
Label with information.
FXButton * myAbortDrawingButton
button for abort drawing
bool myDeleteLastCreatedPoint
flag to enable/disable delete point mode
GNEFrame * myFrameParent
pointer to frame parent
FXButton * myStopDrawingButton
button for stop drawing
FXCheckButton * myBlockShapeCheckButton
checkBox for block shape
FXTextField * myLengthTextField
textField for length
FXHorizontalFrame * myBlockShapeFrame
horizontal frame for block shape
FXCheckButton * myCenterViewAfterCreationButton
checkbox to enable/disable center element after creation
FXHorizontalFrame * myCenterViewAfterCreationFrame
horizontal frame for center view after creation frame
GNEFrame * myFrameParent
pointer to frame parent
FXHorizontalFrame * myBlockMovementFrame
horizontal frame for block movement
bool myCurrentLengthValid
Flag to check if current length is valid.
FXCheckButton * myBlockMovementCheckButton
checkBox for block movement
FXHorizontalFrame * myLengthFrame
horizontal frame for length
FXComboBox * myReferencePointMatchBox
match box with the list of reference points
FXHorizontalFrame * myCloseShapeFrame
horizontal frame for close polygon
AdditionalReferencePoint myActualAdditionalReferencePoint
actual additional reference point selected in the match Box
FXButton * helpReferencePoint
Button for help about the reference point.
FXCheckButton * myCloseShapeCheckButton
checkbox to enable/disable close polygon
Parameterised::ParameterisedAttrType myAttrType
flag for parameters type
std::map< std::string, std::string > myParameters
pointer to current map of parameters
static bool isSupermodeValid(const GNEViewNet *viewNet, const GNEAttributeCarrier *AC)
return true if AC can be edited in the current supermode
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:45
ParameterisedAttrType
@brie enum for Parameterised type
Definition: Parameterised.h:43
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
A list of positions.