[Kst] extragear/graphics/kst/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Fri Feb 3 22:02:37 CET 2006
SVN commit 505429 by netterfield:
Revert patch.
M +29 -80 ksttoplevelview.cpp
M +0 -1 ksttoplevelview.h
--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #505428:505429
@@ -37,7 +37,6 @@
#include "kstaccessibility.h"
#include "kstdoc.h"
#include "kstgfxmousehandler.h"
-#include "kstmath.h"
#include "kstplotgroup.h"
#include "kstsettings.h"
#include "ksttimers.h"
@@ -781,80 +780,12 @@
}
-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 {
@@ -864,22 +795,40 @@
aspect = 1.0E300;
}
}
-
+ QPoint fromPoint, toPoint;
if (_pressDirection & UP) {
- // UP means we are on the "from" point
- ptFixed = line->to();
- _prevBand.setTopLeft(handlePoint(shift, ptFixed, pos, aspect));
- _prevBand.setBottomRight(ptFixed);
+ // 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;
+ }
} else if (_pressDirection & DOWN) {
- // DOWN means we are on the "to" point
- ptFixed = line->from();
- _prevBand.setTopLeft(ptFixed);
- _prevBand.setBottomRight(handlePoint(shift, ptFixed, pos, aspect));
+ // 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;
+ }
} else {
- assert(false);
- return;
+ abort();
}
+ _prevBand.setTopLeft(fromPoint);
+ _prevBand.setBottomRight(toPoint);
+
if (old != _prevBand) {
KstPainter p;
p.begin(_w);
--- trunk/extragear/graphics/kst/kst/ksttoplevelview.h #505428:505429
@@ -98,7 +98,6 @@
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);
More information about the Kst
mailing list