mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-1474 Fixed a sizing/value calculation issue.
This commit is contained in:
parent
25cf7fcaf5
commit
9d42430ee7
@ -36,8 +36,8 @@
|
||||
#include "mixercurvepoint.h"
|
||||
#include "mixercurvewidget.h"
|
||||
|
||||
MixerNode::MixerNode(MixerCurveWidget *graphWidget)
|
||||
: m_graph(graphWidget)
|
||||
MixerNode::MixerNode(MixerCurveWidget *graphWidget, QGraphicsItem* graphItem)
|
||||
: m_graph(graphWidget), m_graphItem(graphItem)
|
||||
{
|
||||
setFlag(ItemIsMovable);
|
||||
setFlag(ItemSendsGeometryChanges);
|
||||
@ -136,7 +136,7 @@ void MixerNode::verticalMove(bool flag)
|
||||
|
||||
double MixerNode::value()
|
||||
{
|
||||
double h = m_graph->sceneRect().height();
|
||||
double h = m_graphItem->boundingRect().height();
|
||||
double ratio = (h - pos().y()) / h;
|
||||
|
||||
return ((m_graph->getMax() - m_graph->getMin()) * ratio) + m_graph->getMin();
|
||||
@ -146,7 +146,7 @@ double MixerNode::value()
|
||||
QVariant MixerNode::itemChange(GraphicsItemChange change, const QVariant &val)
|
||||
{
|
||||
QPointF newPos = val.toPointF();
|
||||
double h = m_graph->sceneRect().height();
|
||||
double h = m_graphItem->boundingRect().height();
|
||||
|
||||
switch (change) {
|
||||
case ItemPositionChange:
|
||||
|
@ -45,7 +45,7 @@ class UAVOBJECTWIDGETUTILS_EXPORT MixerNode : public QObject, public QGraphicsIt
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
MixerNode(MixerCurveWidget *graphWidget);
|
||||
MixerNode(MixerCurveWidget *graphWidget, QGraphicsItem* graphItem);
|
||||
void addEdge(Edge *edge);
|
||||
QList<Edge *> edges() const;
|
||||
|
||||
@ -103,6 +103,7 @@ private:
|
||||
QList<Edge *> m_edgeList;
|
||||
QPointF m_newPos;
|
||||
MixerCurveWidget *m_graph;
|
||||
QGraphicsItem* m_graphItem;
|
||||
|
||||
qreal m_alpha;
|
||||
QColor m_positiveColor;
|
||||
|
@ -60,7 +60,7 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) :
|
||||
|
||||
setFrameStyle(QFrame::NoFrame);
|
||||
setStyleSheet("background:transparent");
|
||||
|
||||
setRenderHint(QPainter::HighQualityAntialiasing, true);
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
QSvgRenderer *renderer = new QSvgRenderer();
|
||||
m_plot = new QGraphicsSvgItem();
|
||||
@ -149,7 +149,7 @@ void MixerCurveWidget::initNodes(int numPoints)
|
||||
// Create the nodes and edges
|
||||
MixerNode *prevNode = 0;
|
||||
for (int i = 0; i < numPoints; i++) {
|
||||
MixerNode *node = new MixerNode(this);
|
||||
MixerNode *node = new MixerNode(this, m_plot);
|
||||
|
||||
m_nodeList.append(node);
|
||||
scene()->addItem(node);
|
||||
@ -183,7 +183,6 @@ void MixerCurveWidget::setupYAxisLabel()
|
||||
m_yAxisTextItem->setPlainText(m_yAxisString);
|
||||
} else {
|
||||
m_yAxisTextItem = new QGraphicsTextItem(m_yAxisString, m_plot);
|
||||
// m_yAxisTextItem->setTransformOriginPoint(m_yAxisTextItem->boundingRect().height(), m_yAxisTextItem->boundingRect().left());
|
||||
m_yAxisTextItem->setRotation(270);
|
||||
scene()->addItem(m_yAxisTextItem);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user