Eclipse SUMO - Simulation of Urban MObility
GNEFrameAttributeModules.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-2022 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 Modules (only for attributes edition)
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
28 
29 // ===========================================================================
30 // class declaration
31 // ===========================================================================
32 
33 class GNEFrame;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
38 
40 
41 public:
42  // ===========================================================================
43  // class declaration
44  // ===========================================================================
45 
46  class AttributesCreator;
47  class AttributesEditor;
50 
51  // ===========================================================================
52  // class AttributesCreatorRow
53  // ===========================================================================
54 
55  class AttributesCreatorRow : public FXHorizontalFrame {
58 
59  public:
61  AttributesCreatorRow(AttributesCreator* AttributesCreatorParent, const GNEAttributeProperties& attrProperties);
62 
64  void destroy();
65 
68 
70  std::string getValue() const;
71 
73  bool getAttributeCheckButtonCheck() const;
74 
76  void setAttributeCheckButtonCheck(bool value);
77 
80 
83 
85  bool isAttributesCreatorRowEnabled() const;
86 
88  void refreshRow();
89 
91  void disableRow();
92 
94  bool isAttributeValid() const;
95 
98 
102  long onCmdSetAttribute(FXObject*, FXSelector, void*);
103 
105  long onCmdOpenAttributeDialog(FXObject*, FXSelector, void*);
107 
108  protected:
109  FOX_CONSTRUCTOR(AttributesCreatorRow)
110 
111 
112  std::string generateID() const;
113 
115  bool isValidID() const;
116 
117  private:
120 
123 
125  std::string myInvalidValue;
126 
128  FXLabel* myAttributeLabel = nullptr;
129 
131  FXCheckButton* myEnableAttributeCheckButton = nullptr;
132 
134  FXButton* myAttributeButton = nullptr;
135 
137  FXTextField* myValueTextField = nullptr;
138 
140  FXCheckButton* myValueCheckButton = nullptr;
141 
143  FXComboBox* myValueComboBox = nullptr;
144  };
145 
146  // ===========================================================================
147  // class AttributesCreator
148  // ===========================================================================
149 
153 
154  // declare friend class
155  friend class Row;
156 
157  public:
159  AttributesCreator(GNEFrame* frameParent);
160 
163 
165  void showAttributesCreatorModule(GNEAttributeCarrier* templateAC, const std::vector<SumoXMLAttr>& hiddenAttributes);
166 
169 
171  GNEFrame* getFrameParent() const;
172 
174  void getAttributesAndValues(CommonXMLStructure::SumoBaseObject* baseObject, bool includeAll) const;
175 
178 
180  bool areValuesValid() const;
181 
183  void showWarningMessage(std::string extra = "") const;
184 
187 
190 
194  long onCmdReset(FXObject*, FXSelector, void*);
195 
197  long onCmdHelp(FXObject*, FXSelector, void*);
198 
200 
201  protected:
203 
205  void refreshRows(const bool createRows);
206 
207  private:
210 
213 
216 
219 
222 
224  FXHorizontalFrame* myFrameButtons = nullptr;
225 
227  FXButton* myResetButton = nullptr;
228  };
229 
230  // ===========================================================================
231  // class AttributesCreatorFlow
232  // ===========================================================================
233 
237 
238  public:
240  AttributesCreatorFlow(AttributesCreator* attributesCreatorParent);
241 
244 
246  void showAttributesCreatorFlowModule();
247 
249  void hideAttributesCreatorFlowModule();
250 
252  bool shownAttributesCreatorFlowModule() const;
253 
255  void refreshAttributesCreatorFlow();
256 
258  void setFlowParameters(CommonXMLStructure::SumoBaseObject* baseObject);
259 
261  bool areValuesValid() const;
262 
264  void showWarningMessage(std::string extra = "") const;
265 
269  long onCmdSetFlowAttribute(FXObject*, FXSelector, void*);
270 
272  long onCmdSelectFlowRadioButton(FXObject*, FXSelector, void*);
274 
275  protected:
277 
278  private:
281 
283  FXRadioButton* myAttributeEndRadioButton = nullptr;
284 
286  FXTextField* myValueEndTextField = nullptr;
287 
289  FXRadioButton* myAttributeNumberRadioButton = nullptr;
290 
292  FXTextField* myValueNumberTextField = nullptr;
293 
295  FXRadioButton* myAttributeVehsPerHourRadioButton = nullptr;
296 
298  FXTextField* myValueVehsPerHourTextField = nullptr;
299 
301  FXRadioButton* myAttributePeriodRadioButton = nullptr;
302 
304  FXTextField* myValuePeriodTextField = nullptr;
305 
307  FXRadioButton* myAttributeProbabilityRadioButton = nullptr;
308 
310  FXTextField* myValueProbabilityTextField = nullptr;
311 
314  };
315 
316  // ===========================================================================
317  // class AttributesEditorRow
318  // ===========================================================================
319 
320  class AttributesEditorRow : protected FXHorizontalFrame {
323 
324  public:
326  AttributesEditorRow(AttributesEditor* attributeEditorParent, const GNEAttributeProperties& ACAttr, const std::string& value,
327  const bool attributeEnabled, const bool computed);
328 
330  void destroy();
331 
333  void refreshAttributesEditorRow(const std::string& value, const bool forceRefresh, const bool attributeEnabled, const bool computed);
334 
336  bool isAttributesEditorRowValid() const;
337 
340 
342  long onCmdSetAttribute(FXObject*, FXSelector, void*);
343 
345  long onCmdSelectCheckButton(FXObject*, FXSelector, void*);
346 
348  long onCmdOpenAttributeDialog(FXObject*, FXSelector, void*);
350 
351  protected:
354 
356  std::string stripWhitespaceAfterComma(const std::string& stringValue);
357 
359  bool mergeJunction(SumoXMLAttr attr, const std::vector<GNEAttributeCarrier*>& inspectedACs, const std::string& newVal) const;
360 
361  private:
364 
367 
369  const bool myMultiple;
370 
372  FXLabel* myAttributeLabel = nullptr;
373 
375  FXCheckButton* myAttributeCheckButton = nullptr;
376 
378  FXButton* myAttributeButtonCombinableChoices = nullptr;
379 
381  FXButton* myAttributeColorButton = nullptr;
382 
384  FXTextField* myValueTextField = nullptr;
385 
387  FXComboBox* myValueComboBoxChoices = nullptr;
388 
390  FXCheckButton* myValueCheckButton = nullptr;
391  };
392 
393  // ===========================================================================
394  // class AttributesEditor
395  // ===========================================================================
396 
400 
401  public:
403  AttributesEditor(GNEFrame* inspectorFrameParent);
404 
406  void showAttributeEditorModule(bool includeExtended, bool forceAttributeEnabled);
407 
409  void hideAttributesEditorModule();
410 
412  void refreshAttributeEditor(bool forceRefreshShape, bool forceRefreshPosition);
413 
415  GNEFrame* getFrameParent() const;
416 
420  long onCmdAttributesEditorHelp(FXObject*, FXSelector, void*);
422 
423  protected:
426 
427  private:
430 
432  AttributesEditorFlow* myAttributesEditorFlow = nullptr;
433 
435  std::vector<AttributesEditorRow*> myAttributesEditorRows;
436 
438  FXButton* myHelpButton = nullptr;
439 
442  };
443 
444  // ===========================================================================
445  // class AttributesEditorFlow
446  // ===========================================================================
447 
451 
452  public:
454  AttributesEditorFlow(AttributesEditor* attributesEditorParent);
455 
457  void showAttributeEditorFlowModule();
458 
460  void hideAttributesEditorFlowModule();
461 
463  bool isAttributesEditorFlowModuleShown() const;
464 
466  void refreshAttributeEditorFlow();
467 
471  long onCmdSetFlowAttribute(FXObject*, FXSelector, void*);
472 
474  long onCmdSelectFlowRadioButton(FXObject*, FXSelector, void*);
476 
477  protected:
479 
480 
481  void refreshEnd();
482 
484  void refreshNumber();
485 
487  void refreshVehsPerHour();
488 
490  void refreshPeriod();
491 
493  void refreshProbability();
494 
495  private:
497  AttributesEditor* myAttributesEditorParent = nullptr;
498 
500  FXRadioButton* myAttributeEndRadioButton = nullptr;
501 
503  FXTextField* myValueEndTextField = nullptr;
504 
506  FXRadioButton* myAttributeNumberRadioButton = nullptr;
507 
509  FXTextField* myValueNumberTextField = nullptr;
510 
512  FXRadioButton* myAttributeVehsPerHourRadioButton = nullptr;
513 
515  FXTextField* myValueVehsPerHourTextField = nullptr;
516 
518  FXRadioButton* myAttributePeriodRadioButton = nullptr;
519 
521  FXTextField* myValuePeriodTextField = nullptr;
522 
524  FXRadioButton* myAttributeProbabilityRadioButton = nullptr;
525 
527  FXTextField* myValueProbabilityTextField = nullptr;
528  };
529 
530  // ===========================================================================
531  // class AttributesEditorExtended
532  // ===========================================================================
533 
537 
538  public:
540  AttributesEditorExtended(GNEFrame* frameParent);
541 
544 
546  void showAttributesEditorExtendedModule();
547 
549  void hideAttributesEditorExtendedModule();
550 
554  long onCmdOpenDialog(FXObject*, FXSelector, void*);
556 
557  protected:
559 
560  private:
563  };
564 
565  // ===========================================================================
566  // class GenericDataAttributes
567  // ===========================================================================
568 
572 
573  public:
575  GenericDataAttributes(GNEFrame* frameParent);
576 
579 
581  void showGenericDataAttributes();
582 
584  void hideGenericDataAttributes();
585 
587  void refreshGenericDataAttributes();
588 
590  const std::map<std::string, std::string>& getParametersMap() const;
591 
593  std::string getParametersStr() const;
594 
596  std::vector<std::pair<std::string, std::string> > getParameters() const;
597 
599  void setParameters(const std::vector<std::pair<std::string, std::string> >& parameters);
600 
602  GNEFrame* getFrameParent() const;
603 
607  long onCmdEditParameters(FXObject*, FXSelector, void*);
608 
610  long onCmdSetParameters(FXObject*, FXSelector, void*);
612 
613  protected:
615 
616  private:
619 
621  std::map<std::string, std::string> myParameters;
622 
624  FXTextField* myTextFieldParameters = nullptr;
625 
627  FXButton* myButtonEditParameters = nullptr;
628  };
629 
630  // ===========================================================================
631  // class DrawingShape
632  // ===========================================================================
633 
637 
638  public:
640  DrawingShape(GNEFrame* frameParent);
641 
643  ~DrawingShape();
644 
646  void showDrawingShape();
647 
649  void hideDrawingShape();
650 
652  void startDrawing();
653 
655  void stopDrawing();
656 
658  void abortDrawing();
659 
661  void addNewPoint(const Position& P);
662 
664  void removeLastPoint();
665 
667  const PositionVector& getTemporalShape() const;
668 
670  bool isDrawing() const;
671 
673  void setDeleteLastCreatedPoint(bool value);
674 
676  bool getDeleteLastCreatedPoint();
677 
681  long onCmdStartDrawing(FXObject*, FXSelector, void*);
682 
684  long onCmdStopDrawing(FXObject*, FXSelector, void*);
685 
687  long onCmdAbortDrawing(FXObject*, FXSelector, void*);
689 
690  protected:
692 
693  private:
696 
699 
702 
705 
708 
711 
714  };
715 
716  // ===========================================================================
717  // class NeteditAttributes
718  // ===========================================================================
719 
723 
724  public:
726  NeteditAttributes(GNEFrame* frameParent);
727 
730 
732  void showNeteditAttributesModule(const GNETagProperties& tagValue);
733 
735  void hideNeteditAttributesModule();
736 
738  bool getNeteditAttributesAndValues(CommonXMLStructure::SumoBaseObject* baseObject, const GNELane* lane) const;
739 
743  long onCmdSetNeteditAttribute(FXObject*, FXSelector, void*);
744 
746  long onCmdHelp(FXObject*, FXSelector, void*);
748 
749  protected:
751 
752  private:
755  LEFT,
756  RIGHT,
757  CENTER,
758  INVALID
759  };
760 
762  double setStartPosition(double positionOfTheMouseOverLane, double lengthOfAdditional) const;
763 
765  double setEndPosition(double positionOfTheMouseOverLane, double lengthOfAdditional) const;
766 
769 
772 
774  FXHorizontalFrame* myLengthFrame;
775 
777  FXTextField* myLengthTextField;
778 
780  FXHorizontalFrame* myCloseShapeFrame;
781 
783  FXCheckButton* myCloseShapeCheckButton;
784 
786  FXHorizontalFrame* myCenterViewAfterCreationFrame;
787 
790 
793 
796 
799  };
800 
802  static bool isSupermodeValid(const GNEViewNet* viewNet, const GNEAttributeCarrier* AC);
803 
805  static bool isSupermodeValid(const GNEViewNet* viewNet, const GNEAttributeProperties& ACAttr);
806 };
@ RIGHT
At the rightmost side of the lane.
@ LEFT
At the leftmost side of the lane.
@ CENTER
At the center of the lane.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NOTHING
invalid attribute
FXGroupBoxModule (based on FXGroupBox)
AttributesCreator * myAttributesCreatorParent
pointer to Attributes Creator Parent
GNEAttributeCarrier * getCurrentTemplateAC() const
get current template AC
void showWarningMessage(std::string extra="") const
show warning message with information about non-valid attributes
AttributesCreatorFlow * myAttributesCreatorFlow
pointer to myAttributesCreatorFlow
bool areValuesValid() const
check if parameters of attributes are valid
void refreshAttributesCreator()
refresh attribute creator
GNEAttributeCarrier * myTemplateAC
current templateAC
void showAttributesCreatorModule(GNEAttributeCarrier *templateAC, const std::vector< SumoXMLAttr > &hiddenAttributes)
show AttributesCreator modul
GNEFrame * myFrameParent
pointer to Frame Parent
void getAttributesAndValues(CommonXMLStructure::SumoBaseObject *baseObject, bool includeAll) const
get attributes and their values
GNEFrame * getFrameParent() const
return frame parent
void disableAttributesCreator()
disable AttributesCreator
std::vector< AttributesCreatorRow * > myAttributesCreatorRows
vector with the AttributesCreatorRow
long onCmdHelp(FXObject *, FXSelector, void *)
Called when help button is pressed.
std::vector< SumoXMLAttr > myHiddenAttributes
hidden attributes
void refreshRows(const bool createRows)
refresh rows
long onCmdReset(FXObject *, FXSelector, void *)
long onCmdOpenAttributeDialog(FXObject *, FXSelector, void *)
called when user press the open dialog button
AttributesCreator * myAttributesCreatorParent
pointer to AttributesCreator
std::string myInvalidValue
string which indicates the reason due current value is invalid
bool isAttributesCreatorRowEnabled() const
check if row is enabled
const GNEAttributeProperties & getAttrProperties() const
return Attr
long onCmdSetAttribute(FXObject *, FXSelector, void *)
AttributesCreator * getAttributesCreatorParent() const
get AttributesCreator parent
FXTextField * myValueTextField
textField to modify the default value of string parameters
void setAttributeCheckButtonCheck(bool value)
enable or disable label checkbox button for optional attributes
void destroy()
destroy AttributesCreatorRow (but don't delete)
FXButton * myAttributeButton
Button for open color or allow/disallow editor.
bool isAttributeValid() const
check if current attribute is valid
AttributesCreatorRow(AttributesCreator *AttributesCreatorParent, const GNEAttributeProperties &attrProperties)
FOX-declaration.
FXCheckButton * myValueCheckButton
check button to enable/disable the value of boolean parameters
bool isValidID() const
check if current ID placed in myValueTextField is valid
const GNEAttributeProperties myAttrProperties
attribute properties
FXComboBox * myValueComboBox
comboBox for discrete vaues
FXLabel * myAttributeLabel
Label with the name of the attribute.
bool getAttributeCheckButtonCheck() const
return status of label checkbox button
FXCheckButton * myEnableAttributeCheckButton
check button to enable/disable Label attribute
bool myIncludeExtended
flag used to mark if current edited ACs are bein edited including extended attribute
std::vector< AttributesEditorRow * > myAttributesEditorRows
list of Attribute editor rows
const GNEAttributeProperties myACAttr
current AC Attribute
const bool myMultiple
flag to check if input element contains multiple values
AttributesEditor * myAttributesEditorParent
pointer to AttributesEditor parent
FXButton * myStartDrawingButton
button for start drawing
bool myDeleteLastCreatedPoint
flag to enable/disable delete point mode
PositionVector myTemporalShapeShape
current drawed shape
FXButton * myStopDrawingButton
button for stop drawing
FXButton * myAbortDrawingButton
button for abort drawing
GNEFrame * myFrameParent
pointer to frame parent
FXLabel * myInformationLabel
Label with information.
std::map< std::string, std::string > myParameters
pointer to current map of parameters
FXButton * helpReferencePoint
Button for help about the reference point.
FXHorizontalFrame * myCenterViewAfterCreationFrame
horizontal frame for center view after creation frame
AdditionalReferencePoint myActualAdditionalReferencePoint
actual additional reference point selected in the match Box
FXHorizontalFrame * myCloseShapeFrame
horizontal frame for close polygon
FXHorizontalFrame * myLengthFrame
horizontal frame for length
GNEFrame * myFrameParent
pointer to frame parent
FXComboBox * myReferencePointMatchBox
match box with the list of reference points
FXCheckButton * myCenterViewAfterCreationButton
checkbox to enable/disable center element after creation
bool myCurrentLengthValid
Flag to check if current length is valid.
FXTextField * myLengthTextField
textField for length
FXCheckButton * myCloseShapeCheckButton
checkbox to enable/disable close polygon
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:46
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.