Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
CameraSettings.cpp
1/*
2Copyright (C) 2019,2022 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#include "WorldEditor.h"
17#include "CameraSettings.h"
18#include <iostream>
19#include <QComboBox>
20#include <QDoubleSpinBox>
21#include <QDialogButtonBox>
22
23namespace AeonGames
24{
26 QWidget *parent, Qt::WindowFlags f ) : QDialog ( parent, f )
27 {
28 mUi.setupUi ( this );
29 QSettings settings{};
30 settings.beginGroup ( "Camera" );
31 setFieldOfView ( settings.value ( "FieldOfView", 60.0f ).toDouble() );
32 setNear ( settings.value ( "Near", 1.0f ).toDouble() );
33 setFar ( settings.value ( "Far", 1600.0f ).toDouble() );
34 settings.endGroup();
35 }
36
38 {
39 disconnect();
40 std::cout << "CameraSettings::~CameraSettings()" << std::endl;
41 }
43 {
44 return mUi.dblFieldOfView->value();
45 }
47 {
48 return mUi.dblNear->value();
49 }
51 {
52 return mUi.dblFar->value();
53 }
54 void CameraSettings::setFieldOfView ( double aFieldOfView )
55 {
56 QSettings settings{};
57 settings.beginGroup ( "Camera" );
58 settings.setValue ( "FieldOfView", static_cast<float> ( aFieldOfView ) );
59 settings.endGroup();
60 bool blkSignals = mUi.dblFieldOfView->blockSignals ( true );
61 mUi.dblFieldOfView->setValue ( aFieldOfView );
62 mUi.dblFieldOfView->blockSignals ( blkSignals );
63 emit fieldOfViewChanged ( aFieldOfView );
64 }
65 void CameraSettings::setNear ( double aNear )
66 {
67 QSettings settings{};
68 settings.beginGroup ( "Camera" );
69 settings.setValue ( "Near", static_cast<float> ( aNear ) );
70 settings.endGroup();
71 bool blkSignals = mUi.dblNear->blockSignals ( true );
72 mUi.dblNear->setValue ( aNear );
73 mUi.dblNear->blockSignals ( blkSignals );
74 emit nearChanged ( aNear );
75 }
76 void CameraSettings::setFar ( double aFar )
77 {
78 QSettings settings{};
79 settings.beginGroup ( "Camera" );
80 settings.setValue ( "Far", static_cast<float> ( aFar ) );
81 settings.endGroup();
82 bool blkSignals = mUi.dblFar->blockSignals ( true );
83 mUi.dblFar->setValue ( aFar );
84 mUi.dblFar->blockSignals ( blkSignals );
85 emit farChanged ( aFar );
86 }
87 void CameraSettings::clicked ( QAbstractButton* aButton )
88 {
89 if ( mUi.buttonBox->buttonRole ( aButton ) == QDialogButtonBox::ResetRole )
90 {
91 setFieldOfView ( 60.0 );
92 setNear ( 1.0 );
93 setFar ( 1600.0 );
94 }
95 }
96}
void nearChanged(double aNear)
Emitted when the near plane changes.
void fieldOfViewChanged(double aFieldOfView)
Emitted when the field of view changes.
float GetNear() const
Get the near clipping plane distance.
~CameraSettings() override
Destructor.
float GetFar() const
Get the far clipping plane distance.
void farChanged(double aFar)
Emitted when the far plane changes.
CameraSettings(QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags())
Construct the camera settings dialog.
float GetFieldOfView() const
Get the field of view angle.
<- This is here just for the literals
Definition AABB.hpp:31