* @brief Removes the interface associated to the given node. * @param permanently The interface is destroyed instead of being hidden * @param setAnotherFromSamePlugin If true, if another node of the same plug-in is a candidate for a viewer interface, it will replace the existing * viewer interface for this plug-in **/
| 658 | * viewer interface for this plug-in |
| 659 | **/ |
| 660 | void |
| 661 | ViewerTab::removeNodeViewerInterface(const NodeGuiPtr& n, |
| 662 | bool permanently, |
| 663 | bool setAnotherFromSamePlugin) |
| 664 | { |
| 665 | ViewerTabPrivate::NodeViewerContextsMap::iterator found = _imp->nodesContext.find(n); |
| 666 | |
| 667 | if ( found == _imp->nodesContext.end() ) { |
| 668 | return; |
| 669 | } |
| 670 | |
| 671 | std::string pluginID = n->getNode()->getPluginID(); |
| 672 | NodeGuiPtr activeNodeForPlugin; |
| 673 | QToolBar* activeItemToolBar = 0; |
| 674 | QWidget* activeItemContainer = 0; |
| 675 | |
| 676 | { |
| 677 | // Keep the iterator under this scope since we erase it |
| 678 | std::list<ViewerTabPrivate::PluginViewerContext>::iterator foundActive = _imp->findActiveNodeContextForPlugin(pluginID); |
| 679 | if ( foundActive != _imp->currentNodeContext.end() ) { |
| 680 | activeNodeForPlugin = foundActive->currentNode.lock(); |
| 681 | |
| 682 | if (activeNodeForPlugin == n) { |
| 683 | activeItemToolBar = foundActive->currentContext->getToolBar(); |
| 684 | activeItemContainer = foundActive->currentContext->getContainerWidget(); |
| 685 | _imp->currentNodeContext.erase(foundActive); |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | // Remove the widgets of the current node |
| 691 | if (activeItemToolBar) { |
| 692 | int nLayoutItems = _imp->viewerLayout->count(); |
| 693 | for (int i = 0; i < nLayoutItems; ++i) { |
| 694 | QLayoutItem* item = _imp->viewerLayout->itemAt(i); |
| 695 | if (item->widget() == activeItemToolBar) { |
| 696 | activeItemToolBar->hide(); |
| 697 | _imp->viewerLayout->removeItem(item); |
| 698 | break; |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | if (activeItemContainer) { |
| 703 | int buttonsBarIndex = _imp->mainLayout->indexOf(activeItemContainer); |
| 704 | assert(buttonsBarIndex >= 0); |
| 705 | if (buttonsBarIndex >= 0) { |
| 706 | _imp->mainLayout->removeWidget(activeItemContainer); |
| 707 | } |
| 708 | activeItemContainer->hide(); |
| 709 | } |
| 710 | |
| 711 | if (setAnotherFromSamePlugin && activeNodeForPlugin == n) { |
| 712 | ///If there's another roto node, set it as the current roto interface |
| 713 | ViewerTabPrivate::NodeViewerContextsMap::iterator newInterface = _imp->nodesContext.end(); |
| 714 | for (ViewerTabPrivate::NodeViewerContextsMap::iterator it2 = _imp->nodesContext.begin(); it2 != _imp->nodesContext.end(); ++it2) { |
| 715 | NodeGuiPtr otherNode = it2->first.lock(); |
| 716 | if (!otherNode) { |
| 717 | continue; |
nothing calls this directly
no test coverage detected