PeriDyno 1.2.1
Loading...
Searching...
No Matches
WtModuleWidget.h
Go to the documentation of this file.
1#pragma once
2
3#include "json.hpp"
4#include "WtNodeDataModel.h"
5#include "WtFieldData.h"
6
7#include "Module.h"
8
9#include <iostream>
10
11using dyno::Module;
12using dyno::FBase;
13
15{
16public:
17 WtModuleWidget(std::shared_ptr<Module> base = nullptr);
18
19 virtual ~WtModuleWidget() {}
20
21public:
22
23 std::string caption() const override;
24
25 bool captionVisible() const override;
26
27 std::string name() const override;
28
29 void setName(std::string name) { m_name = name; }
30
31 std::string portCaption(PortType portType, PortIndex portIndex) const override;
32
33 std::string nodeTips() const override;
34
35 std::string portTips(PortType portType, PortIndex portIndex) const override;
36
37 std::string validationMessage() const override;
38
39 unsigned int nPorts(PortType portType) const override;
40
41 bool hotkeyEnabled() const override { return false; }
42
43 bool allowExported() const override { return false; }
44
45 bool portCaptionVisible(PortType portType, PortIndex portIndex) const override;
46
47 std::shared_ptr<WtNodeData> outData(PortIndex port) override;
48
49 void setInData(std::shared_ptr<WtNodeData> data, PortIndex portIndex) override;
50
51 bool tryInData(PortIndex portIndex, std::shared_ptr<WtNodeData> nodeData) override;
52
53 NodeDataType dataType(PortType portType, PortIndex portIndex) const override;
54
55 //QWidget* embeddedWidget() override { return nullptr; }
56
57 NodeValidationState validationState() const override;
58
59 std::shared_ptr<Module> getModule();
60
61 void enableEditing();
62
63 void disableEditing();
64
65protected:
66 virtual void updateModule();
67
68protected:
69
70 using OutFieldPtr = std::vector<std::shared_ptr<WtFieldData>>;
71
72 using InFieldPtr = std::vector<std::shared_ptr<WtFieldData>>;
73
75
77
78 std::string m_name;
79
80 std::shared_ptr<Module> m_Module = nullptr;
81
83
84 std::string modelValidationError = "Missing or incorrect inputs";
85
86private:
87
88 FBase* getField(PortType portType, PortIndex portIndex) const;
89
90 std::vector<FBase*>& getOutputFields();
91
92 std::vector<FBase*>& getInputFields();
93
94private:
95
96 bool mEditingEnabled = true;
97};
int PortIndex
PortType
NodeValidationState
std::string validationMessage() const override
bool portCaptionVisible(PortType portType, PortIndex portIndex) const override
It is possible to hide port caption in GUI.
std::vector< FBase * > & getOutputFields()
virtual void updateModule()
FBase * getField(PortType portType, PortIndex portIndex) const
std::vector< std::shared_ptr< WtFieldData > > OutFieldPtr
std::shared_ptr< Module > m_Module
NodeValidationState validationState() const override
std::string portCaption(PortType portType, PortIndex portIndex) const override
Port caption is used in GUI to label individual ports.
std::shared_ptr< WtNodeData > outData(PortIndex port) override
std::vector< FBase * > & getInputFields()
bool allowExported() const override
std::string m_name
NodeValidationState modelValidationState
std::vector< std::shared_ptr< WtFieldData > > InFieldPtr
WtModuleWidget(std::shared_ptr< Module > base=nullptr)
OutFieldPtr output_fields
std::string nodeTips() const override
std::string modelValidationError
bool tryInData(PortIndex portIndex, std::shared_ptr< WtNodeData > nodeData) override
std::string caption() const override
bool captionVisible() const override
It is possible to hide caption in GUI.
std::string name() const override
Name makes this model unique.
virtual ~WtModuleWidget()
InFieldPtr input_fields
bool hotkeyEnabled() const override
unsigned int nPorts(PortType portType) const override
void setName(std::string name)
std::shared_ptr< Module > getModule()
void setInData(std::shared_ptr< WtNodeData > data, PortIndex portIndex) override
Triggers the algorithm.
NodeDataType dataType(PortType portType, PortIndex portIndex) const override
std::string portTips(PortType portType, PortIndex portIndex) const override