SUMO - Simulation of Urban MObility
GNEPolygonFrame.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // The Widget for add polygons
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef GNEPolygonFrame_h
21 #define GNEPolygonFrame_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GNEFrame.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
39 class GNENetElement;
40 class GNEShape;
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
49 class GNEPolygonFrame : public GNEFrame {
51  FXDECLARE(GNEPolygonFrame)
52 
53 public:
54 
57  ADDSHAPE_SUCCESS, // Shape was successfully created
58  ADDSHAPE_NEWPOINT, // New point was sucesfully added to temporal shape
59  ADDSHAPE_INVALID, // Shape wasn't created
60  ADDSHAPE_NOTHING // Nothing to do
61  };
62 
63  // ===========================================================================
64  // class ShapeAttributeSingle
65  // ===========================================================================
66 
67  class ShapeAttributeSingle : public FXHorizontalFrame {
70 
71  public:
73  ShapeAttributeSingle(FXComposite* parent);
74 
77 
79  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, std::string value);
80 
82  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, int value);
83 
85  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, double value);
86 
88  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, bool value);
89 
91  void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, RGBColor value);
92 
94  void hideParameter();
95 
97  SumoXMLTag getTag() const;
98 
100  SumoXMLAttr getAttr() const;
101 
103  std::string getValue() const;
104 
106  const std::string& isAttributeValid() const;
107 
111  long onCmdSetAttribute(FXObject*, FXSelector, void*);
112 
114  long onCmdSetBooleanAttribute(FXObject*, FXSelector, void*);
115 
117  long onCmdSetColorAttribute(FXObject*, FXSelector, void*);
119 
120  protected:
123 
124  private:
127 
130 
132  FXLabel* myLabel;
133 
135  FXTextField* myTextFieldInt;
136 
138  FXTextField* myTextFieldReal;
139 
141  FXTextField* myTextFieldStrings;
142 
144  FXCheckButton* myBoolCheckButton;
145 
147  FXButton* mycolorEditor;
148 
150  std::string myInvalidValue;
151  };
152 
153 
154  // ===========================================================================
155  // class ShapeAttributes
156  // ===========================================================================
157 
158  class ShapeAttributes : public FXGroupBox {
161 
162  public:
164  ShapeAttributes(GNEViewNet* viewNet, FXComposite* parent);
165 
167  ~ShapeAttributes();
168 
170  void clearAttributes();
171 
173  void addAttribute(SumoXMLTag additionalTag, SumoXMLAttr ShapeAttributeSingle);
174 
176  void showShapeParameters();
177 
179  void hideShapeParameters();
180 
182  std::map<SumoXMLAttr, std::string> getAttributesAndValues() const;
183 
185  bool areValuesValid() const;
186 
188  void showWarningMessage(std::string extra = "") const;
189 
191  int getNumberOfAddedAttributes() const;
192 
196  long onCmdHelp(FXObject*, FXSelector, void*);
198 
199  protected:
202 
203  private:
206 
209 
211  std::vector<ShapeAttributeSingle*> myVectorOfsingleShapeParameter;
212 
215 
218 
221 
224 
226  FXButton* helpShape;
227  };
228 
229  // ===========================================================================
230  // class NeteditAttributes
231  // ===========================================================================
232 
233  class NeteditAttributes : public FXGroupBox {
236 
237  public:
239  NeteditAttributes(FXComposite* parent);
240 
243 
245  void show(bool shapeEditing);
246 
248  void hide();
249 
251  bool isBlockMovementEnabled() const;
252 
254  bool isBlockShapeEnabled() const;
255 
257  bool isCloseShapeEnabled() const;
258 
262  long onCmdSetBlockMovement(FXObject*, FXSelector, void*);
263 
265  long onCmdSetBlockShape(FXObject*, FXSelector, void*);
266 
268  long onCmdsetClosingClosing(FXObject*, FXSelector, void*);
270 
271  protected:
274 
275  private:
278 
281 
283  FXHorizontalFrame* myBlockShapeFrame;
284 
287 
289  FXCheckButton* myBlockShapeCheckButton;
290 
292  FXHorizontalFrame* myClosePolygonFrame;
293 
296 
299  };
300 
301  // ===========================================================================
302  // class DrawingMode
303  // ===========================================================================
304 
305  class DrawingMode : public FXGroupBox {
308 
309  public:
311  DrawingMode(GNEPolygonFrame* polygonFrameParent);
312 
314  ~DrawingMode();
315 
317  void show();
318 
320  void hide();
321 
323  void startDrawing();
324 
326  void stopDrawing();
327 
329  void abortDrawing();
330 
332  void addNewPoint(const Position& P);
333 
335  void removeLastPoint();
336 
338  const PositionVector& getTemporalShape() const;
339 
341  bool isDrawing() const;
342 
346  long onCmdStartDrawing(FXObject*, FXSelector, void*);
347 
349  long onCmdStopDrawing(FXObject*, FXSelector, void*);
350 
352  long onCmdAbortDrawing(FXObject*, FXSelector, void*);
354 
355  protected:
358 
359  private:
362 
365 
368 
371 
374 
377  };
378 
383  GNEPolygonFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
384 
387 
392  AddShapeResult processClick(const Position& clickedPosition);
393 
398  bool buildPoly(const PositionVector& drawedShape);
399 
402 
405 
409  long onCmdSelectShape(FXObject*, FXSelector, void*);
411 
413  void show();
414 
416  static std::string getIdsSelected(const FXList* list);
417 
418 protected:
421 
423  bool addPolygon(const std::map<SumoXMLAttr, std::string>& POIValues);
424 
426  bool addPOI(const std::map<SumoXMLAttr, std::string>& POIValues);
427 
428 private:
430  void setParametersOfShape(SumoXMLTag actualShapeType);
431 
434 
436  FXComboBox* myShapeMatchBox;
437 
440 
443 
446 
449 };
450 
451 
452 #endif
453 
454 /****************************************************************************/
std::string getValue() const
return value
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool buildPoly(const PositionVector &drawedShape)
build Polygon using values of Fields and drawed shap return true if was sucesfully created ...
GNEPolygonFrame()
FOX needs this.
void setParametersOfShape(SumoXMLTag actualShapeType)
set parameters depending of the new additionalType
FXHorizontalFrame * myBlockShapeFrame
frame for Block shape
~GNEPolygonFrame()
Destructor.
FXTextField * myTextFieldInt
textField to modify the default value of int/float/string parameters
SumoXMLTag myShapeTag
current XML attribute
GNEPolygonFrame::NeteditAttributes * getNetEditParameters() const
get editor parameters
AddShapeResult
FOX-declaration.
FXLabel * myClosePolygonLabel
Label for open/close polygon.
GNEPolygonFrame::NeteditAttributes * myEditorParameters
Netedit parameter.
AddShapeResult processClick(const Position &clickedPosition)
process click over Viewnet
long onCmdSetBooleanAttribute(FXObject *, FXSelector, void *)
called when user change the value of myBoolCheckButton
int myIndexParameter
Index for myVectorOfsingleShapeParameter.
GNEViewNet * myViewNet
pointer to viewNet
FXGroupBox * myGroupBoxForMyShapeMatchBox
groupBox for Match Box of additionals
FXLabel * myInformationLabel
Label with information.
FXTextField * myTextFieldReal
textField to modify the default value of real/times parameters
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
GNEPolygonFrame::DrawingMode * getDrawingMode() const
get drawing mode
FXCheckButton * myBlockMovementCheckButton
checkBox for block movement
FXLabel * myBlockMovementLabel
Label for block movement.
FXButton * myStopDrawingButton
button for stop drawing
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.
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
const std::string & isAttributeValid() const
returns a empty string if current value is valid, a string with information about invalid value in ot...
FXButton * mycolorEditor
Button for open color editor.
PositionVector myTemporalShapeShape
current drawed shape
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
FXCheckButton * myClosePolygonCheckButton
checkbox to enable/disable closing polygon
A list of positions.
void hideParameter()
hide all parameters
GNEPolygonFrame::DrawingMode * myDrawingMode
drawing mode
FXButton * myAbortDrawingButton
button for abort drawing
void showParameter(SumoXMLTag additionalTag, SumoXMLAttr additionalAttr, std::string value)
show name and value of attribute of type string
FXCheckButton * myBlockShapeCheckButton
checkBox for block shape
SumoXMLTag getTag() const
return tag
FXComboBox * myShapeMatchBox
combo box with the list of additional elements
SumoXMLTag myActualShapeType
actual additional type selected in the match Box
SumoXMLTag myShapeTag
current additional tag
int maxNumberOfParameters
max number of parameters (Defined in constructor)
void show()
show additional frame and update use selected edges/lanes
FXButton * myStartDrawingButton
button for start drawing
std::vector< ShapeAttributeSingle * > myVectorOfsingleShapeParameter
vector with the additional parameters
FXLabel * myBlockShapeLabel
Label for block shape.
GNEPolygonFrame::ShapeAttributes * myShapeAttributes
additional internal attributes
virtual void hide()
hide Frame
Definition: GNEFrame.cpp:107
static std::string getIdsSelected(const FXList *list)
get list of selecte id&#39;s in string format
int myIndexParameterList
index for myIndexParameterList
SumoXMLAttr getAttr() const
return Attr
SumoXMLAttr myShapeAttr
current XML attribute
FXCheckButton * myBoolCheckButton
check button to enable/disable the value of boolean parameters
GNEPolygonFrame * myPolygonFrameParent
polygon frame parent
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