[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice
From: Thomas Zander <zander () kde ! org>
Date: 2007-02-28 14:19:35
Message-ID: 1172672375.772899.2774.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 638000 by zander:
Make the connection use the actual connection point.
M +30 -5 libs/flake/KoShapeConnection.cpp
M +1 -4 libs/flake/KoShapeConnection.h
M +10 -6 plugins/defaultTools/ConnectionTool.cpp
M +2 -2 plugins/defaultTools/ConnectionTool.h
--- trunk/koffice/libs/flake/KoShapeConnection.cpp #637999:638000
@@ -26,19 +26,33 @@
class KoShapeConnection::Private {
public:
- Private(KoShape *from, KoShape *to) : shape1(from), shape2(to) {}
+ Private(KoShape *from, int gp1, KoShape *to, int gp2)
+ : shape1(from),
+ shape2(to),
+ gluePointIndex1(gp1),
+ gluePointIndex2(gp2)
+ {
+ Q_ASSERT(shape1->connectors().count() > gp1);
+ Q_ASSERT(shape2 && shape2->connectors().count() > gp2);
+ point1 = shape1->connectors()[gp1];
+ if(shape2)
+ point2 = shape1->connectors()[gp2];
+ }
+
KoShape * const shape1;
KoShape * const shape2;
QPointF point1, point2;
+ int gluePointIndex1;
+ int gluePointIndex2;
/*
Properties like ConnectionType
*/
};
-KoShapeConnection::KoShapeConnection(KoShape *from, KoShape *to)
- : d(new Private(from, to))
+KoShapeConnection::KoShapeConnection(KoShape *from, int gp1, KoShape *to, int gp2)
+ : d(new Private(from, gp1, to, gp2))
{
d->shape1->addConnection(this);
d->shape2->addConnection(this);
@@ -51,8 +65,19 @@
}
void KoShapeConnection::paint(QPainter &painter, const KoViewConverter &converter) {
- QPointF a = converter.documentToView(d->shape1->absolutePosition());
- QPointF b = converter.documentToView(d->shape2->absolutePosition());
+ double x, y;
+ converter.zoom(&x, &y);
+ QMatrix matrix = d->shape1->transformationMatrix(&converter);
+ matrix.scale(x, y);
+ QPointF a = matrix.map(d->point1);
+ QPointF b;
+ if(d->shape2) {
+ matrix = d->shape2->transformationMatrix(&converter);
+ matrix.scale(x, y);
+ b = matrix.map(d->point2);
+ }
+ else
+ b = converter.documentToView(d->point2);
QPen pen(Qt::black);
painter.setPen(pen);
--- trunk/koffice/libs/flake/KoShapeConnection.h #637999:638000
@@ -34,7 +34,7 @@
// etc?
};
- KoShapeConnection(KoShape *from, KoShape *to = 0);
+ KoShapeConnection(KoShape *from, int gluePointIndex1, KoShape *to = 0, int \
gluePointIndex2 = 0); ~KoShapeConnection();
void paint(QPainter &painter, const KoViewConverter &converter);
@@ -53,9 +53,6 @@
This class will have an rtree of all the connectors.
This class will recalculate the perfect path when shapes move/etc.
- ConnectionTool (under koffice/plugins)
- Used to create new connections.
-
Add a strategy for InteractionTool that when it selects a connection it can be \
used to change the properties or delete it.
*/
--- trunk/koffice/plugins/defaultTools/ConnectionTool.cpp #637999:638000
@@ -30,7 +30,8 @@
ConnectionTool::ConnectionTool(KoCanvasBase *canvas)
: KoTool(canvas),
- m_startShape(0)
+ m_startShape(0),
+ m_gluePointIndex(-1)
{
}
@@ -61,19 +62,22 @@
foreach(KoShape *shape, m_canvas->shapeManager()->shapesAt(region)) {
QMatrix matrix = shape->transformationMatrix(0);
+ int index = 0;
foreach(QPointF point, shape->connectors()) {
QPointF p = matrix.map(point);
QPointF distance = m_canvas->viewConverter()->documentToView(p - \
event->point);
if(qAbs(distance.x()) < 10 && qAbs(distance.y()) < 10) { // distance is \
in pixels. if(m_startShape == 0) {
m_startShape = shape;
- m_startPoint = point;
+ m_gluePointIndex = index;
}
else {
- createConnection(m_startShape, m_startPoint, shape, point);
- m_startShape = 0;
+ createConnection(m_startShape, m_gluePointIndex, shape, index);
+ m_gluePointIndex = 0;
}
+ return;
}
+ index++;
}
}
}
@@ -111,9 +115,9 @@
m_startShape = 0;
}
-void ConnectionTool::createConnection(KoShape *shape1, QPointF point1, KoShape \
*shape2, QPointF point2) { +void ConnectionTool::createConnection(KoShape *shape1, \
int gluePointIndex1, KoShape *shape2, int gluePointIndex2) { kDebug() << "create \
Connection!\n";
- KoShapeConnection *connection = new KoShapeConnection(shape1, shape2); // will \
add itself. + new KoShapeConnection(shape1, gluePointIndex1, shape2, \
gluePointIndex2); // will add itself. }
#include "ConnectionTool.moc"
--- trunk/koffice/plugins/defaultTools/ConnectionTool.h #637999:638000
@@ -47,11 +47,11 @@
void deactivate();
private:
- void createConnection(KoShape *shape1, QPointF point1, KoShape *shape2, QPointF \
point2); + void createConnection(KoShape *shape1, int gluePointIndex1, KoShape \
*shape2, int gluePointIndex2);
private:
KoShape *m_startShape;
- QPointF m_startPoint;
+ int m_gluePointIndex;
QList<KoShape*> m_shapesPaintedWithConnections;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic