You've already forked nodeeditor
mirror of
https://github.com/AxioDL/nodeeditor.git
synced 2026-03-30 11:48:31 -07:00
110 lines
1.7 KiB
C++
110 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <nodes/NodeDataModel>
|
|
|
|
#include <iostream>
|
|
|
|
class ExpressionRangeData;
|
|
|
|
class QWidget;
|
|
class QLineEdit;
|
|
class QSpinBox;
|
|
|
|
using QtNodes::PortType;
|
|
using QtNodes::PortIndex;
|
|
using QtNodes::NodeData;
|
|
using QtNodes::NodeDataType;
|
|
using QtNodes::NodeDataModel;
|
|
using QtNodes::NodeValidationState;
|
|
|
|
class ExpressionConstantModel
|
|
: public NodeDataModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
ExpressionConstantModel();
|
|
|
|
virtual
|
|
~ExpressionConstantModel() {}
|
|
|
|
public:
|
|
|
|
QString
|
|
caption() const override
|
|
{ return QStringLiteral("Expression Constant"); }
|
|
|
|
bool
|
|
captionVisible() const override
|
|
{ return true; }
|
|
|
|
QString
|
|
name() const override
|
|
{ return QStringLiteral("Expression Constant"); }
|
|
|
|
std::unique_ptr<NodeDataModel>
|
|
clone() const override
|
|
{ return std::make_unique<ExpressionConstantModel>(); }
|
|
|
|
public:
|
|
|
|
QJsonObject
|
|
save() const override;
|
|
|
|
void
|
|
restore(QJsonObject const &p) override;
|
|
|
|
public:
|
|
|
|
unsigned int
|
|
nPorts(PortType portType) const override;
|
|
|
|
NodeDataType
|
|
dataType(PortType portType, PortIndex portIndex) const override;
|
|
|
|
std::shared_ptr<NodeData>
|
|
outData(PortIndex port) override;
|
|
|
|
void
|
|
setInData(std::shared_ptr<NodeData>, int) override
|
|
{ }
|
|
|
|
QWidget *
|
|
embeddedWidget() override;
|
|
|
|
private slots:
|
|
|
|
void
|
|
onVariableEdited(QString const &string);
|
|
|
|
void
|
|
onRangeEdited(QString const &string);
|
|
|
|
void
|
|
processData();
|
|
|
|
private:
|
|
|
|
std::vector<double>
|
|
processRangeText(QString const &numberText, int times) const;
|
|
|
|
QString
|
|
convertRangeToText(std::vector<double> const &range) const;
|
|
|
|
private:
|
|
|
|
std::shared_ptr<ExpressionRangeData> _expression;
|
|
|
|
QWidget * _widget;
|
|
|
|
QLineEdit * _variableEdit;
|
|
|
|
QLineEdit * _numberEdit;
|
|
|
|
QSpinBox * _spinBox;
|
|
|
|
QLineEdit * _rangeEdit;
|
|
};
|