Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2025 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 : using FXDialogBox::show; // to silence the warning C4266 about a hidden function
67 :
68 : /// @name FOX-callbacks
69 : /// @{
70 :
71 : /// Called when the user changes the viewport
72 : long onCmdChanged(FXObject*, FXSelector, void*);
73 :
74 : /// Called when the user wants to keep the viewport
75 : long onCmdOk(FXObject*, FXSelector, void*);
76 :
77 : /// Called when the user wants to restore the viewport
78 : long onCmdCancel(FXObject*, FXSelector, void*);
79 :
80 : /// Called when the user wants to load a viewport
81 : long onCmdLoad(FXObject*, FXSelector, void*);
82 :
83 : /// Called when the user wants to save a viewport
84 : long onCmdSave(FXObject*, FXSelector, void*);
85 : /// @}
86 :
87 : /// write the settings to the given device
88 : void writeXML(OutputDevice& dev);
89 :
90 : /** @brief Sets the given values into the dialog
91 : * @param[in] zoom Current view's zoom
92 : * @param[in] xoff Current view's x-offset
93 : * @param[in] yoff Current view's y-offset
94 : */
95 : void setValues(double zoom, double xoff, double yoff, double rotation);
96 :
97 : /** @brief Sets the given values into the dialog
98 : * @param[in] lookFrom Current viewport's from
99 : * @param[in] lookAt Current viewport's at
100 : */
101 : void setValues(const Position& lookFrom, const Position& lookAt, double rotation);
102 :
103 : /** @brief Resets old values
104 : * @param[in] lookFrom Current viewport's from
105 : * @param[in] lookAt Current viewport's at
106 : */
107 : void setOldValues(const Position& lookFrom, const Position& lookAt, double rotation);
108 :
109 : /** @brief Returns the information whether one of the spin dialers is grabbed
110 : * @return Whether the spin dialers are currently used
111 : */
112 : bool haveGrabbed() const;
113 :
114 : /** @brief Returns the current zoom value stored in the corresponding spin dialer
115 : * @return The current zoom value in the spin dialer
116 : */
117 : double getZoomValue() const;
118 :
119 :
120 : /** @brief Resets the zoom spin dialer
121 : * @param[in] zoom the value to set the spin dialer to
122 : */
123 : void setZoomValue(double zoom);
124 :
125 : protected:
126 0 : FOX_CONSTRUCTOR(GUIDialog_EditViewport)
127 :
128 : /// @brief save window position to the registry
129 : void saveWindowPos();
130 :
131 : private:
132 : /// @brief The calling view
133 : GUISUMOAbstractView* myParent = nullptr;
134 :
135 : /// @brief The old viewport
136 : Position myOldLookFrom, myOldLookAt;
137 : double myOldRotation;
138 :
139 : /// @brief load button
140 : FXButton* myLoadButton = nullptr;
141 :
142 : /// @brief save button
143 : FXButton* mySaveButton = nullptr;
144 :
145 : /// @brief The spin dialers used to change the view
146 : FXRealSpinner* myZoom = nullptr;
147 : FXRealSpinner* myXOff = nullptr;
148 : FXRealSpinner* myYOff = nullptr;
149 : FXRealSpinner* myZOff = nullptr;
150 : FXRealSpinner* myRotation = nullptr;
151 :
152 : /// @brief The spin dialers used to change the view at (osg only)
153 : FXRealSpinner* myLookAtX = nullptr;
154 : FXRealSpinner* myLookAtY = nullptr;
155 : FXRealSpinner* myLookAtZ = nullptr;
156 :
157 : /// @brief OK button
158 : FXButton* myOKButton = nullptr;
159 :
160 : /// @brief Cancel button
161 : FXButton* myCancelButton = nullptr;
162 : };
|