V-ART
graphicobj.cpp
Go to the documentation of this file.
1 
5 #include "vart/graphicobj.h"
6 #include "vart/transform.h"
7 #include <cassert>
8 #include <list>
9 
10 using namespace std;
11 
13  static unsigned int pickCounter = 0;
14  show = true;
15  howToShow = FILLED;
16  pickName = ++pickCounter;
17 }
18 
20  show = true;
21 }
22 
24  show = false;
25 }
26 
28  show = !show;
29 }
30 
32  list<VART::SceneNode*>::const_iterator iter;
33  VART::GraphicObj* objPtr;
34  VART::Transform* transPtr;
35 
36  for (iter = childList.begin(); iter != childList.end(); ++iter) {
37  objPtr = dynamic_cast<VART::GraphicObj*>(*iter);
38  if (objPtr) { // object is a graphic object
39  objPtr->ToggleVisibility();
40  }
41  else { // object is not a graphic object
42  transPtr = dynamic_cast<VART::Transform*>(*iter);
43  if (transPtr) { // object is a transform
44  transPtr->ToggleRecVisibility();
45  }
46  // If not a transform, then it must be a light. Ignore it.
47  }
48  }
49 }
50 
52  bBox.visible = !bBox.visible;
53 }
54 
56  recBBox.visible = !recBBox.visible;
57 }
58 
60  return show;
61 }
62 
65  list<VART::SceneNode*>::const_iterator iter;
66  VART::GraphicObj* objPtr;
67  VART::Transform* transPtr;
68 
69  recBBox.CopyGeometryFrom(bBox); // start with its own bounding box
70 
71  for (iter = childList.begin(); iter != childList.end(); ++iter) {
72  objPtr = dynamic_cast<VART::GraphicObj*>(*iter);
73  if (objPtr) { // object is a graphic object
75  recBBox.MergeWith(objPtr->GetRecursiveBoundingBox());
76  }
77  else { // object is not a graphic object
78  transPtr = dynamic_cast<VART::Transform*>(*iter);
79  if (transPtr) { // object is a transform
80  if (transPtr->RecursiveBoundingBox(&box)) {
81  recBBox.MergeWith(box);
82  }
83  }
84  // If not a transform, then it must be a light. Ignore it.
85  }
86  }
87  recBBox.ProcessCenter();
88 }
89 
91  list<VART::SceneNode*>::const_iterator iter;
92 
93  glLoadName(pickName);
94  DrawInstanceOGL();
95  for (iter = childList.begin(); iter != childList.end(); ++iter)
96  (*iter)->DrawForPicking();
97 }
void ToggleRecVisibility()
Toggles the recursive object's visibility.
Definition: transform.cpp:340
virtual void DrawForPicking() const
Draws and object, setting pick info.
Definition: graphicobj.cpp:90
Header file for V-ART class "GraphicObj".
void Hide()
Makes the object invisible.
Definition: graphicobj.cpp:23
void ComputeRecursiveBoundingBox()
Computes the recursive bounding box.
Definition: graphicobj.cpp:63
void ToggleVisibility()
Toggles the object's visibility.
Definition: graphicobj.cpp:27
bool IsVisible()
Checks whether the object is visible.
Definition: graphicobj.cpp:59
Axis aligned bounding box.
Definition: boundingbox.h:23
Geometric transformations.
Definition: transform.h:24
void ToggleRecVisibility()
Toggles the recursive object's visibility.
Definition: graphicobj.cpp:31
virtual bool RecursiveBoundingBox(BoundingBox *bBox)
Returns the recursive bounding box.
Definition: transform.cpp:293
An scene node that is associated with a shape.
Definition: graphicobj.h:18
void Show()
Makes the object visible.
Definition: graphicobj.cpp:19
Header file for V-ART class "Transform".
void ToggleRecBBoxVisibility()
Toggles the recursive bounding box visibility.
Definition: graphicobj.cpp:55
void ToggleBBoxVisibility()
Toggles the bounding box visibility.
Definition: graphicobj.cpp:51
const BoundingBox & GetRecursiveBoundingBox() const
Returns the recursive bounding box.
Definition: graphicobj.h:58