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