MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / cloneSelectedNodes

Method cloneSelectedNodes

Gui/NodeGraph40.cpp:232–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232void
233NodeGraph::cloneSelectedNodes(const QPointF& scenePos)
234{
235 if ( _imp->_selection.empty() ) {
236 Dialogs::warningDialog( tr("Clone").toStdString(), tr("You must select at least a node to clone first.").toStdString() );
237
238 return;
239 }
240
241 double xmax = std::numeric_limits<int>::min();
242 double xmin = std::numeric_limits<int>::max();
243 double ymin = std::numeric_limits<int>::max();
244 double ymax = std::numeric_limits<int>::min();
245 NodesGuiList nodesToCopy = _imp->_selection;
246 for (NodesGuiList::iterator it = _imp->_selection.begin(); it != _imp->_selection.end(); ++it) {
247 if ( (*it)->getNode()->getMasterNode() ) {
248 Dialogs::errorDialog( tr("Clone").toStdString(), tr("You cannot clone a node which is already a clone.").toStdString() );
249
250 return;
251 }
252 QRectF bbox = (*it)->mapToScene( (*it)->boundingRect() ).boundingRect();
253 if ( ( bbox.x() + bbox.width() ) > xmax ) {
254 xmax = ( bbox.x() + bbox.width() );
255 }
256 if (bbox.x() < xmin) {
257 xmin = bbox.x();
258 }
259
260 if ( ( bbox.y() + bbox.height() ) > ymax ) {
261 ymax = ( bbox.y() + bbox.height() );
262 }
263 if (bbox.y() < ymin) {
264 ymin = bbox.y();
265 }
266
267 ///Also copy all nodes within the backdrop
268 BackdropGui* isBd = dynamic_cast<BackdropGui*>( it->get() );
269 if (isBd) {
270 NodesGuiList nodesWithinBD = getNodesWithinBackdrop(*it);
271 for (NodesGuiList::iterator it2 = nodesWithinBD.begin(); it2 != nodesWithinBD.end(); ++it2) {
272 NodesGuiList::iterator found = std::find(nodesToCopy.begin(), nodesToCopy.end(), *it2);
273 if ( found == nodesToCopy.end() ) {
274 nodesToCopy.push_back(*it2);
275 }
276 }
277 }
278 }
279
280 for (NodesGuiList::iterator it = nodesToCopy.begin(); it != nodesToCopy.end(); ++it) {
281 if ( (*it)->getNode()->getEffectInstance()->isSlave() ) {
282 Dialogs::errorDialog( tr("Clone").toStdString(), tr("You cannot clone a node which is already a clone.").toStdString() );
283
284 return;
285 }
286 ViewerInstance* isViewer = (*it)->getNode()->isEffectViewer();
287 if (isViewer) {
288 Dialogs::errorDialog( tr("Clone").toStdString(), tr("Cloning a viewer is not a valid operation.").toStdString() );
289

Callers

nothing calls this directly

Calls 15

maxFunction · 0.85
getGuiFunction · 0.85
pushUndoCommandFunction · 0.85
emptyMethod · 0.80
toStdStringMethod · 0.80
getMasterNodeMethod · 0.80
isSlaveMethod · 0.80
getEffectInstanceMethod · 0.80
isMultiInstanceMethod · 0.80
pasteNodeMethod · 0.80
restoreConnectionsMethod · 0.80

Tested by

no test coverage detected