| 366 | } |
| 367 | |
| 368 | NodeGuiPtr |
| 369 | NodeGraph::createNodeGUI(const NodePtr & node, |
| 370 | const CreateNodeArgs& args) |
| 371 | { |
| 372 | NodeGuiPtr node_ui; |
| 373 | Dot* isDot = dynamic_cast<Dot*>( node->getEffectInstance().get() ); |
| 374 | Backdrop* isBd = dynamic_cast<Backdrop*>( node->getEffectInstance().get() ); |
| 375 | NodeGroup* isGrp = dynamic_cast<NodeGroup*>( node->getEffectInstance().get() ); |
| 376 | |
| 377 | |
| 378 | if (isDot) { |
| 379 | node_ui.reset( new DotGui(_imp->_nodeRoot) ); |
| 380 | } else if (isBd) { |
| 381 | node_ui.reset( new BackdropGui(_imp->_nodeRoot) ); |
| 382 | } else { |
| 383 | node_ui.reset( new NodeGui(_imp->_nodeRoot) ); |
| 384 | } |
| 385 | assert(node_ui); |
| 386 | node_ui->initialize(this, node); |
| 387 | |
| 388 | if (isBd) { |
| 389 | BackdropGui* bd = dynamic_cast<BackdropGui*>( node_ui.get() ); |
| 390 | assert(bd); |
| 391 | NodesGuiList selectedNodes = _imp->_selection; |
| 392 | if ( bd && !selectedNodes.empty() ) { |
| 393 | ///make the backdrop large enough to contain the selected nodes and position it correctly |
| 394 | QRectF bbox; |
| 395 | for (NodesGuiList::iterator it = selectedNodes.begin(); it != selectedNodes.end(); ++it) { |
| 396 | QRectF nodeBbox = (*it)->mapToScene( (*it)->boundingRect() ).boundingRect(); |
| 397 | bbox = bbox.united(nodeBbox); |
| 398 | } |
| 399 | |
| 400 | double border50 = mapToScene( QPoint(50, 0) ).x(); |
| 401 | double border0 = mapToScene( QPoint(0, 0) ).x(); |
| 402 | double border = border50 - border0; |
| 403 | double headerHeight = bd->getFrameNameHeight(); |
| 404 | QPointF scenePos(bbox.x() - border, bbox.y() - border); |
| 405 | |
| 406 | bd->setPos( bd->mapToParent( bd->mapFromScene(scenePos) ) ); |
| 407 | bd->resize(bbox.width() + 2 * border, bbox.height() + 2 * border - headerHeight); |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | |
| 412 | { |
| 413 | QMutexLocker l(&_imp->_nodesMutex); |
| 414 | _imp->_nodes.push_back(node_ui); |
| 415 | } |
| 416 | |
| 417 | //NodeGroup* parentIsGroup = dynamic_cast<NodeGroup*>(node->getGroup().get());; |
| 418 | const std::list<NodePtr>& nodesBeingCreated = getGui()->getApp()->getNodesBeingCreated(); |
| 419 | bool isTopLevelNodeBeingCreated = false; |
| 420 | if ( !nodesBeingCreated.empty() && (nodesBeingCreated.front() == node) ) { |
| 421 | isTopLevelNodeBeingCreated = true; |
| 422 | } |
| 423 | |
| 424 | NodeSerializationPtr serialization = args.getProperty<NodeSerializationPtr>(kCreateNodeArgsPropNodeSerialization); |
| 425 |
nothing calls this directly
no test coverage detected