Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEGeometryPointDialog.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A dialog for set Geometry Points
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
25
27
28// ===========================================================================
29// FOX callback mapping
30// ===========================================================================
31
32FXDEFMAP(GNEGeometryPointDialog) GNEGeometryPointDialogMap[] = {
34};
35
36// Object abstract implementation
37FXIMPLEMENT_ABSTRACT(GNEGeometryPointDialog, FXTopWindow, GNEGeometryPointDialogMap, ARRAYNUMBER(GNEGeometryPointDialogMap))
38
39// ===========================================================================
40// member method definitions
41// ===========================================================================
42
44 GNEDialog(applicationWindow, TL("Custom Geometry Point"), GUIIcon::MODEMOVE, DialogType::GEOMETRYPOINT,
45 Buttons::ACCEPT_CANCEL_RESET, OpenType::MODAL, ResizeMode::STATIC, 320, 80),
47 myOriginalPos(pos),
48 myGeo(GeoConvHelper::getFinal().getProjString() != "!") {
49 // create main frame
50 FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
51 // create frame for X,Y
52 FXHorizontalFrame* XYFrame = new FXHorizontalFrame(mainFrame, GUIDesignAuxiliarHorizontalFrame);
53 new FXLabel(XYFrame, "X,Y,[Z]", nullptr, GUIDesignLabelThickedFixed(75));
55 myTextFieldXY->setText(toString(pos).c_str());
56 // create frame for lon,lat
57 FXHorizontalFrame* lonLatFrame = new FXHorizontalFrame(mainFrame, GUIDesignAuxiliarHorizontalFrame);
58 new FXLabel(lonLatFrame, "lon,lat,[Z]", nullptr, GUIDesignLabelThickedFixed(75));
60 // check if enable geo coordinates
61 if (myGeo) {
62 Position geoPos = pos;
64 myTextFieldLonLat->setText(toString(geoPos, gPrecisionGeo).c_str());
65 } else {
66 myTextFieldLonLat->disable();
67 }
68 // create buttons centered
69 FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
70 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
74 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
75 // create
76 create();
77 // show in the given position
78 show(PLACEMENT_SCREEN);
79 // open as modal dialog (will block all windows until stop() or stopModal() is called)
80 getApp()->runModalFor(this);
81}
82
83
87
88
89const Position&
93
94
95void
97 // nothing to do
98}
99
100
101long
102GNEGeometryPointDialog::onCmdChangeGeometryPoint(FXObject* sender, FXSelector, void*) {
103 // check text field
104 if (sender == myTextFieldXY) {
105 // check if position can be parsed
107 // set valid color and kill focus
109 myTextFieldXY->killFocus();
110 // obtain position
112 // check if there is geo coordinates
113 if (myGeo) {
114 // calculate geo position
115 Position geoPos = myEditedPosition;
117 // set geo position in myTextFieldLonLat
118 myTextFieldLonLat->setText(toString(geoPos).c_str(), FALSE);
120 }
121 } else {
122 // set invalid color
124 }
125 } else {
126 // check if position can be parsed
128 // set valid color and kill focus
130 myTextFieldLonLat->killFocus();
131 // obtain geo position
133 // calculate cartesian position
134 myEditedPosition = geoPo;
136 // set geo position in myTextFieldXY
137 myTextFieldXY->setText(toString(myEditedPosition).c_str(), FALSE);
139 } else {
140 // set invalid color
142 }
143 }
144 return 1;
145}
146
147
148long
149GNEGeometryPointDialog::onCmdAccept(FXObject*, FXSelector, void*) {
150 // stop modal
151 getApp()->stopModal(this);
152 return 1;
153}
154
155
156long
157GNEGeometryPointDialog::onCmdCancel(FXObject*, FXSelector, void*) {
158 // set original position
160 // stop modal
161 getApp()->stopModal(this);
162 return 1;
163}
164
165
166long
167GNEGeometryPointDialog::onCmdReset(FXObject*, FXSelector, void*) {
168 // set original position
170 // calculate geo position
171 Position geoPos = myEditedPosition;
173 // set valid colors
175 // check geo
176 if (myGeo) {
178 }
179 // set text field
180 myTextFieldXY->setText(toString(myEditedPosition).c_str(), FALSE);
181 // check geo
182 if (myGeo) {
183 myTextFieldLonLat->setText(toString(geoPos).c_str(), FALSE);
184 }
185 return 1;
186}
187
188
194
195/****************************************************************************/
DialogType
Definition DialogType.h:30
FXDEFMAP(GNEGeometryPointDialog) GNEGeometryPointDialogMap[]
@ MID_GNE_SET_ATTRIBUTE
attribute edited
@ MID_GNE_BUTTON_CANCEL
cancel button
@ MID_GNE_BUTTON_RESET
reset button
@ MID_GNE_BUTTON_ACCEPT
accept button
#define GUIDesignTextColorRed
red color (for invalid text)
Definition GUIDesigns.h:44
#define GUIDesignButtonCustomWidth(width)
Button with custom width (used in GNEGeometryPointDialog).
Definition GUIDesigns.h:186
#define GUIDesignTextField
Definition GUIDesigns.h:74
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:430
#define GUIDesignTextFieldNCol
Num of column of text field.
Definition GUIDesigns.h:92
#define GUIDesignTextColorBlack
black color (for correct text)
Definition GUIDesigns.h:38
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
Definition GUIDesigns.h:409
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
Definition GUIDesigns.h:254
#define GUIDesignHorizontalFrame
Horizontal frame extended over frame parent with padding and spacing.
Definition GUIDesigns.h:347
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ MODEMOVE
Definition GUIIcons.h:369
#define TL(string)
Definition MsgHandler.h:304
int gPrecisionGeo
Definition StdDefs.cpp:29
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
OpenType
Open dialog type.
Definition GNEDialog.h:58
GNEDialog(GNEApplicationWindow *applicationWindow, const std::string &name, GUIIcon titleIcon, DialogType type, Buttons buttons, OpenType openType, ResizeMode resizeMode)
basic constructor
Definition GNEDialog.cpp:60
FXButton * myKeepOldButton
accept button
long onCmdAccept(FXObject *sender, FXSelector sel, void *ptr)
event after press accept button
const bool myGeo
flag for geo
FXTextField * myTextFieldXY
text field for X, Y
long onCmdCancel(FXObject *sender, FXSelector sel, void *ptr)
event after press cancel button
long onCmdChangeGeometryPoint(FXObject *sender, FXSelector sel, void *ptr)
event after change position in TextFields
FXButton * myCancelButton
cancel button
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
Position myEditedPosition
edited position
FXButton * myResetButton
cancel button
GNEGeometryPointDialog(GNEApplicationWindow *applicationWindow, const Position &pos)
FOX-declaration abstract.
const Position & getEditedPosition() const
get edited position
FXTextField * myTextFieldLonLat
text field for lon, Lat
long onCmdReset(FXObject *, FXSelector, void *)
event after press cancel button
GNEViewNet * myViewNet
viewNet
const Position myOriginalPos
original position (used for reset)
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static methods for processing the coordinates conversion for the current net
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
dialog arguments, used for certain modal dialogs that can not be edited using tab
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37