Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonzqt/doublepairfield.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/dvdialog.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qlabel></qlabel>
Toshihiro Shimizu 890ddd
#include <qpainter></qpainter>
Toshihiro Shimizu 890ddd
#include <qmouseevent></qmouseevent>
Toshihiro Shimizu 890ddd
#include <qslider></qslider>
Toshihiro Shimizu 890ddd
#include <qhboxlayout></qhboxlayout>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace DVGui;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Toshihiro Shimizu 890ddd
#define MARGIN_OFFSET 7
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define MARGIN_OFFSET 2
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DoubleValuePairField
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DoubleValuePairField::DoubleValuePairField(QWidget *parent, bool isMaxRangeLimited,
Toshihiro Shimizu 890ddd
										   DoubleValueLineEdit *leftLineEdit,
Toshihiro Shimizu 890ddd
										   DoubleValueLineEdit *rightLineEdit)
Toshihiro Shimizu 890ddd
	: QWidget(parent), m_values(0, 0), m_minValue(0), m_maxValue(100), m_grabOffset(0), m_grabIndex(-1), m_leftMargin(72), m_rightMargin(72), m_isMaxRangeLimited(isMaxRangeLimited), m_leftLineEdit(leftLineEdit), m_rightLineEdit(rightLineEdit)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert(m_leftLineEdit);
Toshihiro Shimizu 890ddd
	assert(m_rightLineEdit);
Toshihiro Shimizu 890ddd
	setObjectName("DoublePairField");
Toshihiro Shimizu 890ddd
	setFixedHeight(WidgetHeight);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_leftLabel = new QLabel("", this);
Toshihiro Shimizu 890ddd
	m_rightLabel = new QLabel("", this);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_leftLineEdit->setFixedWidth(60);
Toshihiro Shimizu 890ddd
	m_rightLineEdit->setFixedWidth(60);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//---- layout
Toshihiro Shimizu 890ddd
	QHBoxLayout *m_mainLayout = new QHBoxLayout;
Toshihiro Shimizu 890ddd
	m_mainLayout->setMargin(0);
Toshihiro Shimizu 890ddd
	m_mainLayout->setSpacing(3);
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_mainLayout->addWidget(m_leftLabel, 1);
Toshihiro Shimizu 890ddd
		m_mainLayout->addWidget(m_leftLineEdit, 1, Qt::AlignLeft);
Toshihiro Shimizu 890ddd
		m_mainLayout->addSpacing(35);
Toshihiro Shimizu 890ddd
		m_mainLayout->addStretch(100);
Toshihiro Shimizu 890ddd
		m_mainLayout->addWidget(m_rightLabel, 1);
Toshihiro Shimizu 890ddd
		m_mainLayout->addWidget(m_rightLineEdit, 1, Qt::AlignRight);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	setLayout(m_mainLayout);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//---- signal-slot connections
Toshihiro Shimizu 890ddd
	bool ret = connect(m_leftLineEdit, SIGNAL(editingFinished()), SLOT(onLeftEditingFinished()));
Toshihiro Shimizu 890ddd
	ret = ret && connect(m_rightLineEdit, SIGNAL(editingFinished()), SLOT(onRightEditingFinished()));
Toshihiro Shimizu 890ddd
	assert(ret);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
double DoubleValuePairField::pos2value(int x) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int xMin = m_leftMargin, xMax = width() - m_rightMargin;
Toshihiro Shimizu 890ddd
	return m_minValue + (m_maxValue - m_minValue) * (x - xMin) / (xMax - xMin);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int DoubleValuePairField::value2pos(double v) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	int xMin = m_leftMargin, xMax = width() - m_rightMargin;
Toshihiro Shimizu 890ddd
	return xMin + (int)(((xMax - xMin) * (v - m_minValue)) / (m_maxValue - m_minValue));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::paintEvent(QPaintEvent *)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	QPainter p(this);
Toshihiro Shimizu 890ddd
	p.setBrush(Qt::NoBrush);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int x0 = value2pos(m_minValue);
Toshihiro Shimizu 890ddd
	int x1 = value2pos(m_maxValue);
Toshihiro Shimizu 890ddd
	int y = height() / 2;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	p.setPen(getLightLineColor());
Toshihiro Shimizu 890ddd
	p.drawLine(x0 - 1, y, x1 + 1, y);
Toshihiro Shimizu 890ddd
	p.drawPoint(x1 + 1, y - 1);
Toshihiro Shimizu 890ddd
	p.drawPoint(x1 + 1, y - 2);
Toshihiro Shimizu 890ddd
	p.drawPoint(x1 + 1, y - 3);
Toshihiro Shimizu 890ddd
	p.setPen(QColor(0, 0, 0));
Toshihiro Shimizu 890ddd
	p.drawLine(x0, y - 2, x1 - 1, y - 2);
Toshihiro Shimizu 890ddd
	p.setPen(getDarkLineColor());
Toshihiro Shimizu 890ddd
	p.drawLine(x0 - 1, y - 3, x1, y - 3);
Toshihiro Shimizu 890ddd
	p.drawPoint(x0 - 1, y - 1);
Toshihiro Shimizu 890ddd
	p.drawPoint(x0 - 1, y - 2);
Toshihiro Shimizu 890ddd
	p.setPen(Qt::black);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int y1 = height() - 1;
Toshihiro Shimizu 890ddd
	int x;
Toshihiro Shimizu 890ddd
	x = value2pos(m_values.first);
Toshihiro Shimizu 890ddd
	QRect sliderRect = QRect(x0, -5, x1 - x0 + 1, 10);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (sliderRect.contains(QPoint(x, 0)))
Toshihiro Shimizu 890ddd
		p.drawPixmap(x - m_handleLeftPixmap.width() + 1, 2, m_handleLeftPixmap);
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		p.drawPixmap(sliderRect.right() - m_handleLeftPixmap.width() + 1, 2, m_handleLeftGrayPixmap);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	x = value2pos(m_values.second);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (sliderRect.contains(QPoint(x, 0)))
Toshihiro Shimizu 890ddd
		p.drawPixmap(x, 2, m_handleRightPixmap);
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		p.drawPixmap(sliderRect.right(), 2, m_handleRightGrayPixmap);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::setLeftText(const QString &text)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	QString oldText = m_leftLabel->text();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int oldLabelSize = fontMetrics().width(oldText);
Toshihiro Shimizu 890ddd
	int newLabelSize = fontMetrics().width(text);
Toshihiro Shimizu 890ddd
	int labelSize = newLabelSize - oldLabelSize;
Toshihiro Shimizu 890ddd
	m_leftMargin += labelSize + MARGIN_OFFSET;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_leftLabel->setText(text);
Toshihiro Shimizu 890ddd
	update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::setRightText(const QString &text)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	QString oldText = m_rightLabel->text();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int oldLabelSize = fontMetrics().width(oldText);
Toshihiro Shimizu 890ddd
	int newLabelSize = fontMetrics().width(text);
Toshihiro Shimizu 890ddd
	int labelSize = newLabelSize - oldLabelSize;
Toshihiro Shimizu 890ddd
	m_rightMargin += labelSize + MARGIN_OFFSET;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_rightLabel->setText(text);
Toshihiro Shimizu 890ddd
	update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::setLabelsEnabled(bool enable)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (!enable) {
Toshihiro Shimizu 890ddd
		m_rightLabel->hide();
Toshihiro Shimizu 890ddd
		m_leftLabel->hide();
Toshihiro Shimizu 890ddd
	} else {
Toshihiro Shimizu 890ddd
		m_rightLabel->show();
Toshihiro Shimizu 890ddd
		m_leftLabel->show();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::setValue(double value)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	value = tcrop(value, m_minValue, m_maxValue);
Toshihiro Shimizu 890ddd
	value = tround(value * 10000) * 0.0001;
Toshihiro Shimizu 890ddd
	if (m_grabIndex == 0) //Left grab
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_values.first = value;
Toshihiro Shimizu 890ddd
		m_leftLineEdit->setValue(m_values.first);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (value > m_values.second) {
Toshihiro Shimizu 890ddd
			m_values.second = value;
Toshihiro Shimizu 890ddd
			m_rightLineEdit->setValue(m_values.second);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} else //Right grab
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		m_values.second = value;
Toshihiro Shimizu 890ddd
		m_rightLineEdit->setValue(m_values.second);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		if (value < m_values.first) {
Toshihiro Shimizu 890ddd
			m_values.first = value;
Toshihiro Shimizu 890ddd
			m_leftLineEdit->setValue(m_values.first);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::setValues(const std::pair<double, double=""> &values)</double,>
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	assert(values.first <= values.second);
Toshihiro Shimizu 890ddd
	m_values.first = tcrop(values.first, m_minValue, m_maxValue);
Toshihiro Shimizu 890ddd
	m_leftLineEdit->setValue(m_values.first);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_values.second = values.second;
Toshihiro Shimizu 890ddd
	if (m_isMaxRangeLimited)
Toshihiro Shimizu 890ddd
		m_values.second = tcrop(values.second, m_values.first, m_maxValue);
Toshihiro Shimizu 890ddd
	m_rightLineEdit->setValue(m_values.second);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::setRange(double minValue, double maxValue)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_minValue = minValue;
Toshihiro Shimizu 890ddd
	m_maxValue = maxValue;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (!m_isMaxRangeLimited)
Toshihiro Shimizu 890ddd
		maxValue = (std::numeric_limits<int>::max)();</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	m_leftLineEdit->setRange(minValue, maxValue);
Toshihiro Shimizu 890ddd
	m_rightLineEdit->setRange(minValue, maxValue);
Toshihiro Shimizu 890ddd
	update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::getRange(double &minValue, double &maxValue)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	minValue = m_minValue;
Toshihiro Shimizu 890ddd
	maxValue = m_maxValue;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::mousePressEvent(QMouseEvent *event)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (event->button() == Qt::LeftButton) {
Toshihiro Shimizu 890ddd
		int x = event->pos().x();
Toshihiro Shimizu 890ddd
		int cur0, cur1;
Toshihiro Shimizu 890ddd
		if (m_values.first > m_maxValue)
Toshihiro Shimizu 890ddd
			cur0 = value2pos(m_maxValue) - 5;
Toshihiro Shimizu 890ddd
		else
Toshihiro Shimizu 890ddd
			cur0 = value2pos(m_values.first);
Toshihiro Shimizu 890ddd
		if (m_values.second > m_maxValue)
Toshihiro Shimizu 890ddd
			cur1 = value2pos(m_maxValue);
Toshihiro Shimizu 890ddd
		else
Toshihiro Shimizu 890ddd
			cur1 = value2pos(m_values.second);
Toshihiro Shimizu 890ddd
		int d0 = abs(cur0 - x);
Toshihiro Shimizu 890ddd
		int d1 = abs(cur1 - x);
Toshihiro Shimizu 890ddd
		int d, cur;
Toshihiro Shimizu 890ddd
		if (d0 < d1 || (d0 == d1 && x < cur0)) {
Toshihiro Shimizu 890ddd
			d = abs(d0);
Toshihiro Shimizu 890ddd
			cur = cur0;
Toshihiro Shimizu 890ddd
			m_grabIndex = 0;
Toshihiro Shimizu 890ddd
		} else {
Toshihiro Shimizu 890ddd
			d = abs(d1);
Toshihiro Shimizu 890ddd
			cur = cur1;
Toshihiro Shimizu 890ddd
			m_grabIndex = 1;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		if (d < 6)
Toshihiro Shimizu 890ddd
			m_grabOffset = cur - x;
Toshihiro Shimizu 890ddd
		else {
Toshihiro Shimizu 890ddd
			m_grabOffset = 0;
Toshihiro Shimizu 890ddd
			setValue(pos2value(x));
Toshihiro Shimizu 890ddd
			emit valuesChanged(true);
Toshihiro Shimizu 890ddd
			update();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::mouseMoveEvent(QMouseEvent *event)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (event->buttons()) {
Toshihiro Shimizu 890ddd
		std::pair<double, double=""> oldValues = m_values;</double,>
Toshihiro Shimizu 890ddd
		int x = event->pos().x() + m_grabOffset;
Toshihiro Shimizu 890ddd
		setValue(pos2value(x));
Toshihiro Shimizu 890ddd
		if (oldValues != m_values) {
Toshihiro Shimizu 890ddd
			emit valuesChanged(true);
Toshihiro Shimizu 890ddd
			update();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::mouseReleaseEvent(QMouseEvent *event)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_grabOffset = 0;
Toshihiro Shimizu 890ddd
	m_grabIndex = 0;
Toshihiro Shimizu 890ddd
	emit valuesChanged(false);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::onLeftEditingFinished()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	double value = m_leftLineEdit->getValue();
Toshihiro Shimizu 890ddd
	if (value == m_values.first)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	if (!m_isMaxRangeLimited && value < m_minValue)
Toshihiro Shimizu 890ddd
		value = m_minValue;
Toshihiro Shimizu 890ddd
	else if (m_isMaxRangeLimited)
Toshihiro Shimizu 890ddd
		value = tcrop(value, m_minValue, m_maxValue);
Toshihiro Shimizu 890ddd
	m_values.first = value;
Toshihiro Shimizu 890ddd
	if (m_values.first > m_values.second) {
Toshihiro Shimizu 890ddd
		m_values.second = m_values.first;
Toshihiro Shimizu 890ddd
		m_rightLineEdit->setValue(m_values.second);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	emit valuesChanged(false);
Toshihiro Shimizu 890ddd
	update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DoubleValuePairField::onRightEditingFinished()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	double value = m_rightLineEdit->getValue();
Toshihiro Shimizu 890ddd
	if (value == m_values.second)
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	if (m_isMaxRangeLimited)
Toshihiro Shimizu 890ddd
		value = tcrop(value, m_minValue, m_maxValue);
Toshihiro Shimizu 890ddd
	m_values.second = value;
Toshihiro Shimizu 890ddd
	if (m_values.second < m_values.first) {
Toshihiro Shimizu 890ddd
		m_values.first = m_values.second;
Toshihiro Shimizu 890ddd
		m_leftLineEdit->setValue(m_values.first);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	emit valuesChanged(false);
Toshihiro Shimizu 890ddd
	update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DoublePairField
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DoublePairField::DoublePairField(QWidget *parent, bool isMaxRangeLimited)
Toshihiro Shimizu 890ddd
	: DoubleValuePairField(parent, isMaxRangeLimited, new DoubleLineEdit(0), new DoubleLineEdit(0))
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	DoubleLineEdit *leftLineEdit = dynamic_cast<doublelineedit *="">(m_leftLineEdit);</doublelineedit>
Toshihiro Shimizu 890ddd
	leftLineEdit->setDecimals(2);
Toshihiro Shimizu 890ddd
	DoubleLineEdit *rightLineEdit = dynamic_cast<doublelineedit *="">(m_rightLineEdit);</doublelineedit>
Toshihiro Shimizu 890ddd
	rightLineEdit->setDecimals(2);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// MeasuredDoublePairField
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
MeasuredDoublePairField::MeasuredDoublePairField(QWidget *parent, bool isMaxRangeLimited)
Toshihiro Shimizu 890ddd
	: DoubleValuePairField(parent, isMaxRangeLimited, new MeasuredDoubleLineEdit(0), new MeasuredDoubleLineEdit(0))
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_leftLineEdit->setFixedSize(63, WidgetHeight);
Toshihiro Shimizu 890ddd
	m_rightLineEdit->setFixedSize(63, WidgetHeight);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
void MeasuredDoublePairField::setMeasure(std::string measureName)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	MeasuredDoubleLineEdit *leftLineEdit = dynamic_cast<measureddoublelineedit *="">(m_leftLineEdit);</measureddoublelineedit>
Toshihiro Shimizu 890ddd
	assert(leftLineEdit);
Toshihiro Shimizu 890ddd
	leftLineEdit->setMeasure(measureName);
Toshihiro Shimizu 890ddd
	MeasuredDoubleLineEdit *rightLineEdit = dynamic_cast<measureddoublelineedit *="">(m_rightLineEdit);</measureddoublelineedit>
Toshihiro Shimizu 890ddd
	assert(rightLineEdit);
Toshihiro Shimizu 890ddd
	rightLineEdit->setMeasure(measureName);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*--設定ファイルからインタフェースの精度を変える--*/
Toshihiro Shimizu 890ddd
void MeasuredDoublePairField::setPrecision(int precision)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	MeasuredDoubleLineEdit *leftLineEdit = dynamic_cast<measureddoublelineedit *="">(m_leftLineEdit);</measureddoublelineedit>
Toshihiro Shimizu 890ddd
	if (leftLineEdit)
Toshihiro Shimizu 890ddd
		leftLineEdit->setDecimals(precision);
Toshihiro Shimizu 890ddd
	MeasuredDoubleLineEdit *rightLineEdit = dynamic_cast<measureddoublelineedit *="">(m_rightLineEdit);</measureddoublelineedit>
Toshihiro Shimizu 890ddd
	if (rightLineEdit)
Toshihiro Shimizu 890ddd
		rightLineEdit->setDecimals(precision);
Toshihiro Shimizu 890ddd
}