| 109 | } |
| 110 | |
| 111 | bool IPProcessGridScene::addEdge(IPProcessEdge* edge) |
| 112 | { |
| 113 | if(edge->from() == edge->to()) |
| 114 | return false; |
| 115 | |
| 116 | // check type |
| 117 | int indexOut = edge->indexFrom(); |
| 118 | int indexIn = edge->indexTo(); |
| 119 | |
| 120 | if(indexOut >= edge->from()->process()->outputs()->size()) |
| 121 | return false; |
| 122 | if(indexIn >= edge->to()->process()->inputs()->size()) |
| 123 | return false; |
| 124 | |
| 125 | IPLProcessIO output = edge->from()->process()->outputs()->at(indexOut); |
| 126 | IPLProcessIO input = edge->to()->process()->inputs()->at(indexIn); |
| 127 | |
| 128 | // inputs can accept lower types |
| 129 | // COLOR accepts GRAY and BW |
| 130 | if(output.type > input.type) |
| 131 | return false; |
| 132 | |
| 133 | /*IPLData* outputData = edge->from()->process()->getResultData(indexOut); |
| 134 | if (!outputData->isConvertibleTo(input.type)) |
| 135 | return false;*/ |
| 136 | |
| 137 | _edges.append(edge); |
| 138 | addItem(edge); |
| 139 | |
| 140 | //set outgoing and ingoing edges |
| 141 | edge->from()->addEdgeOut(edge); |
| 142 | edge->to()->addEdgeIn(edge); |
| 143 | |
| 144 | // set input occupied |
| 145 | edge->to()->process()->inputs()->at(edge->indexTo()).occupied = true; |
| 146 | |
| 147 | return true; |
| 148 | } |
| 149 | |
| 150 | void IPProcessGridScene::removeEdge(IPProcessEdge* edge) |
| 151 | { |