Commit d1fcda86 authored by ita1024's avatar ita1024

Improve the zoom system

parent 5f61b7fb
......@@ -584,7 +584,7 @@ void canvas_view::notify_open_map() {
return;
}
check_canvas_size();
fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
fit_zoom();
}
void canvas_view::notify_select(const QList<int>& unsel, const QList<int>& sel) {
......@@ -1038,7 +1038,20 @@ void canvas_view::fit_zoom()
}
else
{
fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
if (scene()->items().size())
{
QRectF l_oRect = scene()->items().at(0)->sceneBoundingRect();
foreach (QGraphicsItem *l_o, scene()->items())
{
if (!l_o->isVisible())
{
continue;
}
l_oRect |= l_o->sceneBoundingRect();
}
l_oRect = QRectF(l_oRect.topLeft() - QPointF(PIPAD, PIPAD), l_oRect.bottomRight() + QPointF(PIPAD, PIPAD));
fitInView(l_oRect, Qt::KeepAspectRatio);
}
}
}
......
......@@ -295,6 +295,8 @@ box_view::box_view(QWidget *i_oWidget, sem_mediator *i_oControl) : QGraphicsView
m_oMenu = NULL;
setMouseTracking(true);
setBackgroundBrush(Qt::white);
}
void box_view::init_menu()
......@@ -1462,7 +1464,20 @@ void box_view::fit_zoom()
}
else
{
fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
if (scene()->items().size())
{
QRectF l_oRect = scene()->items().at(0)->sceneBoundingRect();
foreach (QGraphicsItem *l_o, scene()->items())
{
if (!l_o->isVisible())
{
continue;
}
l_oRect |= l_o->sceneBoundingRect();
}
l_oRect = QRectF(l_oRect.topLeft() - QPointF(PIPAD, PIPAD), l_oRect.bottomRight() + QPointF(PIPAD, PIPAD));
fitInView(l_oRect, Qt::KeepAspectRatio);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment