From 96eb784d28087d44fcd68b55be3131d564613579 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Fri, 3 Jun 2016 23:06:56 -0600 Subject: [PATCH 01/18] Adds pixels as an option to the preferences. --- toonz/sources/toonz/preferencespopup.cpp | 2 +- toonz/sources/toonzqt/camerasettingswidget.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index a842f7f0..0b765e09 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -1042,7 +1042,7 @@ PreferencesPopup::PreferencesPopup() styleSheetType->setCurrentIndex(currentIndex); QStringList type; - type << tr("cm") << tr("mm") << tr("inch") << tr("field"); + type << tr("cm") << tr("mm") << tr("inch") << tr("field") << tr("pixel"); unitOm->addItems(type); int idx = std::find(::units, ::units + ::unitsCount, m_pref->getUnits()) - ::units; unitOm->setCurrentIndex((idx < ::unitsCount) ? idx : ::inchIdx); diff --git a/toonz/sources/toonzqt/camerasettingswidget.cpp b/toonz/sources/toonzqt/camerasettingswidget.cpp index 03bc6a85..71966cec 100644 --- a/toonz/sources/toonzqt/camerasettingswidget.cpp +++ b/toonz/sources/toonzqt/camerasettingswidget.cpp @@ -20,6 +20,7 @@ #include "toonz/txshlevel.h" #include "toonz/txshsimplelevel.h" #include "toonz/txshleveltypes.h" +#include "toonz/preferences.h" // TnzCore includes #include "tconvert.h" @@ -286,7 +287,8 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) gridLay->addWidget(m_yPrev, 0, 4, Qt::AlignCenter); gridLay->addWidget(m_inchPrev, 1, 0, Qt::AlignRight | Qt::AlignVCenter); - gridLay->addWidget(new QLabel("Inch"), 1, 1, Qt::AlignRight | Qt::AlignVCenter); + QString units = Preferences::instance()->getCameraUnits(); + gridLay->addWidget(new QLabel(units), 1, 1, Qt::AlignRight | Qt::AlignVCenter); gridLay->addWidget(m_lxFld, 1, 2); gridLay->addWidget(new QLabel("x"), 1, 3, Qt::AlignCenter); gridLay->addWidget(m_lyFld, 1, 4); From 99ca93cb9021a7bcb1824b58bf40902993d7e573 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Sat, 4 Jun 2016 01:01:44 -0600 Subject: [PATCH 02/18] Ruler tool now working too --- toonz/sources/tnztools/tooloptions.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index 5d6dcb95..08bd8a30 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -1798,6 +1798,15 @@ RulerToolOptionsBox::RulerToolOptionsBox(QWidget *parent, m_Afld->setMeasure("angle"); + if (Preferences::instance()->getUnits() == "pixel") + { + m_Xfld->setMeasure("camera.lx"); + m_Yfld->setMeasure("camera.lx"); + m_Wfld->setMeasure("camera.lx"); + m_Hfld->setMeasure("camera.lx"); + m_Lfld->setMeasure("camera.lx"); + } + m_Xfld->setObjectName("RulerToolOptionValues"); m_Yfld->setObjectName("RulerToolOptionValues"); m_Wfld->setObjectName("RulerToolOptionValues"); From d0657441de889eb7183287a6d0caf21df5776266 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Sat, 4 Jun 2016 14:19:27 -0600 Subject: [PATCH 03/18] Level settings now support pixels --- toonz/sources/tnztools/tooloptions.cpp | 10 ++++----- toonz/sources/toonz/levelcreatepopup.cpp | 12 +++++++++-- toonz/sources/toonz/levelsettingspopup.cpp | 6 ++++++ toonz/sources/toonz/preferencespopup.cpp | 25 ++++++++++++++++------ 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index 08bd8a30..34eede0b 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -1800,11 +1800,11 @@ RulerToolOptionsBox::RulerToolOptionsBox(QWidget *parent, if (Preferences::instance()->getUnits() == "pixel") { - m_Xfld->setMeasure("camera.lx"); - m_Yfld->setMeasure("camera.lx"); - m_Wfld->setMeasure("camera.lx"); - m_Hfld->setMeasure("camera.lx"); - m_Lfld->setMeasure("camera.lx"); + m_Xfld->setMeasure("length.x"); + m_Yfld->setMeasure("length.y"); + m_Wfld->setMeasure("length.x"); + m_Hfld->setMeasure("length.y"); + m_Lfld->setMeasure("length.x"); } m_Xfld->setObjectName("RulerToolOptionValues"); diff --git a/toonz/sources/toonz/levelcreatepopup.cpp b/toonz/sources/toonz/levelcreatepopup.cpp index 254e2b7a..d6249ea5 100644 --- a/toonz/sources/toonz/levelcreatepopup.cpp +++ b/toonz/sources/toonz/levelcreatepopup.cpp @@ -206,8 +206,16 @@ LevelCreatePopup::LevelCreatePopup() m_levelTypeOm->addItem(RasterLevel); m_levelTypeOm->addItem(ScanLevel); - m_widthFld->setMeasure("level.lx"); - m_heightFld->setMeasure("level.ly"); + if (Preferences::instance()->getUnits() == "pixel") + { + m_widthFld->setMeasure("camera.lx"); + m_heightFld->setMeasure("camera.ly"); + } + else + { + m_widthFld->setMeasure("level.lx"); + m_heightFld->setMeasure("level.ly"); + } m_widthFld->setRange(0.1, (std::numeric_limits::max)()); m_heightFld->setRange(0.1, (std::numeric_limits::max)()); m_dpiFld->setRange(0.1, (std::numeric_limits::max)()); diff --git a/toonz/sources/toonz/levelsettingspopup.cpp b/toonz/sources/toonz/levelsettingspopup.cpp index 8b39165d..603e4ec3 100644 --- a/toonz/sources/toonz/levelsettingspopup.cpp +++ b/toonz/sources/toonz/levelsettingspopup.cpp @@ -158,6 +158,12 @@ LevelSettingsPopup::LevelSettingsPopup() m_widthFld->setMeasure("camera.lx"); m_heightFld->setMeasure("camera.ly"); + if (Preferences::instance()->getCameraUnits() == "pixel") + { + m_widthFld->setDecimals(0); + m_heightFld->setDecimals(0); + } + m_doPremultiply->setChecked(false); m_doAntialias->setChecked(false); diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 0b765e09..fd2c4c31 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -1138,12 +1138,25 @@ PreferencesPopup::PreferencesPopup() } } - m_defLevelWidth->setRange(0.1, (std::numeric_limits::max)()); - m_defLevelWidth->setMeasure("level.lx"); - m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); - m_defLevelHeight->setRange(0.1, (std::numeric_limits::max)()); - m_defLevelHeight->setMeasure("level.ly"); - m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + + if (Preferences::instance()->getUnits() == "pixel") + { + m_defLevelWidth->setRange(0.1, (std::numeric_limits::max)()); + m_defLevelWidth->setMeasure("camera.lx"); + m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); + m_defLevelHeight->setRange(0.1, (std::numeric_limits::max)()); + m_defLevelHeight->setMeasure("camera.ly"); + m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + } + else + { + m_defLevelWidth->setRange(0.1, (std::numeric_limits::max)()); + m_defLevelWidth->setMeasure("level.lx"); + m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); + m_defLevelHeight->setRange(0.1, (std::numeric_limits::max)()); + m_defLevelHeight->setMeasure("level.ly"); + m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + } m_defLevelDpi->setRange(0.1, (std::numeric_limits::max)()); m_defLevelDpi->setValue(m_pref->getDefLevelDpi()); QStringList autocreationTypes; From 7c096e2b825d4f18812efa9c49397f22857dfa40 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Sat, 18 Jun 2016 21:47:11 -0600 Subject: [PATCH 04/18] starter interface options --- toonz/sources/include/toonz/preferences.h | 13 +++- toonz/sources/include/toonz/tcamera.h | 2 +- toonz/sources/toonz/iocommand.cpp | 2 +- toonz/sources/toonz/preferencespopup.cpp | 88 +++++++++++++++++----- toonz/sources/toonz/preferencespopup.h | 5 +- toonz/sources/toonzlib/preferences.cpp | 42 +++++++++++ toonz/sources/toonzlib/tcamera.cpp | 2 +- toonz/sources/toonzlib/txshsimplelevel.cpp | 12 +++ 8 files changed, 142 insertions(+), 24 deletions(-) diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index ffe92a0c..0f781635 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 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 79aeef50..1e8f4505 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 808e86ef..8f47e06d 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 b0e77a7a..501a4a59 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 e508e133..4c220dcb 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 8e766a26..f728ed2b 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 365e4710..495ecab7 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 1d73bb08..2c30e21f 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 &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); } From b99ed3bab602f29b8f98c7579e1d678a401f3012 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Thu, 30 Jun 2016 21:41:31 -0600 Subject: [PATCH 05/18] added shun-iwasawa's suggestions --- toonz/sources/common/tunit/tunit.cpp | 13 +++++++++---- toonz/sources/toonz/preferencespopup.cpp | 4 ++++ toonz/sources/toonzlib/preferences.cpp | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp index 9c1f2ee2..46efe326 100644 --- a/toonz/sources/common/tunit/tunit.cpp +++ b/toonz/sources/common/tunit/tunit.cpp @@ -347,22 +347,27 @@ TMeasureManager::TMeasureManager() { m->add(cameraYFld.clone()); add(m); + const double stage_inch = 53.33333; //Stage::inch + TUnit fxLength(L"fxLength"), - fxInch(L"in", new TSimpleUnitConverter(1 / 53.33333)), - fxCm(L"cm", new TSimpleUnitConverter(2.54 / 53.33333)), - fxMm(L"mm", new TSimpleUnitConverter(25.4 / 53.33333)), - fxXfld(L"fld", new TSimpleUnitConverter(2 / 53.33333)); + fxInch(L"in", new TSimpleUnitConverter(1 / stage_inch)), + fxCm(L"cm", new TSimpleUnitConverter(2.54 / stage_inch)), + fxMm(L"mm", new TSimpleUnitConverter(25.4 / stage_inch)), + fxXfld(L"fld", new TSimpleUnitConverter(2 / stage_inch)), + fxPx(L"px", new TSimpleUnitConverter(1)); fxInch.addExtension(L"inch"); fxInch.addExtension(L"\""); fxInch.addExtension(L"''"); fxInch.setDefaultExtension(L"\""); fxXfld.addExtension(L"field"); fxXfld.addExtension(L"F"); + fxXfld.addExtension(L"pixel"); m = new TMeasure("fxLength", fxLength.clone()); m->add(fxInch.clone()); m->add(fxCm.clone()); m->add(fxMm.clone()); m->add(fxXfld.clone()); + m->add(fxPx.clone()); add(m); m = new TMeasure("angle", degree.clone()); diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 501a4a59..fc8b3eff 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -883,6 +883,10 @@ PreferencesPopup::PreferencesPopup() new CheckBox(tr("All imported images will use the same DPI"), this); m_unitOm = new QComboBox(this); m_cameraUnitOm = new QComboBox(this); + if (m_pref->getPixelsOnly()){ + m_unitOm->setDisabled(true); + m_cameraUnitOm->setDisabled(true); + } // Choose between standard and Studio Ghibli rooms QComboBox *roomChoice = new QComboBox(this); diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index f728ed2b..83ce957d 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -377,10 +377,10 @@ Preferences::Preferences() //for Pixels only QString units; - units = m_settings->value("oldUnits").toString(); + units = m_settings->value("oldUnits", m_units).toString(); m_oldUnits = units; - units = m_settings->value("oldCameraUnits").toString(); + units = m_settings->value("oldCameraUnits", m_cameraUnits).toString(); m_oldCameraUnits = units; //end for pixels only From 20a966a908303c32c9c6af440d908af26f216ff1 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Thu, 30 Jun 2016 23:46:29 -0600 Subject: [PATCH 06/18] set stage::inch to 120 --- toonz/sources/common/tunit/tunit.cpp | 2 +- toonz/sources/include/toonz/stage.h | 1 + toonz/sources/include/toonz/tcamera.h | 2 +- toonz/sources/toonz/iocommand.cpp | 2 +- toonz/sources/toonz/preferencespopup.cpp | 21 ++++++++++++--------- toonz/sources/toonzlib/preferences.cpp | 10 ++++++++-- toonz/sources/toonzlib/stage.cpp | 3 ++- toonz/sources/toonzlib/tcamera.cpp | 2 +- toonz/sources/toonzlib/toonzscene.cpp | 2 +- toonz/sources/toonzlib/txshsimplelevel.cpp | 15 ++++++++------- 10 files changed, 36 insertions(+), 24 deletions(-) diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp index 46efe326..de79b5c8 100644 --- a/toonz/sources/common/tunit/tunit.cpp +++ b/toonz/sources/common/tunit/tunit.cpp @@ -347,7 +347,7 @@ TMeasureManager::TMeasureManager() { m->add(cameraYFld.clone()); add(m); - const double stage_inch = 53.33333; //Stage::inch + const double stage_inch = 120; //Stage::inch used to be 53.33333 TUnit fxLength(L"fxLength"), fxInch(L"in", new TSimpleUnitConverter(1 / stage_inch)), diff --git a/toonz/sources/include/toonz/stage.h b/toonz/sources/include/toonz/stage.h index b25ad606..af6f99e1 100644 --- a/toonz/sources/include/toonz/stage.h +++ b/toonz/sources/include/toonz/stage.h @@ -43,6 +43,7 @@ namespace Stage { //============================================================================= DVVAR extern const double inch; +DVVAR extern const double vectorDpi; class Visitor; struct VisitArgs; diff --git a/toonz/sources/include/toonz/tcamera.h b/toonz/sources/include/toonz/tcamera.h index 1e8f4505..abb7cfdc 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 (35.9955, 20.2544) and resolution (1920,1080). + Constructs TCamera with default value, size (16, 9) and resolution (1920,1080). - 05/31/16 */ TCamera(); diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index b0beba88..75326dc1 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 = 53.3333; + double cameraDpi = 120; //used to be 64 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 fc8b3eff..30087f5d 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -216,14 +216,15 @@ Preferences::LevelFormat PreferencesPopup::FormatProperties::levelFormat() void PreferencesPopup::onPixelsOnlyChanged(int index) { bool enabled = index == Qt::Checked; if (enabled) { - m_pref->setDefLevelDpi(53.3333); + + m_pref->setDefLevelDpi(120); 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; + camSize.lx = camRes.lx / 120; + camSize.ly = camRes.ly / 120; camera->setSize(camSize); m_pref->storeOldUnits(); if (m_unitOm->currentIndex() != 4) @@ -883,10 +884,7 @@ PreferencesPopup::PreferencesPopup() new CheckBox(tr("All imported images will use the same DPI"), this); m_unitOm = new QComboBox(this); m_cameraUnitOm = new QComboBox(this); - if (m_pref->getPixelsOnly()){ - m_unitOm->setDisabled(true); - m_cameraUnitOm->setDisabled(true); - } + // Choose between standard and Studio Ghibli rooms QComboBox *roomChoice = new QComboBox(this); @@ -1065,8 +1063,13 @@ PreferencesPopup::PreferencesPopup() } styleSheetType->addItems(styleSheetList); styleSheetType->setCurrentIndex(currentIndex); - //m_pixelsOnlyCB->setChecked(m_pref->getPixelsOnly()); - m_pixelsOnlyCB->setChecked(true); + bool po = m_pref->getPixelsOnly(); + m_pixelsOnlyCB->setChecked(po); + //m_pixelsOnlyCB->setChecked(true); + if (po){ + m_unitOm->setDisabled(true); + m_cameraUnitOm->setDisabled(true); + } QStringList type; type << tr("cm") << tr("mm") << tr("inch") << tr("field") << tr("pixel"); m_unitOm->addItems(type); diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index 83ce957d..ecaaaa3f 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -208,7 +208,8 @@ bool Preferences::LevelFormat::matches(const TFilePath &fp) const { //********************************************************************************** Preferences::Preferences() - : m_units("mm") + : m_pixelsOnly(false) + , m_units("mm") , m_cameraUnits("inch") , m_currentRoomChoice("Default") , m_scanLevelType("tif") @@ -373,9 +374,14 @@ Preferences::Preferences() setUndoMemorySize(m_undoMemorySize); m_blankColor = TPixel32(r, g, b); - getValue(*m_settings, "pixelsOnly", m_pixelsOnly); + //for Pixels only + + getValue(*m_settings, "pixelsOnly", m_pixelsOnly); //doesn't work for some reason. + QString pos = m_settings->value("pixelsOnly").toString(); + if (pos == "true") m_pixelsOnly = true; + QString units; units = m_settings->value("oldUnits", m_units).toString(); m_oldUnits = units; diff --git a/toonz/sources/toonzlib/stage.cpp b/toonz/sources/toonzlib/stage.cpp index edcc9911..ce3f670a 100644 --- a/toonz/sources/toonzlib/stage.cpp +++ b/toonz/sources/toonzlib/stage.cpp @@ -69,7 +69,8 @@ typedef std::vector PlayerSet; thickness of images .pli. */ -const double Stage::inch = 53.33333; +const double Stage::inch = 120; //used to be 53.33333 +const double Stage::vectorDpi = 53.3333; namespace { void updateOnionSkinSize(const PlayerSet &players) { diff --git a/toonz/sources/toonzlib/tcamera.cpp b/toonz/sources/toonzlib/tcamera.cpp index 495ecab7..dbc35cde 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(35.9955, 20.2544), + : m_size(16, 9), m_res(1920, 1080), m_xPrevalence(true) {} diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cpp index 354620b1..7ccd82eb 100644 --- a/toonz/sources/toonzlib/toonzscene.cpp +++ b/toonz/sources/toonzlib/toonzscene.cpp @@ -1176,7 +1176,7 @@ TXshLevel *ToonzScene::loadLevel(const TFilePath &actualPath, // We must check whether the image actually has a dpi. const TPointD &imageDpi = xl->getImageDpi(); - if (imageDpi == TPointD()) { + if (imageDpi == TPointD() || Preferences::instance()->getUnits() == "pixel") { // Change to "Custom Dpi" policy and use camera dpi TStageObjectId cameraId = getXsheet()->getStageObjectTree()->getCurrentCameraId(); diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index c46a7a87..e91f67b2 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -382,7 +382,7 @@ void TXshSimpleLevel::setPath(const TFilePath &fp, bool keepFrames) { } catch (...) { } } - + if (getType() != PLI_XSHLEVEL) { if (!m_frames.empty()) { std::string imageId = getImageId(getFirstFid()); @@ -396,8 +396,8 @@ void TXshSimpleLevel::setPath(const TFilePath &fp, bool keepFrames) { imageDpi.x = imageInfo->m_dpix; imageDpi.y = imageInfo->m_dpiy; if (Preferences::instance()->getUnits() == "pixel") { - imageDpi.x = 53.3333; - imageDpi.y = 53.3333; + imageDpi.x = Stage::inch; + imageDpi.y = Stage::inch; } m_properties->setImageDpi(imageDpi); m_properties->setImageRes(imageRes); @@ -1179,9 +1179,10 @@ void TXshSimpleLevel::load() { imageRes.ly = imageInfo->m_ly; imageDpi.x = imageInfo->m_dpix; imageDpi.y = imageInfo->m_dpiy; + std::string un = Preferences::instance()->getUnits().toStdString(); if (Preferences::instance()->getUnits() == "pixel") { - imageDpi.x = 53.3333; - imageDpi.y = 53.3333; + imageDpi.x = Stage::inch; + imageDpi.y = Stage::inch; } m_properties->setImageDpi(imageDpi); m_properties->setImageRes(imageRes); @@ -1291,8 +1292,8 @@ void TXshSimpleLevel::load(const std::vector &fIds) { imageDpi.x = imageInfo->m_dpix; imageDpi.y = imageInfo->m_dpiy; if (Preferences::instance()->getUnits() == "pixel") { - imageDpi.x = 53.3333; - imageDpi.y = 53.3333; + imageDpi.x = Stage::inch; + imageDpi.y = Stage::inch; } m_properties->setImageDpi(imageDpi); m_properties->setImageRes(imageRes); From 0049ac939db8e60721e55b7709c5ac25b7f3f95d Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Thu, 30 Jun 2016 23:49:53 -0600 Subject: [PATCH 07/18] removed image dpi modification --- toonz/sources/toonzlib/txshsimplelevel.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index e91f67b2..7a11b217 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -395,10 +395,6 @@ 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 = Stage::inch; - imageDpi.y = Stage::inch; - } m_properties->setImageDpi(imageDpi); m_properties->setImageRes(imageRes); m_properties->setBpp(imageInfo->m_bitsPerSample * @@ -1180,10 +1176,6 @@ void TXshSimpleLevel::load() { imageDpi.x = imageInfo->m_dpix; imageDpi.y = imageInfo->m_dpiy; std::string un = Preferences::instance()->getUnits().toStdString(); - if (Preferences::instance()->getUnits() == "pixel") { - imageDpi.x = Stage::inch; - imageDpi.y = Stage::inch; - } m_properties->setImageDpi(imageDpi); m_properties->setImageRes(imageRes); m_properties->setBpp(imageInfo->m_bitsPerSample * @@ -1291,10 +1283,6 @@ void TXshSimpleLevel::load(const std::vector &fIds) { imageRes.ly = imageInfo->m_ly; imageDpi.x = imageInfo->m_dpix; imageDpi.y = imageInfo->m_dpiy; - if (Preferences::instance()->getUnits() == "pixel") { - imageDpi.x = Stage::inch; - imageDpi.y = Stage::inch; - } m_properties->setImageDpi(imageDpi); m_properties->setImageRes(imageRes); } From 733ddbef67d9c9da4f64fed2a0237aa854b91942 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Sat, 2 Jul 2016 23:30:00 -0600 Subject: [PATCH 08/18] hid gui elements if pixels selected --- .../include/toonzqt/camerasettingswidget.h | 5 ++ toonz/sources/toonz/levelcreatepopup.cpp | 11 ++++ toonz/sources/toonz/levelsettingspopup.cpp | 45 ++++++++++++-- toonz/sources/toonz/levelsettingspopup.h | 3 + toonz/sources/toonz/preferencespopup.cpp | 24 +++++--- toonz/sources/toonz/preferencespopup.h | 2 + .../sources/toonzqt/camerasettingswidget.cpp | 60 ++++++++++++++++++- 7 files changed, 134 insertions(+), 16 deletions(-) diff --git a/toonz/sources/include/toonzqt/camerasettingswidget.h b/toonz/sources/include/toonzqt/camerasettingswidget.h index 14f7f2db..f922cada 100644 --- a/toonz/sources/include/toonzqt/camerasettingswidget.h +++ b/toonz/sources/include/toonzqt/camerasettingswidget.h @@ -28,6 +28,7 @@ class TCamera; class QRadioButton; class QComboBox; +class QLabel; class ResListManager; class TFilePath; class TXshSimpleLevel; @@ -82,6 +83,9 @@ class DVAPI CameraSettingsWidget final : public QFrame { double m_arValue; DVGui::IntLineEdit *m_xResFld, *m_yResFld; DVGui::DoubleLineEdit *m_xDpiFld, *m_yDpiFld; + QLabel* m_dpiLabel; + QLabel* m_resLabel; + QLabel* m_xLabel; QPushButton *m_fspChk; // Force Squared Pixel => dpix == dpiy @@ -147,6 +151,7 @@ public: protected: bool eventFilter(QObject *obj, QEvent *e) override; + void showEvent(QShowEvent *e) override; void hComputeLx(); void hComputeLy(); diff --git a/toonz/sources/toonz/levelcreatepopup.cpp b/toonz/sources/toonz/levelcreatepopup.cpp index 3a0ed2f9..98fc8e2f 100644 --- a/toonz/sources/toonz/levelcreatepopup.cpp +++ b/toonz/sources/toonz/levelcreatepopup.cpp @@ -277,6 +277,8 @@ LevelCreatePopup::LevelCreatePopup() m_buttonLayout->addStretch(1); } + + //---- signal-slot connections bool ret = true; ret = ret && @@ -335,6 +337,15 @@ void LevelCreatePopup::showEvent(QShowEvent *) { nextName(); update(); m_nameFld->setFocus(); + if (Preferences::instance()->getUnits() == "pixel") + { + m_dpiFld->hide(); + m_dpiLabel->hide(); + } + else { + m_dpiFld->show(); + m_dpiLabel->show(); + } } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/levelsettingspopup.cpp b/toonz/sources/toonz/levelsettingspopup.cpp index a31f2550..be3e961e 100644 --- a/toonz/sources/toonz/levelsettingspopup.cpp +++ b/toonz/sources/toonz/levelsettingspopup.cpp @@ -132,6 +132,9 @@ LevelSettingsPopup::LevelSettingsPopup() m_cameraDpiLabel = new QLabel(tr("")); m_imageDpiLabel = new QLabel(tr("")); m_imageResLabel = new QLabel(tr("")); + m_cameraDpiTitle = new QLabel(tr("Camera DPI:")); + m_imageDpiTitle = new QLabel(tr("Image DPI:")); + m_imageResTitle = new QLabel(tr("Resolution:")); // subsampling m_subsamplingLabel = new QLabel(tr("Subsampling:")); @@ -200,9 +203,13 @@ LevelSettingsPopup::LevelSettingsPopup() m_topLayout->addWidget(nameBox); //----DPI & Resolution - QGroupBox *dpiBox = new QGroupBox(tr("DPI && Resolution"), this); + QGroupBox *dpiBox; + if (Preferences::instance()->getUnits() == "pixel") + dpiBox = new QGroupBox(tr("Resolution"), this); + else + dpiBox = new QGroupBox(tr("DPI && Resolution"), this); QGridLayout *dpiLayout = new QGridLayout(); - dpiLayout->setMargin(5); + dpiLayout->setMargin(5); dpiLayout->setSpacing(5); { dpiLayout->addWidget(m_dpiTypeOm, 0, 1, 1, 3); @@ -217,15 +224,16 @@ LevelSettingsPopup::LevelSettingsPopup() Qt::AlignRight | Qt::AlignVCenter); dpiLayout->addWidget(m_heightFld, 2, 3); dpiLayout->addWidget(m_useCameraDpiBtn, 3, 1, 1, 3); - dpiLayout->addWidget(new QLabel(tr("Camera DPI:"), this), 4, 0, + dpiLayout->addWidget(m_cameraDpiTitle, 4, 0, Qt::AlignRight | Qt::AlignVCenter); dpiLayout->addWidget(m_cameraDpiLabel, 4, 1, 1, 3); - dpiLayout->addWidget(new QLabel(tr("Image DPI:"), this), 5, 0, + dpiLayout->addWidget(m_imageDpiTitle, 5, 0, Qt::AlignRight | Qt::AlignVCenter); dpiLayout->addWidget(m_imageDpiLabel, 5, 1, 1, 3); - dpiLayout->addWidget(new QLabel(tr("Resolution:"), this), 6, 0, + dpiLayout->addWidget(m_imageResTitle, 6, 0, Qt::AlignRight | Qt::AlignVCenter); dpiLayout->addWidget(m_imageResLabel, 6, 1, 1, 3); + } dpiLayout->setColumnStretch(0, 0); dpiLayout->setColumnStretch(1, 1); @@ -312,6 +320,33 @@ void LevelSettingsPopup::showEvent(QShowEvent *e) { assert(ret); updateLevelSettings(); + if (Preferences::instance()->getUnits() == "pixel") + { + m_dpiTypeOm->hide(); + m_dpiLabel->hide(); + m_dpiFld->hide(); + m_squarePixCB->hide(); + m_useCameraDpiBtn->hide(); + m_cameraDpiLabel->hide(); + m_imageDpiLabel->hide(); + m_imageDpiTitle->hide(); + m_cameraDpiTitle->hide(); + m_imageResTitle->hide(); + m_imageResLabel->hide(); + } + else { + m_dpiTypeOm->show(); + m_dpiLabel->show(); + m_dpiFld->show(); + m_squarePixCB->show(); + m_useCameraDpiBtn->show(); + m_cameraDpiLabel->show(); + m_imageDpiLabel->show(); + m_imageDpiTitle->show(); + m_cameraDpiTitle->show(); + m_imageResTitle->show(); + m_imageResLabel->show(); + } } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/levelsettingspopup.h b/toonz/sources/toonz/levelsettingspopup.h index 955ce107..a93d2149 100644 --- a/toonz/sources/toonz/levelsettingspopup.h +++ b/toonz/sources/toonz/levelsettingspopup.h @@ -56,6 +56,9 @@ class LevelSettingsPopup final : public DVGui::Dialog { QLabel *m_cameraDpiLabel; QLabel *m_imageDpiLabel; QLabel *m_imageResLabel; + QLabel *m_cameraDpiTitle; + QLabel *m_imageDpiTitle; + QLabel *m_imageResTitle; DVGui::CheckBox *m_doPremultiply; DVGui::CheckBox *m_whiteTransp; DVGui::CheckBox *m_doAntialias; diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 30087f5d..57c1caff 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -233,6 +233,8 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) { m_cameraUnitOm->setCurrentIndex(4); m_unitOm->setDisabled(true); m_cameraUnitOm->setDisabled(true); + m_defLevelDpi->setDisabled(true); + m_defLevelDpi->setValue(120); } else { @@ -247,6 +249,11 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) { m_unitOm->setDisabled(false); m_cameraUnitOm->setDisabled(false); m_pref->setPixelsOnly(false); + int levelType = m_pref->getDefLevelType(); + bool isRaster = levelType != PLI_XSHLEVEL; + if (isRaster) { + m_defLevelDpi->setDisabled(false); + } } } @@ -719,7 +726,8 @@ void PreferencesPopup::onDefLevelTypeChanged(int index) { bool isRaster = levelType != PLI_XSHLEVEL; m_defLevelWidth->setEnabled(isRaster); m_defLevelHeight->setEnabled(isRaster); - m_defLevelDpi->setEnabled(isRaster); + if (!m_pixelsOnlyCB->isChecked()) + m_defLevelDpi->setEnabled(isRaster); } } @@ -959,7 +967,7 @@ PreferencesPopup::PreferencesPopup() m_defLevelHeight = new MeasuredDoubleLineEdit(0); m_defLevelDpi = new DoubleLineEdit(0, 66.76); m_autocreationType = new QComboBox(this); - + m_dpiLabel = new QLabel(tr("DPI:"), this); CheckBox *keepOriginalCleanedUpCB = new CheckBox(tr("Keep Original Cleaned Up Drawings As Backup"), this); CheckBox *multiLayerStylePickerCB = new CheckBox( @@ -1337,7 +1345,7 @@ PreferencesPopup::PreferencesPopup() Qt::AlignRight | Qt::AlignVCenter); styleLay->addWidget(m_cameraUnitOm, 3, 1); - styleLay->addWidget(new QLabel(tr("Rooms *:"), this), 4, 0, + styleLay->addWidget(new QLabel(tr("Rooms*:"), this), 4, 0, Qt::AlignRight | Qt::AlignVCenter); styleLay->addWidget(roomChoice, 4, 1); } @@ -1509,11 +1517,9 @@ PreferencesPopup::PreferencesPopup() drawingTopLay->addWidget(new QLabel(tr(" Height:")), 2, 2, Qt::AlignRight); drawingTopLay->addWidget(m_defLevelHeight, 2, 3); - - drawingTopLay->addWidget(new QLabel(tr("DPI:")), 3, 0, Qt::AlignRight); - drawingTopLay->addWidget(m_defLevelDpi, 3, 1); - - drawingTopLay->addWidget(new QLabel(tr("Autocreation:")), 4, 0, + drawingTopLay->addWidget(m_dpiLabel, 3, 0, Qt::AlignRight); + drawingTopLay->addWidget(m_defLevelDpi, 3, 1); + drawingTopLay->addWidget(new QLabel(tr("Autocreation:")), 4, 0, Qt::AlignRight); drawingTopLay->addWidget(m_autocreationType, 4, 1, 1, 3); } @@ -1531,6 +1537,8 @@ PreferencesPopup::PreferencesPopup() } drawingBox->setLayout(drawingFrameLay); stackedWidget->addWidget(drawingBox); + if (m_pixelsOnlyCB->isChecked()) + m_defLevelDpi->setDisabled(true); //--- Xsheet -------------------------- QWidget *xsheetBox = new QWidget(this); diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h index de64ef1e..31575a30 100644 --- a/toonz/sources/toonz/preferencespopup.h +++ b/toonz/sources/toonz/preferencespopup.h @@ -57,6 +57,8 @@ private: DVGui::DoubleLineEdit *m_defLevelDpi; + QLabel* m_dpiLabel; + DVGui::IntLineEdit *m_minuteFld, *m_chunkSizeFld, *m_iconSizeLx, *m_iconSizeLy, *m_viewShrink, *m_viewStep, *m_blanksCount, *m_onionPaperThickness, *m_animationStepField, *m_undoMemorySize, diff --git a/toonz/sources/toonzqt/camerasettingswidget.cpp b/toonz/sources/toonzqt/camerasettingswidget.cpp index f0daef81..dbeadc32 100644 --- a/toonz/sources/toonzqt/camerasettingswidget.cpp +++ b/toonz/sources/toonzqt/camerasettingswidget.cpp @@ -194,6 +194,10 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) m_xDpiFld = new DoubleLineEdit(); m_yDpiFld = new DoubleLineEdit(); + m_dpiLabel = new QLabel(tr("DPI")); + m_resLabel = new QLabel(tr("Pixels")); + m_xLabel = new QLabel(tr("x")); + m_fspChk = new QPushButton(""); m_useLevelSettingsBtn = new QPushButton(tr("Use Current Level Settings")); @@ -290,13 +294,13 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) gridLay->addWidget(m_arFld, 2, 4); gridLay->addWidget(m_dotPrev, 3, 0, Qt::AlignRight | Qt::AlignVCenter); - gridLay->addWidget(new QLabel("Pixel"), 3, 1, + gridLay->addWidget(m_resLabel, 3, 1, Qt::AlignRight | Qt::AlignVCenter); gridLay->addWidget(m_xResFld, 3, 2); - gridLay->addWidget(new QLabel("x"), 3, 3, Qt::AlignCenter); + gridLay->addWidget(m_xLabel, 3, 3, Qt::AlignCenter); gridLay->addWidget(m_yResFld, 3, 4); - gridLay->addWidget(new QLabel("DPI"), 4, 1, + gridLay->addWidget(m_dpiLabel, 4, 1, Qt::AlignRight | Qt::AlignVCenter); gridLay->addWidget(m_xDpiFld, 4, 2); gridLay->addWidget(m_fspChk, 4, 3, Qt::AlignCenter); @@ -323,6 +327,30 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) } setLayout(mainLay); + if (Preferences::instance()->getCameraUnits() == "pixel") + { + m_resLabel->hide(); + m_dpiLabel->hide(); + m_xLabel->hide(); + m_xResFld->hide(); + m_yResFld->hide(); + m_xDpiFld->hide(); + m_yDpiFld->hide(); + m_fspChk->hide(); + m_dotPrev->hide(); + } + else { + m_resLabel->show(); + m_dpiLabel->show(); + m_xLabel->show(); + m_xResFld->show(); + m_yResFld->show(); + m_xDpiFld->show(); + m_yDpiFld->show(); + m_fspChk->show(); + m_dotPrev->show(); + } + // initialize fields TCamera camera; setFields(&camera); @@ -367,6 +395,32 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) CameraSettingsWidget::~CameraSettingsWidget() { setCurrentLevel(0); } +void CameraSettingsWidget::showEvent(QShowEvent *e) { + if (Preferences::instance()->getCameraUnits() == "pixel") + { + m_resLabel->hide(); + m_dpiLabel->hide(); + m_xLabel->hide(); + m_xResFld->hide(); + m_yResFld->hide(); + m_xDpiFld->hide(); + m_yDpiFld->hide(); + m_fspChk->hide(); + m_dotPrev->hide(); + } + else { + m_resLabel->show(); + m_dpiLabel->show(); + m_xLabel->show(); + m_xResFld->show(); + m_yResFld->show(); + m_xDpiFld->show(); + m_yDpiFld->show(); + m_fspChk->show(); + m_dotPrev->show(); + } +} + void CameraSettingsWidget::loadPresetList() { if (m_presetListFile == "") return; m_presetListOm->clear(); From 3c545e052248ed630c91ecbbceeed5f7682fcb23 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Sat, 2 Jul 2016 23:35:53 -0600 Subject: [PATCH 09/18] removed duplicate code --- .../sources/toonzqt/camerasettingswidget.cpp | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/toonz/sources/toonzqt/camerasettingswidget.cpp b/toonz/sources/toonzqt/camerasettingswidget.cpp index dbeadc32..78ae7258 100644 --- a/toonz/sources/toonzqt/camerasettingswidget.cpp +++ b/toonz/sources/toonzqt/camerasettingswidget.cpp @@ -327,30 +327,6 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) } setLayout(mainLay); - if (Preferences::instance()->getCameraUnits() == "pixel") - { - m_resLabel->hide(); - m_dpiLabel->hide(); - m_xLabel->hide(); - m_xResFld->hide(); - m_yResFld->hide(); - m_xDpiFld->hide(); - m_yDpiFld->hide(); - m_fspChk->hide(); - m_dotPrev->hide(); - } - else { - m_resLabel->show(); - m_dpiLabel->show(); - m_xLabel->show(); - m_xResFld->show(); - m_yResFld->show(); - m_xDpiFld->show(); - m_yDpiFld->show(); - m_fspChk->show(); - m_dotPrev->show(); - } - // initialize fields TCamera camera; setFields(&camera); From 93c27a36d0c5f34dbaa104af37373f8273529c35 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Sat, 2 Jul 2016 23:40:23 -0600 Subject: [PATCH 10/18] removed debug code --- toonz/sources/toonzlib/txshsimplelevel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index 7a11b217..9d153a3e 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -1175,7 +1175,6 @@ void TXshSimpleLevel::load() { imageRes.ly = imageInfo->m_ly; imageDpi.x = imageInfo->m_dpix; imageDpi.y = imageInfo->m_dpiy; - std::string un = Preferences::instance()->getUnits().toStdString(); m_properties->setImageDpi(imageDpi); m_properties->setImageRes(imageRes); m_properties->setBpp(imageInfo->m_bitsPerSample * From f44848c78dc69d4cead1640d13b99e1e27dca2f0 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Sun, 3 Jul 2016 00:15:54 -0600 Subject: [PATCH 11/18] reverted stage::inch change, should be its own PR --- toonz/sources/common/tunit/tunit.cpp | 2 +- toonz/sources/include/toonz/tcamera.h | 2 +- toonz/sources/toonz/iocommand.cpp | 2 +- toonz/sources/toonz/preferencespopup.cpp | 20 ++++++++++++++++---- toonz/sources/toonzlib/stage.cpp | 2 +- toonz/sources/toonzlib/tcamera.cpp | 2 +- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp index de79b5c8..dc211528 100644 --- a/toonz/sources/common/tunit/tunit.cpp +++ b/toonz/sources/common/tunit/tunit.cpp @@ -347,7 +347,7 @@ TMeasureManager::TMeasureManager() { m->add(cameraYFld.clone()); add(m); - const double stage_inch = 120; //Stage::inch used to be 53.33333 + const double stage_inch = 53.33333; //Consider changing to 120 or 160 TUnit fxLength(L"fxLength"), fxInch(L"in", new TSimpleUnitConverter(1 / stage_inch)), diff --git a/toonz/sources/include/toonz/tcamera.h b/toonz/sources/include/toonz/tcamera.h index abb7cfdc..bb48e380 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 (16, 9) and resolution (1920,1080). + Constructs TCamera with default value, size (36, 20.25) and resolution (1920,1080). - 05/31/16 */ TCamera(); diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index 75326dc1..cc7db294 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 = 120; //used to be 64 + double cameraDpi = 53.33333; //used to be 64, consider changing to 120 or 160 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 57c1caff..91d8c0ba 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -217,14 +217,14 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) { bool enabled = index == Qt::Checked; if (enabled) { - m_pref->setDefLevelDpi(120); + m_pref->setDefLevelDpi(53.33333); m_pref->setPixelsOnly(true); TCamera* camera; camera = TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera(); TDimension camRes = camera->getRes(); TDimensionD camSize; - camSize.lx = camRes.lx / 120; - camSize.ly = camRes.ly / 120; + camSize.lx = camRes.lx / 53.33333; + camSize.ly = camRes.ly / 53.33333; camera->setSize(camSize); m_pref->storeOldUnits(); if (m_unitOm->currentIndex() != 4) @@ -234,7 +234,13 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) { m_unitOm->setDisabled(true); m_cameraUnitOm->setDisabled(true); m_defLevelDpi->setDisabled(true); - m_defLevelDpi->setValue(120); + m_defLevelDpi->setValue(53.33333); + m_defLevelWidth->setMeasure("camera.lx"); + m_defLevelHeight->setMeasure("camera.ly"); + m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); + m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + m_defLevelHeight->setDecimals(0); + m_defLevelWidth->setDecimals(0); } else { @@ -254,6 +260,12 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) { if (isRaster) { m_defLevelDpi->setDisabled(false); } + m_defLevelHeight->setMeasure("level.ly"); + m_defLevelWidth->setMeasure("level.lx"); + m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); + m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + m_defLevelHeight->setDecimals(4); + m_defLevelWidth->setDecimals(4); } } diff --git a/toonz/sources/toonzlib/stage.cpp b/toonz/sources/toonzlib/stage.cpp index ce3f670a..4a7a0d58 100644 --- a/toonz/sources/toonzlib/stage.cpp +++ b/toonz/sources/toonzlib/stage.cpp @@ -69,7 +69,7 @@ typedef std::vector PlayerSet; thickness of images .pli. */ -const double Stage::inch = 120; //used to be 53.33333 +const double Stage::inch = 53.33333; //consider changing to 120 or 160 const double Stage::vectorDpi = 53.3333; namespace { diff --git a/toonz/sources/toonzlib/tcamera.cpp b/toonz/sources/toonzlib/tcamera.cpp index dbc35cde..97726621 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(16, 9), + : m_size(36, 20.25), m_res(1920, 1080), m_xPrevalence(true) {} From fdd72e63f678a564b828b658b824d7905d5e8c7a Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Sun, 3 Jul 2016 13:48:39 -0600 Subject: [PATCH 12/18] set pixels as default --- toonz/sources/toonz/preferencespopup.cpp | 5 ++++- toonz/sources/toonzlib/preferences.cpp | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 91d8c0ba..8a333a96 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -1549,8 +1549,11 @@ PreferencesPopup::PreferencesPopup() } drawingBox->setLayout(drawingFrameLay); stackedWidget->addWidget(drawingBox); - if (m_pixelsOnlyCB->isChecked()) + if (m_pixelsOnlyCB->isChecked()) { m_defLevelDpi->setDisabled(true); + m_defLevelWidth->setDecimals(0); + m_defLevelHeight->setDecimals(0); + } //--- Xsheet -------------------------- QWidget *xsheetBox = new QWidget(this); diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index ecaaaa3f..4ea61572 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -208,9 +208,9 @@ bool Preferences::LevelFormat::matches(const TFilePath &fp) const { //********************************************************************************** Preferences::Preferences() - : m_pixelsOnly(false) - , m_units("mm") - , m_cameraUnits("inch") + : m_pixelsOnly(true) + , m_units("pixel") + , m_cameraUnits("pixel") , m_currentRoomChoice("Default") , m_scanLevelType("tif") , m_defLevelWidth(0.0) From b6ada42502d464e0b279ba28d8dc2da273dd2fad Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Tue, 12 Jul 2016 14:52:07 -0600 Subject: [PATCH 13/18] Fixed TUnit error --- toonz/sources/common/tunit/tunit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp index dc211528..8cbe4b20 100644 --- a/toonz/sources/common/tunit/tunit.cpp +++ b/toonz/sources/common/tunit/tunit.cpp @@ -361,7 +361,7 @@ TMeasureManager::TMeasureManager() { fxInch.setDefaultExtension(L"\""); fxXfld.addExtension(L"field"); fxXfld.addExtension(L"F"); - fxXfld.addExtension(L"pixel"); + fxPx.addExtension(L"pixel"); m = new TMeasure("fxLength", fxLength.clone()); m->add(fxInch.clone()); m->add(fxCm.clone()); From 59dbbf498a67b2b0bed316b505058782d0e773a7 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Tue, 12 Jul 2016 21:09:46 -0600 Subject: [PATCH 14/18] Clang formatting applied --- toonz/sources/common/tunit/tunit.cpp | 12 +- toonz/sources/include/toonz/preferences.h | 4 +- toonz/sources/include/toonz/tcamera.h | 3 +- .../include/toonzqt/camerasettingswidget.h | 6 +- toonz/sources/tnztools/tooloptions.cpp | 16 +- toonz/sources/toonz/iocommand.cpp | 3 +- toonz/sources/toonz/levelcreatepopup.cpp | 32 ++- toonz/sources/toonz/levelsettingspopup.cpp | 77 ++++--- toonz/sources/toonz/preferencespopup.cpp | 193 +++++++++--------- toonz/sources/toonz/preferencespopup.h | 2 +- toonz/sources/toonzlib/preferences.cpp | 55 +++-- toonz/sources/toonzlib/stage.cpp | 2 +- toonz/sources/toonzlib/toonzscene.cpp | 3 +- toonz/sources/toonzlib/txshsimplelevel.cpp | 7 +- .../sources/toonzqt/camerasettingswidget.cpp | 56 +++-- 15 files changed, 227 insertions(+), 244 deletions(-) diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp index 8cbe4b20..22d8b990 100644 --- a/toonz/sources/common/tunit/tunit.cpp +++ b/toonz/sources/common/tunit/tunit.cpp @@ -347,14 +347,14 @@ TMeasureManager::TMeasureManager() { m->add(cameraYFld.clone()); add(m); - const double stage_inch = 53.33333; //Consider changing to 120 or 160 + const double stage_inch = 53.33333; // Consider changing to 120 or 160 TUnit fxLength(L"fxLength"), - fxInch(L"in", new TSimpleUnitConverter(1 / stage_inch)), - fxCm(L"cm", new TSimpleUnitConverter(2.54 / stage_inch)), - fxMm(L"mm", new TSimpleUnitConverter(25.4 / stage_inch)), - fxXfld(L"fld", new TSimpleUnitConverter(2 / stage_inch)), - fxPx(L"px", new TSimpleUnitConverter(1)); + fxInch(L"in", new TSimpleUnitConverter(1 / stage_inch)), + fxCm(L"cm", new TSimpleUnitConverter(2.54 / stage_inch)), + fxMm(L"mm", new TSimpleUnitConverter(25.4 / stage_inch)), + fxXfld(L"fld", new TSimpleUnitConverter(2 / stage_inch)), + fxPx(L"px", new TSimpleUnitConverter(1)); fxInch.addExtension(L"inch"); fxInch.addExtension(L"\""); fxInch.addExtension(L"''"); diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index cb7e8d80..188526a0 100644 --- a/toonz/sources/include/toonz/preferences.h +++ b/toonz/sources/include/toonz/preferences.h @@ -418,8 +418,8 @@ private: std::vector m_levelFormats; - QString m_units, m_cameraUnits, m_scanLevelType, m_currentRoomChoice, - m_oldUnits, m_oldCameraUnits; + QString m_units, m_cameraUnits, m_scanLevelType, m_currentRoomChoice, + m_oldUnits, m_oldCameraUnits; double m_defLevelWidth, m_defLevelHeight, m_defLevelDpi; diff --git a/toonz/sources/include/toonz/tcamera.h b/toonz/sources/include/toonz/tcamera.h index bb48e380..3bf62b71 100644 --- a/toonz/sources/include/toonz/tcamera.h +++ b/toonz/sources/include/toonz/tcamera.h @@ -39,7 +39,8 @@ class DVAPI TCamera { public: /*! Constructs TCamera with default value, size (12,9) and resolution (768,576). - Constructs TCamera with default value, size (36, 20.25) and resolution (1920,1080). + Constructs TCamera with default value, size (36, 20.25) and resolution +(1920,1080). - 05/31/16 */ TCamera(); diff --git a/toonz/sources/include/toonzqt/camerasettingswidget.h b/toonz/sources/include/toonzqt/camerasettingswidget.h index f922cada..5cf3e0c2 100644 --- a/toonz/sources/include/toonzqt/camerasettingswidget.h +++ b/toonz/sources/include/toonzqt/camerasettingswidget.h @@ -83,9 +83,9 @@ class DVAPI CameraSettingsWidget final : public QFrame { double m_arValue; DVGui::IntLineEdit *m_xResFld, *m_yResFld; DVGui::DoubleLineEdit *m_xDpiFld, *m_yDpiFld; - QLabel* m_dpiLabel; - QLabel* m_resLabel; - QLabel* m_xLabel; + QLabel *m_dpiLabel; + QLabel *m_resLabel; + QLabel *m_xLabel; QPushButton *m_fspChk; // Force Squared Pixel => dpix == dpiy diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index 9f54f8e1..1d71631d 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -1828,14 +1828,14 @@ RulerToolOptionsBox::RulerToolOptionsBox(QWidget *parent, TTool *tool) m_HpixelFld = new QLabel(this); m_Afld->setMeasure("angle"); - - if (Preferences::instance()->getUnits() == "pixel") { - m_Xfld->setMeasure("length.x"); - m_Yfld->setMeasure("length.y"); - m_Wfld->setMeasure("length.x"); - m_Hfld->setMeasure("length.y"); - m_Lfld->setMeasure("length.x"); - } + + if (Preferences::instance()->getUnits() == "pixel") { + m_Xfld->setMeasure("length.x"); + m_Yfld->setMeasure("length.y"); + m_Wfld->setMeasure("length.x"); + m_Hfld->setMeasure("length.y"); + m_Lfld->setMeasure("length.x"); + } m_Xfld->setObjectName("RulerToolOptionValues"); m_Yfld->setObjectName("RulerToolOptionValues"); diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index cc7db294..4ae3c443 100644 --- a/toonz/sources/toonz/iocommand.cpp +++ b/toonz/sources/toonz/iocommand.cpp @@ -1257,7 +1257,8 @@ bool IoCmd::saveSceneIfNeeded(QString msg) { void IoCmd::newScene() { RenderingSuspender suspender; TApp *app = TApp::instance(); - double cameraDpi = 53.33333; //used to be 64, consider changing to 120 or 160 + double cameraDpi = 53.33333; // used to be 64, consider changing to 120 or + // 160 if (!saveSceneIfNeeded(QApplication::tr("New Scene"))) return; IconGenerator::instance()->clearRequests(); diff --git a/toonz/sources/toonz/levelcreatepopup.cpp b/toonz/sources/toonz/levelcreatepopup.cpp index 98fc8e2f..8442974e 100644 --- a/toonz/sources/toonz/levelcreatepopup.cpp +++ b/toonz/sources/toonz/levelcreatepopup.cpp @@ -194,14 +194,14 @@ LevelCreatePopup::LevelCreatePopup() m_levelTypeOm->addItem(RasterLevel); m_levelTypeOm->addItem(ScanLevel); - if (Preferences::instance()->getUnits() == "pixel") { - m_widthFld->setMeasure("camera.lx"); - m_heightFld->setMeasure("camera.ly"); - } else { - m_widthFld->setMeasure("level.lx"); - m_heightFld->setMeasure("level.ly"); - } - + if (Preferences::instance()->getUnits() == "pixel") { + m_widthFld->setMeasure("camera.lx"); + m_heightFld->setMeasure("camera.ly"); + } else { + m_widthFld->setMeasure("level.lx"); + m_heightFld->setMeasure("level.ly"); + } + m_widthFld->setRange(0.1, (std::numeric_limits::max)()); m_heightFld->setRange(0.1, (std::numeric_limits::max)()); m_dpiFld->setRange(0.1, (std::numeric_limits::max)()); @@ -277,8 +277,6 @@ LevelCreatePopup::LevelCreatePopup() m_buttonLayout->addStretch(1); } - - //---- signal-slot connections bool ret = true; ret = ret && @@ -337,14 +335,12 @@ void LevelCreatePopup::showEvent(QShowEvent *) { nextName(); update(); m_nameFld->setFocus(); - if (Preferences::instance()->getUnits() == "pixel") - { - m_dpiFld->hide(); - m_dpiLabel->hide(); - } - else { - m_dpiFld->show(); - m_dpiLabel->show(); + if (Preferences::instance()->getUnits() == "pixel") { + m_dpiFld->hide(); + m_dpiLabel->hide(); + } else { + m_dpiFld->show(); + m_dpiLabel->show(); } } diff --git a/toonz/sources/toonz/levelsettingspopup.cpp b/toonz/sources/toonz/levelsettingspopup.cpp index be3e961e..cf7bdc4a 100644 --- a/toonz/sources/toonz/levelsettingspopup.cpp +++ b/toonz/sources/toonz/levelsettingspopup.cpp @@ -133,8 +133,8 @@ LevelSettingsPopup::LevelSettingsPopup() m_imageDpiLabel = new QLabel(tr("")); m_imageResLabel = new QLabel(tr("")); m_cameraDpiTitle = new QLabel(tr("Camera DPI:")); - m_imageDpiTitle = new QLabel(tr("Image DPI:")); - m_imageResTitle = new QLabel(tr("Resolution:")); + m_imageDpiTitle = new QLabel(tr("Image DPI:")); + m_imageResTitle = new QLabel(tr("Resolution:")); // subsampling m_subsamplingLabel = new QLabel(tr("Subsampling:")); @@ -161,11 +161,11 @@ LevelSettingsPopup::LevelSettingsPopup() /*--- Levelサイズの単位はCameraUnitにする --*/ m_widthFld->setMeasure("camera.lx"); m_heightFld->setMeasure("camera.ly"); - - if (Preferences::instance()->getCameraUnits() == "pixel") { - m_widthFld->setDecimals(0); - m_heightFld->setDecimals(0); - } + + if (Preferences::instance()->getCameraUnits() == "pixel") { + m_widthFld->setDecimals(0); + m_heightFld->setDecimals(0); + } m_doPremultiply->setChecked(false); @@ -203,13 +203,13 @@ LevelSettingsPopup::LevelSettingsPopup() m_topLayout->addWidget(nameBox); //----DPI & Resolution - QGroupBox *dpiBox; - if (Preferences::instance()->getUnits() == "pixel") - dpiBox = new QGroupBox(tr("Resolution"), this); - else - dpiBox = new QGroupBox(tr("DPI && Resolution"), this); + QGroupBox *dpiBox; + if (Preferences::instance()->getUnits() == "pixel") + dpiBox = new QGroupBox(tr("Resolution"), this); + else + dpiBox = new QGroupBox(tr("DPI && Resolution"), this); QGridLayout *dpiLayout = new QGridLayout(); - dpiLayout->setMargin(5); + dpiLayout->setMargin(5); dpiLayout->setSpacing(5); { dpiLayout->addWidget(m_dpiTypeOm, 0, 1, 1, 3); @@ -233,7 +233,6 @@ LevelSettingsPopup::LevelSettingsPopup() dpiLayout->addWidget(m_imageResTitle, 6, 0, Qt::AlignRight | Qt::AlignVCenter); dpiLayout->addWidget(m_imageResLabel, 6, 1, 1, 3); - } dpiLayout->setColumnStretch(0, 0); dpiLayout->setColumnStretch(1, 1); @@ -320,32 +319,30 @@ void LevelSettingsPopup::showEvent(QShowEvent *e) { assert(ret); updateLevelSettings(); - if (Preferences::instance()->getUnits() == "pixel") - { - m_dpiTypeOm->hide(); - m_dpiLabel->hide(); - m_dpiFld->hide(); - m_squarePixCB->hide(); - m_useCameraDpiBtn->hide(); - m_cameraDpiLabel->hide(); - m_imageDpiLabel->hide(); - m_imageDpiTitle->hide(); - m_cameraDpiTitle->hide(); - m_imageResTitle->hide(); - m_imageResLabel->hide(); - } - else { - m_dpiTypeOm->show(); - m_dpiLabel->show(); - m_dpiFld->show(); - m_squarePixCB->show(); - m_useCameraDpiBtn->show(); - m_cameraDpiLabel->show(); - m_imageDpiLabel->show(); - m_imageDpiTitle->show(); - m_cameraDpiTitle->show(); - m_imageResTitle->show(); - m_imageResLabel->show(); + if (Preferences::instance()->getUnits() == "pixel") { + m_dpiTypeOm->hide(); + m_dpiLabel->hide(); + m_dpiFld->hide(); + m_squarePixCB->hide(); + m_useCameraDpiBtn->hide(); + m_cameraDpiLabel->hide(); + m_imageDpiLabel->hide(); + m_imageDpiTitle->hide(); + m_cameraDpiTitle->hide(); + m_imageResTitle->hide(); + m_imageResLabel->hide(); + } else { + m_dpiTypeOm->show(); + m_dpiLabel->show(); + m_dpiFld->show(); + m_squarePixCB->show(); + m_useCameraDpiBtn->show(); + m_cameraDpiLabel->show(); + m_imageDpiLabel->show(); + m_imageDpiTitle->show(); + m_cameraDpiTitle->show(); + m_imageResTitle->show(); + m_imageResLabel->show(); } } diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 8a333a96..965f7a23 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -214,76 +214,72 @@ Preferences::LevelFormat PreferencesPopup::FormatProperties::levelFormat() //********************************************************************************** void PreferencesPopup::onPixelsOnlyChanged(int index) { - bool enabled = index == Qt::Checked; - if (enabled) { - - m_pref->setDefLevelDpi(53.33333); - m_pref->setPixelsOnly(true); - TCamera* camera; - camera = TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera(); - TDimension camRes = camera->getRes(); - TDimensionD camSize; - camSize.lx = camRes.lx / 53.33333; - camSize.ly = camRes.ly / 53.33333; - 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); - m_defLevelDpi->setDisabled(true); - m_defLevelDpi->setValue(53.33333); - m_defLevelWidth->setMeasure("camera.lx"); - m_defLevelHeight->setMeasure("camera.ly"); - m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); - m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); - m_defLevelHeight->setDecimals(0); - m_defLevelWidth->setDecimals(0); - - } - 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); - int levelType = m_pref->getDefLevelType(); - bool isRaster = levelType != PLI_XSHLEVEL; - if (isRaster) { - m_defLevelDpi->setDisabled(false); - } - m_defLevelHeight->setMeasure("level.ly"); - m_defLevelWidth->setMeasure("level.lx"); - m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); - m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); - m_defLevelHeight->setDecimals(4); - m_defLevelWidth->setDecimals(4); - } + bool enabled = index == Qt::Checked; + if (enabled) { + m_pref->setDefLevelDpi(53.33333); + m_pref->setPixelsOnly(true); + TCamera *camera; + camera = + TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera(); + TDimension camRes = camera->getRes(); + TDimensionD camSize; + camSize.lx = camRes.lx / 53.33333; + camSize.ly = camRes.ly / 53.33333; + 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); + m_defLevelDpi->setDisabled(true); + m_defLevelDpi->setValue(53.33333); + m_defLevelWidth->setMeasure("camera.lx"); + m_defLevelHeight->setMeasure("camera.ly"); + m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); + m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + m_defLevelHeight->setDecimals(0); + m_defLevelWidth->setDecimals(0); + } 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); + int levelType = m_pref->getDefLevelType(); + bool isRaster = levelType != PLI_XSHLEVEL; + if (isRaster) { + m_defLevelDpi->setDisabled(false); + } + m_defLevelHeight->setMeasure("level.ly"); + m_defLevelWidth->setMeasure("level.lx"); + m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); + m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + m_defLevelHeight->setDecimals(4); + m_defLevelWidth->setDecimals(4); + } } void PreferencesPopup::onUnitChanged(int index) { - if (index == 4 && m_pixelsOnlyCB->isChecked() == false) { - m_pixelsOnlyCB->setCheckState(Qt::Checked); - } - 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) { - if (index == 4 && m_pixelsOnlyCB->isChecked() == false) { - m_pixelsOnlyCB->setChecked(true); - } - m_pref->setCameraUnits(::units[index].toStdString()); + if (index == 4 && m_pixelsOnlyCB->isChecked() == false) { + m_pixelsOnlyCB->setChecked(true); + } + m_pref->setCameraUnits(::units[index].toStdString()); } //----------------------------------------------------------------------------- @@ -738,8 +734,7 @@ void PreferencesPopup::onDefLevelTypeChanged(int index) { bool isRaster = levelType != PLI_XSHLEVEL; m_defLevelWidth->setEnabled(isRaster); m_defLevelHeight->setEnabled(isRaster); - if (!m_pixelsOnlyCB->isChecked()) - m_defLevelDpi->setEnabled(isRaster); + if (!m_pixelsOnlyCB->isChecked()) m_defLevelDpi->setEnabled(isRaster); } } @@ -901,9 +896,9 @@ PreferencesPopup::PreferencesPopup() } QComboBox *styleSheetType = 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); + 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); @@ -979,7 +974,7 @@ PreferencesPopup::PreferencesPopup() m_defLevelHeight = new MeasuredDoubleLineEdit(0); m_defLevelDpi = new DoubleLineEdit(0, 66.76); m_autocreationType = new QComboBox(this); - m_dpiLabel = new QLabel(tr("DPI:"), this); + m_dpiLabel = new QLabel(tr("DPI:"), this); CheckBox *keepOriginalCleanedUpCB = new CheckBox(tr("Keep Original Cleaned Up Drawings As Backup"), this); CheckBox *multiLayerStylePickerCB = new CheckBox( @@ -1085,10 +1080,10 @@ PreferencesPopup::PreferencesPopup() styleSheetType->setCurrentIndex(currentIndex); bool po = m_pref->getPixelsOnly(); m_pixelsOnlyCB->setChecked(po); - //m_pixelsOnlyCB->setChecked(true); - if (po){ - m_unitOm->setDisabled(true); - m_cameraUnitOm->setDisabled(true); + // m_pixelsOnlyCB->setChecked(true); + if (po) { + m_unitOm->setDisabled(true); + m_cameraUnitOm->setDisabled(true); } QStringList type; type << tr("cm") << tr("mm") << tr("inch") << tr("field") << tr("pixel"); @@ -1196,21 +1191,21 @@ PreferencesPopup::PreferencesPopup() } } - if (Preferences::instance()->getUnits() == "pixel") { - m_defLevelWidth->setRange(0.1, (std::numeric_limits::max)()); - m_defLevelWidth->setMeasure("camera.lx"); - m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); - m_defLevelHeight->setRange(0.1, (std::numeric_limits::max)()); - m_defLevelHeight->setMeasure("camera.ly"); - m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); - } else { - m_defLevelWidth->setRange(0.1, (std::numeric_limits::max)()); - m_defLevelWidth->setMeasure("level.lx"); - m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); - m_defLevelHeight->setRange(0.1, (std::numeric_limits::max)()); - m_defLevelHeight->setMeasure("level.ly"); - m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); - } + if (Preferences::instance()->getUnits() == "pixel") { + m_defLevelWidth->setRange(0.1, (std::numeric_limits::max)()); + m_defLevelWidth->setMeasure("camera.lx"); + m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); + m_defLevelHeight->setRange(0.1, (std::numeric_limits::max)()); + m_defLevelHeight->setMeasure("camera.ly"); + m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + } else { + m_defLevelWidth->setRange(0.1, (std::numeric_limits::max)()); + m_defLevelWidth->setMeasure("level.lx"); + m_defLevelWidth->setValue(m_pref->getDefLevelWidth()); + m_defLevelHeight->setRange(0.1, (std::numeric_limits::max)()); + m_defLevelHeight->setMeasure("level.ly"); + m_defLevelHeight->setValue(m_pref->getDefLevelHeight()); + } m_defLevelDpi->setRange(0.1, (std::numeric_limits::max)()); m_defLevelDpi->setValue(m_pref->getDefLevelDpi()); QStringList autocreationTypes; @@ -1344,10 +1339,10 @@ 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("Pixels Only:"), this), 1, 0, + Qt::AlignRight | Qt::AlignVCenter); + styleLay->addWidget(m_pixelsOnlyCB, 1, 1); styleLay->addWidget(new QLabel(tr("Unit:"), this), 2, 0, Qt::AlignRight | Qt::AlignVCenter); @@ -1529,9 +1524,9 @@ PreferencesPopup::PreferencesPopup() drawingTopLay->addWidget(new QLabel(tr(" Height:")), 2, 2, Qt::AlignRight); drawingTopLay->addWidget(m_defLevelHeight, 2, 3); - drawingTopLay->addWidget(m_dpiLabel, 3, 0, Qt::AlignRight); - drawingTopLay->addWidget(m_defLevelDpi, 3, 1); - drawingTopLay->addWidget(new QLabel(tr("Autocreation:")), 4, 0, + drawingTopLay->addWidget(m_dpiLabel, 3, 0, Qt::AlignRight); + drawingTopLay->addWidget(m_defLevelDpi, 3, 1); + drawingTopLay->addWidget(new QLabel(tr("Autocreation:")), 4, 0, Qt::AlignRight); drawingTopLay->addWidget(m_autocreationType, 4, 1, 1, 3); } @@ -1549,11 +1544,11 @@ PreferencesPopup::PreferencesPopup() } drawingBox->setLayout(drawingFrameLay); stackedWidget->addWidget(drawingBox); - if (m_pixelsOnlyCB->isChecked()) { - m_defLevelDpi->setDisabled(true); - m_defLevelWidth->setDecimals(0); - m_defLevelHeight->setDecimals(0); - } + if (m_pixelsOnlyCB->isChecked()) { + m_defLevelDpi->setDisabled(true); + m_defLevelWidth->setDecimals(0); + m_defLevelHeight->setDecimals(0); + } //--- Xsheet -------------------------- QWidget *xsheetBox = new QWidget(this); @@ -1754,7 +1749,7 @@ PreferencesPopup::PreferencesPopup() ret = ret && connect(styleSheetType, SIGNAL(currentIndexChanged(int)), SLOT(onStyleSheetTypeChanged(int))); ret = ret && connect(m_pixelsOnlyCB, SIGNAL(stateChanged(int)), - SLOT(onPixelsOnlyChanged(int))); + SLOT(onPixelsOnlyChanged(int))); ret = ret && connect(m_unitOm, SIGNAL(currentIndexChanged(int)), SLOT(onUnitChanged(int))); ret = ret && connect(m_cameraUnitOm, SIGNAL(currentIndexChanged(int)), diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h index 31575a30..07f0c9de 100644 --- a/toonz/sources/toonz/preferencespopup.h +++ b/toonz/sources/toonz/preferencespopup.h @@ -57,7 +57,7 @@ private: DVGui::DoubleLineEdit *m_defLevelDpi; - QLabel* m_dpiLabel; + QLabel *m_dpiLabel; DVGui::IntLineEdit *m_minuteFld, *m_chunkSizeFld, *m_iconSizeLx, *m_iconSizeLy, *m_viewShrink, *m_viewStep, *m_blanksCount, diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index 4ea61572..07b234ee 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -208,8 +208,8 @@ bool Preferences::LevelFormat::matches(const TFilePath &fp) const { //********************************************************************************** Preferences::Preferences() - : m_pixelsOnly(true) - , m_units("pixel") + : m_pixelsOnly(true) + , m_units("pixel") , m_cameraUnits("pixel") , m_currentRoomChoice("Default") , m_scanLevelType("tif") @@ -374,21 +374,20 @@ Preferences::Preferences() setUndoMemorySize(m_undoMemorySize); m_blankColor = TPixel32(r, g, b); - - - //for Pixels only - - getValue(*m_settings, "pixelsOnly", m_pixelsOnly); //doesn't work for some reason. - QString pos = m_settings->value("pixelsOnly").toString(); + // for Pixels only + + getValue(*m_settings, "pixelsOnly", + m_pixelsOnly); // doesn't work for some reason. + QString pos = m_settings->value("pixelsOnly").toString(); if (pos == "true") m_pixelsOnly = true; - + QString units; - units = m_settings->value("oldUnits", m_units).toString(); + units = m_settings->value("oldUnits", m_units).toString(); m_oldUnits = units; - units = m_settings->value("oldCameraUnits", m_cameraUnits).toString(); + units = m_settings->value("oldCameraUnits", m_cameraUnits).toString(); m_oldCameraUnits = units; - //end for pixels only + // end for pixels only units = m_settings->value("linearUnits").toString(); if (units != "") m_units = units; @@ -946,15 +945,13 @@ 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(); - } + m_pixelsOnly = state; + m_settings->setValue("pixelsOnly", m_pixelsOnly); + if (state) { + storeOldUnits(); + } else { + resetOldUnits(); + } } //----------------------------------------------------------------- @@ -983,19 +980,19 @@ 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); + 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()); - } + if (m_oldUnits != "" && m_oldCameraUnits != "") { + setUnits(m_oldUnits.toStdString()); + setCameraUnits(m_oldCameraUnits.toStdString()); + } } //----------------------------------------------------------------- diff --git a/toonz/sources/toonzlib/stage.cpp b/toonz/sources/toonzlib/stage.cpp index 4a7a0d58..56593b43 100644 --- a/toonz/sources/toonzlib/stage.cpp +++ b/toonz/sources/toonzlib/stage.cpp @@ -69,7 +69,7 @@ typedef std::vector PlayerSet; thickness of images .pli. */ -const double Stage::inch = 53.33333; //consider changing to 120 or 160 +const double Stage::inch = 53.33333; // consider changing to 120 or 160 const double Stage::vectorDpi = 53.3333; namespace { diff --git a/toonz/sources/toonzlib/toonzscene.cpp b/toonz/sources/toonzlib/toonzscene.cpp index 7ccd82eb..88b1e9a3 100644 --- a/toonz/sources/toonzlib/toonzscene.cpp +++ b/toonz/sources/toonzlib/toonzscene.cpp @@ -1176,7 +1176,8 @@ TXshLevel *ToonzScene::loadLevel(const TFilePath &actualPath, // We must check whether the image actually has a dpi. const TPointD &imageDpi = xl->getImageDpi(); - if (imageDpi == TPointD() || Preferences::instance()->getUnits() == "pixel") { + if (imageDpi == TPointD() || + Preferences::instance()->getUnits() == "pixel") { // Change to "Custom Dpi" policy and use camera dpi TStageObjectId cameraId = getXsheet()->getStageObjectTree()->getCurrentCameraId(); diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp index 9d153a3e..c798fa85 100644 --- a/toonz/sources/toonzlib/txshsimplelevel.cpp +++ b/toonz/sources/toonzlib/txshsimplelevel.cpp @@ -382,7 +382,7 @@ void TXshSimpleLevel::setPath(const TFilePath &fp, bool keepFrames) { } catch (...) { } } - + if (getType() != PLI_XSHLEVEL) { if (!m_frames.empty()) { std::string imageId = getImageId(getFirstFid()); @@ -2169,9 +2169,8 @@ TFilePath TXshSimpleLevel::getExistingHookFile( } assert(h >= 0); - return (h < 0) ? TFilePath() - : decodedLevelPath.getParentDir() + - TFilePath(hookFiles[h].toStdWString()); + return (h < 0) ? TFilePath() : decodedLevelPath.getParentDir() + + TFilePath(hookFiles[h].toStdWString()); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonzqt/camerasettingswidget.cpp b/toonz/sources/toonzqt/camerasettingswidget.cpp index 78ae7258..4c531d39 100644 --- a/toonz/sources/toonzqt/camerasettingswidget.cpp +++ b/toonz/sources/toonzqt/camerasettingswidget.cpp @@ -196,7 +196,7 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) m_dpiLabel = new QLabel(tr("DPI")); m_resLabel = new QLabel(tr("Pixels")); - m_xLabel = new QLabel(tr("x")); + m_xLabel = new QLabel(tr("x")); m_fspChk = new QPushButton(""); @@ -283,8 +283,8 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) gridLay->addWidget(m_inchPrev, 1, 0, Qt::AlignRight | Qt::AlignVCenter); QString units = Preferences::instance()->getCameraUnits(); - gridLay->addWidget(new QLabel(units), 1, 1, - Qt::AlignRight | Qt::AlignVCenter); + gridLay->addWidget(new QLabel(units), 1, 1, + Qt::AlignRight | Qt::AlignVCenter); gridLay->addWidget(m_lxFld, 1, 2); gridLay->addWidget(new QLabel("x"), 1, 3, Qt::AlignCenter); gridLay->addWidget(m_lyFld, 1, 4); @@ -294,14 +294,12 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) gridLay->addWidget(m_arFld, 2, 4); gridLay->addWidget(m_dotPrev, 3, 0, Qt::AlignRight | Qt::AlignVCenter); - gridLay->addWidget(m_resLabel, 3, 1, - Qt::AlignRight | Qt::AlignVCenter); + gridLay->addWidget(m_resLabel, 3, 1, Qt::AlignRight | Qt::AlignVCenter); gridLay->addWidget(m_xResFld, 3, 2); gridLay->addWidget(m_xLabel, 3, 3, Qt::AlignCenter); gridLay->addWidget(m_yResFld, 3, 4); - gridLay->addWidget(m_dpiLabel, 4, 1, - Qt::AlignRight | Qt::AlignVCenter); + gridLay->addWidget(m_dpiLabel, 4, 1, Qt::AlignRight | Qt::AlignVCenter); gridLay->addWidget(m_xDpiFld, 4, 2); gridLay->addWidget(m_fspChk, 4, 3, Qt::AlignCenter); gridLay->addWidget(m_yDpiFld, 4, 4); @@ -372,29 +370,27 @@ CameraSettingsWidget::CameraSettingsWidget(bool forCleanup) CameraSettingsWidget::~CameraSettingsWidget() { setCurrentLevel(0); } void CameraSettingsWidget::showEvent(QShowEvent *e) { - if (Preferences::instance()->getCameraUnits() == "pixel") - { - m_resLabel->hide(); - m_dpiLabel->hide(); - m_xLabel->hide(); - m_xResFld->hide(); - m_yResFld->hide(); - m_xDpiFld->hide(); - m_yDpiFld->hide(); - m_fspChk->hide(); - m_dotPrev->hide(); - } - else { - m_resLabel->show(); - m_dpiLabel->show(); - m_xLabel->show(); - m_xResFld->show(); - m_yResFld->show(); - m_xDpiFld->show(); - m_yDpiFld->show(); - m_fspChk->show(); - m_dotPrev->show(); - } + if (Preferences::instance()->getCameraUnits() == "pixel") { + m_resLabel->hide(); + m_dpiLabel->hide(); + m_xLabel->hide(); + m_xResFld->hide(); + m_yResFld->hide(); + m_xDpiFld->hide(); + m_yDpiFld->hide(); + m_fspChk->hide(); + m_dotPrev->hide(); + } else { + m_resLabel->show(); + m_dpiLabel->show(); + m_xLabel->show(); + m_xResFld->show(); + m_yResFld->show(); + m_xDpiFld->show(); + m_yDpiFld->show(); + m_fspChk->show(); + m_dotPrev->show(); + } } void CameraSettingsWidget::loadPresetList() { From 3eeb02f307d097c0ad87f934fbf88bf1ea58e7fc Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Wed, 13 Jul 2016 00:28:41 -0600 Subject: [PATCH 15/18] Set cleanup camera settings --- toonz/sources/toonz/preferencespopup.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 965f7a23..c7cbfce1 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -7,6 +7,7 @@ #include "versioncontrol.h" #include "levelsettingspopup.h" #include "tapp.h" +#include "cleanupsettingsmodel.h" // TnzQt includes #include "toonzqt/tabbar.h" @@ -226,7 +227,12 @@ void PreferencesPopup::onPixelsOnlyChanged(int index) { camSize.lx = camRes.lx / 53.33333; camSize.ly = camRes.ly / 53.33333; camera->setSize(camSize); - m_pref->storeOldUnits(); + TDimension cleanupRes = CleanupSettingsModel::instance()->getCurrentParameters()->m_camera.getRes(); + TDimensionD cleanupSize; + cleanupSize.lx = cleanupRes.lx / 53.33333; + cleanupSize.ly = cleanupRes.ly / 53.33333; + CleanupSettingsModel::instance()->getCurrentParameters()->m_camera.setSize(cleanupSize); + 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); From 2e52c6995c37e4c866958919d884faf280851980 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Wed, 13 Jul 2016 00:38:17 -0600 Subject: [PATCH 16/18] reverted default units --- toonz/sources/toonzlib/preferences.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index 07b234ee..acab2fd9 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -208,9 +208,9 @@ bool Preferences::LevelFormat::matches(const TFilePath &fp) const { //********************************************************************************** Preferences::Preferences() - : m_pixelsOnly(true) - , m_units("pixel") - , m_cameraUnits("pixel") + : m_pixelsOnly(false) + , m_units("mm") + , m_cameraUnits("inch") , m_currentRoomChoice("Default") , m_scanLevelType("tif") , m_defLevelWidth(0.0) From ae0f0a65a886e1482108a5d2792e7dee5812b3b5 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Wed, 13 Jul 2016 01:51:33 -0600 Subject: [PATCH 17/18] Fixed new scene having correct dpi even if default settings are set other than 53.33333 --- toonz/sources/toonz/iocommand.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp index 4ae3c443..106c7e2f 100644 --- a/toonz/sources/toonz/iocommand.cpp +++ b/toonz/sources/toonz/iocommand.cpp @@ -1287,6 +1287,13 @@ void IoCmd::newScene() { TDimensionD((double)res.lx / cameraDpi, (double)res.ly / cameraDpi)); scene->getProperties()->setBgColor(TPixel32::White); TProjectManager::instance()->initializeScene(scene); + if (Preferences::instance()->getPixelsOnly()) + { + TCamera *updateCamera = scene->getCurrentCamera(); + TDimension updateRes = updateCamera->getRes(); + updateCamera->setSize( + TDimensionD((double)updateRes.lx / cameraDpi, (double)updateRes.ly / cameraDpi)); + } // Must set current scene after initializeScene!! app->getCurrentScene()->setScene(scene); // initializeScene() load project cleanup palette: set it to cleanup palette From 027819831e0af6b1e68d7c387b18713a67cc7fec Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Wed, 13 Jul 2016 02:28:26 -0600 Subject: [PATCH 18/18] hide fields for exportlevelpopup if pixelsonly --- toonz/sources/toonz/exportlevelpopup.cpp | 25 ++++++++++++++++++------ toonz/sources/toonz/exportlevelpopup.h | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/toonz/sources/toonz/exportlevelpopup.cpp b/toonz/sources/toonz/exportlevelpopup.cpp index 3dfa0d98..35cef834 100644 --- a/toonz/sources/toonz/exportlevelpopup.cpp +++ b/toonz/sources/toonz/exportlevelpopup.cpp @@ -393,7 +393,19 @@ void ExportLevelPopup::showEvent(QShowEvent *se) { { TSelectionHandle *selectionHandle = TApp::instance()->getCurrentSelection(); TSelection *selection = selectionHandle->getSelection(); - + if (Preferences::instance()->getPixelsOnly()) { + m_exportOptions->m_widthFld->hide(); + m_exportOptions->m_heightFld->hide(); + m_exportOptions->m_widthLabel->hide(); + m_exportOptions->m_heightLabel->hide(); + m_exportOptions->m_dpiLabel->hide(); + } else { + m_exportOptions->m_widthFld->show(); + m_exportOptions->m_heightFld->show(); + m_exportOptions->m_widthLabel->show(); + m_exportOptions->m_heightLabel->show(); + m_exportOptions->m_dpiLabel->show(); + } selectionHandle->pushSelection(); selectionHandle->setSelection(selection); } @@ -730,6 +742,10 @@ ExportLevelPopup::ExportOptions::ExportOptions(QWidget *parent) m_hResFld = new DVGui::IntLineEdit; m_vResFld = new DVGui::IntLineEdit; m_dpiLabel = new QLabel; + m_widthLabel = new QLabel; + m_heightLabel = new QLabel; + m_widthLabel->setText("Width: "); + m_heightLabel->setText("Height: "); m_resScale = new DVGui::MeasuredDoubleLineEdit; m_widthFld->setRange(0, dmax); @@ -746,12 +762,9 @@ ExportLevelPopup::ExportOptions::ExportOptions(QWidget *parent) m_vResFld->setFixedSize(50, 20); m_hResFld->setFixedSize(50, 20); m_resScale->setFixedSize(50, 20); - - exportBoxLayout->addWidget(new QLabel(tr("Width:")), 0, 0, - Qt::AlignRight); + exportBoxLayout->addWidget(m_widthLabel, 0, 0, Qt::AlignRight); exportBoxLayout->addWidget(m_widthFld, 0, 1, Qt::AlignLeft); - exportBoxLayout->addWidget(new QLabel(tr("Height:")), 0, 2, - Qt::AlignRight); + exportBoxLayout->addWidget(m_heightLabel, 0, 2, Qt::AlignRight); exportBoxLayout->addWidget(m_heightFld, 0, 3, Qt::AlignLeft); exportBoxLayout->addWidget(m_dpiLabel, 0, 4, Qt::AlignRight); exportBoxLayout->addWidget(new QLabel(tr("H Resolution:")), 1, 0, diff --git a/toonz/sources/toonz/exportlevelpopup.h b/toonz/sources/toonz/exportlevelpopup.h index 4980cd36..5d87e04e 100644 --- a/toonz/sources/toonz/exportlevelpopup.h +++ b/toonz/sources/toonz/exportlevelpopup.h @@ -141,7 +141,7 @@ private: DVGui::MeasuredDoubleLineEdit *m_resScale; - QLabel *m_dpiLabel; + QLabel *m_dpiLabel, *m_widthLabel, *m_heightLabel; QComboBox *m_thicknessTransformMode;