void GraphTreeModel::updateSelectionStatus(const scene::INodePtr& node, const NotifySelectionUpdateFunc& notifySelectionChanged) { NodeMap::const_iterator found = _nodemap.find(scene::INodeWeakPtr(node)); GraphTreeNodePtr foundNode; if (found == _nodemap.end()) { // The node is not in our map, it might have been previously hidden if (node->visible()) { foundNode = insert(node); } } else { foundNode = found->second; } if (foundNode) { notifySelectionChanged(foundNode->getIter(), Node_isSelected(node)); } }
void visit(const scene::INodePtr& node) const { ASSERT_MESSAGE(_count <= _max, "Invalid _count in CollectSelectedBrushesBounds"); // stop if the array is already full if (_count == _max) { return; } if (Node_isSelected(node) && Node_isBrush(node)) { _bounds[_count] = node->worldAABB(); ++_count; } }
void post(const scene::INodePtr& node) { // greebo: We've traversed this subtree, now check if we had selected children if (!node->isRoot() && !_stack.empty() && _stack.top() == false && !Node_isSelected(node)) { // No selected child nodes, hide this node hideSubgraph(node, _hide); } // Go upwards again, one level _stack.pop(); }
bool pre(const scene::INodePtr& node) { // Don't clone root items if (node->isRoot()) { return true; } if (Node_isSelected(node)) { // Don't traverse children of cloned nodes return false; } return true; }
void post(const scene::INodePtr& node) { if (node->isRoot()) { return; } if (Node_isSelected(node)) { // Clone the current node scene::INodePtr clone = map::Node_Clone(node); // Add the cloned node and its parent to the list _cloned.insert(Map::value_type(clone, node->getParent())); // Insert this node in the root _cloneRoot->addChildNode(clone); } }
void GraphTreeModel::updateSelectionStatus(const Glib::RefPtr<Gtk::TreeSelection>& selection, const scene::INodePtr& node) { NodeMap::const_iterator found = _nodemap.find(scene::INodeWeakPtr(node)); GraphTreeNodePtr foundNode; if (found == _nodemap.end()) { // The node is not in our map, it might have been previously hidden if (node->visible()) { foundNode = insert(node); } } else { foundNode = found->second; } if (foundNode) { if (Node_isSelected(node)) { // Select the row in the TreeView selection->select(foundNode->getIter()); // Scroll to the row Gtk::TreeView* tv = selection->get_tree_view(); Gtk::TreeModel::Path selectedPath(foundNode->getIter()); tv->expand_to_path(selectedPath); tv->scroll_to_row(selectedPath, 0.3f); } else { selection->unselect(foundNode->getIter()); } } }
bool pre(const scene::INodePtr& node) { // Check the selection status bool isSelected = Node_isSelected(node); // greebo: Don't check root nodes for selected state if (!node->isRoot() && isSelected) { // We have a selected instance, "remember" this by setting the parent // stack element to TRUE if (!_stack.empty()) { _stack.top() = true; } } // We are going one level deeper, add a new stack element for this subtree _stack.push(false); // Try to go deeper, but don't do this for deselected instances return !isSelected; }
void post(const scene::INodePtr& node) { if (!node->visible()) { return; } Brush* brush = Node_getBrush(node); if (brush != NULL && !Node_isSelected(node)) { BrushNodePtr brushNode = std::dynamic_pointer_cast<BrushNode>(node); // Get the parent of this brush scene::INodePtr parent = node->getParent(); assert(parent != NULL); // parent should not be NULL BrushPtrVector buffer[2]; std::size_t swap = 0; BrushNodePtr original = std::dynamic_pointer_cast<BrushNode>(brushNode->clone()); //Brush* original = new Brush(*brush); buffer[swap].push_back(original); // Iterate over all selected brushes for (BrushPtrVector::const_iterator i(_brushlist.begin()); i != _brushlist.end(); ++i) { for (BrushPtrVector::iterator j(buffer[swap].begin()); j != buffer[swap].end(); ++j) { if (Brush_subtract(*j, (*i)->getBrush(), buffer[1 - swap])) { // greebo: Delete not necessary, nodes get deleted automatically by clear() below // delete (*j); } else { buffer[1 - swap].push_back(*j); } } buffer[swap].clear(); swap = 1 - swap; } BrushPtrVector& out = buffer[swap]; if (out.size() == 1 && out.back() == original) { // greebo: shared_ptr is taking care of this //delete original; } else { _before++; for (BrushPtrVector::const_iterator i = out.begin(); i != out.end(); ++i) { _after++; scene::INodePtr newBrush = GlobalBrushCreator().createBrush(); parent->addChildNode(newBrush); // Move the new Brush to the same layers as the source node newBrush->assignToLayers(node->getLayers()); (*i)->getBrush().removeEmptyFaces(); ASSERT_MESSAGE(!(*i)->getBrush().empty(), "brush left with no faces after subtract"); Node_getBrush(newBrush)->copy((*i)->getBrush()); } _deleteList.push_back(node); } } }