Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2024 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 : /****************************************************************************/
14 : /// @file GUIDialog_EditViewport.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Michael Behrisch
17 : /// @date 2005-05-04
18 : ///
19 : // A dialog to change the viewport
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include <utils/foxtools/fxheader.h>
25 : #include <utils/gui/div/GUIPersistentWindowPos.h>
26 :
27 : // ===========================================================================
28 : // class declarations
29 : // ===========================================================================
30 : class GUISUMOAbstractView;
31 : class Position;
32 :
33 :
34 : // ===========================================================================
35 : // class definitions
36 : // ===========================================================================
37 : /**
38 : * @class GUIDialog_EditViewport
39 : * @brief A dialog to change the viewport
40 : */
41 : class GUIDialog_EditViewport : public FXDialogBox, public GUIPersistentWindowPos {
42 : // FOX-declarations
43 0 : FXDECLARE(GUIDialog_EditViewport)
44 : public:
45 : /// @brief FOX-callback enumerations
46 : enum {
47 : MID_CHANGED = FXDialogBox::ID_LAST,
48 : MID_OK,
49 : MID_CANCEL,
50 : MID_LOAD,
51 : MID_SAVE
52 : };
53 :
54 :
55 : /** @brief Constructor
56 : * @param[in] parent The view to change
57 : * @param[in] name This dialog's caption
58 : */
59 : GUIDialog_EditViewport(GUISUMOAbstractView* parent, const char* name);
60 :
61 : /// @brief Destructor
62 : ~GUIDialog_EditViewport();
63 :
64 : /// @brief overload show function to focus always in OK Button
65 : void show();
66 :
67 : /// @name FOX-callbacks
68 : /// @{
69 :
70 : /// Called when the user changes the viewport
71 : long onCmdChanged(FXObject*, FXSelector, void*);
72 :
73 : /// Called when the user wants to keep the viewport
74 : long onCmdOk(FXObject*, FXSelector, void*);
75 :
76 : /// Called when the user wants to restore the viewport
77 : long onCmdCancel(FXObject*, FXSelector, void*);
78 :
79 : /// Called when the user wants to load a viewport
80 : long onCmdLoad(FXObject*, FXSelector, void*);
81 :
82 : /// Called when the user wants to save a viewport
83 : long onCmdSave(FXObject*, FXSelector, void*);
84 : /// @}
85 :
86 : /// write the settings to the given device
87 : void writeXML(OutputDevice& dev);
88 :
89 : /** @brief Sets the given values into the dialog
90 : * @param[in] zoom Current view's zoom
91 : * @param[in] xoff Current view's x-offset
92 : * @param[in] yoff Current view's y-offset
93 : */
94 : void setValues(double zoom, double xoff, double yoff, double rotation);
95 :
96 : /** @brief Sets the given values into the dialog
97 : * @param[in] lookFrom Current viewport's from
98 : * @param[in] lookAt Current viewport's at
99 : */
100 : void setValues(const Position& lookFrom, const Position& lookAt, double rotation);
101 :
102 : /** @brief Resets old values
103 : * @param[in] lookFrom Current viewport's from
104 : * @param[in] lookAt Current viewport's at
105 : */
106 : void setOldValues(const Position& lookFrom, const Position& lookAt, double rotation);
107 :
108 : /** @brief Returns the information whether one of the spin dialers is grabbed
109 : * @return Whether the spin dialers are currently used
110 : */
111 : bool haveGrabbed() const;
112 :
113 : /** @brief Returns the current zoom value stored in the corresponding spin dialer
114 : * @return The current zoom value in the spin dialer
115 : */
116 : double getZoomValue() const;
117 :
118 :
119 : /** @brief Resets the zoom spin dialer
120 : * @param[in] zoom the value to set the spin dialer to
121 : */
122 : void setZoomValue(double zoom);
123 :
124 : protected:
125 0 : FOX_CONSTRUCTOR(GUIDialog_EditViewport)
126 :
127 : /// @brief save window position to the registry
128 : void saveWindowPos();
129 :
130 : private:
131 : /// @brief The calling view
132 : GUISUMOAbstractView* myParent = nullptr;
133 :
134 : /// @brief The old viewport
135 : Position myOldLookFrom, myOldLookAt;
136 : double myOldRotation;
137 :
138 : /// @brief load button
139 : FXButton* myLoadButton = nullptr;
140 :
141 : /// @brief save button
142 : FXButton* mySaveButton = nullptr;
143 :
144 : /// @brief The spin dialers used to change the view
145 : FXRealSpinner* myZoom = nullptr;
146 : FXRealSpinner* myXOff = nullptr;
147 : FXRealSpinner* myYOff = nullptr;
148 : FXRealSpinner* myZOff = nullptr;
149 : FXRealSpinner* myRotation = nullptr;
150 :
151 : /// @brief The spin dialers used to change the view at (osg only)
152 : FXRealSpinner* myLookAtX = nullptr;
153 : FXRealSpinner* myLookAtY = nullptr;
154 : FXRealSpinner* myLookAtZ = nullptr;
155 :
156 : /// @brief OK button
157 : FXButton* myOKButton = nullptr;
158 :
159 : /// @brief Cancel button
160 : FXButton* myCancelButton = nullptr;
161 : };
|