这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
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
8 changes: 4 additions & 4 deletions app/src/importimageseqdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void ImportImageSeqDialog::setSpace(int number)
uiOptionsBox->spaceSpinBox->setValue(number);
}

void ImportImageSeqDialog::importArbitrarySequence()
void ImportImageSeqDialog::importArbitrarySequence(const ImportImageConfig importImageConfig)
{
QStringList files = getFilePaths();
int number = getSpace();
Expand All @@ -189,7 +189,7 @@ void ImportImageSeqDialog::importArbitrarySequence()
{
QString strImgFileLower = strImgFile.toLower();

Status st = mEditor->importImage(strImgFile);
Status st = mEditor->importImage(strImgFile, importImageConfig);
if (!st.ok())
{
ErrorDialog errorDialog(st.title(), st.description(), st.details().html());
Expand Down Expand Up @@ -288,7 +288,7 @@ const PredefinedKeySetParams ImportImageSeqDialog::predefinedKeySetParams() cons
return setParams;
}

void ImportImageSeqDialog::importPredefinedSet()
void ImportImageSeqDialog::importPredefinedSet(const ImportImageConfig importImageConfig)
{
PredefinedKeySet keySet = generatePredefinedKeySet();

Expand All @@ -310,7 +310,7 @@ void ImportImageSeqDialog::importPredefinedSet()
const QString& filePath = keySet.filePathAt(i);

mEditor->scrubTo(frameIndex);
Status st = mEditor->importImage(filePath);
Status st = mEditor->importImage(filePath, importImageConfig);
if (!st.ok())
{
ErrorDialog errorDialog(st.title(), st.description(), st.details().html());
Expand Down
5 changes: 3 additions & 2 deletions app/src/importimageseqdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ GNU General Public License for more details.
#include "importexportdialog.h"
#include "pencilerror.h"
#include "predefinedsetmodel.h"
#include "importimageconfig.h"

class Editor;

Expand Down Expand Up @@ -52,8 +53,8 @@ class ImportImageSeqDialog : public ImportExportDialog
ImportCriteria importCriteria = ImportCriteria::Arbitrary);
~ImportImageSeqDialog() override;

void importArbitrarySequence();
void importPredefinedSet();
void importArbitrarySequence(const ImportImageConfig importImageConfig);
void importPredefinedSet(const ImportImageConfig importImageConfig);
int getSpace();

void setCore(Editor* editor) { mEditor = editor; }
Expand Down
38 changes: 3 additions & 35 deletions app/src/importpositiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ GNU General Public License for more details.
#include <QSettings>
#include <QStandardItemModel>
#include "editor.h"
#include "layercamera.h"
#include "viewmanager.h"
#include "layermanager.h"
#include "scribblearea.h"

ImportPositionDialog::ImportPositionDialog(Editor* editor, QWidget *parent) :
QDialog(parent),
Expand Down Expand Up @@ -59,44 +56,15 @@ ImportPositionDialog::~ImportPositionDialog()

void ImportPositionDialog::didChangeComboBoxIndex(const int index)
{
mImportOption = ImportPosition::getTypeFromIndex(index);
mImportConfig.positionType = getTypeFromIndex(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)
{
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;
if (mImportConfig.positionType == ImportImageConfig::CenterOfCamera) {
mImportConfig.importFrame = mEditor->currentFrame();
}

Q_ASSERT(mImportOption == ImportPosition::Type::CenterOfCameraFollowed);
mEditor->view()->setImportFollowsCamera(true);
QSettings settings(PENCIL2D, PENCIL2D);
settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex());
}
47 changes: 20 additions & 27 deletions app/src/importpositiondialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ GNU General Public License for more details.

#include <QDialog>

#include "importimageconfig.h"

namespace Ui {
class ImportPositionDialog;
}
Expand All @@ -29,44 +31,35 @@ class ImportPositionDialog : public QDialog
{
Q_OBJECT

struct ImportPosition {

enum Type {
CenterOfView,
CenterOfCanvas,
CenterOfCamera,
CenterOfCameraFollowed,
None
};

static Type getTypeFromIndex(int index) {
switch (index) {
case 0:
return CenterOfView;
case 1:
return CenterOfCanvas;
case 2:
return CenterOfCamera;
case 3:
return CenterOfCameraFollowed;
default:
return None;
}
}
};

public:
explicit ImportPositionDialog(Editor* editor, QWidget *parent = nullptr);
~ImportPositionDialog();

ImportImageConfig importConfig() const { return mImportConfig; }

private slots:
void didChangeComboBoxIndex(const int index);
void changeImportView();

private:
static ImportImageConfig::PositionType getTypeFromIndex(int index) {
switch (index) {
case 0:
return ImportImageConfig::CenterOfView;
case 1:
return ImportImageConfig::CenterOfCanvas;
case 2:
return ImportImageConfig::CenterOfCamera;
case 3:
return ImportImageConfig::CenterOfCameraFollowed;
default:
return ImportImageConfig::None;
}
}

Ui::ImportPositionDialog *ui;

ImportPosition::Type mImportOption = ImportPosition::None;
ImportImageConfig mImportConfig;
Editor* mEditor = nullptr;
};

Expand Down
7 changes: 4 additions & 3 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,8 @@ void MainWindow2::importImage()
return;
}

Status st = mEditor->importImage(strFilePath);
ImportImageConfig importImageConfig = positionDialog->importConfig();
Status st = mEditor->importImage(strFilePath, importImageConfig);
if (!st.ok())
{
ErrorDialog errorDialog(st.title(), st.description(), st.details().html());
Expand Down Expand Up @@ -908,7 +909,7 @@ void MainWindow2::importImageSequence()
return;
}

imageSeqDialog->importArbitrarySequence();
imageSeqDialog->importArbitrarySequence(positionDialog->importConfig());

mSuppressAutoSaveDialog = false;
}
Expand Down Expand Up @@ -937,7 +938,7 @@ void MainWindow2::importPredefinedImageSet()
return;
}

imageSeqDialog->importPredefinedSet();
imageSeqDialog->importPredefinedSet(positionDialog->importConfig());
mSuppressAutoSaveDialog = false;
}

Expand Down
1 change: 1 addition & 0 deletions core_lib/core_lib.pro
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ HEADERS += \
src/util/colordictionary.h \
src/util/fileformat.h \
src/util/filetype.h \
src/util/importimageconfig.h \
src/util/mathutils.h \
src/util/onionskinpainteroptions.h \
src/util/onionskinpaintstate.h \
Expand Down
45 changes: 33 additions & 12 deletions core_lib/src/interface/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ GNU General Public License for more details.
#include "vectorimage.h"
#include "bitmapimage.h"
#include "soundclip.h"
#include "camera.h"
#include "layerbitmap.h"
#include "layervector.h"
#include "layercamera.h"
Expand Down Expand Up @@ -911,7 +912,7 @@ void Editor::updateObject()
emit updateLayerCount();
}

Status Editor::importBitmapImage(const QString& filePath)
Status Editor::importBitmapImage(const QString& filePath, const QTransform& importTransform)
{
QImageReader reader(filePath);

Expand Down Expand Up @@ -954,8 +955,8 @@ Status Editor::importBitmapImage(const QString& filePath)
status = Status(Status::FAIL, dd, tr("Import failed"), errorDesc);
}

const QPoint pos(view()->getImportView().dx() - (img.width() / 2),
view()->getImportView().dy() - (img.height() / 2));
const QPoint pos = importTransform.map(QPoint(-img.width() / 2,
-img.height() / 2));

if (!layer->keyExists(mFrame))
{
Expand Down Expand Up @@ -1008,24 +1009,44 @@ Status Editor::importVectorImage(const QString& filePath)
return status;
}

Status Editor::importImage(const QString& filePath)
Status Editor::importImage(const QString& filePath, const ImportImageConfig importConfig)
{
Layer* layer = layers()->currentLayer();

DebugDetails dd;
dd << QString("Raw file path: %1").arg(filePath);

if (view()->getImportFollowsCamera())
QTransform transform;
switch (importConfig.positionType)
{
LayerCamera* camera = static_cast<LayerCamera*>(layers()->getLastCameraLayer());
Q_ASSERT(camera);
QTransform transform = camera->getViewAtFrame(currentFrame());
view()->setImportView(transform);
case ImportImageConfig::CenterOfCamera: {
LayerCamera* layerCam = static_cast<LayerCamera*>(layers()->getCameraLayerBelow(currentLayerIndex()));
Q_ASSERT(layerCam);
transform = layerCam->getViewAtFrame(importConfig.importFrame).inverted();
break;
}
case ImportImageConfig::CenterOfCameraFollowed: {
LayerCamera* camera = static_cast<LayerCamera*>(layers()->getCameraLayerBelow(currentLayerIndex()));
Q_ASSERT(camera);
transform = camera->getViewAtFrame(currentFrame()).inverted();
break;
}
case ImportImageConfig::CenterOfView: {
QPointF centralPoint = mScribbleArea->getCentralPoint();
transform = QTransform::fromTranslate(centralPoint.x(), centralPoint.y());
break;
}
case ImportImageConfig::CenterOfCanvas:
case ImportImageConfig::None: {
transform = QTransform();
break;
}
}

switch (layer->type())
{
case Layer::BITMAP:
return importBitmapImage(filePath);
return importBitmapImage(filePath, transform);

case Layer::VECTOR:
return importVectorImage(filePath);
Expand Down Expand Up @@ -1058,8 +1079,8 @@ Status Editor::importAnimatedImage(const QString& filePath, int frameSpacing, co
}

QImage img(reader.size(), QImage::Format_ARGB32_Premultiplied);
const QPoint pos(view()->getImportView().dx() - (img.width() / 2),
view()->getImportView().dy() - (img.height() / 2));
const QPoint pos(view()->getView().dx() - (img.width() / 2),
view()->getView().dy() - (img.height() / 2));
int totalFrames = reader.imageCount();
while (reader.read(&img))
{
Expand Down
5 changes: 3 additions & 2 deletions core_lib/src/interface/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ GNU General Public License for more details.
#include <QObject>
#include "pencilerror.h"
#include "pencildef.h"
#include "importimageconfig.h"

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Q_MOC_INCLUDE("colormanager.h")
Expand Down Expand Up @@ -173,7 +174,7 @@ class Editor : public QObject

void clearCurrentFrame();

Status importImage(const QString& filePath);
Status importImage(const QString& filePath, ImportImageConfig importConfig);
Status importAnimatedImage(const QString& filePath, int frameSpacing, const std::function<void (int)>& progressChanged, const std::function<bool ()>& wasCanceled);
void restoreKey();

Expand Down Expand Up @@ -236,7 +237,7 @@ class Editor : public QObject
void resetAutoSaveCounter();

private:
Status importBitmapImage(const QString&);
Status importBitmapImage(const QString&, const QTransform& importTransform);
Status importVectorImage(const QString&);

void pasteToCanvas(BitmapImage* bitmapImage, int frameNumber);
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
Loading
Loading