2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef CAMERASETTINGSWIDGET_H
|
|
|
|
#define CAMERASETTINGSWIDGET_H
|
|
|
|
|
2017-05-09 00:13:29 +12:00
|
|
|
#ifdef _MSC_VER
|
2016-03-19 06:57:51 +13:00
|
|
|
#pragma warning(disable : 4251)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "tcommon.h"
|
|
|
|
#include "tgeometry.h"
|
|
|
|
|
|
|
|
#undef DVAPI
|
|
|
|
#undef DVVAR
|
|
|
|
#ifdef TOONZQT_EXPORTS
|
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#define DVVAR DV_EXPORT_VAR
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#define DVVAR DV_IMPORT_VAR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QValidator>
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
|
|
class TCamera;
|
|
|
|
class QRadioButton;
|
|
|
|
class QComboBox;
|
2016-07-03 17:30:00 +12:00
|
|
|
class QLabel;
|
2016-03-19 06:57:51 +13:00
|
|
|
class ResListManager;
|
|
|
|
class TFilePath;
|
|
|
|
class TXshSimpleLevel;
|
|
|
|
class TXshLevel;
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
namespace DVGui {
|
2016-03-19 06:57:51 +13:00
|
|
|
class LineEdit;
|
|
|
|
class DoubleLineEdit;
|
|
|
|
class IntLineEdit;
|
|
|
|
class MeasuredDoubleLineEdit;
|
|
|
|
class CheckBox;
|
2020-12-18 18:28:25 +13:00
|
|
|
} // namespace DVGui
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class SimpleExpValidator final : public QValidator {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
SimpleExpValidator(QObject *parent) : QValidator(parent){};
|
2016-06-19 20:06:29 +12:00
|
|
|
State validate(QString &input, int &pos) const override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
// for A/R input field
|
2016-06-29 18:17:12 +12:00
|
|
|
class SimpleExpField final : public QLineEdit {
|
2016-06-15 18:43:10 +12:00
|
|
|
SimpleExpValidator *m_validator;
|
|
|
|
QString m_previousValue;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
SimpleExpField(QWidget *parent);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setValue(double);
|
|
|
|
void setValue(double, int, int);
|
|
|
|
double getValue();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
void focusInEvent(QFocusEvent *event) override;
|
|
|
|
void focusOutEvent(QFocusEvent *event) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class DVAPI CameraSettingsWidget final : public QFrame {
|
2016-10-18 19:29:19 +13:00
|
|
|
friend class StartupPopup;
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool m_forCleanup;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QRadioButton *m_xPrev, *m_yPrev, *m_arPrev;
|
|
|
|
QRadioButton *m_inchPrev, *m_dotPrev;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
DVGui::MeasuredDoubleLineEdit *m_lxFld, *m_lyFld;
|
|
|
|
SimpleExpField *m_arFld;
|
|
|
|
double m_arValue;
|
|
|
|
DVGui::IntLineEdit *m_xResFld, *m_yResFld;
|
|
|
|
DVGui::DoubleLineEdit *m_xDpiFld, *m_yDpiFld;
|
2016-07-13 15:09:46 +12:00
|
|
|
QLabel *m_dpiLabel;
|
|
|
|
QLabel *m_resLabel;
|
|
|
|
QLabel *m_xLabel;
|
2016-07-24 17:11:49 +12:00
|
|
|
QLabel *m_unitLabel;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QPushButton *m_fspChk; // Force Squared Pixel => dpix == dpiy
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QPushButton *m_useLevelSettingsBtn;
|
|
|
|
QComboBox *m_presetListOm;
|
|
|
|
QPushButton *m_addPresetBtn, *m_removePresetBtn;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
DVGui::MeasuredDoubleLineEdit *m_offsX, *m_offsY;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString m_presetListFile;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// needed by "use level settings"
|
|
|
|
TXshSimpleLevel *m_currentLevel;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void savePresetList();
|
|
|
|
void loadPresetList();
|
|
|
|
bool parsePresetString(const QString &str, QString &name, int &xres,
|
|
|
|
int &yres, QString &ar);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool parsePresetString(const QString &str, QString &name, int &xres,
|
|
|
|
int &yres, double &fx, double &fy, QString &xoffset,
|
|
|
|
QString &yoffset, double &ar, bool forCleanup = false);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
CameraSettingsWidget(bool forCleanup = false);
|
|
|
|
~CameraSettingsWidget();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setPresetListFile(const TFilePath &fp);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// Defines the level referred by the button "Use level settings".
|
|
|
|
// Calling setCurrentLevel(0) disables the button
|
|
|
|
void setCurrentLevel(TXshLevel *);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// camera => widget fields (i.e. initialize widget)
|
|
|
|
void setFields(const TCamera *camera);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2020-12-18 18:28:25 +13:00
|
|
|
// widget fields => camera return true if the value is actually changed
|
|
|
|
bool getFields(TCamera *camera);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
QSize sizeHint() const override { return minimumSize(); }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// The aspect ratio can be expressed as a fraction (e.g. "4/3")
|
|
|
|
// The following methods convert code/decode the value
|
|
|
|
static double aspectRatioStringToValue(const QString &s);
|
|
|
|
/*---
|
|
|
|
* カメラの縦横ピクセル値を入力できるようにし、valueがX/Yの値に近かったら、"X/Y"と表示する
|
|
|
|
* ---*/
|
|
|
|
static QString aspectRatioValueToString(double ar, int width = 0,
|
|
|
|
int height = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// the current camera dimension (in inches)
|
|
|
|
TDimensionD getSize() const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// the current camera resolution (in pixels)
|
|
|
|
TDimension getRes() const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*--- cleanupCameraSettingsWidgetからポインタを受け取る ---*/
|
|
|
|
void setOffsetWidgetPointers(DVGui::MeasuredDoubleLineEdit *offsX,
|
|
|
|
DVGui::MeasuredDoubleLineEdit *offsY) {
|
|
|
|
m_offsX = offsX;
|
|
|
|
m_offsY = offsY;
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
2016-07-03 17:30:00 +12:00
|
|
|
void showEvent(QShowEvent *e) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void hComputeLx();
|
|
|
|
void hComputeLy();
|
|
|
|
void vComputeLx();
|
|
|
|
void vComputeLy();
|
|
|
|
void computeAr();
|
|
|
|
void computeXRes();
|
|
|
|
void computeYRes();
|
|
|
|
void computeXDpi();
|
|
|
|
void computeYDpi();
|
|
|
|
void computeResOrDpi();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void updatePresetListOm();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setArFld(double ar);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected slots:
|
2016-06-15 18:43:10 +12:00
|
|
|
void onLxChanged();
|
|
|
|
void onLyChanged();
|
|
|
|
void onArChanged();
|
|
|
|
void onXResChanged();
|
|
|
|
void onYResChanged();
|
|
|
|
void onXDpiChanged();
|
|
|
|
void onYDpiChanged();
|
|
|
|
void onFspChanged(bool checked);
|
|
|
|
void onPrevToggled(bool checked);
|
|
|
|
void onPresetSelected(const QString &);
|
|
|
|
void addPreset();
|
|
|
|
void removePreset();
|
|
|
|
void useLevelSettings();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
signals:
|
2016-06-15 18:43:10 +12:00
|
|
|
void changed(); // some value has been changed
|
|
|
|
void
|
|
|
|
levelSettingsUsed(); // the "Use level settings" button has been pressed.
|
|
|
|
// Note: a changed() signal is always emitted after levelSettingsUsed()
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|