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]); } }
/*! \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 KantShelling::SetAdjFaces() /* set Brin2Face, Face2Brin, IsOuterV, IsOuterE. b = Face2Brin[num] b and acir[b] defines an angle Moving along a face: cir[-b] or -acir[b] */ {tbrin b, b0; // Mark the vertices incident to the last face Prop<short> ecolor(G.Set(tedge()),PROP_COLOR); Prop<int> ewidth(G.Set(tedge()),PROP_WIDTH); b = b0 = FirstBrin(); do {BelongToLastFace[G.vin[b]()] = 1; if(debug()) {ecolor[b.GetEdge()] = Green2;ewidth[b.GetEdge()] = 3;} }while((b = -G.cir[b]) != b0); IntList Brins; // Brins: list of all brins for(int i = -G.ne();i <= G.ne();i++) if(i)Brins.push(i); // the edge {v_1,v_2}. IsOuterE is set to 0. Brin2Face[FirstBrin()]=1; IsOuterV[v_1] = 1; Brins.del(FirstBrin()); // the outer face is indexed 1 b = G.cir[-FirstBrin]; do {Brins.del(b()); Brin2Face[b()] = 1; IsOuterE[b.GetEdge()] = 1; IsOuterV[G.vin[b]()] = 1; }while ((b = G.cir[-b]) != FirstBrin); Face2Brin[1]=FirstBrin(); // indexing other faces. int FaceIndex=2; while (!Brins.empty()) {b0 = b =Brins.first(); if(debug())cout << "face:" << FaceIndex << endl; do {Brins.del(b()); Brin2Face[b]=FaceIndex; if(debug())cout << G.vin[b]() << " " <<endl; } while((b = G.cir[-b]) != b0); Face2Brin[FaceIndex]=b(); FaceIndex++; } }
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]); } }
static void do_sysinit() { struct utsname uts; const char *sys; /* exec init-early.sh if it exists * This should just setup the console to use the correct * font. Maybe it should setup the keyboard too? */ if (exists(INITEARLYSH)) run_program(INITEARLYSH); uname(&uts); printf("\n %sOpenRC %s" VERSION "%s is starting up %s", ecolor(ECOLOR_GOOD), ecolor(ECOLOR_HILITE), ecolor(ECOLOR_NORMAL), ecolor(ECOLOR_BRACKET)); #ifdef BRANDING printf(BRANDING " (%s)", uts.machine); #else printf("%s %s (%s)", uts.sysname, uts.release, uts.machine); #endif if ((sys = rc_sys())) printf(" [%s]", sys); printf("%s\n\n", ecolor(ECOLOR_NORMAL)); if (!rc_yesno(getenv ("EINFO_QUIET")) && rc_conf_yesno("rc_interactive")) printf("Press %sI%s to enter interactive boot mode\n\n", ecolor(ECOLOR_GOOD), ecolor(ECOLOR_NORMAL)); setenv("RC_RUNLEVEL", RC_LEVEL_SYSINIT, 1); run_program(INITSH); /* init may have mounted /proc so we can now detect or real * sys */ if ((sys = rc_sys())) setenv("RC_SYS", sys, 1); }
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); }
int EmbedPolyline(TopologicalGraph &G) {if(G.nv() < 3 || G.ne() < 2)return -1; int OldNumEdge = G.ne(); PSet1 propSave(G.Set()); G.MakeConnected(); if(!G.FindPlanarMap() ) {Tprintf("Not Planar Graph"); for(tedge e = G.ne(); e > OldNumEdge; e--) G.DeleteEdge(e); return -1; } tbrin FirstBrin = 1; bool MaxPlanar = (G.ne() != 3 * G.nv() - 6) ? false : true; int len; if(!FirstBrin && !MaxPlanar) G.LongestFace(FirstBrin,len); else if(FirstBrin == 0) {FirstBrin = G.extbrin();FirstBrin = -G.acir[FirstBrin];} if(!MaxPlanar && G.ZigZagTriangulate())return -2; svector<short> ecolor(1, G.ne()); SchnyderDecomp(G,FirstBrin,ecolor); GeometricGraph G0(G); //Compute trees tedge ee; Prop<Tpoint> Ebend(G.Set(tedge()),PROP_DRAW_POINT_3); svector<tbrin> FatherB(1,G.nv(),(tbrin)0); FatherB.SetName("FatherB"); svector<tbrin> FatherG(1,G.nv(),(tbrin)0); FatherG.SetName("FatherG"); svector<tbrin> FatherR(1,G.nv(),(tbrin)0); FatherR.SetName("FatherR"); svector<int> x(1,G.nv(),0), y(1,G.nv(),0); x.clear(); y.clear(); compute_parents(G0, Blue, -FirstBrin, FatherB, ecolor); compute_parents(G0, Red, FirstBrin, FatherR, ecolor); compute_parents(G0, Green, -G0.acir[FirstBrin], FatherG, ecolor); // Compute the number of leaves of each tree int nb_leavesB, nb_leavesR, nb_leavesG; nb_leavesB = nb_leaves(G0, Blue, -FirstBrin, ecolor); nb_leavesR = nb_leaves(G0, Red, FirstBrin, ecolor); nb_leavesG = nb_leaves(G0, Green, -G0.acir[FirstBrin], ecolor); // Compute the coordinates using the tree with the minimum number of leaves ForAllEdges(ee, G) Ebend[ee] = Tpoint(-1,-1); if (nb_leavesB <= nb_leavesR && nb_leavesB <= nb_leavesG) compute_coords(G0,Red,Blue,-FirstBrin,FatherB,FatherR,FatherG,ecolor,x,y,Ebend); else if (nb_leavesR <= nb_leavesG) compute_coords(G0,Green,Red,G0.acir[FirstBrin],FatherR,FatherG,FatherB,ecolor,x,y,Ebend); else compute_coords(G0,Blue,Green,G0.acir[-G0.acir[FirstBrin]],FatherG,FatherB,FatherR,ecolor,x,y,Ebend); // computes extremities of vertices Prop<Tpoint> Epoint1(G.Set(tedge()),PROP_DRAW_POINT_1); Prop<Tpoint> Epoint2(G.Set(tedge()),PROP_DRAW_POINT_2); Prop<Tpoint> Vcoord(G.Set(tvertex()),PROP_DRAW_POINT_1); G.Set() = propSave; Prop1<Tpoint> pmin(G.Set(),PROP_POINT_MIN); Prop1<Tpoint> pmax(G.Set(),PROP_POINT_MAX); tvertex vv; pmin() = Tpoint(0,0); pmax() = Tpoint(0,0); ForAllVertices(vv, G0) {Vcoord[vv] = Tpoint(x[vv], y[vv]); if (Vcoord[vv].x() > pmax().x()) pmax().x() = Vcoord[vv].x(); if (Vcoord[vv].y() > pmax().y()) pmax().y() = Vcoord[vv].y(); }