简体   繁体   English

节点图编辑器布局算法

[英]Node graph editor layout algorithm

I'm very much trying to do what was asked here: 我非常想做这里要问的事情:

http://www.qtcentre.org/threads/45028-Designing-a-Node-Editor-(Hint-Blender-Node-Editor) http://www.qtcentre.org/threads/45028-Designing-a-Node-Editor-(提示-Blender-Node-Editor)

Which is basically a blender style node editor using Qt. 这基本上是使用Qt的Blender样式节点编辑器。 Creating rects with circles which can be drag/dropped is fairly simple to figure out (see the image below). 创建带有可以拖放的圆圈的矩形非常简单(请参见下图)。

The issue I have is how the algorithm for connecting the circles between nodes would work. 我的问题是节点之间的圆圈连接算法将如何工作。 Also I don't know how this could be drawn efficiently using QGraphicsItem API's? 我也不知道如何使用QGraphicsItem API有效地绘制此图形? I have seen QPainter::cubicTo() which looks like it may be the way to go? 我看过QPainter :: cubicTo()看起来像是要走的路?

I assume it somehow manages to find a none overlapping path? 我认为它设法找到了一条没有重叠的路径? But it must also handle the case where it has to overlap? 但是它还必须处理必须重叠的情况吗?

And what about the user being able to move these lines around in case the algorithm has done a bad job? 在算法做得不好的情况下,用户能够移动这些行呢? I don't think this would be simple to implement using QPainter::cubicTo() as you could only move the curves control points? 我认为使用QPainter :: cubicTo()实现起来并不简单,因为您只能移动曲线控制点?

在此处输入图片说明

I don't think you'll get anyone posting the code for doing the whole lot here. 我认为您不会在这里发布任何代码来完成全部工作。

Well, I volunteer -- just in case someone still needs such a library. 好吧,我自愿-以防万一有人仍然需要这样的图书馆。

It is a Qt-based node editor implemented on top of QGraphicsView. 它是在QGraphicsView之上实现的基于Qt的节点编辑器。 A library consumer defines data models, the rest is done by the node editor. 库使用者定义数据模型,其余的由节点编辑器完成。 Some features: 一些功能:

  • Model-view approach. 模型视图方法。
  • Models describe data types, number of input and outputs and optional embedded QWidget. 模型描述数据类型,输入和输出数量以及可选的嵌入式QWidget。
  • The Scene could be saved to file. 场景可以保存到文件中。

The rest similar projects were either not finished, not supported anymore or lacking some features. 其余的类似项目要么没有完成,要么不再受支持,要么缺少某些功能。

https://github.com/paceholder/nodeeditor https://github.com/paceholder/nodeeditor 在此处输入图片说明

I would suggest that you implement it without taking into consideration overlap but with the possibility of overriding how the connecting line is drawn. 我建议您在实现时不要考虑重叠,但有可能覆盖连接线的绘制方式。

It looks like there were some good replies on the Qt forum. Qt论坛上似乎有一些不错的答复。 I don't think you'll get anyone posting the code for doing the whole lot here. 我认为您不会在这里发布任何代码来完成全部工作。

Perhaps take a look at the Qt demos Graphics View/Elastic Nodes - There is code for the demo that you can use as a starting point, but it is a lot of work to get from there to something like the Blender node editor. 也许看一看Qt演示图形视图/弹性节点-可以将演示代码用作起点,但是从那里到Blender节点编辑器之类的工作很多。

Another node editor to take a look at is SynthEdit or Synth Maker (has a nice one). 另一个要查看的节点编辑器是SynthEdit或Synth Maker(非常不错)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM