Ejemplo n.º 1
0
	ResizingView::ResizingView(QGraphicsScene * scene, QWidget * parent):
		QGraphicsView(scene, parent),
		wasResized(false),
		computedScale(1)
	{
		assert(scene);
		connect(scene, SIGNAL(sceneSizeChanged()), SLOT(recomputeScale()));
	}
Ejemplo n.º 2
0
	void ResizingView::recomputeScale()
	{
		//qDebug() << "recompute scale";
		
		disconnect(scene(), SIGNAL(sceneSizeChanged()), this, SLOT(recomputeScale()));
		
		// set transform
		resetTransform();
		const qreal widthScale(0.95*qreal(viewport()->width())/qreal(scene()->width()));
		const qreal heightScale(qreal(viewport()->height()) / qreal(80+410*3));
		computedScale = qMin(widthScale, heightScale);
		scale(computedScale, computedScale);
		
		connect(scene(), SIGNAL(sceneSizeChanged()), this, SLOT(recomputeScale()));
		
		recomputeTimer->stop();
		/*ignoreResize = true;
		ignoreResizeTimer->start();*/
	}
Ejemplo n.º 3
0
	ResizingView::ResizingView(QGraphicsScene * scene, QWidget * parent):
		QGraphicsView(scene, parent),
		computedScale(1)/*,
		ignoreResize(false)*/
	{
		assert(scene);
		recomputeTimer = new QTimer(this);
		//ignoreResizeTimer = new QTimer(this);
		connect(recomputeTimer, SIGNAL(timeout()), SLOT(recomputeScale()));
		//connect(ignoreResizeTimer, SIGNAL(timeout()), SLOT(clearIgnoreResize()));
		connect(scene, SIGNAL(sceneSizeChanged()), recomputeTimer, SLOT(start()));
	}