Esempio n. 1
0
/// Adjusts the underlying grid based on the graphs that are displayed in the diagram
void DiagramScene::constructGrid()
{
	// be very careful with scaling parameters here!
	int numXTicks, numYTicks;
	float xMin = _unscaledBounds.left();
	float yMin = _unscaledBounds.top();
	float xMax = _unscaledBounds.right();
	float yMax = _unscaledBounds.bottom();

	adjustAxis(xMin, xMax, numXTicks);
	adjustAxis(yMin, yMax, numYTicks);

	// adjust boundaries of coordinate system according to scaling
	_bounds.setRect(    xMin * _scaleX,
	                    yMin * _scaleY,
	                    (xMax - xMin) * _scaleX,
	                    (yMax - yMin) * _scaleY
	                    );

	QPen pen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin);
	_grid = addGrid(_bounds, numXTicks, numYTicks, pen);

	if (_startDate == QDateTime())
	{
		for (int i = 0; i <= numXTicks; ++i)
		{
			int x = static_cast<int>(_bounds.left() / _scaleX +
									 (i * (_bounds.width() / _scaleX) / numXTicks));
			_xTicksText.push_back(addNonScalableText(QString::number(x)));
			_xTicksText.last()->setPos(x * _scaleX, _bounds.bottom() + 15);
		}
	}
	else
	{
		for (int i = 0; i <= numXTicks; ++i)
		{
			int x = static_cast<int>(_bounds.left() / _scaleX +
									 (i * (_bounds.width() / _scaleX) / numXTicks));
			QDateTime currentDate = _startDate.addSecs(x);
			_xTicksText.push_back(addNonScalableText(currentDate.toString("dd.MM.yyyy")));
			_xTicksText.last()->setPos(x * _scaleX, _bounds.bottom() + 15);
		}
	}

	for (int j = 0; j <= numYTicks; ++j)
	{
		float y     = _bounds.bottom() / _scaleY -
		              (j * (_bounds.height() / _scaleY) / numYTicks);
		float label = _bounds.top()   / _scaleY +
		              (j * (_bounds.height() / _scaleY) / numYTicks);
		_yTicksText.push_back(addNonScalableText(QString::number(label)));
		_yTicksText.last()->setPos(_bounds.left() - MARGIN / 2, y * _scaleY);
	}
}
Esempio n. 2
0
File: plotter.cpp Progetto: Qmax/PT6
void PlotSettings::adjust()
{
    adjustAxis(minX,maxX,numXTicks);
    adjustAxis(minY,maxY,numYTicks);
}
Esempio n. 3
0
void PlotSettings::adjust()
{
    this->numXTicks= adjustAxis(minX,maxX);
    this->numYTicks = adjustAxis(minY,maxY);
}