43 #ifdef CHECK_MEMORY_LEAKS 45 #endif // CHECK_MEMORY_LEAKS 61 FXIMPLEMENT(
GUIDialog_EditViewport, FXDialogBox, GUIDialog_EditViewportMap, ARRAYNUMBER(GUIDialog_EditViewportMap))
68 const
char* name,
int x,
int y)
69 : FXDialogBox(parent, name, DECOR_TITLE | DECOR_BORDER, x, y, 0, 0),
71 FXVerticalFrame* f1 =
new FXVerticalFrame(
this, LAYOUT_TOP | FRAME_NONE | LAYOUT_FILL_X, 0, 0, 0, 0, 0, 0, 1, 1);
73 FXHorizontalFrame* frame0 =
74 new FXHorizontalFrame(f1, FRAME_THICK, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2);
75 new FXButton(frame0,
"\t\tLoad viewport from file",
77 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
78 new FXButton(frame0,
"\t\tSave viewport to file",
80 ICON_ABOVE_TEXT | BUTTON_TOOLBAR | FRAME_RAISED | LAYOUT_TOP | LAYOUT_LEFT);
82 FXMatrix* m1 =
new FXMatrix(f1, 2, MATRIX_BY_COLUMNS);
83 new FXLabel(m1,
"Zoom:", 0, LAYOUT_CENTER_Y);
84 myZoom =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK);
85 myZoom->setRange(0.0001, 100000);
86 myZoom->setNumberFormat(4);
87 new FXLabel(m1,
"X:", 0, LAYOUT_CENTER_Y);
88 myXOff =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
89 new FXLabel(m1,
"Y:", 0, LAYOUT_CENTER_Y);
90 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,
"LookAtX:", 0, LAYOUT_CENTER_Y);
93 myLookAtX =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
94 new FXLabel(m1,
"LookAtY:", 0, LAYOUT_CENTER_Y);
95 myLookAtY =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
96 new FXLabel(m1,
"LookAtZ:", 0, LAYOUT_CENTER_Y);
97 myLookAtZ =
new FXRealSpinDial(m1, 16,
this, MID_CHANGED, LAYOUT_CENTER_Y | LAYOUT_TOP | FRAME_SUNKEN | FRAME_THICK |
SPINDIAL_NOMIN |
SPINDIAL_NOMAX);
100 new FXHorizontalSeparator(f1, SEPARATOR_GROOVE | LAYOUT_FILL_X);
101 FXHorizontalFrame* f6 =
new FXHorizontalFrame(f1, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 0);
104 BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X,
105 0, 0, 0, 0, 4, 4, 3, 3);
107 FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X,
108 0, 0, 0, 0, 4, 4, 3, 3);
121 Position(myLookAtX->getValue(), myLookAtY->getValue(), myLookAtZ->getValue())
143 Position(myLookAtX->getValue(), myLookAtY->getValue(), myLookAtZ->getValue())
154 FXFileDialog opendialog(
this,
"Load Viewport");
156 opendialog.setSelectMode(SELECTFILE_ANY);
157 opendialog.setPatternList(
"*.xml");
161 if (opendialog.execute()) {
165 handler.setViewport(lookFrom, lookAt);
166 if (lookFrom.z() > 0) {
188 FXMessageBox::error(
this, MBOX_OK,
"Storing failed!",
"%s", e.what());
218 myZoom->setValue(lookFrom.
z());
219 myXOff->setValue(lookFrom.
x());
220 myYOff->setValue(lookFrom.
y());
222 myLookAtX->setValue(lookAt.
x());
223 myLookAtY->setValue(lookAt.
y());
224 myLookAtZ->setValue(lookAt.
z());
241 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 setViewport(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.
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)
A point in 2D or 3D with translation and scaling methods.
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.
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.
bool haveGrabbed() const
Returns the information whether one of the spin dialers is grabbed.
static FXIcon * getIcon(GUIIcon which)
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.