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-2018 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 polygons
16 /****************************************************************************/
17 #ifndef GNEPolygonFrame_h
18 #define GNEPolygonFrame_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "GNEFrame.h"
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
32 class GNENetElement;
33 class GNEShape;
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
42 class GNEPolygonFrame : public GNEFrame {
43 
44 public:
45 
48  ADDSHAPE_SUCCESS, // Shape was successfully created
49  ADDSHAPE_NEWPOINT, // New point was sucesfully added to temporal shape
50  ADDSHAPE_INVALID, // Shape wasn't created
51  ADDSHAPE_NOTHING // Nothing to do
52  };
53 
55  class ShapeAttributes;
56 
57  // ===========================================================================
58  // class ShapeSelector
59  // ===========================================================================
60 
61  class ShapeSelector : public FXGroupBox {
64 
65  public:
67  ShapeSelector(GNEPolygonFrame* shapeFrameParent);
68 
71 
74 
76  void setCurrentShape(SumoXMLTag actualShapeType);
77 
81  long onCmdselectAttributeCarrier(FXObject*, FXSelector, void*);
83 
84  protected:
87 
88  private:
91 
93  FXComboBox* myShapeMatchBox;
94 
97  };
98 
99  // ===========================================================================
100  // class ShapeAttributeSingle
101  // ===========================================================================
102 
103  class ShapeAttributeSingle : public FXHorizontalFrame {
106 
107  public:
109  ShapeAttributeSingle(ShapeAttributes* shapeAttributesParent);
110 
113 
115  void showParameter(SumoXMLAttr shapeAttr, std::string value);
116 
118  void hideParameter();
119 
121  SumoXMLAttr getAttr() const;
122 
124  std::string getValue() const;
125 
127  const std::string& isAttributeValid() const;
128 
130  ShapeAttributes* getShapeAttributesParent() const;
131 
135  long onCmdSetAttribute(FXObject*, FXSelector, void*);
136 
138  long onCmdSetBooleanAttribute(FXObject*, FXSelector, void*);
139 
141  long onCmdSetColorAttribute(FXObject*, FXSelector, void*);
143 
144  protected:
147 
148  private:
151 
154 
156  FXLabel* myLabel;
157 
159  FXTextField* myTextFieldInt;
160 
162  FXTextField* myTextFieldReal;
163 
165  FXTextField* myTextFieldStrings;
166 
168  FXCheckButton* myBoolCheckButton;
169 
171  FXButton* myColorEditor;
172 
174  std::string myInvalidValue;
175  };
176 
177  // ===========================================================================
178  // class ShapeAttributes
179  // ===========================================================================
180 
181  class ShapeAttributes : public FXGroupBox {
184 
185  public:
187  ShapeAttributes(GNEPolygonFrame* polygonFrameParent);
188 
190  ~ShapeAttributes();
191 
193  void clearAttributes();
194 
196  void addAttribute(SumoXMLAttr ShapeAttributeSingle);
197 
199  void showShapeParameters();
200 
202  void hideShapeParameters();
203 
205  std::map<SumoXMLAttr, std::string> getAttributesAndValues() const;
206 
208  bool areValuesValid() const;
209 
211  void showWarningMessage(std::string extra = "") const;
212 
214  int getNumberOfAddedAttributes() const;
215 
217  GNEPolygonFrame* getPolygonFrameParent() const;
218 
222  long onCmdHelp(FXObject*, FXSelector, void*);
224 
225  protected:
228 
229  private:
232 
234  std::vector<ShapeAttributeSingle*> myVectorOfsingleShapeParameter;
235  };
236 
237  // ===========================================================================
238  // class NeteditAttributes
239  // ===========================================================================
240 
241  class NeteditAttributes : private FXGroupBox {
244 
245  public:
247  NeteditAttributes(GNEPolygonFrame* polygonFrameParent);
248 
251 
253  void showNeteditAttributes(bool shapeEditing);
254 
256  void hideNeteditAttributes();
257 
259  bool isBlockMovementEnabled() const;
260 
262  bool isBlockShapeEnabled() const;
263 
265  bool isCloseShapeEnabled() const;
266 
270  long onCmdSetNeteditAttribute(FXObject*, FXSelector, void*);
271 
273  long onCmdHelp(FXObject*, FXSelector, void*);
275 
276  protected:
279 
280  private:
283 
286 
288  FXHorizontalFrame* myBlockShapeFrame;
289 
292 
294  FXCheckButton* myBlockShapeCheckButton;
295 
297  FXHorizontalFrame* myClosePolygonFrame;
298 
301 
304  };
305 
306  // ===========================================================================
307  // class DrawingMode
308  // ===========================================================================
309 
310  class DrawingMode : private FXGroupBox {
313 
314  public:
316  DrawingMode(GNEPolygonFrame* polygonFrameParent);
317 
319  ~DrawingMode();
320 
322  void showDrawingMode();
323 
325  void hideDrawingMode();
326 
328  void startDrawing();
329 
331  void stopDrawing();
332 
334  void abortDrawing();
335 
337  void addNewPoint(const Position& P);
338 
340  void removeLastPoint();
341 
343  const PositionVector& getTemporalShape() const;
344 
346  bool isDrawing() const;
347 
351  long onCmdStartDrawing(FXObject*, FXSelector, void*);
352 
354  long onCmdStopDrawing(FXObject*, FXSelector, void*);
355 
357  long onCmdAbortDrawing(FXObject*, FXSelector, void*);
359 
360  protected:
363 
364  private:
367 
370 
373 
376 
379 
382  };
383 
388  GNEPolygonFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
389 
392 
398  AddShapeResult processClick(const Position& clickedPosition, GNELane* lane);
399 
404  bool buildPoly(const PositionVector& drawedShape);
405 
407  void show();
408 
410  static std::string getIdsSelected(const FXList* list);
411 
414 
417 
420 
422  DrawingMode* getDrawingMode() const;
423 
424 protected:
426  bool addPolygon(const std::map<SumoXMLAttr, std::string>& POIValues);
427 
429  bool addPOI(const std::map<SumoXMLAttr, std::string>& POIValues);
430 
432  bool addPOILane(const std::map<SumoXMLAttr, std::string>& POIValues);
433 
434 private:
437 
440 
443 
446 };
447 
448 
449 #endif
450 
451 /****************************************************************************/
AddShapeResult processClick(const Position &clickedPosition, GNELane *lane)
process click over Viewnet
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool buildPoly(const PositionVector &drawedShape)
build Polygon using values of Fields and drawed shape return true if was sucesfully created ...
FXHorizontalFrame * myBlockShapeFrame
frame for Block shape
ShapeAttributes * myShapeAttributesParent
pointer to ShapeAttributes
~GNEPolygonFrame()
Destructor.
FXTextField * myTextFieldInt
textField to modify the default value of int/float/string parameters
SumoXMLTag getCurrentShapeType() const
get current shape type
void setCurrentShape(SumoXMLTag actualShapeType)
set parameters depending of the given shapeType
AddShapeResult
enum with all possible values after try to create an shape using frame
long onCmdselectAttributeCarrier(FXObject *, FXSelector, void *)
GNEPolygonFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
FXLabel * myClosePolygonLabel
Label for open/close polygon.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:47
FXLabel * myInformationLabel
Label with information.
FXTextField * myTextFieldReal
textField to modify the default value of real/times parameters
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
FXCheckButton * myBlockMovementCheckButton
checkBox for block movement
FXLabel * myBlockMovementLabel
Label for block movement.
FXButton * myStopDrawingButton
button for stop drawing
FXButton * myColorEditor
Button for open color editor.
bool addPolygon(const std::map< SumoXMLAttr, std::string > &POIValues)
add Polygon
bool addPOI(const std::map< SumoXMLAttr, std::string > &POIValues)
add POI
FXHorizontalFrame * myClosePolygonFrame
Frame for open/close polygon.
FXTextField * myTextFieldStrings
textField to modify the default value of string parameters
PositionVector myTemporalShapeShape
current drawed shape
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
FXCheckButton * myClosePolygonCheckButton
checkbox to enable/disable closing polygon
A list of positions.
bool addPOILane(const std::map< SumoXMLAttr, std::string > &POIValues)
add POILane
FXButton * myAbortDrawingButton
button for abort drawing
SumoXMLTag myCurrentShapeType
actual shape type selected in the match Box
ShapeAttributes * myShapeAttributes
shape internal attributes
ShapeAttributes * getShapeAttributes() const
get shape attributes
ShapeSelector * getShapeSelector() const
get shape selector
FXCheckButton * myBlockShapeCheckButton
checkBox for block shape
NeteditAttributes * myNeteditAttributes
Netedit parameter.
NeteditAttributes * getNeteditAttributes() const
get netedit attributes editor
ShapeSelector * myShapeSelector
additional selector
DrawingMode * getDrawingMode() const
get drawing mode editor
DrawingMode * myDrawingMode
drawing mode
void show()
show shape frame and update use selected edges/lanes
GNEPolygonFrame * myPolygonFrameParent
pointer to Polygon Frame Parent
GNEPolygonFrame * myShapeFrameParent
pointer to Shape Frame Parent
FXButton * myStartDrawingButton
button for start drawing
std::vector< ShapeAttributeSingle * > myVectorOfsingleShapeParameter
vector with the shape parameters
FXLabel * myBlockShapeLabel
Label for block shape.
FXComboBox * myShapeMatchBox
combo box with the list of shape elements
static std::string getIdsSelected(const FXList *list)
get list of selecte id&#39;s in string format
SumoXMLAttr myShapeAttr
current XML attribute
FXCheckButton * myBoolCheckButton
check button to enable/disable the value of boolean parameters
GNEPolygonFrame * myPolygonFrameParent
frame frame parent
std::string myInvalidValue
string which indicates the reason due current value is invalid
FXLabel * myLabel
lael with the name of the parameter