00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TLatex.h"
00013 #include "TEllipse.h"
00014 #include "TGraphNode.h"
00015
00016 #include <gvc.h>
00017
00018 ClassImp(TGraphNode)
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 TGraphNode::TGraphNode(): TNamed(), TAttText()
00029 {
00030
00031
00032 fGVNode = 0;
00033 fX = 0;
00034 fY = 0;
00035 fW = 0;
00036 fH = 0;
00037 }
00038
00039
00040
00041 TGraphNode::TGraphNode(const char *name,const char *title)
00042 :TNamed(name,title), TAttText()
00043 {
00044
00045
00046 fGVNode = 0;
00047 fX = 0;
00048 fY = 0;
00049 fW = 0;
00050 fH = 0;
00051 }
00052
00053
00054
00055 TGraphNode::~TGraphNode()
00056 {
00057
00058
00059 }
00060
00061
00062
00063 void TGraphNode::CreateGVNode(Agraph_t *gv)
00064 {
00065
00066
00067 if (gv) {
00068 fGVNode = agnode(gv, (char *)GetName());
00069 } else {
00070 Error("CreateGVNode","Invalid graphviz graph");
00071 }
00072 }
00073
00074
00075
00076 Int_t TGraphNode::DistancetoPrimitive(Int_t px, Int_t py)
00077 {
00078
00079
00080 Int_t dist;
00081
00082
00083 TEllipse ellipse(fX, fY, fW, fH, 0., 360., 0.);
00084 ellipse.SetFillColor(1);
00085 dist = ellipse.DistancetoPrimitive(px, py);
00086
00087 return dist;
00088 }
00089
00090
00091
00092 void TGraphNode::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00093 {
00094
00095
00096 TEllipse ellipse(fX, fY, fW, fH, 0., 360., 0.);
00097 ellipse.ExecuteEvent(event,px, py);
00098 fX = ellipse.GetX1();
00099 fY = ellipse.GetY1();
00100 fW = ellipse.GetR1();
00101 fH = ellipse.GetR2();
00102 }
00103
00104
00105
00106 void TGraphNode::Layout()
00107 {
00108
00109
00110
00111 #ifdef ND_coord
00112 fX = ND_coord(fGVNode).x;
00113 fY = ND_coord(fGVNode).y;
00114 #endif
00115 #ifdef ND_coord_i
00116 fX = ND_coord_i(fGVNode).x;
00117 fY = ND_coord_i(fGVNode).y;
00118 #endif
00119 fW = ND_width(fGVNode)*36;
00120 fH = ND_height(fGVNode)*36;
00121 }
00122
00123
00124
00125 void TGraphNode::Paint(Option_t *)
00126 {
00127
00128
00129 TEllipse ellipse;
00130 TLatex text;
00131 text.SetTextAlign(22);
00132
00133
00134
00135 ellipse.SetFillStyle(GetFillStyle());
00136 ellipse.SetFillColor(GetFillColor());
00137 ellipse.SetLineColor(GetLineColor());
00138 ellipse.SetLineStyle(GetLineStyle());
00139 ellipse.SetLineWidth(GetLineWidth());
00140 ellipse.PaintEllipse(fX, fY, fW, fH, 0., 360., 0., "");
00141
00142
00143 text.SetTextColor(GetTextColor());
00144 text.SetTextFont(GetTextFont());
00145 text.PaintLatex(fX, fY, 0., GetTextSize(), (char*)GetTitle());
00146 }
00147
00148
00149
00150 void TGraphNode::SavePrimitive(ostream &, Option_t *)
00151 {
00152
00153 }
00154
00155
00156
00157 void TGraphNode::SaveAttributes(ostream &out)
00158 {
00159
00160
00161
00162 SaveFillAttributes(out,GetName(),0,1001);
00163 SaveLineAttributes(out,GetName(),1,1,1);
00164 SaveTextAttributes(out,GetName(),0,0,0,0,0);
00165 }
00166
00167
00168 void TGraphNode::Streamer(TBuffer &)
00169 {
00170 }