Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
68 lines (51 loc) · 1.74 KB

File metadata and controls

68 lines (51 loc) · 1.74 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once
#include <memory>
#include <QtCore/QPointF>
#include "Definitions.hpp"
namespace QtNodes {
class ConnectionGraphicsObject;
class NodeGraphicsObject;
class BasicGraphicsScene;
/// Class wraps conecting and disconnecting checks.
/**
* An instance should be created on the stack and destroyed
* automatically when the operation is completed
*/
class NodeConnectionInteraction
{
public:
NodeConnectionInteraction(NodeGraphicsObject &ngo,
ConnectionGraphicsObject &cgo,
BasicGraphicsScene &scene);
/**
* Can connect when following conditions are met:
* 1. Connection 'requires' a port.
* 2. Connection loose end is above the node port.
* 3. Source and target `nodeId`s are different.
* 4. GraphModel permits connection.
*/
bool canConnect(PortIndex *portIndex) const;
/// Creates a new connectino if possible.
/**
* 1. Check conditions from 'canConnect'.
* 2. Creates new connection with `GraphModel::addConnection`.
* 3. Adjust connection geometry.
*/
bool tryConnect() const;
/**
* 1. Delete connection with `GraphModel::deleteConnection`.
* 2. Create a "draft" connection with incomplete `ConnectionId`.
* 3. Repaint both previously connected nodes.
*/
bool disconnect(PortType portToDisconnect) const;
private:
PortType connectionRequiredPort() const;
QPointF connectionEndScenePosition(PortType) const;
QPointF nodePortScenePosition(PortType portType, PortIndex portIndex) const;
PortIndex nodePortIndexUnderScenePoint(PortType portType, QPointF const &p) const;
private:
NodeGraphicsObject &_ngo;
ConnectionGraphicsObject &_cgo;
BasicGraphicsScene &_scene;
};
} // namespace QtNodes
Morty Proxy This is a proxified and sanitized view of the page, visit original site.