| 2332 | } |
| 2333 | |
| 2334 | void |
| 2335 | TrackerPanelPrivateV1::createCornerPinFromSelection(const std::list<Node*> & selection, |
| 2336 | bool linked, |
| 2337 | bool useTransformRefFrame, |
| 2338 | bool invert) |
| 2339 | { |
| 2340 | if ( (selection.size() > 4) || selection.empty() ) { |
| 2341 | Dialogs::errorDialog( tr("Export").toStdString(), |
| 2342 | tr("Export to corner pin needs between 1 and 4 selected tracks.").toStdString() ); |
| 2343 | |
| 2344 | return; |
| 2345 | } |
| 2346 | |
| 2347 | KnobDoublePtr centers[4]; |
| 2348 | int i = 0; |
| 2349 | for (std::list<Node*>::const_iterator it = selection.begin(); it != selection.end(); ++it, ++i) { |
| 2350 | centers[i] = getCenterKnobForTracker(*it); |
| 2351 | assert(centers[i]); |
| 2352 | } |
| 2353 | GuiAppInstancePtr app = publicInterface->getGui()->getApp(); |
| 2354 | CreateNodeArgs args(PLUGINID_OFX_CORNERPIN, publicInterface->getMainInstance()->getGroup() ); |
| 2355 | args.setProperty<bool>(kCreateNodeArgsPropAddUndoRedoCommand, false); |
| 2356 | args.setProperty<bool>(kCreateNodeArgsPropAutoConnect, false); |
| 2357 | NodePtr cornerPin = app->createNode(args); |
| 2358 | |
| 2359 | if (!cornerPin) { |
| 2360 | return; |
| 2361 | } |
| 2362 | |
| 2363 | ///Move the node on the right of the tracker node |
| 2364 | NodeGuiIPtr cornerPinGui_i = cornerPin->getNodeGui(); |
| 2365 | NodeGui* cornerPinGui = dynamic_cast<NodeGui*>( cornerPinGui_i.get() ); |
| 2366 | assert(cornerPinGui); |
| 2367 | |
| 2368 | NodeGuiPtr mainInstanceGui = publicInterface->getMainInstanceGui(); |
| 2369 | assert(mainInstanceGui); |
| 2370 | |
| 2371 | QPointF mainInstancePos = mainInstanceGui->scenePos(); |
| 2372 | |
| 2373 | if (cornerPinGui) { |
| 2374 | mainInstancePos = cornerPinGui->mapToParent( cornerPinGui->mapFromScene(mainInstancePos) ); |
| 2375 | cornerPinGui->refreshPosition( mainInstancePos.x() + mainInstanceGui->getSize().width() * 2, mainInstancePos.y() ); |
| 2376 | } |
| 2377 | KnobDoublePtr toPoints[4]; |
| 2378 | KnobDoublePtr fromPoints[4]; |
| 2379 | double timeForFromPoints = useTransformRefFrame ? referenceFrame->getValue() : app->getTimeLine()->currentFrame(); |
| 2380 | |
| 2381 | for (unsigned int i = 0; i < selection.size(); ++i) { |
| 2382 | fromPoints[i] = getCornerPinPoint(cornerPin.get(), true, i); |
| 2383 | assert(fromPoints[i] && centers[i]); |
| 2384 | for (int j = 0; j < fromPoints[i]->getDimension(); ++j) { |
| 2385 | fromPoints[i]->setValue(centers[i]->getValueAtTime(timeForFromPoints, j), ViewSpec::all(), j); |
| 2386 | } |
| 2387 | |
| 2388 | toPoints[i] = getCornerPinPoint(cornerPin.get(), false, i); |
| 2389 | assert(toPoints[i]); |
| 2390 | if (!linked) { |
| 2391 | toPoints[i]->cloneAndUpdateGui( centers[i].get() ); |
no test coverage detected