test implementation of nodes. just a simple calculator for now.
This commit is contained in:
@@ -193,6 +193,7 @@ add_subdirectory (src/external/qt-color-widgets)
|
|||||||
add_subdirectory (src/external/framelesshelper)
|
add_subdirectory (src/external/framelesshelper)
|
||||||
add_subdirectory (src/external/qtimgui)
|
add_subdirectory (src/external/qtimgui)
|
||||||
add_subdirectory (src/external/QtAdvancedDockingSystem)
|
add_subdirectory (src/external/QtAdvancedDockingSystem)
|
||||||
|
add_subdirectory (src/external/NodeEditor)
|
||||||
|
|
||||||
# Add the found include directories to our include list.
|
# Add the found include directories to our include list.
|
||||||
include_directories (SYSTEM "${CMAKE_SOURCE_DIR}/include/")
|
include_directories (SYSTEM "${CMAKE_SOURCE_DIR}/include/")
|
||||||
@@ -331,6 +332,7 @@ TARGET_LINK_LIBRARIES (noggit
|
|||||||
FramelessHelper
|
FramelessHelper
|
||||||
qt_imgui_widgets
|
qt_imgui_widgets
|
||||||
qtadvanceddocking
|
qtadvanceddocking
|
||||||
|
nodes
|
||||||
)
|
)
|
||||||
|
|
||||||
set (_noggit_revision_output_dir "${CMAKE_BINARY_DIR}/revision_output")
|
set (_noggit_revision_output_dir "${CMAKE_BINARY_DIR}/revision_output")
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<!DOCTYPE RCC>
|
<!DOCTYPE RCC>
|
||||||
<RCC version="1.0">
|
<RCC version="1.0">
|
||||||
|
<qresource>
|
||||||
|
<file>DefaultStyle.json</file>
|
||||||
|
<file>convert.png</file>
|
||||||
|
</qresource>
|
||||||
<qresource prefix="/fonts">
|
<qresource prefix="/fonts">
|
||||||
<file>font_awesome.otf</file>
|
<file>font_awesome.otf</file>
|
||||||
<file>noggit_font.ttf</file>
|
<file>noggit_font.ttf</file>
|
||||||
|
|||||||
@@ -3,10 +3,108 @@
|
|||||||
#include <noggit/ui/font_noggit.hpp>
|
#include <noggit/ui/font_noggit.hpp>
|
||||||
#include <noggit/DBC.h>
|
#include <noggit/DBC.h>
|
||||||
|
|
||||||
|
#include <external/NodeEditor/include/nodes/NodeData>
|
||||||
|
#include <external/NodeEditor/include/nodes/FlowScene>
|
||||||
|
#include <external/NodeEditor/include/nodes/FlowView>
|
||||||
|
#include <external/NodeEditor/include/nodes/ConnectionStyle>
|
||||||
|
#include <external/NodeEditor/include/nodes/TypeConverter>
|
||||||
|
#include <noggit/Red/PresetEditor/Nodes/MathNode.hpp>
|
||||||
|
#include <noggit/Red/PresetEditor/Nodes/BaseNode.hpp>
|
||||||
|
#include <noggit/Red/PresetEditor/Nodes/Data/DecimalData.hpp>
|
||||||
|
#include <noggit/Red/PresetEditor/Nodes/Data/IntegerData.hpp>
|
||||||
|
|
||||||
|
|
||||||
using namespace noggit::Red::PresetEditor::Ui;
|
using namespace noggit::Red::PresetEditor::Ui;
|
||||||
using namespace noggit::ui;
|
using namespace noggit::ui;
|
||||||
|
|
||||||
|
using QtNodes::DataModelRegistry;
|
||||||
|
using QtNodes::FlowScene;
|
||||||
|
using QtNodes::FlowView;
|
||||||
|
using QtNodes::ConnectionStyle;
|
||||||
|
using QtNodes::TypeConverter;
|
||||||
|
using QtNodes::TypeConverterId;
|
||||||
|
|
||||||
|
using noggit::Red::PresetEditor::Nodes::MathNode;
|
||||||
|
using noggit::Red::PresetEditor::Nodes::BaseNode;
|
||||||
|
|
||||||
|
static std::shared_ptr<DataModelRegistry>
|
||||||
|
registerDataModels()
|
||||||
|
{
|
||||||
|
auto ret = std::make_shared<DataModelRegistry>();
|
||||||
|
// ret->registerModel<NumberSourceDataModel>("I/O//Sources");
|
||||||
|
|
||||||
|
//ret->registerModel<NumberDisplayDataModel>("I/O//Displays");
|
||||||
|
|
||||||
|
ret->registerModel<MathNode>("Operators");
|
||||||
|
|
||||||
|
/*
|
||||||
|
ret->registerTypeConverter(std::make_pair(DecimalData().type(),
|
||||||
|
IntegerData().type()),
|
||||||
|
TypeConverter{DecimalToIntegerConverter()});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ret->registerTypeConverter(std::make_pair(IntegerData().type(),
|
||||||
|
DecimalData().type()),
|
||||||
|
TypeConverter{IntegerToDecimalConverter()});
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
setStyle()
|
||||||
|
{
|
||||||
|
ConnectionStyle::setConnectionStyle(
|
||||||
|
R"(
|
||||||
|
{
|
||||||
|
"FlowViewStyle": {
|
||||||
|
"BackgroundColor": [53, 53, 53],
|
||||||
|
"FineGridColor": [60, 60, 60],
|
||||||
|
"CoarseGridColor": [25, 25, 25]
|
||||||
|
},
|
||||||
|
"NodeStyle": {
|
||||||
|
"NormalBoundaryColor": [255, 255, 255],
|
||||||
|
"SelectedBoundaryColor": [255, 165, 0],
|
||||||
|
"GradientColor0": "gray",
|
||||||
|
"GradientColor1": [80, 80, 80],
|
||||||
|
"GradientColor2": [64, 64, 64],
|
||||||
|
"GradientColor3": [58, 58, 58],
|
||||||
|
"ShadowColor": [20, 20, 20],
|
||||||
|
"FontColor" : "white",
|
||||||
|
"FontColorFaded" : "gray",
|
||||||
|
"ConnectionPointColor": [169, 169, 169],
|
||||||
|
"FilledConnectionPointColor": "cyan",
|
||||||
|
"ErrorColor": "red",
|
||||||
|
"WarningColor": [128, 128, 0],
|
||||||
|
|
||||||
|
"PenWidth": 1.0,
|
||||||
|
"HoveredPenWidth": 1.5,
|
||||||
|
|
||||||
|
"ConnectionPointDiameter": 8.0,
|
||||||
|
|
||||||
|
"Opacity": 0.8
|
||||||
|
},
|
||||||
|
"ConnectionStyle": {
|
||||||
|
"ConstructionColor": "gray",
|
||||||
|
"NormalColor": "darkcyan",
|
||||||
|
"SelectedColor": [100, 100, 100],
|
||||||
|
"SelectedHaloColor": "orange",
|
||||||
|
"HoveredColor": "lightcyan",
|
||||||
|
|
||||||
|
"LineWidth": 3.0,
|
||||||
|
"ConstructionLineWidth": 2.0,
|
||||||
|
"PointDiameter": 10.0,
|
||||||
|
|
||||||
|
"UseDataDefinedColors": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
PresetEditorWidget::PresetEditorWidget(QWidget *parent)
|
PresetEditorWidget::PresetEditorWidget(QWidget *parent)
|
||||||
: QMainWindow(parent, Qt::Window)
|
: QMainWindow(parent, Qt::Window)
|
||||||
{
|
{
|
||||||
@@ -101,6 +199,26 @@ PresetEditorWidget::PresetEditorWidget(QWidget *parent)
|
|||||||
ui->minimapWidget->draw_boundaries(true);
|
ui->minimapWidget->draw_boundaries(true);
|
||||||
ui->minimapWidget->camera(ui->viewport->getWorldCamera());
|
ui->minimapWidget->camera(ui->viewport->getWorldCamera());
|
||||||
|
|
||||||
|
// Handles nodes
|
||||||
|
::setStyle();
|
||||||
|
auto nodes_tab = ui->editorTabs->widget(1);
|
||||||
|
auto scene = new FlowScene(::registerDataModels(), nodes_tab);
|
||||||
|
nodes_tab->setLayout(new QVBoxLayout(nodes_tab));
|
||||||
|
nodes_tab->layout()->addWidget(new FlowView(scene));
|
||||||
|
nodes_tab->layout()->setContentsMargins(0, 0, 0, 0);
|
||||||
|
nodes_tab->layout()->setSpacing(0);
|
||||||
|
nodes_tab->resize(800, 600);
|
||||||
|
|
||||||
|
connect(ui->executeButton, &QPushButton::clicked
|
||||||
|
, [this, scene]()
|
||||||
|
{
|
||||||
|
scene->iterateOverNodeDataDependentOrder(
|
||||||
|
[](NodeDataModel* model)
|
||||||
|
{
|
||||||
|
reinterpret_cast<BaseNode*>(model)->compute();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PresetEditorWidget::setupConnectsCommon()
|
void PresetEditorWidget::setupConnectsCommon()
|
||||||
|
|||||||
@@ -208,7 +208,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="editorTabs">
|
<widget class="QTabWidget" name="editorTabs">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="viewport_tab">
|
<widget class="QWidget" name="viewport_tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -263,10 +263,10 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item alignment="Qt::AlignTop">
|
||||||
<widget class="QToolBox" name="toolBox">
|
<widget class="QToolBox" name="toolBox">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page">
|
<widget class="QWidget" name="page">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@@ -274,7 +274,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>376</width>
|
<width>376</width>
|
||||||
<height>684</height>
|
<height>76</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -372,13 +372,22 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>98</width>
|
<width>376</width>
|
||||||
<height>28</height>
|
<height>76</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Page 2</string>
|
<string>Page 2</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item alignment="Qt::AlignTop">
|
||||||
|
<widget class="QPushButton" name="executeButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Execute</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include <QtWidgets/QLabel>
|
#include <QtWidgets/QLabel>
|
||||||
#include <QtWidgets/QMessageBox>
|
#include <QtWidgets/QMessageBox>
|
||||||
#include <QSplashScreen>
|
#include <QSplashScreen>
|
||||||
|
#include <QStyleFactory>
|
||||||
|
|
||||||
#include "revision.h"
|
#include "revision.h"
|
||||||
|
|
||||||
@@ -343,6 +344,7 @@ int main(int argc, char *argv[])
|
|||||||
noggit::RegisterErrorHandlers();
|
noggit::RegisterErrorHandlers();
|
||||||
std::set_terminate (noggit_terminate_handler);
|
std::set_terminate (noggit_terminate_handler);
|
||||||
|
|
||||||
|
QApplication::setStyle(QStyleFactory::create("Fusion"));
|
||||||
QApplication qapp (argc, argv);
|
QApplication qapp (argc, argv);
|
||||||
qapp.setApplicationName ("Noggit");
|
qapp.setApplicationName ("Noggit");
|
||||||
qapp.setOrganizationName ("Noggit");
|
qapp.setOrganizationName ("Noggit");
|
||||||
|
|||||||
Reference in New Issue
Block a user