Comments (10)
Acutally there is a hack around this.
static const char* typetocreate = "";
class RuntimeNodeType : public NodeDataModel {
QString type;
...
// this works because the map is based on the name
static QString name()
if(strcmp(typetocreate, "hello") == 0) {
type = typetocreate;
}
};
// now in virtual functions just have conditional functionality based on name
Definitely a hack, it would be better to have real support for this.
from nodeeditor.
Actually, it won't work due to the name call in RegisteryItemImpl
from nodeeditor.
I think the best way to do this is instead of RegistryItem
s being stored in DataModelRegistry
's _registeredModels
, store a unique_ptr<NodeDataModel>
which would allow for custom storage in node types. I'm writing it right now to see if it works.
from nodeeditor.
An instance of NodeDataModel
represents a specific node, model with given state located in the memory. RegistryItem
is a way of storing the class information without creating the class. We use factory method to create as many instances as required. I do not see any point in throwing away the RegistryItem
from nodeeditor.
Well my idea was to create the class so it can hold runtime metadata. I also had to add a clone
virtual function to NodeDataModel
so it can still represent one node.
I'm almost done implementing it, I'll show you
from nodeeditor.
This is what I mean (Here is the relevant commit)
from nodeeditor.
I see, but what is the benefit of this change? Shorter code? Maybe I did not get your idea with runtime metadata. Can I ask what kind of project you are working on?
from nodeeditor.
Okay let me see if I can explain my issue to you.
Instead of a specialized application just for manipulting a specific kind of graph (ie calculator), I'm making a general application for manipulating graphs that have node types that are defined in files.
With your current system, I have to know all possible node types at compile time, which is not ideal.
Let me explain the exact project I'm working on. It could be that I missed something here and what I'm trying to do is already possible. I'm working on a programming language (the repo is here) which is like UE4 blueprints in that instead of being text based, it's a flowgraph. that has what are called "modules". These modules define functions that cen be used from other modules that depend on them (if you've used golang, it's modeled after that). I'm using your library to create a module editor, where you can open up functions into the graph.
You see, at runtime I need to be able to create node types. This system allows metadata to be stored in the instance of the class instead of just in the type data, meaning that I can have hundreds of instances of the same class in a registry, and they can all be different types.
I have already implemented that in chigraph, here
I hope that helps clear it up...
from nodeeditor.
That's very interesting, thanks for explaining. I need to look at your code as it might be useful for my project as well. I planned to process lots of scientific data (1d, 2d, 3d arrays and scalars) by the graph of algorithms. Then I decided to write Node Editor first.
Now I see, you are doing tricks by returning different names for the same Type class depending on the context (metadata).
Besides, I like that we eliminate these ugly static functions:
String const name = ModelType::name();
Please, patch the pull request, squash everything in one commit and I will merge it
from nodeeditor.
Alright! I think it depends on my other PR right now, but I can fix that.
from nodeeditor.
Related Issues (20)
- :-1: error: ninja: build stopped: subcommand failed. HOT 1
- crashed when click twice on a no-connection-port of locked-node
- Qt dependency problem
- an extra "t" in JSON key "intNodeId" but named inNodeId in ConnectionId HOT 2
- Dynamic ports in v3
- how to save file which refer to flow id
- Drag and drop flow file HOT 1
- Missing or incorrect inputs text
- Embedded widget with wrong size when content has changed HOT 3
- NODE_EDITOR_SHARED added to target public definition HOT 2
- Item is Clipped Sometimes. HOT 2
- display a widget but location is wrong HOT 1
- The context menu of QLineEdit can not be closed
- how to change the Graphics style dynamically ?
- connect exception
- Get Warning "qt.core.qobject.connect: QObject::connect: signal not found in NodeDelegateModel" while using load *.dll method. HOT 2
- resizable_images Demo的双击事件无法捕获 HOT 1
- Big issue when using combo embedded widget HOT 2
- Connector selection issue
- Some usage issues.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodeeditor.