00001 #include "PointSet.h"
00002 #include "RenderingNodes.h"
00003
00004 #include <iostream>
00005
00006 using namespace X3DTK;
00007 using namespace std;
00008
00009 PointSet::PointSet()
00010 : X3DGeometryNode(), color_(0), coord_(0)
00011 {
00012 defineTagName("PointSet", "Rendering");
00013 }
00014
00015 PointSet::PointSet(const X3DColorNode *color, const X3DCoordinateNode *coord)
00016 : X3DGeometryNode(), color_((SFNode)color), coord_((SFNode)coord)
00017 {
00018 defineTagName("PointSet", "Rendering");
00019 }
00020
00021
00022 PointSet::PointSet(const PointSet &P)
00023 : X3DGeometryNode(P), color_(P.color_), coord_(P.coord_)
00024 {
00025 defineTagName("PointSet", "Rendering");
00026 }
00027
00028 SFNode PointSet::clone() const
00029 {
00030 return new PointSet(*this);
00031 }
00032
00033 PointSet::~PointSet()
00034 {
00035 }
00036
00037
00038 void PointSet::setColor(const X3DColorNode *color)
00039 {
00040 removeLink(this, color_);
00041 color_ = (SFNode)color;
00042 removeLink(this, color_);
00043 }
00044
00045 void PointSet::setCoord(const X3DCoordinateNode *coord)
00046 {
00047 removeLink(this, coord_);
00048 coord_ = (SFNode)coord;
00049 removeLink(this, coord_);
00050 }
00051
00052 bool PointSet::addChild(const SFNode &N)
00053 {
00054 if (dynamic_cast<X3DColorNode *>(N) != 0)
00055 {
00056 if (color_ != 0)
00057 return false;
00058
00059 setColor(static_cast<X3DColorNode *>(N));
00060 return true;
00061 }
00062
00063 if (dynamic_cast<X3DCoordinateNode *>(N) != 0)
00064 {
00065 if (coord_ != 0)
00066 return false;
00067
00068 setCoord(static_cast<X3DCoordinateNode *>(N));
00069 return true;
00070 }
00071
00072 cerr << "PointSet::addChild : a node of type " << N->getTypeName() << " cannot be a child!" << endl;
00073 return false;
00074 }
00075
00076 bool PointSet::setChild(const SFNode &N)
00077 {
00078 if (dynamic_cast<X3DColorNode *>(N) != 0)
00079 {
00080 setColor(static_cast<X3DColorNode *>(N));
00081 return true;
00082 }
00083
00084 if (dynamic_cast<X3DCoordinateNode *>(N) != 0)
00085 {
00086 setCoord(static_cast<X3DCoordinateNode *>(N));
00087 return true;
00088 }
00089
00090 cerr << "PointSet::setChild : a node of type " << N->getTypeName() << " cannot be a child!" << endl;
00091 return false;
00092 }
00093
00094 bool PointSet::removeChild(const SFNode &N)
00095 {
00096 if (color_ == N)
00097 {
00098 setColor(0);
00099 return true;
00100 }
00101
00102 if (coord_ == N)
00103 {
00104 setCoord(0);
00105 return true;
00106 }
00107
00108 return false;
00109 }
00110
00111 void PointSet::removeScenesToChildren(const MFScene &sceneList)
00112 {
00113 removeScenes(color_, sceneList);
00114 removeScenes(coord_, sceneList);
00115 }
00116
00117 void PointSet::addScenesToChildren(const MFScene &sceneList)
00118 {
00119 addScenes(color_, sceneList);
00120 addScenes(coord_, sceneList);
00121 }