void DrawGeneralVisibility(QPainter *p,pigalePaint *paint) {TopologicalGraph G(paint->GCP); Prop<Tpoint> P1(G.Set(tedge()),PROP_DRAW_POINT_1); Prop<Tpoint> P2(G.Set(tedge()),PROP_DRAW_POINT_2); Prop<int> x1(G.Set(tvertex()),PROP_DRAW_INT_1); Prop<int> x2(G.Set(tvertex()),PROP_DRAW_INT_2); Prop<int> x1m(G.Set(tvertex()),PROP_DRAW_INT_3); Prop<int> x2m(G.Set(tvertex()),PROP_DRAW_INT_4); Prop<int> y(G.Set(tvertex()),PROP_DRAW_INT_5); Prop<short> ecolor(G.Set(tedge()),PROP_COLOR); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); Prop<int> ewidth(G.Set(tedge()),PROP_WIDTH,1); double alpha=0.35; Tpoint a,b; p->setFont(QFont("sans",Min((int)(1.8*alpha * Min(paint->xscale,paint->yscale) + .5),13))); for(tvertex v=1;v<=G.nv();v++) {if(x1m[v] != x2m[v]) // always {a.x() = x1m[v]; a.y() = y[v]; b.x() = x2m[v]; b.y() = y[v]; paint->DrawSeg(p,a,b,Black); } paint->DrawText(p,x1[v]-alpha,y[v]+alpha, x2[v]-x1[v]+2*alpha,2*alpha,v,vcolor[v]); } for (tedge e = 1;e <= G.ne();e++) {a.x() = P1[e].x(); a.y() = P1[e].y(); if (a.x()>=x1[G.vin[e]] && a.x()<=x2[G.vin[e]]) a.y()+=alpha; b.x() = P1[e].x(); b.y() = P2[e].y(); if (b.x()>=x1[G.vin[-e]] && b.x()<=x2[G.vin[-e]]) b.y()-=alpha; paint->DrawSeg(p,a,b,ecolor[e],ewidth[e]); } }
bool CGWIC_Cell::InitLand() { std::cout << "InitLand() called" << std::endl; const float dim = GWIC_METERS_PER_CELL * GWIC_IRRUNITS_PER_METER; vector3df pos(posX*dim,groundLevel,posY*dim); vector3df csize(GWIC_IRRUNITS_PER_METER,maxHeight,GWIC_IRRUNITS_PER_METER); SColor vcolor(255,255,255,255); path flnm = GWIC_TERRAIN_DIR + "cell"; flnm += posX; flnm += '-'; flnm += posY; flnm += ".bmp"; terrain = scManager->addTerrainSceneNode(flnm,NULL,GWIC_PICKABLE_MASK,pos,vector3df(0),csize,vcolor,maxLOD,maxPATCH,terraSmooth); if (!terrain) { std::cerr << "Terrain for cell " << posX << ';' << pos.Y << " not found!"; std::cerr << "Using default terrain mesh." << std::endl; flnm = GWIC_TERRAIN_DIR + "default_terrain.bmp"; terrain = scManager->addTerrainSceneNode(flnm,NULL,GWIC_PICKABLE_MASK,pos,vector3df(0),csize,vcolor,maxLOD,maxPATCH,terraSmooth); visible = false; if (!terrain) { std::cerr << "Unable to create terrain for cell " << posX << ';' << posY << std::endl; return false; } } terrain->setMaterialFlag(EMF_LIGHTING,true); terrain->setMaterialType(EMT_SOLID); groundTex = irDriver->getTexture(GWIC_TEXTURES_DIR+initParams.txdpath); if (!groundTex) return false; terrain->setMaterialTexture(0,groundTex); terrain->scaleTexture(initParams.texrepeats); return true; }
void ViewTspCircuit(TSP_Data &tsp) { ListGraph h; ListGraph::NodeMap<string> h_vname(h); // node names ListGraph::NodeMap<Node> h_g2h(tsp.g); // maps a node of g to a node of h ListGraph::NodeMap<double> h_posx(h); ListGraph::NodeMap<double> h_posy(h); ListGraph::NodeMap<int> vcolor(h); // color of the vertices ListGraph::EdgeMap<int> acolor(h); // color of edges ListGraph::EdgeMap<string> aname(h); // name of edges for (ListGraph::NodeIt v(tsp.g); v!=INVALID; ++v) { Node hv; hv = h.addNode(); h_g2h[v] = hv; h_posx[hv] = tsp.posx[v]; h_posy[hv] = tsp.posy[v]; h_vname[hv] = tsp.vname[v]; vcolor[hv] = BLUE; } for (int i=0;i<tsp.NNodes;i++) { ListGraph::Node u,v; ListGraph::Edge a; u = tsp.BestCircuit[i]; v = tsp.BestCircuit[(i+1) % tsp.NNodes]; a = h.addEdge(h_g2h[u] , h_g2h[v]); aname[a] = ""; acolor[a] = BLUE; } ViewListGraph(h,h_vname,aname,h_posx,h_posy,vcolor,acolor,"TSP Circuit with cost "+DoubleToString(tsp.BestCircuitValue)); }
void DrawPolar(QPainter *p,pigalePaint *paint) {TopologicalGraph G(paint->GCP); Prop<Tpoint> Vcoord(G.Set(tvertex()),PROP_DRAW_COORD); Prop<Tpoint> Epoint1(G.Set(tedge()),PROP_DRAW_POINT_1); Prop<Tpoint> Epoint2(G.Set(tedge()),PROP_DRAW_POINT_2); Prop<Tpoint> Epoint11(G.Set(tedge()),PROP_DRAW_POINT_3); Prop<Tpoint> Epoint12(G.Set(tedge()),PROP_DRAW_POINT_4); Prop<Tpoint> Epoint21(G.Set(tedge()),PROP_DRAW_POINT_5); Prop<Tpoint> Epoint22(G.Set(tedge()),PROP_DRAW_POINT_6); Prop<double> Erho (G.Set(tedge()),PROP_DRAW_DBLE_1); Prop<double> Etheta1(G.Set(tedge()),PROP_DRAW_DBLE_2); Prop<double> Etheta2(G.Set(tedge()),PROP_DRAW_DBLE_3); Prop1<double> nw(G.Set(),PROP_DRAW_DBLE_1); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); int m = G.ne(); int ox,oy,nx,ny,theta,dt; QPen pn = p->pen();pn.setWidth(1); for (tedge ee=1; ee<=m; ee++) {if (Erho[ee]==-1) {paint->DrawSeg(p,Epoint1[ee],Epoint2[ee],Red); continue; } if (Epoint11[ee]!=Tpoint(-1,-1)) {paint->DrawSeg(p,Epoint1[ee],Epoint11[ee],Blue); paint->DrawSeg(p,Epoint11[ee],Epoint12[ee],Blue); } else if (Epoint12[ee]!=Tpoint(-1,-1)) paint->DrawSeg(p,Epoint1[ee],Epoint12[ee],Blue); if (Epoint21[ee]!=Tpoint(-1,-1)) {paint->DrawSeg(p,Epoint2[ee],Epoint21[ee],Blue); paint->DrawSeg(p,Epoint21[ee],Epoint22[ee],Blue); } else if (Epoint22[ee]!=Tpoint(-1,-1)) paint->DrawSeg(p,Epoint2[ee],Epoint22[ee],Blue); pn.setColor(color[Blue]);pn.setWidth(2);p->setPen(pn); ox = paint->to_x(-Erho[ee]); oy = paint->to_y(Erho[ee]); nx = (int)(2*Erho[ee]*paint->xscale + .5); ny = (int)(2*Erho[ee]*paint->yscale + .5); theta = (int)(Etheta1[ee]*16*180/PI+.5); dt = (int)((Etheta2[ee] - Etheta1[ee])*16*180/PI+.5); p->drawArc(ox,oy,nx,ny,theta,dt); } // Draw the vertices double dx = .001; for(tvertex v = 1;v <= G.nv();v++) {double x = Vcoord[v].x()-dx*.5; double y = Vcoord[v].y()-dx*.5; Tpoint pt(x,y); paint->DrawText(p,pt, v,vcolor[v],1); } }
/*! \file \brief To display non Fary drawings */ void DrawPolrec(QPainter *p,pigalePaint *paint) {TopologicalGraph G(paint->GCP); Prop1<tstring> title(G.Set(),PROP_TITRE); Prop1<Tpoint> pmin(G.Set(),PROP_POINT_MIN); Prop<Tpoint> p1(G.Set(tvertex()),PROP_DRAW_POINT_1); Prop<Tpoint> p2(G.Set(tvertex()),PROP_DRAW_POINT_2); Prop<double> x1(G.Set(tedge()),PROP_DRAW_DBLE_1 ); Prop<double> x2(G.Set(tedge()),PROP_DRAW_DBLE_2 ); Prop<double> y1(G.Set(tedge()),PROP_DRAW_DBLE_3 ); Prop<double> y2(G.Set(tedge()),PROP_DRAW_DBLE_4); Prop<double> y(G.Set(tedge()),PROP_DRAW_DBLE_5); Prop<short> ecolor(G.Set(tedge()),PROP_COLOR); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); Prop<bool> isTree(G.Set(tedge()),PROP_ISTREE); Prop<int> elabel(G.Set(tedge()),PROP_LABEL); Prop<int> ewidth(G.Set(tedge()),PROP_WIDTH); bool drawTextEdges = (G.ne() < 100); QString stitle(~title()); if(drawTextEdges)paint->DrawText(p,pmin().x(),pmin().y(),stitle); // draw vertices for(tvertex v = 1;v <= G.nv();v++) {double dx = (p2[v].x() - p1[v].x()) ; double x = p1[v].x() ; double y = p1[v].y(); paint->DrawText(p,x,y, dx,1.,v,vcolor[v]); } // draw edges Tpoint e1,e2,e3,e4; for(tedge e = 1;e <= G.ne();e++) {if(isTree[e]) {e1 = Tpoint(x1[e],y1[e]); e2 = Tpoint(x1[e],y2[e]); paint->DrawSeg(p,e1,e2,ecolor[e],ewidth[e]); } else // cotree edges (x1,y1) -> (x1,y) -> (x2,y) -> (x2,y2) {e1 = Tpoint(x1[e],y1[e]); e2 = Tpoint(x1[e],y[e]); e3 = Tpoint(x2[e],y[e]); e4 = Tpoint(x2[e],y2[e]); paint->DrawSeg(p,e1,e2,ecolor[e],ewidth[e]); paint->DrawSeg(p,e2,e3,ecolor[e],ewidth[e]); paint->DrawSeg(p,e3,e4,ecolor[e],ewidth[e]); if(drawTextEdges) {QString label=QString("%1").arg(elabel[e]); // text is drawn at position of lower edge occu paint->DrawText(p,x1[e],y[e],label); } } } }
void DrawFPPVisibility(QPainter *p,pigalePaint *paint) {TopologicalGraph G(paint->GCP); Prop<int> xliv(G.Set(tvertex()),PROP_DRAW_INT_1); Prop<int> xriv(G.Set(tvertex()),PROP_DRAW_INT_2); Prop<int> y(G.Set(tvertex()),PROP_DRAW_INT_3); Prop<int> xje(G.Set(tedge()),PROP_DRAW_INT_4); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); Prop<short> ecolor(G.Set(tedge()),PROP_COLOR); // Draw edges int h1,h2,x1,x2; double alpha = .5; double beta = .825; Tpoint a,b; for(tedge e=1; e <= G.ne();e++) {h1 = y[G.vin[e]]; h2 = y[G.vin[-e]]; x1 = xriv[G.vin[e]]; x2 = xliv[G.vin[-e]]; if(h1 < h2) {a.x() = b.x() = xje[e]; a.y() = h1; b.y() = h2 - 2*alpha; paint->DrawSeg(p,a,b,ecolor[e]); } else if(h1 > h2) {a.x() = b.x() = xje[e]; a.y() = h2; b.y() = h1 - 2*alpha; paint->DrawSeg(p,a,b,ecolor[e]); } else if(x1 < x2) {a.x() = x1 + beta; b.x() = x2 - beta; a.y() = b.y() = h1 -alpha; paint->DrawSeg(p,a,b,ecolor[e]); } else if(x1 > x2) {a.x() = xriv[G.vin[-e]] + beta; b.x() = xliv[G.vin[e]] - beta; a.y() = b.y() = h1 -alpha; paint->DrawSeg(p,a,b,ecolor[e]); } } // Draw vertices double xt = .9*Min(2*alpha*paint->xscale,beta*paint->yscale); p->setFont(QFont("sans",Min((int)(xt + .5),13))); for(tvertex v=1; v <= G.nv();v++) paint->DrawText(p,xliv[v]-beta, y[v], xriv[v]-xliv[v]+2.*beta, 2.*alpha,v,vcolor[v]); }
void DrawTriangle(QPainter *p,pigalePaint *paint) {TopologicalGraph G(paint->GCP); Prop1<Tpoint> pmin(G.Set(),PROP_POINT_MIN); Prop1<Tpoint> pmax(G.Set(),PROP_POINT_MAX); Prop<Tpoint> pleft(G.Set(tvertex()),PROP_DRAW_POINT_1); Prop<Tpoint> pright(G.Set(tvertex()),PROP_DRAW_POINT_2); Prop<Tpoint> ptop(G.Set(tvertex()),PROP_DRAW_POINT_3); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); p->setFont(QFont("sans",Min((int)(Min(paint->xscale,paint->yscale) + .5),13))); for(tvertex iv = 1; iv <= G.nv();iv++) {paint->DrawTriangle(p,pleft[iv],pright[iv],ptop[iv],vcolor[iv]); Tpoint center = (pleft[iv]+pright[iv]+ptop[iv])/3.; paint->DrawText(p,center,iv,vcolor[iv],1); } }
void TextWriter::addGlyphToMesh(Letter &letter, ofRectangle box, ofMesh& mesh) { //float randomness = 0.05; for( int i = 0; i < letter.points.size(); i++ ) { ofVec3f v; v.x = box.x + ofMap(letter.points[i].x + ofRandom(-lineRandomness, lineRandomness), 0, glyphWidth, 0, box.width); v.y = box.y + ofMap(letter.points[i].y + ofRandom(-lineRandomness, lineRandomness), 0, glyphHeight, 0, box.height); mesh.addVertex(v); ofColor vcolor(colour); vcolor.setBrightness(vcolor.getBrightness() * ofRandom(colourFlickerMin, 1)); mesh.addColor(vcolor); } }
void DrawVisibility(QPainter *p,pigalePaint *paint) {TopologicalGraph G(paint->GCP); Prop<Tpoint> P1(G.Set(tedge()),PROP_DRAW_POINT_1); Prop<Tpoint> P2(G.Set(tedge()),PROP_DRAW_POINT_2); Prop<int> x1(G.Set(tvertex()),PROP_DRAW_INT_1); Prop<int> x2(G.Set(tvertex()),PROP_DRAW_INT_2); Prop<int> y(G.Set(tvertex()),PROP_DRAW_INT_5); Prop<short> ecolor(G.Set(tedge()),PROP_COLOR); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); double alpha=0.35; p->setFont(QFont("sans",Min((int)(1.8*alpha * Min(paint->xscale,paint->yscale) + .5),13))); Tpoint a,b; for(tvertex v=1;v<=G.nv();v++) paint->DrawText(p,x1[v]-alpha,y[v]+alpha, x2[v]-x1[v]+2*alpha,2*alpha,v,vcolor[v]); for (tedge e = 1;e <= G.ne();e++) {a.x() = P1[e].x(); a.y() = P1[e].y() + alpha; b.x() = P1[e].x(); b.y() = P2[e].y() - alpha; paint->DrawSeg(p,a,b,ecolor[e]); } }
void DrawCurves(QPainter *p,pigalePaint *paint) {GeometricGraph G(paint->GCP); Prop<Tpoint> Epoint1(G.Set(tedge()),PROP_DRAW_POINT_1); Prop<Tpoint> Epoint2(G.Set(tedge()),PROP_DRAW_POINT_2); Prop<Tpoint> Epoint3(G.Set(tedge()),PROP_DRAW_POINT_3); Prop<Tpoint> vcoord(G.Set(tvertex()),PROP_DRAW_POINT_1); Prop<short> ecolor(G.Set(tedge()),PROP_COLOR); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); int m = G.ne(); int n = G.nv(); QPen pn = p->pen();pn.setWidth(2); QVector<QPoint> bez(7); for (tedge ee=1; ee<=m; ee++) {if (Epoint2[ee]!=Tpoint(0,0)) { bez[0] = QPoint(paint->to_x(vcoord[G.vin[ee]].x()),paint->to_y(vcoord[G.vin[ee]].y())); bez[1] = QPoint(paint->to_x(Epoint1[ee].x()),paint->to_y(Epoint1[ee].y())); bez[2] = QPoint(paint->to_x(Epoint1[ee].x()),paint->to_y(Epoint1[ee].y())); bez[3] = QPoint(paint->to_x(Epoint2[ee].x()),paint->to_y(Epoint2[ee].y())); bez[4] = QPoint(paint->to_x(Epoint3[ee].x()),paint->to_y(Epoint3[ee].y())); bez[5] = QPoint(paint->to_x(Epoint3[ee].x()),paint->to_y(Epoint3[ee].y())); bez[6] = QPoint(paint->to_x(vcoord[G.vin[-ee]].x()),paint->to_y(vcoord[G.vin[-ee]].y())); QPainterPath path; path.moveTo(bez.at(0)); path.cubicTo(bez.at(1),bez.at(2),bez.at(3)); p->strokePath(path, p->pen()); path.moveTo(bez.at(3)); path.cubicTo(bez.at(4),bez.at(5),bez.at(6)); p->strokePath(path, p->pen()); //paint->DrawRect(p,Epoint1[ee],3,3,Red); //paint->DrawRect(p,Epoint3[ee],3,3,Red); } else paint->DrawSeg(p, vcoord[G.vin[ee]], vcoord[G.vin[-ee]] , ecolor[ee]); } // Draw the vertices p->setFont(QFont("sans",Min((int)(10*Min(paint->xscale,paint->yscale) + .5),13))); for(tvertex v = 1;v <= n;v++) paint->DrawText(p,vcoord[v],v,vcolor[v],1); }
void DrawPolyline(QPainter *p,pigalePaint *paint) {GeometricGraph G(paint->GCP); Prop<Tpoint> Vcoord(G.Set(tvertex()),PROP_DRAW_POINT_1); Prop<Tpoint> Epoint1(G.Set(tedge()),PROP_DRAW_POINT_1); Prop<Tpoint> Epoint2(G.Set(tedge()),PROP_DRAW_POINT_2); Prop<Tpoint> Ebend(G.Set(tedge()),PROP_DRAW_POINT_3); Prop<short> ecolor(G.Set(tedge()),PROP_COLOR); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); QPen pn = p->pen();pn.setWidth(2); for (tedge ee=1; ee<= G.ne(); ee++) {if (Ebend[ee] != Tpoint(-1, -1)) {paint->DrawSeg(p, Epoint1[ee], Ebend[ee],ecolor[ee]); paint->DrawSeg(p, Ebend[ee], Epoint2[ee],ecolor[ee]); } else paint->DrawSeg(p, Epoint1[ee], Epoint2[ee] , ecolor[ee]); } // Draw the vertices p->setFont(QFont("sans",Min((int)(.45 * Min(paint->xscale,paint->yscale) + .5),13))); for(tvertex v = 1;v <= G.nv();v++) paint->DrawText(p,Vcoord[v],v,vcolor[v],1); }