Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

starter interface options

Jeremy Bullock7c096e2b825d
diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h
index ffe92a0c7..0f7816357 100644
--- a/toonz/sources/include/toonz/preferences.h
+++ b/toonz/sources/include/toonz/preferences.h
@@ -122,6 +122,14 @@ public:
QString getStyleSheet(int index) const;
int getStyleSheetCount() const;
+ void setPixelsOnly(bool state);
+ bool getPixelsOnly() const { return m_pixelsOnly; }
+
+ void storeOldUnits();
+ void resetOldUnits();
+ QString getOldUnits() const { return m_oldUnits; }
+ QString getOldCameraUnits() const { return m_oldCameraUnits; }
+
void setUnits(std::string s);
QString getUnits() const { return m_units; }
@@ -410,7 +418,8 @@ private:
std::vector<LevelFormat> m_levelFormats;
- QString m_units, m_cameraUnits, m_scanLevelType, m_currentRoomChoice;
+ QString m_units, m_cameraUnits, m_scanLevelType, m_currentRoomChoice,
+ m_oldUnits, m_oldCameraUnits;
double m_defLevelWidth, m_defLevelHeight, m_defLevelDpi;
@@ -432,7 +441,7 @@ private:
m_generatedMovieViewEnabled, m_xsheetAutopanEnabled,
m_ignoreAlphaonColumn1Enabled, m_previewAlwaysOpenNewFlipEnabled,
m_rewindAfterPlaybackEnabled, m_fitToFlipbookEnabled, m_autosaveEnabled,
- m_defaultViewerEnabled;
+ m_defaultViewerEnabled, m_pixelsOnly;
bool m_rasterOptimizedMemory, m_saveUnpaintedInCleanup,
m_askForOverrideRender, m_automaticSVNFolderRefreshEnabled, m_SVNEnabled,
m_levelsBackupEnabled, m_minimizeSaveboxAfterEditing,
diff --git a/toonz/sources/include/toonz/tcamera.h b/toonz/sources/include/toonz/tcamera.h
index 79aeef50e..1e8f45056 100644
--- a/toonz/sources/include/toonz/tcamera.h
+++ b/toonz/sources/include/toonz/tcamera.h
@@ -39,7 +39,7 @@ class DVAPI TCamera {
public:
/*!
Constructs TCamera with default value, size (12,9) and resolution (768,576).
- Constructs TCamera with default value, size (12,9) and resolution (1920,1080).
+ Constructs TCamera with default value, size (35.9955, 20.2544) and resolution (1920,1080).
- 05/31/16
*/
TCamera();
diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp
index 808e86ef6..8f47e06d4 100644
--- a/toonz/sources/toonz/iocommand.cpp
+++ b/toonz/sources/toonz/iocommand.cpp
@@ -1257,7 +1257,7 @@ bool IoCmd::saveSceneIfNeeded(QString msg) {
void IoCmd::newScene() {
RenderingSuspender suspender;
TApp *app = TApp::instance();
- double cameraDpi = 64.0;
+ double cameraDpi = 53.3333;
if (!saveSceneIfNeeded(QApplication::tr("New Scene"))) return;
IconGenerator::instance()->clearRequests();
diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp
index b0e77a7a2..501a4a59f 100644
--- a/toonz/sources/toonz/preferencespopup.cpp
+++ b/toonz/sources/toonz/preferencespopup.cpp
@@ -22,6 +22,8 @@
#include "toonz/txshlevelhandle.h"
#include "toonz/txshleveltypes.h"
#include "toonz/tscenehandle.h"
+#include "toonz/toonzscene.h"
+#include "toonz/tcamera.h"
#include "toonz/levelproperties.h"
#include "toonz/tonionskinmaskhandle.h"
@@ -211,14 +213,57 @@ Preferences::LevelFormat PreferencesPopup::FormatProperties::levelFormat()
// PreferencesPopup implementation
//**********************************************************************************
+void PreferencesPopup::onPixelsOnlyChanged(int index) {
+ bool enabled = index == Qt::Checked;
+ if (enabled) {
+ m_pref->setDefLevelDpi(53.3333);
+ m_pref->setPixelsOnly(true);
+ TCamera* camera;
+ camera = TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
+ TDimension camRes = camera->getRes();
+ TDimensionD camSize;
+ camSize.lx = camRes.lx / 53.3333;
+ camSize.ly = camRes.ly / 53.3333;
+ camera->setSize(camSize);
+ m_pref->storeOldUnits();
+ if (m_unitOm->currentIndex() != 4)
+ m_unitOm->setCurrentIndex(4);
+ if (m_cameraUnitOm->currentIndex() != 4)
+ m_cameraUnitOm->setCurrentIndex(4);
+ m_unitOm->setDisabled(true);
+ m_cameraUnitOm->setDisabled(true);
+
+ }
+ else {
+ QString tempUnit;
+ int unitIndex;
+ tempUnit = m_pref->getOldUnits();
+ unitIndex = m_unitOm->findText(tempUnit);
+ m_unitOm->setCurrentIndex(unitIndex);
+ tempUnit = m_pref->getOldCameraUnits();
+ unitIndex = m_cameraUnitOm->findText(tempUnit);
+ m_cameraUnitOm->setCurrentIndex(unitIndex);
+ m_unitOm->setDisabled(false);
+ m_cameraUnitOm->setDisabled(false);
+ m_pref->setPixelsOnly(false);
+ }
+
+}
+
void PreferencesPopup::onUnitChanged(int index) {
- m_pref->setUnits(::units[index].toStdString());
+ if (index == 4 && m_pixelsOnlyCB->isChecked() == false) {
+ m_pixelsOnlyCB->setCheckState(Qt::Checked);
+ }
+ m_pref->setUnits(::units[index].toStdString());
}
//-----------------------------------------------------------------------------
void PreferencesPopup::onCameraUnitChanged(int index) {
- m_pref->setCameraUnits(::units[index].toStdString());
+ if (index == 4 && m_pixelsOnlyCB->isChecked() == false) {
+ m_pixelsOnlyCB->setChecked(true);
+ }
+ m_pref->setCameraUnits(::units[index].toStdString());
}
//-----------------------------------------------------------------------------
@@ -834,8 +879,10 @@ PreferencesPopup::PreferencesPopup()
languageType->setCurrentIndex(currentIndex);
}
QComboBox *styleSheetType = new QComboBox(this);
- QComboBox *unitOm = new QComboBox(this);
- QComboBox *cameraUnitOm = new QComboBox(this);
+ m_pixelsOnlyCB =
+ new CheckBox(tr("All imported images will use the same DPI"), this);
+ m_unitOm = new QComboBox(this);
+ m_cameraUnitOm = new QComboBox(this);
// Choose between standard and Studio Ghibli rooms
QComboBox *roomChoice = new QComboBox(this);
@@ -1014,18 +1061,19 @@ PreferencesPopup::PreferencesPopup()
}
styleSheetType->addItems(styleSheetList);
styleSheetType->setCurrentIndex(currentIndex);
-
+ //m_pixelsOnlyCB->setChecked(m_pref->getPixelsOnly());
+ m_pixelsOnlyCB->setChecked(true);
QStringList type;
type << tr("cm") << tr("mm") << tr("inch") << tr("field") << tr("pixel");
- unitOm->addItems(type);
+ m_unitOm->addItems(type);
int idx =
std::find(::units, ::units + ::unitsCount, m_pref->getUnits()) - ::units;
- unitOm->setCurrentIndex((idx < ::unitsCount) ? idx : ::inchIdx);
- cameraUnitOm->addItems(type);
+ m_unitOm->setCurrentIndex((idx < ::unitsCount) ? idx : ::inchIdx);
+ m_cameraUnitOm->addItems(type);
idx = std::find(::units, ::units + ::unitsCount, m_pref->getCameraUnits()) -
::units;
- cameraUnitOm->setCurrentIndex((idx < ::unitsCount) ? idx : ::inchIdx);
+ m_cameraUnitOm->setCurrentIndex((idx < ::unitsCount) ? idx : ::inchIdx);
QStringList roomList;
int currentRoomIndex = 0;
@@ -1269,18 +1317,22 @@ PreferencesPopup::PreferencesPopup()
styleLay->addWidget(new QLabel(tr("Style:")), 0, 0,
Qt::AlignRight | Qt::AlignVCenter);
styleLay->addWidget(styleSheetType, 0, 1);
+
+ styleLay->addWidget(new QLabel(tr("Pixels Only:"), this), 1, 0,
+ Qt::AlignRight | Qt::AlignVCenter);
+ styleLay->addWidget(m_pixelsOnlyCB, 1, 1);
- styleLay->addWidget(new QLabel(tr("Unit:"), this), 1, 0,
+ styleLay->addWidget(new QLabel(tr("Unit:"), this), 2, 0,
Qt::AlignRight | Qt::AlignVCenter);
- styleLay->addWidget(unitOm, 1, 1);
+ styleLay->addWidget(m_unitOm, 2, 1);
- styleLay->addWidget(new QLabel(tr("Camera Unit:"), this), 2, 0,
+ styleLay->addWidget(new QLabel(tr("Camera Unit:"), this), 3, 0,
Qt::AlignRight | Qt::AlignVCenter);
- styleLay->addWidget(cameraUnitOm, 2, 1);
+ styleLay->addWidget(m_cameraUnitOm, 3, 1);
- styleLay->addWidget(new QLabel(tr("Rooms *:"), this), 3, 0,
+ styleLay->addWidget(new QLabel(tr("Rooms *:"), this), 4, 0,
Qt::AlignRight | Qt::AlignVCenter);
- styleLay->addWidget(roomChoice, 3, 1);
+ styleLay->addWidget(roomChoice, 4, 1);
}
styleLay->setColumnStretch(0, 0);
styleLay->setColumnStretch(1, 0);
@@ -1671,9 +1723,11 @@ PreferencesPopup::PreferencesPopup()
//--- Interface ----------------------
ret = ret && connect(styleSheetType, SIGNAL(currentIndexChanged(int)),
SLOT(onStyleSheetTypeChanged(int)));
- ret = ret && connect(unitOm, SIGNAL(currentIndexChanged(int)),
+ ret = ret && connect(m_pixelsOnlyCB, SIGNAL(stateChanged(int)),
+ SLOT(onPixelsOnlyChanged(int)));
+ ret = ret && connect(m_unitOm, SIGNAL(currentIndexChanged(int)),
SLOT(onUnitChanged(int)));
- ret = ret && connect(cameraUnitOm, SIGNAL(currentIndexChanged(int)),
+ ret = ret && connect(m_cameraUnitOm, SIGNAL(currentIndexChanged(int)),
SLOT(onCameraUnitChanged(int)));
ret = ret && connect(roomChoice, SIGNAL(currentIndexChanged(int)),
SLOT(onRoomChoiceChanged(int)));
diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h
index e508e133e..4c220dcbf 100644
--- a/toonz/sources/toonz/preferencespopup.h
+++ b/toonz/sources/toonz/preferencespopup.h
@@ -51,7 +51,7 @@ private:
QComboBox *m_keyframeType, *m_cellsDragBehaviour, *m_defScanLevelType,
*m_defLevelType, *m_autocreationType, *m_levelFormatNames,
- *m_columnIconOm;
+ *m_columnIconOm, *m_unitOm, *m_cameraUnitOm;
DVGui::MeasuredDoubleLineEdit *m_defLevelWidth, *m_defLevelHeight;
@@ -65,7 +65,7 @@ private:
QPushButton *m_addLevelFormat, *m_removeLevelFormat, *m_editLevelFormat;
DVGui::CheckBox *m_inksOnly, *m_enableVersionControl, *m_levelsBackup,
- *m_onionSkinVisibility;
+ *m_onionSkinVisibility, *m_pixelsOnlyCB;
private:
// QWidget* create(const QString& lbl, bool def, const char* slot);
@@ -73,6 +73,7 @@ private:
private slots:
+ void onPixelsOnlyChanged(int index);
void onUnitChanged(int index);
void onCameraUnitChanged(int index);
void onRoomChoiceChanged(int index);
diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp
index 8e766a263..f728ed2b8 100644
--- a/toonz/sources/toonzlib/preferences.cpp
+++ b/toonz/sources/toonzlib/preferences.cpp
@@ -373,7 +373,17 @@ Preferences::Preferences()
setUndoMemorySize(m_undoMemorySize);
m_blankColor = TPixel32(r, g, b);
+ getValue(*m_settings, "pixelsOnly", m_pixelsOnly);
+
+ //for Pixels only
QString units;
+ units = m_settings->value("oldUnits").toString();
+ m_oldUnits = units;
+
+ units = m_settings->value("oldCameraUnits").toString();
+ m_oldCameraUnits = units;
+ //end for pixels only
+
units = m_settings->value("linearUnits").toString();
if (units != "") m_units = units;
setUnits(m_units.toStdString());
@@ -929,6 +939,20 @@ void setCurrentUnits(std::string measureName, std::string units) {
//-----------------------------------------------------------------
+void Preferences::setPixelsOnly(bool state) {
+ m_pixelsOnly = state;
+ m_settings->setValue("pixelsOnly", m_pixelsOnly);
+ if (state) {
+ storeOldUnits();
+ }
+ else
+ {
+ resetOldUnits();
+ }
+}
+
+//-----------------------------------------------------------------
+
void Preferences::setUnits(std::string units) {
m_units = QString::fromStdString(units);
m_settings->setValue("linearUnits", m_units);
@@ -952,6 +976,24 @@ void Preferences::setCameraUnits(std::string units) {
//-----------------------------------------------------------------
+void Preferences::storeOldUnits() {
+ m_oldUnits = getUnits();
+ m_oldCameraUnits = getCameraUnits();
+ m_settings->setValue("oldUnits", m_oldUnits);
+ m_settings->setValue("oldCameraUnits", m_oldCameraUnits);
+}
+
+//-----------------------------------------------------------------
+
+void Preferences::resetOldUnits() {
+ if (m_oldUnits != "" && m_oldCameraUnits != "") {
+ setUnits(m_oldUnits.toStdString());
+ setCameraUnits(m_oldCameraUnits.toStdString());
+ }
+}
+
+//-----------------------------------------------------------------
+
void Preferences::setCurrentRoomChoice(int currentRoomChoice) {
m_currentRoomChoice = getRoomChoice(currentRoomChoice);
m_settings->setValue("CurrentRoomChoice", m_currentRoomChoice);
diff --git a/toonz/sources/toonzlib/tcamera.cpp b/toonz/sources/toonzlib/tcamera.cpp
index 365e4710c..495ecab73 100644
--- a/toonz/sources/toonzlib/tcamera.cpp
+++ b/toonz/sources/toonzlib/tcamera.cpp
@@ -10,7 +10,7 @@
TCamera::TCamera()
//: m_size(12, 9), m_res(768, 576), m_xPrevalence(true)
- : m_size(30, 16.875),
+ : m_size(35.9955, 20.2544),
m_res(1920, 1080),
m_xPrevalence(true) {}
diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp
index 1d73bb089..2c30e21fa 100644
--- a/toonz/sources/toonzlib/txshsimplelevel.cpp
+++ b/toonz/sources/toonzlib/txshsimplelevel.cpp
@@ -395,6 +395,10 @@ void TXshSimpleLevel::setPath(const TFilePath &fp, bool keepFrames) {
imageRes.ly = imageInfo->m_ly;
imageDpi.x = imageInfo->m_dpix;
imageDpi.y = imageInfo->m_dpiy;
+ if (Preferences::instance()->getUnits() == "pixel") {
+ imageDpi.x = 53.3333;
+ imageDpi.y = 53.3333;
+ }
m_properties->setImageDpi(imageDpi);
m_properties->setImageRes(imageRes);
m_properties->setBpp(imageInfo->m_bitsPerSample *
@@ -1175,6 +1179,10 @@ void TXshSimpleLevel::load() {
imageRes.ly = imageInfo->m_ly;
imageDpi.x = imageInfo->m_dpix;
imageDpi.y = imageInfo->m_dpiy;
+ if (Preferences::instance()->getUnits() == "pixel") {
+ imageDpi.x = 53.3333;
+ imageDpi.y = 53.3333;
+ }
m_properties->setImageDpi(imageDpi);
m_properties->setImageRes(imageRes);
m_properties->setBpp(imageInfo->m_bitsPerSample *
@@ -1282,6 +1290,10 @@ void TXshSimpleLevel::load(const std::vector<TFrameId> &fIds) {
imageRes.ly = imageInfo->m_ly;
imageDpi.x = imageInfo->m_dpix;
imageDpi.y = imageInfo->m_dpiy;
+ if (Preferences::instance()->getUnits() == "pixel") {
+ imageDpi.x = 53.3333;
+ imageDpi.y = 53.3333;
+ }
m_properties->setImageDpi(imageDpi);
m_properties->setImageRes(imageRes);
}