git-svn-id: svn://db.shs.com.ru/libs@506 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-03-03 15:45:57 +00:00
parent 89ed188370
commit dba3fbf1f1
3 changed files with 33 additions and 11 deletions

View File

@@ -315,6 +315,9 @@
</item> </item>
<item> <item>
<widget class="BlockView" name="blockView"> <widget class="BlockView" name="blockView">
<property name="navigateAnimationEnabled">
<bool>true</bool>
</property>
<property name="miniMap" stdset="0"> <property name="miniMap" stdset="0">
<bool>false</bool> <bool>false</bool>
</property> </property>

View File

@@ -46,7 +46,7 @@ void BlockView::_init() {
cur_scl = thumb_scl = prev_app_scale = 1.; cur_scl = thumb_scl = prev_app_scale = 1.;
_talpha = 0.; _talpha = 0.;
ae_enabled = is_block_anim = true; ae_enabled = is_block_anim = true;
is_nav_anim = false; is_nav_anim = true;
nav_prev_aa = nav_prev_imaa = nav_prev_grid = true; nav_prev_aa = nav_prev_imaa = nav_prev_grid = true;
thumb_size = QSizeF(200, 200); thumb_size = QSizeF(200, 200);
if (scene() == 0) { if (scene() == 0) {
@@ -667,7 +667,8 @@ void BlockView::wheelEvent(QWheelEvent * e) {
//r.setHeight(r.height() * scl); //r.setHeight(r.height() * scl);
r.setHeight(r.width() * vh / vw); r.setHeight(r.width() * vh / vw);
r.translate(cx * (pw - r.width()), cy * (ph - r.height())); r.translate(cx * (pw - r.width()), cy * (ph - r.height()));
animateNav(r); animateNav(r, scl);
//_setNav(r);
return; return;
} }
if (!wheel_zoom) QGraphicsView::wheelEvent(e); if (!wheel_zoom) QGraphicsView::wheelEvent(e);
@@ -1620,26 +1621,31 @@ QList<QGraphicsItem * > BlockView::selectedDecors() const {
} }
QRectF BlockView::_nav() const { void BlockView::animateNav(QRectF d, double scl) {
return mapToScene(viewport()->rect()).boundingRect();
}
void BlockView::animateNav(QRectF d) {
nav_target = d; nav_target = d;
if (is_nav_anim) { if (is_nav_anim) {
if (anim_el.elapsed() < 10 || (qAbs<double>(scl - 1.) <= 0.1)) {
if (nav_anim.state() == QAbstractAnimation::Running) {
nav_anim.stop();
_navFinished();
}
_setNav(d);
anim_el.restart();
return;
}
if (nav_anim.state() != QAbstractAnimation::Running) { if (nav_anim.state() != QAbstractAnimation::Running) {
nav_prev_aa = renderHints().testFlag(QPainter::Antialiasing); nav_prev_aa = renderHints().testFlag(QPainter::Antialiasing);
nav_prev_imaa = renderHints().testFlag(QPainter::SmoothPixmapTransform); nav_prev_imaa = renderHints().testFlag(QPainter::SmoothPixmapTransform);
nav_prev_grid = isGridVisible(); nav_prev_grid = isGridVisible();
setRenderHint(QPainter::Antialiasing, false); setRenderHint(QPainter::Antialiasing, false);
setRenderHint(QPainter::Antialiasing, false); setRenderHint(QPainter::SmoothPixmapTransform, false);
setGridVisible(false); setGridVisible(false);
} }
nav_anim.stop(); nav_anim.stop();
nav_anim.setStartValue(_nav()); nav_anim.setStartValue(_nav());
nav_anim.setEndValue(d); nav_anim.setEndValue(d);
nav_anim.start(); nav_anim.start();
anim_el.restart();
} else } else
_setNav(d); _setNav(d);
} }
@@ -1815,7 +1821,19 @@ void BlockView::_setThumb(double v) {
void BlockView::_setNav(QRectF v) { void BlockView::_setNav(QRectF v) {
QGraphicsView::fitInView(v); //QGraphicsView::fitInView(v);
double vw = viewport()->width(), vh = viewport()->height();
if (vw < 1. || vh < 1. || v.isEmpty()) return;
QTransform matrix;
double scl = qMin(vw / v.width(), vh / v.height());
matrix.scale(scl, scl);
QGraphicsView::setTransform(matrix);
QGraphicsView::centerOn(v.center());
}
QRectF BlockView::_nav() const {
return mapToScene(viewport()->rect()).boundingRect();
} }

View File

@@ -153,7 +153,7 @@ protected:
void hideTmpBuses(bool clear = true); void hideTmpBuses(bool clear = true);
double _thumb() const {return _talpha;} double _thumb() const {return _talpha;}
QRectF _nav() const; QRectF _nav() const;
void animateNav(QRectF d); void animateNav(QRectF d, double scl = 0.);
void scrollFromThumb(); void scrollFromThumb();
void deleteCopyTemp(); void deleteCopyTemp();
void emitActionEvent(BlockItemBase::Action action, QList<QGraphicsItem * > items); void emitActionEvent(BlockItemBase::Action action, QList<QGraphicsItem * > items);
@@ -188,6 +188,7 @@ protected:
QWidget widget_thumb; QWidget widget_thumb;
Qt::KeyboardModifiers mm_mods; Qt::KeyboardModifiers mm_mods;
QPropertyAnimation thumb_anim, nav_anim; QPropertyAnimation thumb_anim, nav_anim;
QTime anim_el;
int timer_thumb, thumb_hide_delay, thick; int timer_thumb, thumb_hide_delay, thick;
bool mm_drag, new_bus, new_branch, moved, mm_cancel, iconnect, mm_copy, mm_thumb, ae_enabled, is_nav_anim, is_block_anim, move_bus_point; bool mm_drag, new_bus, new_branch, moved, mm_cancel, iconnect, mm_copy, mm_thumb, ae_enabled, is_nav_anim, is_block_anim, move_bus_point;
bool grid_visible, grid_snap, pm_connect, navigation, m_connect, m_trace_with_buses, m_pin_mc, minimap, prev_tcb, wheel_zoom; bool grid_visible, grid_snap, pm_connect, navigation, m_connect, m_trace_with_buses, m_pin_mc, minimap, prev_tcb, wheel_zoom;