nodeeditor icon indicating copy to clipboard operation
nodeeditor copied to clipboard

Support connection style

Open Wzshun opened this issue 3 years ago • 5 comments

I want to change connection style, such as directly line or ployline connect instead of cubic path, and also add triangular arrow at the connect point(PortType In).

It seems that none of these features are supported, and are they planned in the roadmap?

Wzshun avatar Jan 18 '21 09:01 Wzshun

Hi!

This is actually a nice idea. I did not think about customizing the painting that deeply.

I am working currently on a proper and long promised "headless" mode when the graph processing could work independently of the scene and is wrapped in its own "GraphModel" class.

The new approach must be close to the QAbstractItemModel. The painting will be completely independent of the underlying data in this case. We could come up with something like: GraphicsScene::setConnectionPaintDelegate(ConnectionPaintDelegate * delegate); and GraphicsScene::setNodePaintDelegate(NodePaintDelegate * delegate);

paceholder avatar Jan 18 '21 10:01 paceholder

Hi For now, I need to make a flowchart with input arguments for my backend sevices. But I just need a static flowchart, without node item moving, editing, reconnecting etc(so we can have a function to close interact), but keep view interact(zoom, pan etc). Thus, I want make a flow file by a dsigner, and load it in my application's FlowView.

This is a pretty project, however I think it could have a designer example project. We could make it with QtPropertyBrowser: https://github.com/qtproject/qt-solutions/tree/master/qtpropertybrowser With it's ObjectController(in an example), we can easy change NodeDataModel through the qtpropertybrowser, so we can easily find missing features.

Here is piece of code with nodeeditor v2.1.3 and qtpropertybrowser v2.6, but it has a lot bugs, so I give up... by the way, this library is lack a of documentation...

class TerminalNodeModel : public QtNodes::NodeDataModel
{
	Q_OBJECT
	Q_PROPERTY(QString caption READ caption WRITE setCaption)
	Q_PROPERTY(bool isStart READ isStart WRITE setIsStart)

public:
	QString caption() const override { return m_caption; }
	unsigned int nPorts(QtNodes::PortType portType) const override
	{
		unsigned int result = 1;
	
		switch (portType)
		{
		case PortType::In:
			result = m_isStart ? 0 : 1;
			break;
	
		case PortType::Out:
			result = m_isStart ? 1 : 0;
	
		default:
			break;
		}
	
		return result;
	}
// other override ...

	void setCaption(const QString &caption) { m_caption = caption; } // here need Node Item update signal

	bool isStart() const { return m_isStart; }
	void setIsStart(bool isStart) { m_isStart = isStart; } // here need dynamic port and port changed update signal

private:
	QString m_caption;
	bool m_isStart;
};

// with objectcontroller
void FlowDesigner::init()
{
	m_objectController = new ObjectController(dock);
	dock->setWidget(m_objectController);

	connect(m_scene, &FlowScene::selectionChanged, this, &FlowDesigner::onSelectionChanged);
}

void FlowDesigner::onSelectionChanged()
{
	auto nodes = m_scene->selectedNodes();
	if(nodes.empty())
	{
		m_objectController->setObject(nullptr);
	}
	else
	{
		auto lastNode = nodes.back();
		m_objectController->setObject(lastNode->nodeDataModel());
	}
}

Wzshun avatar Jan 21 '21 03:01 Wzshun

I am sorry but I did not quite get it from your last comment -- what are you trying to achieve and what would be an appropriate change in the node library

paceholder avatar Jan 25 '21 14:01 paceholder

I'm sorry for my poor English. I just want to achieve a designer with nodeeditor: image

In the reply above, there are comments in the code that nodeeditor maybe lack of features, such as: // here need Node Item update signal

Wzshun avatar Jan 27 '21 05:01 Wzshun

Your English is great, I juts did not get what was missing from the node-editor side. Thanks for the picture.

paceholder avatar Jan 27 '21 11:01 paceholder