1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

MixerCurve, add support for node background image.

This commit is contained in:
Mike LaBranche 2012-07-13 16:34:29 -07:00
parent d2c99fefaf
commit cb66f5000a
3 changed files with 65 additions and 12 deletions

View File

@ -46,7 +46,7 @@ Node::Node(MixerCurveWidget *graphWidget)
cmdActive = false;
vertical = false;
cmdNode = false;
cmdToggle = true;
cmdToggle = true;
posColor0 = "#1c870b"; //greenish?
posColor1 = "#116703"; //greenish?
@ -109,6 +109,8 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
painter->setBrush(gradient);
painter->setPen(QPen(Qt::black, 0));
painter->drawEllipse(boundingRect());
if (!image.isNull())
painter->drawImage(boundingRect().adjusted(1,1,-1,-1), image);
painter->setPen(QPen(Qt::white, 0));
if (cmdNode) {

View File

@ -65,6 +65,7 @@ public:
void setPositiveColor(QString color0 = "#00ff00", QString color1 = "#00ff00") { posColor0 = color0; posColor1 = color1; }
void setNegativeColor(QString color0 = "#ff0000", QString color1 = "#ff0000") { negColor0 = color0; negColor1 = color1; }
void setImage(QImage img) { image = img; }
QRectF boundingRect() const;
QPainterPath shape() const;
@ -89,6 +90,7 @@ private:
QString posColor1;
QString negColor0;
QString negColor1;
QImage image;
bool vertical;
QString cmdName;

View File

@ -92,35 +92,56 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
node = getCommandNode(1);
node->setName("Linear");
node->setToolTip("Generate a Linear Curve");
node->commandText("/");
QImage img = QImage(":/core/images/curve_linear.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("/");
scene->addItem(node);
// log
node = getCommandNode(2);
node->setName("Log");
node->setToolTip("Generate a Logarithmic Curve");
node->commandText("(");
img = QImage(":/core/images/curve_log.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("(");
scene->addItem(node);
// exp
node = getCommandNode(3);
node->setName("Exp");
node->setToolTip("Generate an Exponential Curve");
node->commandText(")");
img = QImage(":/core/images/curve_exp.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText(")");
scene->addItem(node);
// flat
node = getCommandNode(4);
node->setName("Flat");
node->setToolTip("Generate a Flat Curve");
node->commandText("--");
img = QImage(":/core/images/curve_flat.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("--");
scene->addItem(node);
// step
node = getCommandNode(5);
node->setName("Step");
node->setToolTip("Generate a Stepped Curve");
node->commandText("z");
img = QImage(":/core/images/curve_step.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("z");
scene->addItem(node);
@ -128,55 +149,83 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
node = getCommandNode(6);
node->setName("MinPlus");
node->setToolTip("Increase Curve Minimum");
img = QImage(":/core/images/curve_plus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("+");
node->setToggle(false);
node->setPositiveColor("#00aa00", "#00aa00"); //green
node->setNegativeColor("#00aa00", "#00aa00");
node->commandText("+");
scene->addItem(node);
node = getCommandNode(7);
node->setName("MinMinus");
node->setToolTip("Decrease Curve Minimum");
img = QImage(":/core/images/curve_minus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("-");
node->setToggle(false);
node->setPositiveColor("#aa0000", "#aa0000"); //red
node->setNegativeColor("#aa0000", "#aa0000");
node->commandText("-");
scene->addItem(node);
node = getCommandNode(8);
node->setName("MaxPlus");
node->setToolTip("Increase Curve Maximum");
img = QImage(":/core/images/curve_plus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("+");
node->setToggle(false);
node->setPositiveColor("#00aa00", "#00aa00"); //green
node->setNegativeColor("#00aa00", "#00aa00");
node->commandText("+");
scene->addItem(node);
node = getCommandNode(9);
node->setName("MaxMinus");
node->setToolTip("Decrease Curve Maximum");
img = QImage(":/core/images/curve_plus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("-");
node->setToggle(false);
node->setPositiveColor("#aa0000", "#aa0000"); //red
node->setNegativeColor("#aa0000", "#aa0000");
node->commandText("-");
scene->addItem(node);
node = getCommandNode(10);
node->setName("StepPlus");
node->setToolTip("Increase Step/Power Value");
img = QImage(":/core/images/curve_plus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("+");
node->setToggle(false);
node->setPositiveColor("#00aa00", "#00aa00"); //green
node->setNegativeColor("#00aa00", "#00aa00");
node->commandText("+");
scene->addItem(node);
node = getCommandNode(11);
node->setName("StepMinus");
node->setToolTip("Decrease Step/Power Value");
img = QImage(":/core/images/curve_minus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("-");
node->setToggle(false);
node->setPositiveColor("#aa0000", "#aa0000"); //red
node->setNegativeColor("#aa0000", "#aa0000");
node->commandText("-");
scene->addItem(node);
node = getCommandNode(12);