Summary: | child view object placement seems to use stale parent geometry info | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Netterfield <netterfield> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | VHI | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Netterfield
2006-01-31 06:41:45 UTC
I had noticed this as well. It seems to be due entirely to axis alignment. The axis alignment changes the plot region in the plot draw code (in paint()) after we've finished resizing all the children. On a move, they finally catch up to the parent because axis alignment doesn't change. updateSelf() should do the axis alignment. This needs to be fixed (at least cosmetically) for 1.2. The following is most likely the same bug: Start Kst Switch to Childframe MDI mode In the default window creates two plots Create a rectangle contained completely by one the plots Maximize the window The rectangle is drawn incorrectly This seems to be related to the new paint code, as it did not happen prior to the recent changes. SVN commit 505359 by arwalker: BUG:121082 Restrict lines and arrows to their parent - consistent with other view objects. M +80 -29 ksttoplevelview.cpp M +1 -0 ksttoplevelview.h --- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #505358:505359 @@ -37,6 +37,7 @@ #include "kstaccessibility.h" #include "kstdoc.h" #include "kstgfxmousehandler.h" +#include "kstmath.h" #include "kstplotgroup.h" #include "kstsettings.h" #include "ksttimers.h" @@ -780,12 +781,80 @@ } +QPoint KstTopLevelView::handlePoint(bool shift, const QPoint& ptFixed, const QPoint& pos, double aspect) { + QPoint ptMoved = pos; + + if (shift) { + double absAspect = fabs(aspect); + if (absAspect < 500.0 && (double(abs((pos.y() - ptFixed.y())/(pos.x() - ptFixed.x()))) < aspect || + absAspect < 0.1)) { + ptMoved = QPoint(pos.x(), ptFixed.y() + int(aspect*(pos.x() - ptFixed.x()))); + } else { + ptMoved = QPoint(ptFixed.x() + int((pos.y() - ptFixed.y())/aspect), pos.y()); + } + } + + // + // ensure that the point we just moved is contained by its parent... + // + QRect parentRect = _pressTarget->_parent->_geom; + if (parentRect.contains(ptFixed) && !parentRect.contains(ptMoved)) { + double gradient; + bool found = false; + int x; + int y; + + if (!found && ptMoved.x() < parentRect.left()) { + gradient = double(ptMoved.y() - ptFixed.y())/double(ptMoved.x() - ptFixed.x()); + x = parentRect.left(); + y = ptFixed.y() + d2i(double(x - ptFixed.x()) * gradient); + if (y >= parentRect.top() && y <= parentRect.bottom()) { + found = true; + } + } + if (!found && ptMoved.x() > parentRect.right()) { + gradient = double(ptMoved.y() - ptFixed.y())/double(ptMoved.x() - ptFixed.x()); + x = parentRect.right(); + y = ptFixed.y() + d2i(double(x - ptFixed.x()) * gradient); + if (y >= parentRect.top() && y <= parentRect.bottom()) { + found = true; + } + } + if (!found && ptMoved.y() < parentRect.top()) { + gradient = double(ptMoved.x() - ptFixed.x())/double(ptMoved.y() - ptFixed.y()); + y = parentRect.top(); + x = ptFixed.x() + d2i(double(y - ptFixed.y()) * gradient); + if (x >= parentRect.left() && x <= parentRect.right()) { + found = true; + } + } + if (!found && ptMoved.y() > parentRect.bottom()) { + gradient = double(ptMoved.x() - ptFixed.x())/double(ptMoved.y() - ptFixed.y()); + y = parentRect.bottom(); + x = ptFixed.x() + d2i(double(y - ptFixed.y()) * gradient); + if (x >= parentRect.left() && x <= parentRect.right()) { + found = true; + } + } + + if (found) { + ptMoved.setX(x); + ptMoved.setY(y); + } + } + + return ptMoved; +} + + void KstTopLevelView::pressMoveLayoutModeEndPoint(const QPoint& pos, bool shift) { // FIXME: remove this!! Should not know about any specific type // for now we only know how to deal with lines if (KstViewLinePtr line = kst_cast<KstViewLine>(_pressTarget)) { const QRect old(_prevBand); + QPoint ptFixed; double aspect; + if (line->to().x() != line->from().x()) { aspect = double(line->to().y() - line->from().y()) / double(line->to().x() - line->from().x()); } else { @@ -795,40 +864,22 @@ aspect = 1.0E300; } } - QPoint fromPoint, toPoint; + if (_pressDirection & UP) { - // UP means we are on the start endpoint - toPoint = line->to(); - if (shift) { - double absAspect = fabs(aspect); - if (absAspect < 500 && (double(abs((pos.y() - toPoint.y())/(pos.x() - toPoint.x()))) < aspect || absAspect < 0.1)) { - fromPoint = QPoint(pos.x(), toPoint.y() + int(aspect*(pos.x() - toPoint.x()))); - } else { - fromPoint = QPoint(toPoint.x() + int((pos.y() - toPoint.y())/aspect), pos.y()); - } - } else { - fromPoint = pos; - } + // UP means we are on the "from" point + ptFixed = line->to(); + _prevBand.setTopLeft(handlePoint(shift, ptFixed, pos, aspect)); + _prevBand.setBottomRight(ptFixed); } else if (_pressDirection & DOWN) { - // DOWN means we are on the end endpoint - fromPoint = line->from(); - if (shift) { - double absAspect = fabs(aspect); - if (absAspect < 500 && (double(abs((pos.y() - toPoint.y())/(pos.x() - toPoint.x()))) < aspect || absAspect < 0.1)) { - toPoint = QPoint(pos.x(), fromPoint.y() + int(aspect*(pos.x() - fromPoint.x()))); - } else { - toPoint = QPoint(fromPoint.x() + int((pos.y() - fromPoint.y())/aspect), pos.y()); - } - } else { - toPoint = pos; - } + // DOWN means we are on the "to" point + ptFixed = line->from(); + _prevBand.setTopLeft(ptFixed); + _prevBand.setBottomRight(handlePoint(shift, ptFixed, pos, aspect)); } else { - abort(); + assert(false); + return; } - _prevBand.setTopLeft(fromPoint); - _prevBand.setBottomRight(toPoint); - if (old != _prevBand) { KstPainter p; p.begin(_w); --- trunk/extragear/graphics/kst/kst/ksttoplevelview.h #505358:505359 @@ -98,6 +98,7 @@ void pressMove(const QPoint& pos, bool shift = false); void pressMoveLayoutMode(const QPoint& pos, bool shift = false); // helpers for pressMoveLayoutMode + QPoint handlePoint(bool shift, const QPoint& ptFixed, const QPoint& pos, double aspect); void pressMoveLayoutModeMove(const QPoint& pos, bool shift = false); void pressMoveLayoutModeResize(const QPoint& pos, bool shift = false); void pressMoveLayoutModeSelect(const QPoint& pos, bool shift = false); Sorry, wrong bug number. 1.2.0 showstopper On Friday 03 February 2006 13:39, Andrew Walker wrote:
> This seems to be related to the new paint code, as it did not
> happen prior to the recent changes.
No, it's not related to the new paint code. It's due to the change that
makes view objects adjust relative to the contentsRect instead of the
geometry. This is the desired behavior, but Kst2DPlot is messy and it's hard
to get it right.
SVN commit 507745 by staikos: Objects are adjusted relative to the contents rect, not the parent geometry. BUG: 121082 M +20 -49 kst2dplot.cpp M +0 -1 kst2dplot.h M +3 -3 kstviewlabel.cpp M +3 -2 kstviewlegend.cpp M +26 -10 kstviewobject.cpp |