57 myPolygonFrameParent(polygonFrameParent) {
62 myLatLonRadioButton->setCheck(TRUE);
70 myLabelCartesianPosition =
new FXLabel(
this,
"Cartesian equivalence:\n- X = give valid longitude\n- Y = give valid latitude", 0,
GUIDesignLabelFrameInformation);
81 myCoordinatesTextField->enable();
82 myCoordinatesTextField->setText(
"");
83 myCoordinatesTextField->enable();
84 myCreateGEOPOIButton->enable();
86 myCoordinatesTextField->setText(
"No geo-conversion defined");
87 myCoordinatesTextField->disable();
88 myCreateGEOPOIButton->disable();
103 std::string input = myCoordinatesTextField->getText().text();
104 std::string inputWithoutSpaces;
105 for (
const auto& i : input) {
107 inputWithoutSpaces.push_back(i);
111 if (input.size() != inputWithoutSpaces.size()) {
112 myCoordinatesTextField->setText(inputWithoutSpaces.c_str());
114 if (inputWithoutSpaces.size() > 0) {
115 myCreateGEOPOIButton->setText(
"Create GEO POI");
117 myCreateGEOPOIButton->setText(
"Create GEO POI (clipboard)");
120 if (GNEAttributeCarrier::canParse<Position>(myCoordinatesTextField->getText().text())) {
121 myCoordinatesTextField->setTextColor(FXRGB(0, 0, 0));
122 myCoordinatesTextField->killFocus();
124 Position geoPos = GNEAttributeCarrier::parse<Position>(myCoordinatesTextField->getText().text());
125 if (myLatLonRadioButton->getCheck() == TRUE) {
131 myLabelCartesianPosition->setText((
"Cartesian equivalence:\n- X = " +
toString(geoPos.
x()) +
"\n- Y = " +
toString(geoPos.
y())).c_str());
133 myCoordinatesTextField->setTextColor(FXRGB(255, 0, 0));
134 myLabelCartesianPosition->setText(
"Cartesian equivalence:\n- X = give valid longitude\n- Y = give valid latitude");
143 if (obj == myLonLatRadioButton) {
144 myLonLatRadioButton->setCheck(TRUE);
145 myLatLonRadioButton->setCheck(FALSE);
146 }
else if (obj == myLatLonRadioButton) {
147 myLonLatRadioButton->setCheck(FALSE);
148 myLatLonRadioButton->setCheck(TRUE);
151 onCmdSetCoordinates(0, 0, 0);
159 if (myPolygonFrameParent->myShapeAttributes->areValuesValid()) {
160 std::string geoPosStr = myCoordinatesTextField->getText().text();
161 if (geoPosStr.empty()) {
165 myCoordinatesTextField->setText(geoPosStr.c_str());
167 onCmdSetCoordinates(0, 0, 0);
168 geoPosStr = myCoordinatesTextField->getText().text();
169 myCoordinatesTextField->setText(
"");
170 myCreateGEOPOIButton->setText(
"Create GEO POI (clipboard)");
172 if (GNEAttributeCarrier::canParse<Position>(geoPosStr)) {
174 auto valuesMap = myPolygonFrameParent->myShapeAttributes->getAttributesAndValues(
true);
176 myPolygonFrameParent->myNeteditAttributes->getNeteditAttributesAndValues(valuesMap,
nullptr);
179 valuesMap[
SUMO_ATTR_ID] = myPolygonFrameParent->myViewNet->getNet()->generateShapeID(myPolygonFrameParent->myShapeTagSelector->getCurrentTagProperties().getTag());
183 Position geoPos = GNEAttributeCarrier::parse<Position>(geoPosStr);
185 if (myLatLonRadioButton->getCheck() == TRUE) {
191 if (myPolygonFrameParent->addPOI(valuesMap)) {
193 if (myCenterViewAfterCreationCheckButton->getCheck() == TRUE) {
196 centerPosition.
add(geoPos);
197 centerPosition = centerPosition.
grow(10);
198 myPolygonFrameParent->myViewNet->getViewParent()->getView()->centerTo(centerPosition);
205 myPolygonFrameParent->myShapeAttributes->refreshRows();
216 GNEFrame(horizontalFrameParent, viewNet,
"Shapes") {
254 std::map<SumoXMLAttr, std::string> valuesMap;
336 std::string vectorOfIds;
337 for (
int i = 0; i < list->getNumItems(); i++) {
338 if (list->isItemSelected(i)) {
339 if (vectorOfIds.size() > 0) {
342 vectorOfIds += (list->getItem(i)->getText()).text();
428 double angle = GNEAttributeCarrier::parse<double>(polyValues.at(
SUMO_ATTR_ANGLE));
432 bool fill = GNEAttributeCarrier::parse<bool>(polyValues.at(
SUMO_ATTR_FILL));
435 double layer = GNEAttributeCarrier::canParse<double>(layerStr) ? GNEAttributeCarrier::parse<double>(layerStr) :
Shape::DEFAULT_LAYER;
438 if ((shape.size() > 0) &&
myViewNet->
getNet()->
getAttributeCarriers()->
addPolygon(
id, type, color, layer, angle, imgFile, relativePath, shape,
false, fill, lineWidth)) {
461 double angle = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_ANGLE));
464 double widthPOI = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_WIDTH));
465 double heightPOI = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_HEIGHT));
466 double layer = GNEAttributeCarrier::canParse<double>(layerStr) ? GNEAttributeCarrier::parse<double>(layerStr) :
Shape::DEFAULT_LAYER_POI;
467 bool geo = GNEAttributeCarrier::parse<bool>(POIValues.at(
SUMO_ATTR_GEO));
470 if (
myViewNet->
getNet()->
getAttributeCarriers()->
addPOI(
id, type, color, pos, geo,
"", 0, 0, layer, angle, imgFile, relativePath, widthPOI, heightPOI)) {
491 double angle = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_ANGLE));
495 double posLane = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_POSITION));
497 double widthPOI = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_WIDTH));
498 double heightPOI = GNEAttributeCarrier::parse<double>(POIValues.at(
SUMO_ATTR_HEIGHT));
500 double layer = GNEAttributeCarrier::canParse<double>(layerStr) ? GNEAttributeCarrier::parse<double>(layerStr) :
Shape::DEFAULT_LAYER_POI;
503 if (
myViewNet->
getNet()->
getAttributeCarriers()->
addPOI(
id, type, color,
Position(),
false, lane->
getID(), posLane, posLat, layer, angle, imgFile, relativePath, widthPOI, heightPOI)) {
FXDEFMAP(GNEPolygonFrame::GEOPOICreator) GEOPOICreatorMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
@ MID_CHOOSEN_OPERATION
set type of selection
@ MID_GNE_CREATE
create element
#define GUIDesignTextField
#define GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignGroupBoxFrame
Group box design extended over frame.
#define GUIDesignCheckButton
checkButton placed in left position
#define GUIDesignRadioButton
#define GUIDesignLabelFrameInformation
label extended over frame without thick and with text justify to left, used to show information in fr...
#define WRITE_WARNING(msg)
@ SUMO_TAG_NOTHING
invalid tag
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_POILANE
begin/end of the description of a Point of interest over Lane (used by Netedit)
@ GNE_ATTR_BLOCK_MOVEMENT
block movement of a graphic element
@ GNE_ATTR_CLOSE_SHAPE
Close shape of a polygon (Used by GNEPolys)
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_FILL
Fill the polygon.
@ SUMO_ATTR_LAYER
A layer number.
@ GNE_ATTR_BLOCK_SHAPE
block shape of a graphic element (Used mainly in GNEShapes)
@ SUMO_ATTR_COLOR
A color information.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
void hideAttributesCreatorModul()
hide group box
void refreshRows()
refresh rows (called after creating an element)
void showAttributesCreatorModul(const GNETagProperties &tagProperties, const std::vector< SumoXMLAttr > &hiddenAttributes)
show AttributesCreator modul
std::map< SumoXMLAttr, std::string > getAttributesAndValues(bool includeAll) const
get attributes and their values
bool areValuesValid() const
check if parameters of attributes are valid
void showWarningMessage(std::string extra="") const
show warning message with information about non-valid attributes
void showNeteditAttributesModul(const GNETagProperties &tagValue)
show Netedit attributes modul
bool getNeteditAttributesAndValues(std::map< SumoXMLAttr, std::string > &valuesMap, const GNELane *lane) const
fill valuesMap with netedit attributes
void hideNeteditAttributesModul()
hide Netedit attributes modul
GNEViewNet * myViewNet
View Net.
virtual void show()
show Frame
virtual void hide()
hide Frame
void showDrawingShape()
show Drawing mode
bool getDeleteLastCreatedPoint()
get flag delete last created point
void hideDrawingShape()
hide Drawing mode
const PositionVector & getTemporalShape() const
get Temporal shape
void addNewPoint(const Position &P)
add new point to temporal shape
void removeLastPoint()
remove last added point
bool isDrawing() const
return true if currently a shape is drawed
void refreshTagProperties()
due myCurrentTagProperties is a Reference, we need to refresh it when frameParent is show
const GNETagProperties & getCurrentTagProperties() const
get current type tag
void setCurrentTag(SumoXMLTag newTag)
set current type manually
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
const PositionVector & getLaneShape() const
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.
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 geo, bool fill, double lineWidth, bool ignorePruning=false)
Builds a polygon using the given values and adds it to the container.
GNELane * retrieveLane(const std::string &id, bool failHard=true, bool checkVolatileChange=false)
get lane by id
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
retrieve all attribute carriers of Net
std::string generateShapeID(SumoXMLTag shapeTag) const
generate Shape ID
GNEShape * retrieveShape(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named shape.
const std::string & getID() const
get ID
void showGEOPOICreatorModul()
Show list of GEOPOICreator Modul.
long onCmdCreateGEOPOI(FXObject *, FXSelector, void *)
called when user type in search box
void hideGEOPOICreatorModul()
hide GEOPOICreator Modul
~GEOPOICreator()
destructor
long onCmdSetFormat(FXObject *, FXSelector, void *)
called when user select a format radio button
long onCmdSetCoordinates(FXObject *, FXSelector, void *)
GNEFrameAttributesModuls::NeteditAttributes * myNeteditAttributes
Netedit parameter.
bool addPOI(const std::map< SumoXMLAttr, std::string > &POIValues)
add POI
GNEFrameModuls::TagSelector * myShapeTagSelector
shape tag selector
GNEFrameModuls::DrawingShape * getDrawingShapeModul() const
get drawing mode editor
static std::string getIdsSelected(const FXList *list)
get list of selecte id's in string format
void tagSelected()
Tag selected in TagSelector.
~GNEPolygonFrame()
Destructor.
AddShape
enum with all possible values after try to create an shape using frame
GNEPolygonFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
GEOPOICreator * myGEOPOICreator
GEOPOICreator.
GNEFrameAttributesModuls::AttributesCreator * myShapeAttributes
shape internal attributes
bool shapeDrawed()
build a shaped element using the drawed shape return true if was successfully created
GNEFrameModuls::DrawingShape * myDrawingShape
Drawing shape.
bool addPOILane(const std::map< SumoXMLAttr, std::string > &POIValues)
add POILane
GNEPolygonFrame::AddShape processClick(const Position &clickedPosition, const GNEViewNetHelper::ObjectsUnderCursor &objectsUnderCursor)
process click over Viewnet
bool addPolygon(const std::map< SumoXMLAttr, std::string > &POIValues)
add Polygon
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
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...
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void p_abort()
reverts and discards ALL active command groups
class used to group all variables related with objects under cursor after a click over view
GNELane * getLaneFront() const
get front lane or a pointer to nullptr
GNENet * getNet() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
void setStatusBarText(const std::string &text)
set staturBar text
static std::string copyFromClipboard(const FXApp &app)
Copies text from the clipboard.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
C++ TraCI client API implementation.
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
void swapXY()
swap position X and Y
double y() const
Returns the y-position.
void closePolygon()
ensures that the last position equals the first
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
static RGBColor parseColor(std::string coldef)
Parses a color information.
static const double DEFAULT_LAYER
static const double DEFAULT_LAYER_POI