Debian Codegraph @

src/Gui/PreferencePages/DlgSettingsLightSources.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /***************************************************************************
4 * Copyright (c) 2023 Werner Mayer <wmayer[at]users.sourceforge.net> *
5 * *
6 * This file is part of FreeCAD. *
7 * *
8 * FreeCAD is free software: you can redistribute it and/or modify it *
9 * under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation, either version 2.1 of the *
11 * License, or (at your option) any later version. *
12 * *
13 * FreeCAD is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with FreeCAD. If not, see *
20 * <https://www.gnu.org/licenses/>. *
21 * *
22 **************************************************************************/
23
24
25 #ifndef GUI_DIALOG_DLGSETTINGSLIGHTSOURCES_H
26 #define GUI_DIALOG_DLGSETTINGSLIGHTSOURCES_H
27
28 #include <Gui/PropertyPage.h>
29 #include <memory>
30 #include <QPointer>
31 #include <App/Application.h>
32 #include <Base/Parameter.h>
33 #include <Base/Vector3D.h>
34
35 class SoDragger;
36 class SbRotation;
37 class SoDirectionalLightDragger;
38 class SoOrthographicCamera;
39
40 namespace Gui
41 {
42 class View3DInventorViewer;
43 namespace Dialog
44 {
45 class Ui_DlgSettingsLightSources;
46
47 /**
48 * The DlgSettingsLightSources class implements a preference page to change settings
49 * for the light sources of a 3D view.
50 * @author Werner Mayer
51 */
52 class DlgSettingsLightSources: public PreferencePage
53 {
54 Q_OBJECT
55
56 public:
57 explicit DlgSettingsLightSources(QWidget* parent = nullptr);
58 ~DlgSettingsLightSources() override = default;
59
60 void saveSettings() override;
61 void loadSettings() override;
62 void resetSettingsToDefaults() override;
63
64 public Q_SLOTS:
65 void zoomIn() const;
66 void zoomOut() const;
67
68 protected:
69 void changeEvent(QEvent* event) override;
70
71 private:
72 void configureViewer();
73
74 Base::Vector3d azimuthElevationToDirection(double azimuth, double elevation);
75 std::pair<double, double> directionToAzimuthElevation(Base::Vector3d direction);
76
77 private:
78 std::unique_ptr<Ui_DlgSettingsLightSources> ui;
79 QPointer<View3DInventorViewer> view;
80 SoOrthographicCamera* camera = nullptr;
81
82 ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
83 "User parameter:BaseApp/Preferences/View/LightSources"
84 );
85 ParameterGrp::handle hGrpView = App::GetApplication().GetParameterGroupByPath(
86 "User parameter:BaseApp/Preferences/View"
87 );
88
89 float zoomStep = 3.0f;
90 };
91
92 } // namespace Dialog
93 } // namespace Gui
94
95 #endif // GUI_DIALOG_DLGSETTINGSLIGHTSOURCES_H