Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iss: 1877 - image import camera transform broken #1878

Open
wants to merge 4 commits into
base: release/0.7.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions app/src/importpositiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ GNU General Public License for more details.
#include "viewmanager.h"
#include "layermanager.h"
#include "scribblearea.h"
#include "camera.h"

ImportPositionDialog::ImportPositionDialog(Editor* editor, QWidget *parent) :
QDialog(parent),
Expand Down Expand Up @@ -64,39 +65,25 @@ void ImportPositionDialog::didChangeComboBoxIndex(const int index)

void ImportPositionDialog::changeImportView()
{
mEditor->view()->setImportFollowsCamera(false);
QTransform transform;
if (mImportOption == ImportPosition::Type::CenterOfView)
{
QPointF centralPoint = mEditor->getScribbleArea()->getCentralPoint();
transform = transform.fromTranslate(centralPoint.x(), centralPoint.y());
mEditor->view()->setImportView(transform);
QSettings settings(PENCIL2D, PENCIL2D);
settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
return;
}
else if (mImportOption == ImportPosition::Type::CenterOfCanvas)
{
transform = transform.fromTranslate(0, 0);
mEditor->view()->setImportView(transform);
QSettings settings(PENCIL2D, PENCIL2D);
settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
return;
}
else if (mImportOption == ImportPosition::Type::CenterOfCamera)
else if (mImportOption == ImportPosition::Type::CenterOfCamera || mImportOption == ImportPosition::Type::CenterOfCameraFollowed)
{
LayerCamera* layerCam = static_cast<LayerCamera*>(mEditor->layers()->getCameraLayerBelow(mEditor->currentLayerIndex()));
Q_ASSERT(layerCam);
QRectF cameraRect = layerCam->getViewRect();
transform = transform.fromTranslate(cameraRect.center().x(), cameraRect.center().y());
mEditor->view()->setImportView(transform);
QSettings settings(PENCIL2D, PENCIL2D);
settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
return;
}

Q_ASSERT(mImportOption == ImportPosition::Type::CenterOfCameraFollowed);
mEditor->view()->setImportFollowsCamera(true);
if (mImportOption == ImportPosition::Type::CenterOfCamera) {
KeyFrame* camKey = layerCam->getLastCameraAtFrame(mEditor->currentFrame(), 0);
transform = layerCam->getViewAtFrame(camKey->pos()).inverted();
} else {
transform = layerCam->getViewAtFrame(mEditor->currentFrame()).inverted();
}
}
mEditor->view()->setImportView(transform);
QSettings settings(PENCIL2D, PENCIL2D);
settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
}
7 changes: 0 additions & 7 deletions core_lib/src/interface/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,13 +1015,6 @@ Status Editor::importImage(const QString& filePath)
DebugDetails dd;
dd << QString("Raw file path: %1").arg(filePath);

if (view()->getImportFollowsCamera())
{
LayerCamera* camera = static_cast<LayerCamera*>(layers()->getLastCameraLayer());
Q_ASSERT(camera);
QTransform transform = camera->getViewAtFrame(currentFrame());
view()->setImportView(transform);
}
switch (layer->type())
{
case Layer::BITMAP:
Expand Down
40 changes: 0 additions & 40 deletions core_lib/src/managers/viewmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,46 +311,6 @@ void ViewManager::flipVertical(bool b)
}
}

void ViewManager::setOverlayCenter(bool b)
{
if (b != mOverlayCenter)
{
mOverlayCenter = b;
updateViewTransforms();
emit viewChanged();
}
}

void ViewManager::setOverlayThirds(bool b)
{
if (b != mOverlayThirds)
{
mOverlayThirds = b;
updateViewTransforms();
emit viewChanged();
}
}

void ViewManager::setOverlayGoldenRatio(bool b)
{
if (b != mOverlayGoldenRatio)
{
mOverlayGoldenRatio = b;
updateViewTransforms();
emit viewChanged();
}
}

void ViewManager::setOverlaySafeAreas(bool b)
{
if (b != mOverlaySafeAreas)
{
mOverlaySafeAreas = b;
updateViewTransforms();
emit viewChanged();
}
}

void ViewManager::setCanvasSize(QSize size)
{
mCanvasSize = size;
Expand Down
19 changes: 0 additions & 19 deletions core_lib/src/managers/viewmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,13 @@ class ViewManager : public BaseManager
void flipHorizontal(bool b);
void flipVertical(bool b);

void setOverlayCenter(bool b);
void setOverlayThirds(bool b);
void setOverlayGoldenRatio(bool b);
void setOverlaySafeAreas(bool b);

bool isFlipHorizontal() const { return mIsFlipHorizontal; }
bool isFlipVertical() const { return mIsFlipVertical; }
bool getOverlayCenter() const { return mOverlayCenter; }
bool getOverlayThirds() const { return mOverlayThirds; }
bool getOverlayGoldenRatio() const { return mOverlayGoldenRatio; }
bool getOverlaySafeAreas() const { return mOverlaySafeAreas; }

void setCanvasSize(QSize size);

QTransform getImportView() { return mImportView; }
void setImportView(const QTransform& newView) { mImportView = newView; }

void setImportFollowsCamera(bool b) { mImportFollowsCamera = b; }
bool getImportFollowsCamera() { return mImportFollowsCamera; }

void forceUpdateViewTransform();

signals:
Expand All @@ -122,12 +109,6 @@ class ViewManager : public BaseManager

bool mIsFlipHorizontal = false;
bool mIsFlipVertical = false;
bool mOverlayCenter = false;
bool mOverlayThirds = false;
bool mOverlayGoldenRatio = false;
bool mOverlaySafeAreas = false;

bool mImportFollowsCamera = false;
};

#endif // VIEWMANAGER_H
Loading