mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 03:08:29 +02:00
more decimal models, added string type and restructured some namespace
This commit is contained in:
parent
77f69f1132
commit
2d8cec3748
55 changed files with 698 additions and 136 deletions
|
@ -25,36 +25,57 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/external)
|
|||
# compile the program
|
||||
add_executable(Atlas_Install
|
||||
source/main.cpp
|
||||
source/Atlas/nodes/decimal/data.cpp
|
||||
include/Atlas/nodes/decimal/data.h
|
||||
|
||||
source/Atlas/nodes/decimal/model/constant.cpp
|
||||
include/Atlas/nodes/decimal/model/constant.h
|
||||
include/Atlas/nodes/node/register.h
|
||||
source/Atlas/nodes/node/register.cpp
|
||||
|
||||
include/Atlas/nodes/common/model/reduce.h
|
||||
source/Atlas/nodes/common/model/reduce.cpp
|
||||
include/Atlas/nodes/node/base/model/reduce.h
|
||||
source/Atlas/nodes/node/base/model/reduce.cpp
|
||||
include/Atlas/nodes/node/base/data.h
|
||||
source/Atlas/nodes/node/base/data.cpp
|
||||
|
||||
include/Atlas/nodes/decimal/model/addition.h
|
||||
source/Atlas/nodes/decimal/model/addition.cpp
|
||||
include/Atlas/nodes/decimal/model/subtraction.h
|
||||
source/Atlas/nodes/decimal/model/subtraction.cpp
|
||||
include/Atlas/nodes/decimal/model/multiplication.h
|
||||
source/Atlas/nodes/decimal/model/multiplication.cpp
|
||||
include/Atlas/nodes/decimal/model/division.h
|
||||
source/Atlas/nodes/decimal/model/division.cpp
|
||||
include/Atlas/nodes/variant/data.h
|
||||
source/Atlas/nodes/variant/data.cpp
|
||||
include/Atlas/nodes/common/data.h
|
||||
source/Atlas/nodes/common/data.cpp
|
||||
include/Atlas/nodes/variant/model/display.h
|
||||
source/Atlas/nodes/variant/model/display.cpp
|
||||
include/Atlas/nodes/variant/model/to_variant.h
|
||||
include/Atlas/nodes/variant/model/from_variant.h
|
||||
source/Atlas/nodes/variant/model/to_variant.cpp
|
||||
source/Atlas/nodes/variant/model/from_variant.cpp
|
||||
source/Atlas/nodes/decimal/model/to_variant.cpp
|
||||
include/Atlas/nodes/decimal/model/to_variant.h
|
||||
source/Atlas/nodes/node/decimal/data.cpp
|
||||
include/Atlas/nodes/node/decimal/data.h
|
||||
source/Atlas/nodes/node/decimal/model/constant.cpp
|
||||
include/Atlas/nodes/node/decimal/model/constant.h
|
||||
include/Atlas/nodes/node/decimal/model/addition.h
|
||||
source/Atlas/nodes/node/decimal/model/addition.cpp
|
||||
include/Atlas/nodes/node/decimal/model/subtraction.h
|
||||
source/Atlas/nodes/node/decimal/model/subtraction.cpp
|
||||
include/Atlas/nodes/node/decimal/model/multiplication.h
|
||||
source/Atlas/nodes/node/decimal/model/multiplication.cpp
|
||||
include/Atlas/nodes/node/decimal/model/division.h
|
||||
source/Atlas/nodes/node/decimal/model/division.cpp
|
||||
source/Atlas/nodes/node/decimal/model/to_variant.cpp
|
||||
include/Atlas/nodes/node/decimal/model/to_variant.h
|
||||
include/Atlas/nodes/node/decimal/model/absolute.h
|
||||
source/Atlas/nodes/node/decimal/model/absolute.cpp
|
||||
include/Atlas/nodes/node/decimal/register.h
|
||||
source/Atlas/nodes/node/decimal/register.cpp
|
||||
|
||||
include/Atlas/nodes/node/variant/data.h
|
||||
source/Atlas/nodes/node/variant/data.cpp
|
||||
include/Atlas/nodes/node/variant/model/display.h
|
||||
source/Atlas/nodes/node/variant/model/display.cpp
|
||||
include/Atlas/nodes/node/variant/model/to_variant.h
|
||||
include/Atlas/nodes/node/variant/model/from_variant.h
|
||||
source/Atlas/nodes/node/variant/model/to_variant.cpp
|
||||
source/Atlas/nodes/node/variant/model/from_variant.cpp
|
||||
source/Atlas/nodes/node/variant/model/to_variant.cpp
|
||||
include/Atlas/nodes/node/variant/model/to_variant.h
|
||||
include/Atlas/nodes/node/variant/model/from_variant.h
|
||||
source/Atlas/nodes/node/variant/model/from_variant.cpp
|
||||
source/Atlas/nodes/node/variant/model/from_variant.cpp
|
||||
source/Atlas/nodes/node/variant/register.cpp
|
||||
include/Atlas/nodes/node/variant/register.h
|
||||
source/Atlas/nodes/node/string/register.cpp
|
||||
source/Atlas/nodes/node/string/data.cpp
|
||||
include/Atlas/nodes/node/string/model/constant.h
|
||||
source/Atlas/nodes/node/string/model/constant.cpp
|
||||
include/utils/string.h
|
||||
source/utils/string.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(Atlas_Install
|
||||
# Qt
|
||||
Qt::Core
|
||||
|
|
2
external/wiimms-szs-tools
vendored
2
external/wiimms-szs-tools
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 336da838ce43edae40dd708dd465f1f43a2c312d
|
||||
Subproject commit a051a6cc397d47a4dee0bac4c67ac31b6e4ab34c
|
19
include/Atlas/nodes/README.md
Normal file
19
include/Atlas/nodes/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Node System Module
|
||||
|
||||
The node system module is an interface allowing you to manipulate nodes on a canvas
|
||||
to assemble a logic that can allow you to describe how to patch a file, a text,
|
||||
an image, etc.
|
||||
|
||||
## Node sub-module
|
||||
|
||||
The directory `node` contains a directory for every type of nodes, plus a `base`
|
||||
directory for special functions and class used by the other type of nodes.
|
||||
|
||||
These type of nodes are:
|
||||
- `decimal`: a node that can be used to manipulate decimal values (`double` in C++).
|
||||
- `variant`: a node that can be used to contains any type of value. Useful to
|
||||
use a function that can use any type of value (example : a print-like function).
|
||||
|
||||
All the directories contains some special files :
|
||||
- `register` file to register all the nodes in the registry.
|
||||
- `data` file containing the implementation of the type itself.
|
|
@ -1,24 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <Atlas/nodes/decimal/data.h>
|
||||
#include <Atlas/nodes/variant/model/to_variant.h>
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
||||
|
||||
namespace Atlas::Nodes::Decimal::Model {
|
||||
|
||||
|
||||
class ToVariant : public Variant::Model::ToVariant<Decimal::Data> {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
[[nodiscard]] QString name() const override;
|
||||
|
||||
[[nodiscard]] QString caption() const override;
|
||||
};
|
||||
|
||||
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <QtNodes/NodeData>
|
||||
#include "QtNodes/NodeData"
|
||||
|
||||
|
||||
namespace Atlas::Nodes::Common {
|
||||
namespace Atlas::Nodes::Base {
|
||||
|
||||
/**
|
||||
* @brief the decimal data type
|
||||
* @details this class is used to store decimal data (double internally)
|
||||
* @brief an abstract data type
|
||||
* @details this class is used to store data
|
||||
*/
|
||||
class Data : public QtNodes::NodeData {
|
||||
public:
|
|
@ -4,7 +4,7 @@
|
|||
#include "QtNodes/NodeDelegateModel"
|
||||
|
||||
|
||||
namespace Atlas::Nodes::Common::Model {
|
||||
namespace Atlas::Nodes::Base::Model {
|
||||
|
||||
|
||||
template<typename DataType>
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "QtNodes/NodeData"
|
||||
#include "Atlas/nodes/common/data.h"
|
||||
#include "Atlas/nodes/node/base/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
@ -13,7 +13,7 @@ namespace Atlas::Nodes::Decimal {
|
|||
* @brief the decimal data type
|
||||
* @details this class is used to store decimal data (double internally)
|
||||
*/
|
||||
class Data : public Common::Data {
|
||||
class Data : public Base::Data {
|
||||
protected:
|
||||
double _value; //< the value of the data
|
||||
|
37
include/Atlas/nodes/node/decimal/model/absolute.h
Normal file
37
include/Atlas/nodes/node/decimal/model/absolute.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "QtNodes/NodeDelegateModel"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
||||
|
||||
namespace Atlas::Nodes::Decimal::Model {
|
||||
|
||||
|
||||
class Absolute : public QtNodes::NodeDelegateModel {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
std::shared_ptr<Decimal::Data> _output; ///< the output
|
||||
|
||||
public:
|
||||
[[nodiscard]] QString name() const override;
|
||||
|
||||
[[nodiscard]] QString caption() const override;
|
||||
|
||||
[[nodiscard]] unsigned int nPorts(QtNodes::PortType portType) const override;
|
||||
|
||||
[[nodiscard]] QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override;
|
||||
|
||||
void setInData(std::shared_ptr<QtNodes::NodeData> nodeData, QtNodes::PortIndex portIndex) override;
|
||||
|
||||
std::shared_ptr<QtNodes::NodeData> outData(QtNodes::PortIndex port) override;
|
||||
|
||||
QWidget *embeddedWidget() override;
|
||||
};
|
||||
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "Atlas/nodes/decimal/data.h"
|
||||
#include "Atlas/nodes/common/model/reduce.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
#include "Atlas/nodes/node/base/model/reduce.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
@ -11,7 +11,7 @@ using namespace Atlas::Nodes;
|
|||
namespace Atlas::Nodes::Decimal::Model {
|
||||
|
||||
|
||||
class Addition : public Common::Model::Reduce<Decimal::Data> {
|
||||
class Addition : public Base::Model::Reduce<Decimal::Data> {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "QtNodes/NodeDelegateModel"
|
||||
#include <QLineEdit>
|
||||
#include "Atlas/nodes/decimal/data.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "Atlas/nodes/decimal/data.h"
|
||||
#include "Atlas/nodes/common/model/reduce.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
#include "Atlas/nodes/node/base/model/reduce.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
@ -11,7 +11,7 @@ using namespace Atlas::Nodes;
|
|||
namespace Atlas::Nodes::Decimal::Model {
|
||||
|
||||
|
||||
class Division : public Common::Model::Reduce<Decimal::Data> {
|
||||
class Division : public Base::Model::Reduce<Decimal::Data> {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "Atlas/nodes/decimal/data.h"
|
||||
#include "Atlas/nodes/common/model/reduce.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
#include "Atlas/nodes/node/base/model/reduce.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
@ -11,7 +11,7 @@ using namespace Atlas::Nodes;
|
|||
namespace Atlas::Nodes::Decimal::Model {
|
||||
|
||||
|
||||
class Multiplication : public Common::Model::Reduce<Decimal::Data> {
|
||||
class Multiplication : public Base::Model::Reduce<Decimal::Data> {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "Atlas/nodes/decimal/data.h"
|
||||
#include "Atlas/nodes/common/model/reduce.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
#include "Atlas/nodes/node/base/model/reduce.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
@ -11,7 +11,7 @@ using namespace Atlas::Nodes;
|
|||
namespace Atlas::Nodes::Decimal::Model {
|
||||
|
||||
|
||||
class Subtraction : public Common::Model::Reduce<Decimal::Data> {
|
||||
class Subtraction : public Base::Model::Reduce<Decimal::Data> {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
21
include/Atlas/nodes/node/decimal/model/to_variant.h
Normal file
21
include/Atlas/nodes/node/decimal/model/to_variant.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "Atlas/nodes/node/variant/model/to_variant.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
||||
|
||||
namespace Atlas::Nodes::Decimal::Model {
|
||||
|
||||
|
||||
class ToVariant : public Variant::Model::ToVariant<Decimal::Data> {
|
||||
public:
|
||||
ToVariant() = default;
|
||||
~ToVariant() override = default;
|
||||
};
|
||||
|
||||
|
||||
}
|
12
include/Atlas/nodes/node/decimal/register.h
Normal file
12
include/Atlas/nodes/node/decimal/register.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include "QtNodes/NodeDelegateModelRegistry"
|
||||
|
||||
|
||||
namespace Atlas::Nodes::Decimal {
|
||||
/// @brief registers all the decimal models
|
||||
/// @param registry the registry to register the models to
|
||||
void register_all(const std::shared_ptr<QtNodes::NodeDelegateModelRegistry>& registry);
|
||||
}
|
12
include/Atlas/nodes/node/register.h
Normal file
12
include/Atlas/nodes/node/register.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include "QtNodes/NodeDelegateModelRegistry"
|
||||
|
||||
|
||||
namespace Atlas::Nodes {
|
||||
/// @brief registers all the models
|
||||
/// @param registry the registry to register the models to
|
||||
void register_all(const std::shared_ptr<QtNodes::NodeDelegateModelRegistry>& registry);
|
||||
}
|
49
include/Atlas/nodes/node/string/data.h
Normal file
49
include/Atlas/nodes/node/string/data.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#pragma once
|
||||
|
||||
#include "QtNodes/NodeData"
|
||||
#include "Atlas/nodes/node/base/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
||||
|
||||
namespace Atlas::Nodes::String {
|
||||
|
||||
/**
|
||||
* @brief the string data type
|
||||
* @details this class is used to store string data (std::string internally)
|
||||
*/
|
||||
class Data : public Base::Data {
|
||||
protected:
|
||||
std::string _value; //< the value of the data
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor
|
||||
* @details Use the default value
|
||||
*/
|
||||
Data();
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param value The value to use
|
||||
*/
|
||||
explicit Data(std::string value);
|
||||
|
||||
/**
|
||||
* @brief Returns the value of the data
|
||||
* @return the value of the data
|
||||
*/
|
||||
[[nodiscard]] std::string value() const;
|
||||
|
||||
/// @copydoc QtNodes::NodeData::type
|
||||
[[nodiscard]] QtNodes::NodeDataType type() const override;
|
||||
|
||||
/**
|
||||
* @brief Returns the representation of the data
|
||||
* @return The representation of the data
|
||||
*/
|
||||
[[nodiscard]] QString text() const override;
|
||||
};
|
||||
|
||||
|
||||
}
|
78
include/Atlas/nodes/node/string/model/constant.h
Normal file
78
include/Atlas/nodes/node/string/model/constant.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "QtNodes/NodeDelegateModel"
|
||||
#include <QLineEdit>
|
||||
#include "Atlas/nodes/node/string/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
||||
|
||||
namespace Atlas::Nodes::String::Model {
|
||||
|
||||
|
||||
class Constant : public QtNodes::NodeDelegateModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Constant();
|
||||
~Constant() override;
|
||||
|
||||
/**
|
||||
* @brief the name of the node
|
||||
* @return the name of the node
|
||||
*/
|
||||
[[nodiscard]] QString name() const override;
|
||||
/**
|
||||
* @brief the caption of the node
|
||||
* @return the caption of the node
|
||||
*/
|
||||
[[nodiscard]] QString caption() const override;
|
||||
|
||||
/**
|
||||
* @brief the number of ports the node has
|
||||
* @param portType the type of the port (input or output)
|
||||
* @return the number of ports the node has
|
||||
*/
|
||||
[[nodiscard]] unsigned int nPorts(QtNodes::PortType portType) const override;
|
||||
/**
|
||||
* @brief the data type of the port
|
||||
* @param portType the type of the port (input or output)
|
||||
* @param portType the index of the port
|
||||
* @return the data type of the port
|
||||
*/
|
||||
[[nodiscard]] QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override;
|
||||
/**
|
||||
* @brief the output data of a port
|
||||
* @param port the index of the port
|
||||
* @return the output data of a port
|
||||
*/
|
||||
std::shared_ptr<QtNodes::NodeData> outData(QtNodes::PortIndex port) override;
|
||||
|
||||
/**
|
||||
* @brief set the input data of a port
|
||||
* @param data the input data
|
||||
* @param portIndex the index of the port
|
||||
*/
|
||||
void setInData(std::shared_ptr<QtNodes::NodeData> data, QtNodes::PortIndex portIndex) override;
|
||||
|
||||
/**
|
||||
* @brief refresh the node
|
||||
* @note this is called when the text in the line edit is changed
|
||||
*/
|
||||
void refresh();
|
||||
|
||||
/**
|
||||
* @brief get the embedded widget
|
||||
* @return the embedded widget
|
||||
*/
|
||||
QWidget *embeddedWidget() override;
|
||||
|
||||
protected:
|
||||
QLineEdit *_lineEdit;
|
||||
std::string _value = "";
|
||||
};
|
||||
|
||||
|
||||
}
|
21
include/Atlas/nodes/node/string/model/to_variant.h
Normal file
21
include/Atlas/nodes/node/string/model/to_variant.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "Atlas/nodes/node/variant/model/to_variant.h"
|
||||
#include "Atlas/nodes/node/string/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
||||
|
||||
namespace Atlas::Nodes::String::Model {
|
||||
|
||||
|
||||
class ToVariant : public Variant::Model::ToVariant<String::Data> {
|
||||
public:
|
||||
ToVariant() = default;
|
||||
~ToVariant() override = default;
|
||||
};
|
||||
|
||||
|
||||
}
|
12
include/Atlas/nodes/node/string/register.h
Normal file
12
include/Atlas/nodes/node/string/register.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include "QtNodes/NodeDelegateModelRegistry"
|
||||
|
||||
|
||||
namespace Atlas::Nodes::String {
|
||||
/// @brief registers all the decimal models
|
||||
/// @param registry the registry to register the models to
|
||||
void register_all(const std::shared_ptr<QtNodes::NodeDelegateModelRegistry>& registry);
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <QtNodes/NodeData>
|
||||
#include "Atlas/nodes/common/data.h"
|
||||
#include "QtNodes/NodeData"
|
||||
#include "Atlas/nodes/node/base/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
@ -15,19 +15,19 @@ namespace Atlas::Nodes::Variant {
|
|||
* @brief the decimal data type
|
||||
* @details this class is used to store decimal data (double internally)
|
||||
*/
|
||||
class Data : public Common::Data {
|
||||
class Data : public Base::Data {
|
||||
protected:
|
||||
std::shared_ptr<Common::Data> _data; //< a reference to a data object
|
||||
std::shared_ptr<Base::Data> _data; //< a reference to a data object
|
||||
|
||||
public:
|
||||
Data();
|
||||
explicit Data(const std::shared_ptr<Common::Data>& data);
|
||||
explicit Data(const std::shared_ptr<Base::Data>& data);
|
||||
|
||||
/**
|
||||
* @brief Returns the value of the data
|
||||
* @return the value of the data
|
||||
*/
|
||||
[[nodiscard]] std::shared_ptr<Common::Data> value() const;
|
||||
[[nodiscard]] std::shared_ptr<Base::Data> value() const;
|
||||
|
||||
/// @copydoc QtNodes::NodeData::type
|
||||
[[nodiscard]] QtNodes::NodeDataType type() const override;
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "Atlas/nodes/variant/data.h"
|
||||
#include "Atlas/nodes/node/variant/data.h"
|
||||
#include "QtNodes/NodeDelegateModel"
|
||||
#include <QLabel>
|
||||
|
46
include/Atlas/nodes/node/variant/model/from_variant.h
Normal file
46
include/Atlas/nodes/node/variant/model/from_variant.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "QtNodes/NodeDelegateModel"
|
||||
#include "Atlas/nodes/node/variant/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
||||
|
||||
namespace Atlas::Nodes::Variant::Model {
|
||||
|
||||
|
||||
class FromVariant : public QtNodes::NodeDelegateModel {
|
||||
private:
|
||||
std::shared_ptr<Variant::Data> _input; ///< the input
|
||||
|
||||
public:
|
||||
FromVariant() = default;
|
||||
~FromVariant() override = default;
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::caption
|
||||
[[nodiscard]] QString caption() const override;
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::name
|
||||
[[nodiscard]] QString name() const override;
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::nPorts
|
||||
[[nodiscard]] unsigned int nPorts(QtNodes::PortType portType) const override;
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::dataType
|
||||
[[nodiscard]] QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override;
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::setInData
|
||||
void setInData(std::shared_ptr<QtNodes::NodeData> data, QtNodes::PortIndex portIndex) override;
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::outData
|
||||
std::shared_ptr<QtNodes::NodeData> outData(QtNodes::PortIndex portIndex) override;
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::embeddedWidget
|
||||
QWidget* embeddedWidget() override;
|
||||
};
|
||||
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
|
||||
#include "QtNodes/NodeDelegateModel"
|
||||
#include <Atlas/nodes/variant/data.h>
|
||||
#include "Atlas/nodes/node/variant/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
||||
|
@ -11,33 +11,47 @@ using namespace Atlas::Nodes;
|
|||
namespace Atlas::Nodes::Variant::Model {
|
||||
|
||||
|
||||
template<typename DataInputType>
|
||||
template<typename NodeInputType>
|
||||
class ToVariant : public QtNodes::NodeDelegateModel {
|
||||
private:
|
||||
std::shared_ptr<DataInputType> _input; ///< the input
|
||||
std::shared_ptr<Variant::Data> _output; ///< the output
|
||||
|
||||
public:
|
||||
ToVariant() = default;
|
||||
~ToVariant() override = default;
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::name
|
||||
QString name() const override {
|
||||
return NodeInputType().type().name + QStringLiteral("::To Variant");
|
||||
}
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::caption
|
||||
QString caption() const override {
|
||||
return NodeInputType().type().name + QStringLiteral(" to Variant");
|
||||
}
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::nPorts
|
||||
[[nodiscard]] unsigned int nPorts(QtNodes::PortType portType) const override {
|
||||
// a "to_variant" function only has one input and one output
|
||||
return 1;
|
||||
// a "to_variant" function only has one input if the output is set and one output
|
||||
return portType == QtNodes::PortType::In ? 1 : 1;
|
||||
}
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::dataType
|
||||
[[nodiscard]] QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override {
|
||||
return portType == QtNodes::PortType::In ? DataInputType().type() : Variant::Data().type();
|
||||
return portType == QtNodes::PortType::In ? NodeInputType().type() : Variant::Data().type();
|
||||
}
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::setInData
|
||||
void setInData(std::shared_ptr<QtNodes::NodeData> data, QtNodes::PortIndex portIndex) override {
|
||||
// convert the data to the correct type
|
||||
std::shared_ptr<DataInputType> casted_data = std::dynamic_pointer_cast<DataInputType>(data);
|
||||
// update the input
|
||||
if (data == nullptr) {
|
||||
// clear the output
|
||||
this->_output = nullptr;
|
||||
} else {
|
||||
// convert the data to the common type
|
||||
std::shared_ptr<Base::Data> casted_data = std::dynamic_pointer_cast<Base::Data>(data);
|
||||
// update the output
|
||||
this->_output = std::make_shared<Variant::Data>(casted_data);
|
||||
}
|
||||
// update the next nodes
|
||||
Q_EMIT dataUpdated(0);
|
||||
}
|
||||
|
@ -45,7 +59,7 @@ namespace Atlas::Nodes::Variant::Model {
|
|||
/// @copydoc QtNodes::NodeDelegateModel::outData
|
||||
std::shared_ptr<QtNodes::NodeData> outData(QtNodes::PortIndex portIndex) override {
|
||||
// return the last computed output
|
||||
return this->_output;
|
||||
return static_cast<const std::shared_ptr<QtNodes::NodeData> &>(this->_output);
|
||||
}
|
||||
|
||||
/// @copydoc QtNodes::NodeDelegateModel::embeddedWidget
|
12
include/Atlas/nodes/node/variant/register.h
Normal file
12
include/Atlas/nodes/node/variant/register.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include "QtNodes/NodeDelegateModelRegistry"
|
||||
|
||||
|
||||
namespace Atlas::Nodes::Variant {
|
||||
/// @brief registers all the variant models
|
||||
/// @param registry the registry to register the models to
|
||||
void register_all(const std::shared_ptr<QtNodes::NodeDelegateModelRegistry>& registry);
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
#pragma once
|
13
include/utils/string.h
Normal file
13
include/utils/string.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Utils::String {
|
||||
/// @brief escapes a string
|
||||
/// @details this function escapes a string so that it look like its c++ representation
|
||||
/// @param str the string to escape
|
||||
/// @return the escaped string
|
||||
std::string escape(const std::string& string);
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
#include <Atlas/nodes/common/data.h>
|
|
@ -1 +0,0 @@
|
|||
#include <Atlas/nodes/common/model/reduce.h>
|
|
@ -1,12 +0,0 @@
|
|||
#include <Atlas/nodes/decimal/model/to_variant.h>
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal::Model;
|
||||
|
||||
|
||||
[[nodiscard]] QString ToVariant::name() const {
|
||||
return QStringLiteral("Decimal to Variant");
|
||||
}
|
||||
[[nodiscard]] QString ToVariant::caption() const {
|
||||
return QStringLiteral("Decimal to Variant");
|
||||
}
|
1
source/Atlas/nodes/node/base/data.cpp
Normal file
1
source/Atlas/nodes/node/base/data.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "Atlas/nodes/node/base/data.h"
|
1
source/Atlas/nodes/node/base/model/reduce.cpp
Normal file
1
source/Atlas/nodes/node/base/model/reduce.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "Atlas/nodes/node/base/model/reduce.h"
|
|
@ -1,4 +1,4 @@
|
|||
#include "Atlas/nodes/decimal/data.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal;
|
41
source/Atlas/nodes/node/decimal/model/absolute.cpp
Normal file
41
source/Atlas/nodes/node/decimal/model/absolute.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <Atlas/nodes/node/decimal/model/absolute.h>
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal::Model;
|
||||
|
||||
|
||||
QString Absolute::name() const {
|
||||
return QStringLiteral("Absolute");
|
||||
}
|
||||
|
||||
QString Absolute::caption() const {
|
||||
return QStringLiteral("Absolute");
|
||||
}
|
||||
|
||||
unsigned int Absolute::nPorts(QtNodes::PortType portType) const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
QtNodes::NodeDataType Absolute::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const {
|
||||
return Decimal::Data().type();
|
||||
}
|
||||
|
||||
void Absolute::setInData(std::shared_ptr<QtNodes::NodeData> nodeData, const QtNodes::PortIndex portIndex) {
|
||||
if (nodeData == nullptr) {
|
||||
this->_output = nullptr;
|
||||
} else {
|
||||
std::shared_ptr<Decimal::Data> casted_data = std::dynamic_pointer_cast<Decimal::Data>(nodeData);
|
||||
double value = std::abs(casted_data->value());
|
||||
this->_output = std::make_shared<Decimal::Data>(value);
|
||||
}
|
||||
|
||||
Q_EMIT dataUpdated(0);
|
||||
}
|
||||
|
||||
std::shared_ptr<QtNodes::NodeData> Absolute::outData(const QtNodes::PortIndex port) {
|
||||
return this->_output;
|
||||
}
|
||||
|
||||
QWidget *Absolute::embeddedWidget() {
|
||||
return nullptr;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include "Atlas/nodes/decimal/model/addition.h"
|
||||
#include "Atlas/nodes/node/decimal/model/addition.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal::Model;
|
|
@ -1,7 +1,7 @@
|
|||
#include <QtGui>
|
||||
#include <iostream>
|
||||
|
||||
#include "Atlas/nodes/decimal/model/constant.h"
|
||||
#include "Atlas/nodes/node/decimal/model/constant.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal::Model;
|
|
@ -1,4 +1,4 @@
|
|||
#include "Atlas/nodes/decimal/model/division.h"
|
||||
#include "Atlas/nodes/node/decimal/model/division.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal::Model;
|
|
@ -1,4 +1,4 @@
|
|||
#include "Atlas/nodes/decimal/model/multiplication.h"
|
||||
#include "Atlas/nodes/node/decimal/model/multiplication.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal::Model;
|
|
@ -1,4 +1,4 @@
|
|||
#include "Atlas/nodes/decimal/model/subtraction.h"
|
||||
#include "Atlas/nodes/node/decimal/model/subtraction.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal::Model;
|
1
source/Atlas/nodes/node/decimal/model/to_variant.cpp
Normal file
1
source/Atlas/nodes/node/decimal/model/to_variant.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "Atlas/nodes/node/variant/model/to_variant.h"
|
27
source/Atlas/nodes/node/decimal/register.cpp
Normal file
27
source/Atlas/nodes/node/decimal/register.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <Atlas/nodes/node/decimal/register.h>
|
||||
|
||||
|
||||
#include "Atlas/nodes/node/decimal/model/constant.h"
|
||||
#include "Atlas/nodes/node/decimal/model/to_variant.h"
|
||||
#include "Atlas/nodes/node/decimal/model/addition.h"
|
||||
#include "Atlas/nodes/node/decimal/model/subtraction.h"
|
||||
#include "Atlas/nodes/node/decimal/model/multiplication.h"
|
||||
#include "Atlas/nodes/node/decimal/model/division.h"
|
||||
#include "Atlas/nodes/node/decimal/model/absolute.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Decimal;
|
||||
|
||||
|
||||
void Atlas::Nodes::Decimal::register_all(const std::shared_ptr<QtNodes::NodeDelegateModelRegistry>& registry) {
|
||||
QString category = Data().type().name;
|
||||
|
||||
registry->registerModel<Model::Constant>(category);
|
||||
registry->registerModel<Model::ToVariant>(category);
|
||||
registry->registerModel<Model::Addition>(category);
|
||||
registry->registerModel<Model::Subtraction>(category);
|
||||
registry->registerModel<Model::Multiplication>(category);
|
||||
registry->registerModel<Model::Division>(category);
|
||||
registry->registerModel<Model::Absolute>(category);
|
||||
}
|
15
source/Atlas/nodes/node/register.cpp
Normal file
15
source/Atlas/nodes/node/register.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include "Atlas/nodes/node/register.h"
|
||||
|
||||
#include "Atlas/nodes/node/decimal/register.h"
|
||||
#include "Atlas/nodes/node/string/register.h"
|
||||
#include "Atlas/nodes/node/variant/register.h"
|
||||
|
||||
|
||||
using namespace Atlas;
|
||||
|
||||
|
||||
void Atlas::Nodes::register_all(const std::shared_ptr<QtNodes::NodeDelegateModelRegistry>& registry) {
|
||||
Nodes::Decimal::register_all(registry);
|
||||
Nodes::String::register_all(registry);
|
||||
Nodes::Variant::register_all(registry);
|
||||
}
|
22
source/Atlas/nodes/node/string/data.cpp
Normal file
22
source/Atlas/nodes/node/string/data.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "Atlas/nodes/node/string/data.h"
|
||||
#include "utils/string.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::String;
|
||||
|
||||
|
||||
|
||||
Data::Data() : _value("") {}
|
||||
Data::Data(std::string value) : _value(value) {}
|
||||
|
||||
[[nodiscard]] std::string Data::value() const {
|
||||
return this->_value;
|
||||
}
|
||||
|
||||
[[nodiscard]] QtNodes::NodeDataType Data::type() const {
|
||||
return QtNodes::NodeDataType("string", "String");
|
||||
}
|
||||
|
||||
QString Data::text() const {
|
||||
return QString::fromStdString(Utils::String::escape(this->_value));
|
||||
}
|
54
source/Atlas/nodes/node/string/model/constant.cpp
Normal file
54
source/Atlas/nodes/node/string/model/constant.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include <QtGui>
|
||||
#include <iostream>
|
||||
|
||||
#include "Atlas/nodes/node/string/model/constant.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::String;
|
||||
|
||||
|
||||
Model::Constant::Constant() {
|
||||
// initialise the line edit
|
||||
this->_lineEdit = new QLineEdit();
|
||||
QObject::connect(this->_lineEdit, &QLineEdit::textChanged, this, &Constant::refresh);
|
||||
}
|
||||
|
||||
|
||||
Model::Constant::~Constant() {
|
||||
// delete the line edit
|
||||
delete this->_lineEdit;
|
||||
}
|
||||
|
||||
|
||||
QString Model::Constant::name() const {
|
||||
return Data().type().name + QStringLiteral("::Constant");
|
||||
}
|
||||
|
||||
QString Model::Constant::caption() const {
|
||||
return QStringLiteral("Constant");
|
||||
}
|
||||
|
||||
unsigned int Model::Constant::nPorts(QtNodes::PortType port_type) const {
|
||||
return port_type == QtNodes::PortType::In ? 0 : 1;
|
||||
}
|
||||
|
||||
[[nodiscard]] QtNodes::NodeDataType Model::Constant::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const {
|
||||
return String::Data().type();
|
||||
}
|
||||
|
||||
std::shared_ptr<QtNodes::NodeData> Model::Constant::outData(QtNodes::PortIndex port) {
|
||||
return std::make_shared<String::Data>(this->_value);
|
||||
}
|
||||
|
||||
void Model::Constant::setInData(std::shared_ptr<QtNodes::NodeData> data, QtNodes::PortIndex portIndex) {
|
||||
Q_ASSERT(false && "No input, shouldn't be called");
|
||||
}
|
||||
|
||||
void Model::Constant::refresh() {
|
||||
this->_value = this->_lineEdit->text().toStdString(); // TODO: use the NodeData type for string directory on this->_output
|
||||
Q_EMIT dataUpdated(0);
|
||||
}
|
||||
|
||||
QWidget* Model::Constant::embeddedWidget() {
|
||||
return this->_lineEdit;
|
||||
}
|
1
source/Atlas/nodes/node/string/model/to_variant.cpp
Normal file
1
source/Atlas/nodes/node/string/model/to_variant.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "Atlas/nodes/node/variant/model/to_variant.h"
|
17
source/Atlas/nodes/node/string/register.cpp
Normal file
17
source/Atlas/nodes/node/string/register.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <Atlas/nodes/node/string/register.h>
|
||||
|
||||
|
||||
#include "Atlas/nodes/node/string/data.h"
|
||||
#include "Atlas/nodes/node/string/model/constant.h"
|
||||
#include "Atlas/nodes/node/string/model/to_variant.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::String;
|
||||
|
||||
|
||||
void Atlas::Nodes::String::register_all(const std::shared_ptr<QtNodes::NodeDelegateModelRegistry>& registry) {
|
||||
QString category = Data().type().name;
|
||||
|
||||
registry->registerModel<Model::Constant>(category);
|
||||
registry->registerModel<Model::ToVariant>(category);
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
#include <Atlas/nodes/variant/data.h>
|
||||
#include <Atlas/nodes/decimal/data.h>
|
||||
#include "Atlas/nodes/node/variant/data.h"
|
||||
#include "Atlas/nodes/node/decimal/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Variant;
|
||||
using namespace Atlas::Nodes;
|
||||
|
||||
|
||||
Data::Data() : _data(std::make_shared<Decimal::Data>(0.0)) {} // TODO: make this a null data type
|
||||
Data::Data(const std::shared_ptr<Common::Data>& data) : _data(data) {}
|
||||
Data::Data() : _data(std::make_shared<Decimal::Data>(0.0)) {}
|
||||
Data::Data(const std::shared_ptr<Base::Data>& data) : _data(data) {}
|
||||
|
||||
[[nodiscard]] std::shared_ptr<Common::Data> Data::value() const {
|
||||
[[nodiscard]] std::shared_ptr<Base::Data> Data::value() const {
|
||||
return this->_data;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "Atlas/nodes/variant/model/display.h"
|
||||
#include "Atlas/nodes/node/variant/model/display.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes;
|
40
source/Atlas/nodes/node/variant/model/from_variant.cpp
Normal file
40
source/Atlas/nodes/node/variant/model/from_variant.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "Atlas/nodes/node/variant/model/from_variant.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Variant::Model;
|
||||
|
||||
|
||||
[[nodiscard]] QString FromVariant::name() const {
|
||||
QString output_name = this->_input == nullptr ? QStringLiteral("...") : this->_input->value()->type().name;
|
||||
return QStringLiteral("Variant to ") + output_name;
|
||||
}
|
||||
[[nodiscard]] QString FromVariant::caption() const {
|
||||
QString output_name = this->_input == nullptr ? QStringLiteral("???") : this->_input->value()->type().name;
|
||||
return QStringLiteral("Variant to ") + output_name;
|
||||
}
|
||||
|
||||
[[nodiscard]] unsigned int FromVariant::nPorts(QtNodes::PortType portType) const {
|
||||
// a "from_variant" function only has one input and one output only if the input is set
|
||||
return portType == QtNodes::PortType::In ? 1 : (this->_input == nullptr ? 0 : 1);
|
||||
}
|
||||
|
||||
[[nodiscard]] QtNodes::NodeDataType FromVariant::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const {
|
||||
return portType == QtNodes::PortType::In ? Variant::Data().type() : this->_input->value()->type();
|
||||
}
|
||||
|
||||
void FromVariant::setInData(std::shared_ptr<QtNodes::NodeData> data, QtNodes::PortIndex portIndex) {
|
||||
// update the input
|
||||
this->_input = data == nullptr ? nullptr : std::dynamic_pointer_cast<Variant::Data>(data);
|
||||
// update the next nodes
|
||||
if (this->_input != nullptr) Q_EMIT dataUpdated(0);
|
||||
}
|
||||
|
||||
std::shared_ptr<QtNodes::NodeData> FromVariant::outData(QtNodes::PortIndex portIndex) {
|
||||
// return the last computed output
|
||||
return this->_input->value();
|
||||
}
|
||||
|
||||
QWidget* FromVariant::embeddedWidget() {
|
||||
// reduced node doesn't have any embedded widget
|
||||
return nullptr;
|
||||
}
|
1
source/Atlas/nodes/node/variant/model/to_variant.cpp
Normal file
1
source/Atlas/nodes/node/variant/model/to_variant.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "Atlas/nodes/node/variant/model/to_variant.h"
|
17
source/Atlas/nodes/node/variant/register.cpp
Normal file
17
source/Atlas/nodes/node/variant/register.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include <Atlas/nodes/node/variant/register.h>
|
||||
|
||||
|
||||
#include "Atlas/nodes/node/variant/model/from_variant.h"
|
||||
#include "Atlas/nodes/node/variant/model/display.h"
|
||||
#include "Atlas/nodes/node/variant/data.h"
|
||||
|
||||
|
||||
using namespace Atlas::Nodes::Variant;
|
||||
|
||||
|
||||
void Atlas::Nodes::Variant::register_all(const std::shared_ptr<QtNodes::NodeDelegateModelRegistry>& registry) {
|
||||
QString category = Data().type().name;
|
||||
|
||||
registry->registerModel<Model::FromVariant>(category);
|
||||
registry->registerModel<Model::Display>(category);
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
#include <Atlas/nodes/variant/model/to_variant.h>
|
|
@ -8,14 +8,7 @@
|
|||
#include "QtNodes/DataFlowGraphicsScene"
|
||||
#include "QtNodes/DataFlowGraphModel"
|
||||
|
||||
#include "Atlas/nodes/decimal/data.h"
|
||||
#include "Atlas/nodes/decimal/model/constant.h"
|
||||
#include "Atlas/nodes/decimal/model/addition.h"
|
||||
#include "Atlas/nodes/decimal/model/subtraction.h"
|
||||
#include "Atlas/nodes/decimal/model/multiplication.h"
|
||||
#include "Atlas/nodes/decimal/model/division.h"
|
||||
#include "Atlas/nodes/variant/model/display.h"
|
||||
#include "Atlas/nodes/decimal/model/to_variant.h"
|
||||
#include "Atlas/nodes/node/register.h"
|
||||
|
||||
|
||||
using namespace Atlas;
|
||||
|
@ -24,15 +17,13 @@ using namespace Atlas;
|
|||
int main(int argc, char *argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
|
||||
// initialise the registry
|
||||
// set up the registry
|
||||
std::shared_ptr<QtNodes::NodeDelegateModelRegistry> registry = std::make_shared<QtNodes::NodeDelegateModelRegistry>();
|
||||
registry->registerModel<Nodes::Decimal::Model::Constant>(QStringLiteral("Decimal"));
|
||||
registry->registerModel<Nodes::Decimal::Model::Addition>(QStringLiteral("Decimal"));
|
||||
registry->registerModel<Nodes::Decimal::Model::Subtraction>(QStringLiteral("Decimal"));
|
||||
registry->registerModel<Nodes::Decimal::Model::Multiplication>(QStringLiteral("Decimal"));
|
||||
registry->registerModel<Nodes::Decimal::Model::Division>(QStringLiteral("Decimal"));
|
||||
registry->registerModel<Nodes::Decimal::Model::ToVariant>(QStringLiteral("Decimal"));
|
||||
registry->registerModel<Nodes::Variant::Model::Display>(QStringLiteral("Variant"));
|
||||
// register all the models
|
||||
Nodes::register_all(registry);
|
||||
|
||||
// set up the graph
|
||||
QtNodes::DataFlowGraphModel dataFlowGraphModel(registry);
|
||||
|
||||
// TEST
|
||||
QWidget mainWidget;
|
||||
|
@ -44,8 +35,6 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
auto *layout = new QVBoxLayout(&mainWidget);
|
||||
|
||||
QtNodes::DataFlowGraphModel dataFlowGraphModel(registry);
|
||||
|
||||
layout->addWidget(menuBar);
|
||||
auto scene = new QtNodes::DataFlowGraphicsScene(dataFlowGraphModel, &mainWidget);
|
||||
|
||||
|
|
8
source/utils/string.cpp
Normal file
8
source/utils/string.cpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <utils/string.h>
|
||||
|
||||
#include <regex>
|
||||
|
||||
|
||||
std::string Utils::String::escape(const std::string& string) {
|
||||
return "\"" + std::regex_replace(string, std::regex("\""), "\\\"") + "\"";
|
||||
}
|
Loading…
Reference in a new issue