88 myShapeFrameParent(shapeFrameParent),
96 for (
auto i : listOfTags) {
97 myShapeMatchBox->appendItem(
toString(i).c_str());
101 myShapeMatchBox->setNumVisible((
int)myShapeMatchBox->getNumItems());
104 myShapeMatchBox->setCurrentItem(2);
130 if (!i.second.isUnique()) {
163 for (
auto i : listOfTags) {
176 WRITE_DEBUG(
"Selected invalid shape in ShapeSelector");
186 myShapeAttributesParent(shapeAttributesParent),
210 if (attributeProperties.isColor()) {
218 if (attributeProperties.isInt()) {
222 }
else if (attributeProperties.isFloat()) {
226 }
else if (attributeProperties.isBool()) {
227 if (GNEAttributeCarrier::parse<bool>(value)) {
267 if (attrValue.isBool()) {
269 }
else if (attrValue.isInt()) {
271 }
else if (attrValue.isFloat() || attrValue.isTime()) {
298 if (attrValues.isInt()) {
299 if (GNEAttributeCarrier::canParse<int>(
myTextFieldInt->getText().text())) {
301 int intValue = GNEAttributeCarrier::parse<int>(
myTextFieldInt->getText().text());
303 if (attrValues.isPositive() && (intValue < 0)) {
309 }
else if (attrValues.isTime()) {
311 if (GNEAttributeCarrier::canParse<double>(
myTextFieldReal->getText().text())) {
313 double doubleValue = GNEAttributeCarrier::parse<double>(
myTextFieldReal->getText().text());
315 if (doubleValue < 0) {
321 }
else if (attrValues.isFloat()) {
322 if (GNEAttributeCarrier::canParse<double>(
myTextFieldReal->getText().text())) {
324 double doubleValue = GNEAttributeCarrier::parse<double>(
myTextFieldReal->getText().text());
326 if (attrValues.isPositive() && (doubleValue < 0)) {
329 }
else if (attrValues.isProbability() && ((doubleValue < 0) || doubleValue > 1)) {
335 }
else if (attrValues.isColor()) {
337 if (GNEAttributeCarrier::canParse<RGBColor>(
myTextFieldStrings->getText().text()) ==
false) {
340 }
else if (attrValues.isFilename()) {
344 myInvalidValue =
"input contains invalid characters for a filename";
387 FXColorDialog colordialog(
this, tr(
"Color Dialog"));
388 colordialog.setTarget(
this);
396 if (colordialog.execute()) {
409 myPolygonFrameParent(polygonFrameParent) {
455 std::map<SumoXMLAttr, std::string>
457 std::map<SumoXMLAttr, std::string> values;
470 std::string errorMessage;
473 if (errorMessage.empty()) {
476 if (attributeValue.size() != 0) {
477 errorMessage = attributeValue;
482 if (extra.size() == 0) {
621 FXDialogBox* polygonNeteditAttributesHelpDialog =
new FXDialogBox(
this,
"Netedit Parameters Help",
GUIDesignDialogBox);
624 std::ostringstream help;
626 <<
"- Block movement: If enabled, the created polygon element will be blocked. i.e. cannot be moved with\n" 627 <<
" the mouse. This option can be modified inspecting element.\n" 629 <<
"- Block shape: If enabled, the shape of created polygon element will be blocked. i.e. their geometry points\n" 630 <<
" cannot be edited be moved with the mouse. This option can be modified inspecting element.\n" 632 <<
"- Close shape: If enabled, the created polygon element will be closed. i.e. the last created geometry point\n" 633 <<
" will be connected with the first geometry point automatically. This option can be modified inspecting element.";
645 WRITE_DEBUG(
"Opening NeteditAttributes dialog for tag '");
647 polygonNeteditAttributesHelpDialog->create();
649 polygonNeteditAttributesHelpDialog->show(PLACEMENT_CURSOR);
653 getApp()->runModalFor(polygonNeteditAttributesHelpDialog);
655 WRITE_DEBUG(
"Closing NeteditAttributes dialog for tag '");
665 myPolygonFrameParent(polygonFrameParent),
666 myDeleteLastCreatedPoint(false) {
673 std::ostringstream information;
675 <<
"- 'Start drawing' or ENTER\n" 676 <<
" draws polygon boundary.\n" 677 <<
"- 'Stop drawing' or ENTER\n" 678 <<
" creates polygon.\n" 679 <<
"- 'Shift + Click'\n" 680 <<
" removes last created point.\n" 681 <<
"- 'Abort drawing' or ESC\n" 682 <<
" removes drawed polygon.";
760 throw ProcessError(
"A new point cannot be added if drawing wasn't started");
820 GNEFrame(horizontalFrameParent, viewNet,
"Shapes") {
846 std::map<SumoXMLAttr, std::string> valuesOfElement;
863 if (
addPOI(valuesOfElement)) {
877 if (lane ==
nullptr) {
958 std::string vectorOfIds;
959 for (
int i = 0; i < list->getNumItems(); i++) {
960 if (list->isItemSelected(i)) {
961 if (vectorOfIds.size() > 0) {
964 vectorOfIds += (list->getItem(i)->getText()).text();
1003 double angle = GNEAttributeCarrier::parse<double>(polyValues.at(
SUMO_ATTR_ANGLE));
1007 bool fill = GNEAttributeCarrier::parse<bool>(polyValues.at(
SUMO_ATTR_FILL));
1009 double layer = GNEAttributeCarrier::canParse<double>(layerStr) ? GNEAttributeCarrier::parse<double>(layerStr) :
Shape::DEFAULT_LAYER;
1012 if ((shape.size() > 0) &&
myViewNet->
getNet()->
addPolygon(
id, type, color, layer, angle, imgFile, relativePath, shape,
false, fill)) {
1036 double angle = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_ANGLE));
1039 double widthPOI = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_WIDTH));
1040 double heightPOI = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_HEIGHT));
1042 double layer = GNEAttributeCarrier::canParse<double>(layerStr) ? GNEAttributeCarrier::parse<double>(layerStr) :
Shape::DEFAULT_LAYER_POI;
1045 if (
myViewNet->
getNet()->
addPOI(
id, type, color, pos,
false,
"", 0, 0, layer, angle, imgFile, relativePath, widthPOI, heightPOI)) {
1066 double angle = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_ANGLE));
1070 double posLane = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_POSITION));
1072 double widthPOI = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_WIDTH));
1073 double heightPOI = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_HEIGHT));
1075 double layer = GNEAttributeCarrier::canParse<double>(layerStr) ? GNEAttributeCarrier::parse<double>(layerStr) :
Shape::DEFAULT_LAYER_POI;
1078 if (
myViewNet->
getNet()->
addPOI(
id, type, color,
Position(),
false, lane->getID(), posLane, posLat, layer, angle, imgFile, relativePath, widthPOI, heightPOI)) {
AddShapeResult processClick(const Position &clickedPosition, GNELane *lane)
process click over Viewnet
ShapeAttributeSingle()
FOX needs this.
long onCmdStopDrawing(FXObject *, FXSelector, void *)
Called when the user press stop drawing button.
bool isBlockShapeEnabled() const
check if block shape is enabled
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::string getValue() const
return value
#define GUIDesignComboBoxNCol
number of column of every combo box
static RGBColor parseColor(std::string coldef)
Parses a color information.
bool buildPoly(const PositionVector &drawedShape)
build Polygon using values of Fields and drawed shape return true if was sucesfully created ...
int getNumberOfAddedAttributes() const
get number of added attributes
#define GUIDesignCheckButtonAttribute
checkButton without thick extended over the frame used for attributes
void addAttribute(SumoXMLAttr ShapeAttributeSingle)
add attribute
#define GUIDesignButtonAttribute
button extended over over column with thick and raise frame
~ShapeAttributeSingle()
destructor
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
void stopDrawing()
stop drawing and create polygon or
~ShapeSelector()
destructor
SumoXMLTag getCurrentShapeType() const
get current shape type
void showNeteditAttributes(bool shapeEditing)
show NeteditAttributes
block shape of a graphic element (Used mainly in GNEShapes)
bool isBlockMovementEnabled() const
check if block movement is enabled
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 *)
static const double DEFAULT_LAYER_POI
GNEPolygonFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
FXLabel * myClosePolygonLabel
Label for open/close polygon.
static RGBColor getRGBColor(FXColor col)
converts FXColor to RGBColor
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
GNEPOI * retrievePOI(const std::string &id, bool failHard=true) const
get POI by id
void showWarningMessage(std::string extra="") const
show warning message with information about non-valid attributes
static int getHigherNumberOfAttributes()
return the number of attributes of the tag with the most highter number of attributes ...
long onCmdHelp(FXObject *, FXSelector, void *)
GNEPoly * retrievePolygon(const std::string &id, bool failHard=true) const
get Polygon by id
void addNewPoint(const Position &P)
add new point to temporal shape
void hideShapeParameters()
hide group box
long onCmdStartDrawing(FXObject *, FXSelector, void *)
std::map< SumoXMLAttr, std::string > getAttributesAndValues() const
get attributes and their values
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.
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
FXLabel * myInformationLabel
Label with information.
bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, const PositionVector &shape, bool fill, bool geo, bool ignorePruning=false)
Builds a polygon using the given values and adds it to the container.
FXTextField * myTextFieldReal
textField to modify the default value of real/times parameters
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
begin/end of the description of a Point of interest
FXCheckButton * myBlockMovementCheckButton
checkBox for block movement
FXLabel * myBlockMovementLabel
Label for block movement.
FXButton * myStopDrawingButton
button for stop drawing
void showDrawingMode()
show Drawing mode
void openHelpAttributesDialog(SumoXMLTag tag) const
Open help attributes dialog.
FXButton * myColorEditor
Button for open color editor.
GNEViewNet * getViewNet() const
get view net
bool addPolygon(const std::map< SumoXMLAttr, std::string > &POIValues)
add Polygon
bool addPOI(const std::map< SumoXMLAttr, std::string > &POIValues)
add POI
long onCmdSetNeteditAttribute(FXObject *, FXSelector, void *)
#define WRITE_WARNING(msg)
FXHorizontalFrame * myClosePolygonFrame
Frame for open/close polygon.
bool isDrawing() const
return true if currently a shape is drawed
#define GUIDesignComboBox
std::string generateShapeID(SumoXMLTag shapeTag) const
generate Shape ID
GNEViewNet * myViewNet
View Net for changes.
GNEUndoList * getUndoList() const
get the undoList object
void removeLastPoint()
remove last added point
FXTextField * myTextFieldStrings
textField to modify the default value of string parameters
~ShapeAttributes()
destructor
#define GUIDesignHorizontalSeparator
#define GUIDesignTextField
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool areValuesValid() const
check if parameters of attributes are valid
FXVerticalFrame * myContentFrame
Vertical frame that holds all widgets of frame.
PositionVector myTemporalShapeShape
current drawed shape
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
A point in 2D or 3D with translation and scaling methods.
void hideDrawingMode()
hide Drawing mode
FXCheckButton * myClosePolygonCheckButton
checkbox to enable/disable closing polygon
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames ...
void hideParameter()
hide all parameters
static std::vector< SumoXMLTag > allowedShapeTags(bool onlyDrawables)
get all editable for tag shape elements
void clearAttributes()
clear attributes
bool addPOI(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, bool geo, const std::string &lane, double posOverLane, double posLat, double layer, double angle, const std::string &imgFile, bool relativePath, double width, double height, bool ignorePruning=false)
Builds a POI using the given values and adds it to the container.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
block movement of a graphic element
bool addPOILane(const std::map< SumoXMLAttr, std::string > &POIValues)
add POILane
FXButton * myAbortDrawingButton
button for abort drawing
attribute edited trought dialog
SumoXMLTag myCurrentShapeType
actual shape type selected in the match Box
ShapeAttributes()
FOX needs this.
ShapeAttributes * myShapeAttributes
shape internal attributes
edge: the shape in xml-definition
ShapeAttributes * getShapeAttributes() const
get shape attributes
const std::string getID() const
function to support debugging
ShapeSelector * getShapeSelector() const
get shape selector
FXCheckButton * myBlockShapeCheckButton
checkBox for block shape
void startDrawing()
start drawing
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
NeteditAttributes * myNeteditAttributes
Netedit parameter.
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
void p_abort()
reverts and discards ALL active command groups
#define GUIDesignButtonRectangular
little button rectangular (46x23) used in frames (For example, in "help" buttons) ...
long onCmdAbortDrawing(FXObject *, FXSelector, void *)
Called when the user press abort drawing button.
NeteditAttributes * getNeteditAttributes() const
get netedit attributes editor
bool isCloseShapeEnabled() const
check if clse shape is enabled
#define GUIDesignTextFieldNCol
Num of column of text field.
NeteditAttributes()
FOX needs this.
ShapeSelector * myShapeSelector
additional selector
DrawingMode * getDrawingMode() const
get drawing mode editor
void showParameter(SumoXMLAttr shapeAttr, std::string value)
show name and value of attribute of type string
const PositionVector & getShape() const
returns the shape of the lane
virtual void show()
show Frame
#define GUIDesignDialogBox
FXDEFMAP(GNEPolygonFrame::ShapeSelector) ShapeSelectorMap[]
DrawingMode * myDrawingMode
drawing mode
bool getDeleteLastCreatedPoint()
get flag delete last created point
bool myDeleteLastCreatedPoint
flag to enable/disable delete point mode
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
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...
GNEPolygonFrame * myPolygonFrameParent
pointer to Polygon Frame Parent
GNEPolygonFrame * myShapeFrameParent
pointer to Shape Frame Parent
SumoXMLAttr getAttr() const
return Attr
FXButton * myStartDrawingButton
button for start drawing
std::vector< ShapeAttributeSingle * > myVectorOfsingleShapeParameter
vector with the shape parameters
void abortDrawing()
abort drawing
FXLabel * myBlockShapeLabel
Label for block shape.
#define GUIDesignTextFieldInt
text field extended over Frame with thick frame and limited to Integers
virtual void hide()
hide Frame
void hideNeteditAttributes()
hide NeteditAttributes
FXComboBox * myShapeMatchBox
combo box with the list of shape elements
static std::string getIdsSelected(const FXList *list)
get list of selecte id's in string format
GNENet * getNet() const
get the net object
#define GUIDesignTextFieldReal
text field extended over Frame with thick frame and limited to Doubles/doubles
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
#define GUIDesignButtonOK
void setStatusBarText(const std::string &text)
set staturBar text
void showShapeParameters()
show group box
SumoXMLAttr myShapeAttr
current XML attribute
used to select a type of element in a combo box
static const TagValues & getTagProperties(SumoXMLTag tag)
get Tag Properties
ShapeAttributes * getShapeAttributesParent() const
get shape attributes parent
GNEPolygonFrame * getPolygonFrameParent() const
get PolygonFrame parent
begin/end of the description of a Point of interest over Lane (used by Netedit)
#define GUIDesignLabelAttribute
label extended over the matrix column with thick frame and height of 23
FXCheckButton * myBoolCheckButton
check button to enable/disable the value of boolean parameters
const PositionVector & getTemporalShape() const
get Temporal shape
GNEPolygonFrame * myPolygonFrameParent
frame frame parent
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void closePolygon()
ensures that the last position equals the first
void setDeleteLastCreatedPoint(bool value)
enable or disable delete last created point
long onCmdSetAttribute(FXObject *, FXSelector, void *)
C++ TraCI client API implementation.
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name) ...
DrawingMode()
FOX needs this.
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
~NeteditAttributes()
destructor
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
long onCmdHelp(FXObject *, FXSelector, void *)
Called when help button is pressed.
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occurred errors.
begin/end of the description of a polygon
static const double DEFAULT_LAYER
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
FXLabel * myLabel
lael with the name of the parameter