#include "SUIT_ResourceMgr.h"
#include "SUIT_Session.h"
-#include <iostream>
+
//=======================================================================
// Name : GraphicsView_ViewPort
// Purpose : Constructor
void GraphicsView_ViewPort::fitAll()
{
+ scene()->setSceneRect(scene()->itemsBoundingRect());
QRectF aRect = scene()->sceneRect();
-/*
- QGraphicsRectItem *sceneRectItem = new QGraphicsRectItem(aRect);
- sceneRectItem->setPen(QPen(QColor("blue"),4));
- addItem(sceneRectItem);
-*/
fitInView( aRect.adjusted(-myFitAllGap, -myFitAllGap, myFitAllGap, myFitAllGap), Qt::KeepAspectRatio);
}
void GraphicsView_ViewPort::resizeEvent(QResizeEvent *event)
{
- QGraphicsView::resizeEvent(event);
+ QSize oldSize = event->oldSize();
+ QSize newSize = event->size();
+
+ qreal w = static_cast<qreal>(newSize.width());
+ qreal h = static_cast<qreal>(newSize.height());
+
+ qreal w0 = static_cast<qreal>(oldSize.width());
+ qreal h0 = static_cast<qreal>(oldSize.height());
+
+ qreal widthRatio = w/w0;
+ qreal heightRatio = h/h0;
+
+
+
+ if (widthRatio>0 && heightRatio>0)
+ {
+ qreal scaleFactor = w<h ? widthRatio : heightRatio;
+ scale(scaleFactor, scaleFactor);
+ }
+
+ QGraphicsView::resizeEvent(event);
}
void GraphicsView_ViewPort::wheelEvent(QWheelEvent *event)