mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-160 Small progress on the widget, points move vertically only now. Next commit will be fully functional.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1685 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
40c9c208cf
commit
be7ff70491
@ -120,6 +120,7 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
|||||||
painter->drawLine(line);
|
painter->drawLine(line);
|
||||||
|
|
||||||
// Draw the arrows
|
// Draw the arrows
|
||||||
|
/*
|
||||||
double angle = ::acos(line.dx() / line.length());
|
double angle = ::acos(line.dx() / line.length());
|
||||||
if (line.dy() >= 0)
|
if (line.dy() >= 0)
|
||||||
angle = TwoPi - angle;
|
angle = TwoPi - angle;
|
||||||
@ -135,5 +136,6 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
|||||||
|
|
||||||
painter->setBrush(Qt::black);
|
painter->setBrush(Qt::black);
|
||||||
painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2);
|
painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2);
|
||||||
painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
|
painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ Node::Node(MixerCurveWidget *graphWidget)
|
|||||||
setFlag(ItemSendsGeometryChanges);
|
setFlag(ItemSendsGeometryChanges);
|
||||||
setCacheMode(DeviceCoordinateCache);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
setZValue(-1);
|
setZValue(-1);
|
||||||
|
vertical = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::addEdge(Edge *edge)
|
void Node::addEdge(Edge *edge)
|
||||||
@ -145,9 +146,22 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
|||||||
painter->drawEllipse(-10, -10, 20, 20);
|
painter->drawEllipse(-10, -10, 20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::verticalMove(bool flag){
|
||||||
|
vertical = flag;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
|
QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (change) {
|
switch (change) {
|
||||||
|
case ItemPositionChange: {
|
||||||
|
if (!vertical)
|
||||||
|
break;
|
||||||
|
// Foce node to move vertically
|
||||||
|
QPointF newPos = value.toPointF();
|
||||||
|
newPos.setX(pos().x());
|
||||||
|
return newPos;
|
||||||
|
}
|
||||||
case ItemPositionHasChanged:
|
case ItemPositionHasChanged:
|
||||||
foreach (Edge *edge, edgeList)
|
foreach (Edge *edge, edgeList)
|
||||||
edge->adjust();
|
edge->adjust();
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
enum { Type = UserType + 1 };
|
enum { Type = UserType + 1 };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
|
|
||||||
|
void verticalMove(bool flag);
|
||||||
void calculateForces();
|
void calculateForces();
|
||||||
bool advance();
|
bool advance();
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ private:
|
|||||||
QList<Edge *> edgeList;
|
QList<Edge *> edgeList;
|
||||||
QPointF newPos;
|
QPointF newPos;
|
||||||
MixerCurveWidget *graph;
|
MixerCurveWidget *graph;
|
||||||
|
bool vertical;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MIXERCURVEPOINT_H
|
#endif // MIXERCURVEPOINT_H
|
||||||
|
@ -83,14 +83,19 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
|
|||||||
scene->addItem(new Edge(node3, node4));
|
scene->addItem(new Edge(node3, node4));
|
||||||
scene->addItem(new Edge(node4, node5));
|
scene->addItem(new Edge(node4, node5));
|
||||||
|
|
||||||
qreal w = plot->boundingRect().width()/5;
|
qreal w = plot->boundingRect().width()/4;
|
||||||
|
|
||||||
node1->setPos(w-w/2,50);
|
node1->setPos(0,50);
|
||||||
node2->setPos(2*w-w/2, 50);
|
node2->setPos(w, 50);
|
||||||
node3->setPos(3*w-w/2, 50);
|
node3->setPos(2*w, 50);
|
||||||
node4->setPos(4*w-w/2, 50);
|
node4->setPos(3*w, 50);
|
||||||
node5->setPos(5*w-w/2, 50);
|
node5->setPos(4*w, 50);
|
||||||
|
|
||||||
|
node1->verticalMove(true);
|
||||||
|
node2->verticalMove(true);
|
||||||
|
node3->verticalMove(true);
|
||||||
|
node4->verticalMove(true);
|
||||||
|
node5->verticalMove(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,5 +124,5 @@ void MixerCurveWidget::resizeEvent(QResizeEvent* event)
|
|||||||
|
|
||||||
void MixerCurveWidget::itemMoved()
|
void MixerCurveWidget::itemMoved()
|
||||||
{
|
{
|
||||||
|
qDebug() << "Moved ball";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user