source: vtkvis/trunk/Group.cpp @ 5119

Last change on this file since 5119 was 3683, checked in by ldelgass, 11 years ago

Improvements to 3D shapes in vtkvis. Add preliminary, experimental grouping.

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2004-2012  HUBzero Foundation, LLC
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#include "Group.h"
9#include "Trace.h"
10
11using namespace VtkVis;
12
13Group::Group()
14{
15}
16
17Group::~Group()
18{
19}
20
21/**
22 * \brief Create and initialize VTK Props to render the Group
23 */
24void Group::initProp()
25{
26    if (_prop == NULL) {
27        _prop = vtkSmartPointer<vtkAssembly>::New();
28    }
29}
30
31void Group::update()
32{
33    initProp();
34}
35
36void Group::addChild(const NodeId& name, GraphicsObject *obj)
37{
38    if (obj == NULL)
39        return;
40    if (obj->getProp3D() != NULL) {
41        getAssembly()->AddPart(obj->getProp3D());
42    }
43    _nodes[name] = obj;
44}
45
46GraphicsObject *Group::getChild(const NodeId& name)
47{
48    NodeHashmap::iterator itr = _nodes.find(name);
49    if (itr == _nodes.end()) {
50        return NULL;
51    } else {
52        return itr->second;
53    }
54}
55
56GraphicsObject *Group::removeChild(const NodeId& name)
57{
58    NodeHashmap::iterator itr = _nodes.find(name);
59    if (itr == _nodes.end()) {
60        ERROR("Node not found: '%s'", name.c_str());
61        return NULL;
62    }
63    GraphicsObject *obj = itr->second;
64    if (obj->getProp3D() != NULL) {
65        getAssembly()->RemovePart(obj->getProp3D());
66    }
67    _nodes.erase(itr);
68    return obj;
69}
70
71/**
72 * \brief Set a group of world coordinate planes to clip rendering
73 *
74 * Passing NULL for planes will remove all cliping planes
75 */
76void Group::setClippingPlanes(vtkPlaneCollection *planes)
77{
78    for (NodeHashmap::iterator itr = _nodes.begin();
79         itr != _nodes.end(); ++itr) {
80        itr->second->setClippingPlanes(planes);
81    }
82}
Note: See TracBrowser for help on using the repository browser.