void Graph :: drawnodes(bool treedee, double sz){ if (treedee) { for (int n=0; n< adjlist.size(); n++) { GraphNode * gn = adjlist.at(n); vec3d point = gn->getPos(); glPushMatrix(); glTranslatef(point.x, point.y, point.z); glScalef(sz, sz, sz); drawsphere (10, 10); glPopMatrix(); } } else { glPointSize(sz); glBegin(GL_POINTS); for (int n=0; n< adjlist.size(); n++) { GraphNode * gn = adjlist.at(n); vec3d point = gn->getPos(); glVertex3d(point.x, point.y, point.z); } glEnd(); pointsz = sz; } }
void Graph :: normalizeinitpos(){ //we want to normalize graph node positions between 0.0 and 1.0 double minx=0.0; double maxx = 1.0; double miny=0.0; double maxy = 1.0; for (int a=0; a<adjlist.size(); a++) { GraphNode * nd = adjlist.at(a); vec3d place = nd->getPos(); minx = min(place.x, minx); maxx = max(place.x, maxx); miny = min(place.y, miny); maxy = max(place.y, maxy); } //printf("min max %f, %f, %f, %f \n", minx, maxx, miny, maxy); double yrange = maxy - miny; double xrange = maxx - minx; for (int a=0; a<adjlist.size(); a++) { GraphNode * nd = adjlist.at(a); vec3d place = nd->getPos(); place.x = (place.x - minx) / xrange; place.y = (place.y - miny) / yrange; nd -> setPos(place); //printf("place of node %f, %f \n", place.x, place.y); } }
Bond::Bond(GraphNode& origin, GraphNode& partner, float strength, sf::RenderWindow& w): m_strength(strength), m_control(new sf::Vector2f(w.getSize().x/2, w.getSize().y/2)), m_origin(&origin), m_partner(&partner), m_graphic(new QuadraticBezier(origin.getPos(), *m_control, partner.getPos(), w)) {}
void Graph :: drawneighbornodes(int ndid, double sz){ //assume threedee vector<GraphNode *> fn = firstNghbrs(ndid); for (int n=0; n<fn.size(); n++) { GraphNode * gn = fn.at(n); vec3d point = gn->getPos(); glPushMatrix(); glTranslatef(point.x, point.y, point.z); glScalef(sz, sz, sz); drawsphere (10, 10); glPopMatrix(); } }