44 #ifdef CHECK_MEMORY_LEAKS 46 #endif // CHECK_MEMORY_LEAKS 62 FXIMPLEMENT(
GUIDialog_EditViewport, FXDialogBox, GUIDialog_EditViewportMap, ARRAYNUMBER(GUIDialog_EditViewportMap))
69 const
char* name,
int x,
int y)
70 : FXDialogBox(parent, name, DECOR_TITLE | DECOR_BORDER, x, y, 0, 0),
72 FXVerticalFrame* f1 =
new FXVerticalFrame(
this, LAYOUT_TOP | FRAME_NONE | LAYOUT_FILL_X, 0, 0, 0, 0, 0, 0, 1, 1);
74 FXHorizontalFrame* frame0 =
75 new FXHorizontalFrame(f1, FRAME_THICK, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
76 new FXButton(frame0,
"\t\tLoad viewport from file",
78 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
79 new FXButton(frame0,
"\t\tSave viewport to file",
81 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
83 FXMatrix* m1 =
new FXMatrix(f1, 2, MATRIX_BY_COLUMNS);
84 new FXLabel(m1,
"Zoom:", 0, LAYOUT_CENTER_Y);
85 myZoom =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
86 myZoom->setRange(0.0001, 100000);
87 myZoom->setNumberFormat(4);
88 new FXLabel(m1,
"X:", 0, LAYOUT_CENTER_Y);
89 myXOff =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
90 new FXLabel(m1,
"Y:", 0, LAYOUT_CENTER_Y);
91 myYOff =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
92 new FXLabel(m1,
"Z:", 0, LAYOUT_CENTER_Y);
93 myZOff =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
95 new FXLabel(m1,
"LookAtX:", 0, LAYOUT_CENTER_Y);
96 myLookAtX =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
97 new FXLabel(m1,
"LookAtY:", 0, LAYOUT_CENTER_Y);
98 myLookAtY =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
99 new FXLabel(m1,
"LookAtZ:", 0, LAYOUT_CENTER_Y);
100 myLookAtZ =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
103 new FXHorizontalSeparator(f1, SEPARATOR_GROOVE | LAYOUT_FILL_X);
104 FXHorizontalFrame* f6 =
new FXHorizontalFrame(f1, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 0);
107 BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X,
108 0, 0, 0, 0, 4, 4, 3, 3);
110 FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X,
111 0, 0, 0, 0, 4, 4, 3, 3);
124 Position(myLookAtX->getValue(), myLookAtY->getValue(), myLookAtZ->getValue())
151 Position(myLookAtX->getValue(), myLookAtY->getValue(), myLookAtZ->getValue())
162 FXFileDialog opendialog(
this,
"Load Viewport");
164 opendialog.setSelectMode(SELECTFILE_ANY);
165 opendialog.setPatternList(
"*.xml");
169 if (opendialog.execute()) {
192 FXMessageBox::error(
this, MBOX_OK,
"Storing failed!",
"%s", e.what());
223 myXOff->setValue(lookFrom.
x());
224 myYOff->setValue(lookFrom.
y());
225 myZOff->setValue(lookFrom.
z());
228 myLookAtX->setValue(lookAt.
x());
229 myLookAtY->setValue(lookAt.
y());
230 myLookAtZ->setValue(lookAt.
z());
247 return myZoom->getDial().grabbed() ||
myXOff->getDial().grabbed() ||
myYOff->getDial().grabbed();
void setValues(SUMOReal zoom, SUMOReal xoff, SUMOReal yoff)
Sets the given values into the dialog.
long onCmdOk(FXObject *, FXSelector, void *)
Called when the user wants to keep the viewport.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void close()
Closes the device and removes it from the dictionary.
virtual void setViewportFromTo(const Position &lookFrom, const Position &lookAt)
applies the given viewport settings
long onCmdCancel(FXObject *, FXSelector, void *)
Called when the user wants to restore the viewport.
long onCmdChanged(FXObject *, FXSelector, void *)
Called when the user changes the viewport.
virtual SUMOReal getZoom() const =0
Returns the zoom factor computed stored in this changer.
void writeXML(OutputDevice &dev)
write the settings to the given device
FXString gCurrentFolder
The folder used as last.
long onCmdLoad(FXObject *, FXSelector, void *)
Called when the user wants to load a viewport.
FXRealSpinDial * myZoom
The spin dialers used to change the view.
SUMOReal x() const
Returns the x-position.
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString ¤tFolder)
Returns the file name to write.
#define UNUSED_PARAMETER(x)
virtual SUMOReal getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
void applyViewport(GUISUMOAbstractView *view) const
Sets the viewport which has been parsed.
A point in 2D or 3D with translation and scaling methods.
virtual SUMOReal zPos2Zoom(SUMOReal zPos) const =0
Returns the zoom level that is achieved at a given camera height.
SUMOReal z() const
Returns the z-position.
~GUIDialog_EditViewport()
Destructor.
long onCmdSave(FXObject *, FXSelector, void *)
Called when the user wants to save a viewport.
GUISUMOAbstractView * myParent
The calling view.
FXDEFMAP(GUIDialog_EditViewport) GUIDialog_EditViewportMap[]
Position myOldLookFrom
The old viewport.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
SUMOReal y() const
Returns the y-position.
GUIPerspectiveChanger & getChanger() const
get changer
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
An XML-handler for visualisation schemes.
A dialog to change the viewport.
virtual SUMOReal getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
bool haveGrabbed() const
Returns the information whether one of the spin dialers is grabbed.
virtual SUMOReal zoom2ZPos(SUMOReal zoom) const =0
Returns the camera height at which the given zoom level is reached.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static const Position INVALID
void setOldValues(const Position &lookFrom, const Position &lookAt)
Resets old values.