Last change
on this file since 6226 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 | |
---|
11 | using namespace VtkVis; |
---|
12 | |
---|
13 | Group::Group() |
---|
14 | { |
---|
15 | } |
---|
16 | |
---|
17 | Group::~Group() |
---|
18 | { |
---|
19 | } |
---|
20 | |
---|
21 | /** |
---|
22 | * \brief Create and initialize VTK Props to render the Group |
---|
23 | */ |
---|
24 | void Group::initProp() |
---|
25 | { |
---|
26 | if (_prop == NULL) { |
---|
27 | _prop = vtkSmartPointer<vtkAssembly>::New(); |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | void Group::update() |
---|
32 | { |
---|
33 | initProp(); |
---|
34 | } |
---|
35 | |
---|
36 | void 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 | |
---|
46 | GraphicsObject *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 | |
---|
56 | GraphicsObject *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 | */ |
---|
76 | void 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.