00001 /*************************************************************************** 00002 * Copyright (C) 2006 by Matthew Williams * 00003 * matt@milliams.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU Library General Public License as * 00007 * published by the Free Software Foundation; either version 2 of the * 00008 * License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU Library General Public * 00016 * License along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00021 #ifndef NODE_H 00022 #define NODE_H 00023 00024 #include "boost/signals.hpp" 00025 00026 #include "shape.h" 00027 //#include "edge.h" 00028 #include "libs/maths.h" 00029 00037 namespace sparkle 00038 { 00039 class Shape; //forward declaration to set owner 00040 class Edge; 00041 00043 00048 class Node 00049 { 00050 public: 00052 00053 00059 Node(double initialX, double initialY, Shape* newOwner) : loc(initialX, initialY, 0.0) {setOwner(newOwner);} 00063 ~Node(); 00065 00067 00068 00073 void applyForce(double xForce, double yForce); 00074 00081 void setPosition(double newX, double newY); 00082 00087 void addEdge(Edge* newEdge); 00088 00093 void setOwner(Shape* newOwner); 00095 00105 double getX() const {return loc.getX();} 00106 00112 double getY() const {return loc.getY();} 00113 00117 Vector<double> getVector() const {return loc;} //inline 00118 00123 Shape* owner() const {return ownerShape;} 00125 00126 protected: 00130 sparkle::Vector<double> loc; 00134 Shape *ownerShape; 00138 std::vector<Edge*> edges; 00139 }; 00140 }; 00141 00142 #endif // NODE_H