Skip to content

Commit

Permalink
Save camera settings in Settings. Get and set values.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlamhauge committed Mar 1, 2024
1 parent da15d2d commit 5ea52b6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/src/camerapropertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,23 @@ void CameraPropertiesDialog::setHeight(int height)
{
ui->heightBox->setValue(height);
}

qreal CameraPropertiesDialog::getDistance()
{
return ui->distanceSpinBox->value();
}

void CameraPropertiesDialog::setDistance(qreal dist)
{
ui->distanceSpinBox->setValue(dist);
}

qreal CameraPropertiesDialog::getAperture()
{
return ui->apertureBox->itemData(ui->apertureBox->currentIndex()).toDouble();
}

void CameraPropertiesDialog::setAperture(qreal aperture)
{
ui->apertureBox->setCurrentText(QString::number(aperture));
}
4 changes: 4 additions & 0 deletions app/src/camerapropertiesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class CameraPropertiesDialog : public QDialog
void setWidth(int);
int getHeight();
void setHeight(int);
qreal getDistance();
void setDistance(qreal dist);
qreal getAperture();
void setAperture(qreal aperture);

private:
Ui::CameraPropertiesDialog* ui = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions app/src/timelinecells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,8 @@ void TimeLineCells::editLayerProperties(LayerCamera* cameraLayer) const
QSettings settings(PENCIL2D, PENCIL2D);
settings.setValue(SETTING_FIELD_W, dialog.getWidth());
settings.setValue(SETTING_FIELD_H, dialog.getHeight());
settings.setValue(SETTING_CAM_DISTANCE, dialog.getDistance());
settings.setValue(SETTING_APERTURE, dialog.getAperture());
cameraLayer->setViewRect(QRect(-dialog.getWidth() / 2, -dialog.getHeight() / 2, dialog.getWidth(), dialog.getHeight()));
mEditor->view()->forceUpdateViewTransform();
}
Expand Down
1 change: 1 addition & 0 deletions core_lib/src/structure/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ bool Layer::isPaintable() const

void Layer::updateFarNearDistance(qreal distance, qreal aperture)
{
// qreal focalLength = 50.0f;
qreal hyperFocalDist = getHyperfocalDistance(50, aperture);
mNearDistance = getDistanceNear(hyperFocalDist, distance, 50);
mFarDistance = getDistanceFar(hyperFocalDist, distance, 50);
Expand Down
5 changes: 4 additions & 1 deletion core_lib/src/structure/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ class Layer : public QObject
qreal getNearDistance() { return mNearDistance; }
void setFarDistance(qreal dist) { mFarDistance = dist; }
qreal getFarDistance() { return mFarDistance; }
void updateFarNearDistance(qreal near, qreal far);

public slots:

void updateFarNearDistance(qreal distance, qreal aperture);

protected:
virtual KeyFrame* createKeyFrame(int position) = 0;
Expand Down

0 comments on commit 5ea52b6

Please sign in to comment.