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