MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / drawConnectionPoints

Method drawConnectionPoints

QtNodeEditor/src/NodePainter.cpp:106–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105
106void
107NodePainter::
108drawConnectionPoints(QPainter* painter,
109 NodeGeometry const& geom,
110 NodeState const& state,
111 NodeDataModel const * model,
112 FlowScene const & scene)
113{
114 NodeStyle const& nodeStyle = model->nodeStyle();
115 auto const &connectionStyle = StyleCollection::connectionStyle();
116
117 float diameter = nodeStyle.ConnectionPointDiameter;
118 auto reducedDiameter = diameter * 0.6;
119
120 for(PortType portType: {PortType::Out, PortType::In})
121 {
122 size_t n = state.getEntries(portType).size();
123
124 for (unsigned int i = 0; i < n; ++i)
125 {
126 QPointF p = geom.portScenePosition(i, portType);
127
128 auto const & dataType = model->dataType(portType, i);
129
130 bool canConnect = (state.getEntries(portType)[i].empty() ||
131 (portType == PortType::Out &&
132 model->portOutConnectionPolicy(i) == NodeDataModel::ConnectionPolicy::Many) );
133
134 double r = 1.0;
135 if (state.isReacting() &&
136 canConnect &&
137 portType == state.reactingPortType())
138 {
139
140 auto diff = geom.draggingPos() - p;
141 double dist = std::sqrt(QPointF::dotProduct(diff, diff));
142 bool typeConvertable = false;
143
144 {
145 if (portType == PortType::In)
146 {
147 typeConvertable = scene.registry().getTypeConverter(state.reactingDataType(), dataType) != nullptr;
148 }
149 else
150 {
151 typeConvertable = scene.registry().getTypeConverter(dataType, state.reactingDataType()) != nullptr;
152 }
153 }
154
155 if (state.reactingDataType().id == dataType.id || typeConvertable)
156 {
157 double const thres = 40.0;
158 r = (dist < thres) ?
159 (2.0 - dist / thres ) :
160 1.0;
161 }
162 else
163 {

Callers

nothing calls this directly

Calls 2

dataTypeMethod · 0.80

Tested by

no test coverage detected