SUMO - Simulation of Urban MObility
GNEPolygonFrame.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 polygons
18 /****************************************************************************/
19 #ifndef GNEPolygonFrame_h
20 #define GNEPolygonFrame_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 GNEShape;
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
48 class GNEPolygonFrame : public GNEFrame {
50  FXDECLARE(GNEPolygonFrame)
51 
52 public:
53 
56  ADDSHAPE_SUCCESS, // Shape was successfully created
57  ADDSHAPE_NEWPOINT, // New point was sucesfully added to temporal shape
58  ADDSHAPE_INVALID, // Shape wasn't created
59  ADDSHAPE_NOTHING // Nothing to do
60  };
61 
62  // ===========================================================================
63  // class ShapeAttributeSingle
64  // ===========================================================================
65 
66  class ShapeAttributeSingle : public FXHorizontalFrame {
69 
70  public:
72  ShapeAttributeSingle(FXComposite* parent);
73 
76 
78  void showParameter(SumoXMLTag shapeTag, SumoXMLAttr shapeAttr, std::string value);
79 
81  void showParameter(SumoXMLTag shapeTag, SumoXMLAttr shapeAttr, int value);
82 
84  void showParameter(SumoXMLTag shapeTag, SumoXMLAttr shapeAttr, double value);
85 
87  void showParameter(SumoXMLTag shapeTag, SumoXMLAttr shapeAttr, bool value);
88 
90  void showParameter(SumoXMLTag shapeTag, SumoXMLAttr shapeAttr, RGBColor value);
91 
93  void hideParameter();
94 
96  SumoXMLTag getTag() const;
97 
99  SumoXMLAttr getAttr() const;
100 
102  std::string getValue() const;
103 
105  const std::string& isAttributeValid() const;
106 
110  long onCmdSetAttribute(FXObject*, FXSelector, void*);
111 
113  long onCmdSetBooleanAttribute(FXObject*, FXSelector, void*);
114 
116  long onCmdSetColorAttribute(FXObject*, FXSelector, void*);
118 
119  protected:
122 
123  private:
126 
129 
131  FXLabel* myLabel;
132 
134  FXTextField* myTextFieldInt;
135 
137  FXTextField* myTextFieldReal;
138 
140  FXTextField* myTextFieldStrings;
141 
143  FXCheckButton* myBoolCheckButton;
144 
146  FXButton* mycolorEditor;
147 
149  std::string myInvalidValue;
150  };
151 
152 
153  // ===========================================================================
154  // class ShapeAttributes
155  // ===========================================================================
156 
157  class ShapeAttributes : public FXGroupBox {
160 
161  public:
163  ShapeAttributes(GNEViewNet* viewNet, FXComposite* parent);
164 
166  ~ShapeAttributes();
167 
169  void clearAttributes();
170 
172  void addAttribute(SumoXMLTag shapeTag, SumoXMLAttr ShapeAttributeSingle);
173 
175  void showShapeParameters();
176 
178  void hideShapeParameters();
179 
181  std::map<SumoXMLAttr, std::string> getAttributesAndValues() const;
182 
184  bool areValuesValid() const;
185 
187  void showWarningMessage(std::string extra = "") const;
188 
190  int getNumberOfAddedAttributes() const;
191 
195  long onCmdHelp(FXObject*, FXSelector, void*);
197 
198  protected:
201 
202  private:
205 
208 
210  std::vector<ShapeAttributeSingle*> myVectorOfsingleShapeParameter;
211 
214 
217 
220 
223 
225  FXButton* helpShape;
226  };
227 
232  GNEPolygonFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
233 
236 
242  AddShapeResult processClick(const Position& clickedPosition, GNELane* lane);
243 
248  bool buildPoly(const PositionVector& drawedShape);
249 
253  long onCmdSelectShape(FXObject*, FXSelector, void*);
255 
257  void show();
258 
260  static std::string getIdsSelected(const FXList* list);
261 
262 protected:
265 
267  bool addPolygon(const std::map<SumoXMLAttr, std::string>& POIValues);
268 
270  bool addPOI(const std::map<SumoXMLAttr, std::string>& POIValues);
271 
273  bool addPOILane(const std::map<SumoXMLAttr, std::string>& POIValues);
274 
275 private:
277  void setParametersOfShape(SumoXMLTag actualShapeType);
278 
281 
283  FXComboBox* myShapeMatchBox;
284 
287 
290 };
291 
292 
293 #endif
294 
295 /****************************************************************************/
AddShapeResult processClick(const Position &clickedPosition, GNELane *lane)
process click over Viewnet
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::string getValue() const
return value
bool buildPoly(const PositionVector &drawedShape)
build Polygon using values of Fields and drawed shape return true if was sucesfully created ...
GNEPolygonFrame()
FOX needs this.
void setParametersOfShape(SumoXMLTag actualShapeType)
set parameters depending of the new shapeType
~GNEPolygonFrame()
Destructor.
FXTextField * myTextFieldInt
textField to modify the default value of int/float/string parameters
SumoXMLTag myShapeTag
current XML attribute
AddShapeResult
FOX-declaration.
long onCmdSetBooleanAttribute(FXObject *, FXSelector, void *)
called when user change the value of myBoolCheckButton
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:53
int myIndexParameter
Index for myVectorOfsingleShapeParameter.
GNEViewNet * myViewNet
pointer to viewNet
FXGroupBox * myGroupBoxForMyShapeMatchBox
groupBox for Match Box of shapes
FXTextField * myTextFieldReal
textField to modify the default value of real/times parameters
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void showParameter(SumoXMLTag shapeTag, SumoXMLAttr shapeAttr, std::string value)
show name and value of attribute of type string
bool addPolygon(const std::map< SumoXMLAttr, std::string > &POIValues)
add Polygon
bool addPOI(const std::map< SumoXMLAttr, std::string > &POIValues)
add POI
int maxNumberOfListParameters
max number of parameters (Defined in constructor)
FXButton * helpShape
button for help
FXTextField * myTextFieldStrings
textField to modify the default value of string parameters
FXButton * mycolorEditor
Button for open color editor.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
void hideParameter()
hide all parameters
bool addPOILane(const std::map< SumoXMLAttr, std::string > &POIValues)
add POILane
FXComboBox * myShapeMatchBox
combo box with the list of shape elements
SumoXMLTag myActualShapeType
actual shape type selected in the match Box
SumoXMLTag myShapeTag
current shape tag
int maxNumberOfParameters
max number of parameters (Defined in constructor)
void show()
show shape frame and update use selected edges/lanes
const std::string & isAttributeValid() const
returns a empty string if current value is valid, a string with information about invalid value in ot...
SumoXMLAttr getAttr() const
return Attr
std::vector< ShapeAttributeSingle * > myVectorOfsingleShapeParameter
vector with the shape parameters
GNEPolygonFrame::ShapeAttributes * myShapeAttributes
shape internal attributes
static std::string getIdsSelected(const FXList *list)
get list of selecte id&#39;s in string format
int myIndexParameterList
index for myIndexParameterList
SumoXMLTag getTag() const
return tag
SumoXMLAttr myShapeAttr
current XML attribute
FXCheckButton * myBoolCheckButton
check button to enable/disable the value of boolean parameters
long onCmdSetAttribute(FXObject *, FXSelector, void *)
long onCmdSetColorAttribute(FXObject *, FXSelector, void *)
called when user press the "Color" button
std::string myInvalidValue
string which indicates the reason due current value is invalid
long onCmdSelectShape(FXObject *, FXSelector, void *)
FXLabel * myLabel
lael with the name of the parameter