Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DCEdge.h

Go to the documentation of this file.
00001 #ifndef DCEDGE_H
00002 #define DCEDGE_H
00003 
00004 #include <iostream>
00005 #include "TLine.h"
00006 #include "TText.h"
00007 #include "TObject.h"
00008 
00009 template<class T> class DCVertex;
00010 template<class T> class DCGraph;
00011 
00012 using std::cout;
00013 using std::endl;
00014 
00015 template<class T> class DCEdge : public TObject
00016 {
00017 public:
00018    DCEdge(){metric=0;end=0;next=0;}
00019    DCEdge(DCVertex<T> *Vert, DCEdge<T> *nextEdge, 
00020           float m, float xm, float ym, float wm, float wxm, float wym)
00021       {metric=m; xmetric=xm, ymetric=ym; 
00022       wmetric=wm; xwmetric=wxm; ywmetric=wym;
00023       end=Vert; next=nextEdge;}
00024 
00025    virtual ~DCEdge() {delete next;}
00026 
00027    DCVertex<T> *GetEnd() {return end;}
00028    DCEdge<T> *GetNext() {return next;}
00029    float GetMetric() const {return metric;}
00030    float GetXMetric() const {return xmetric;}
00031    float GetYMetric() const {return ymetric;}
00032 
00033    float GetWeighMetric() const {return wmetric;}
00034    float GetXWeighMetric() const {return xwmetric;}
00035    float GetYWeighMetric() const {return ywmetric;}
00036 
00037    virtual void Print(Option_t* option="") const;
00038    void DrawThisEdge(DCVertex<T> *vert,Option_t* option="");
00039 
00040 private:
00041    float metric;
00042    float xmetric;
00043    float ymetric;
00044    float wmetric;
00045    float xwmetric;
00046    float ywmetric;
00047 
00048    DCVertex<T> *end;
00049    DCEdge<T> *next;
00050 
00051    ClassDef(DCEdge<T>,1)
00052 };
00053 
00054 ClassImpT(DCEdge,T)
00055 
00056 template<class T> void DCEdge<T>::Print(Option_t* option) const
00057 {
00058    end->GetData()->Print(option);
00059    cout<<" Metric is "<<metric<<" X "<<xmetric<<" Y "<<ymetric<<endl;
00060    cout<<" Weighted Metric is "<<wmetric<<" WX "<<xwmetric<<" WY "<<ywmetric<<endl;
00061    if (next == 0)
00062       cout << endl;
00063    else {
00064       next->Print(option);
00065    }
00066 }
00067 
00068 template<class T> void DCEdge<T>::DrawThisEdge(DCVertex<T> *vert, Option_t* t)
00069 {
00070 //   cout<<"in DCEdge::DrawThisEdge"<<endl;
00071 //   cout<<"Drawing Edge from ";
00072 //   vert->Print();
00073 //   cout<<" to ";
00074 //   end->Print();
00075 //   cout<<endl;
00076    end->GetData()->Draw();
00077 
00078    float x1=0.;
00079    float y1=0.;
00080    float z1=0.;
00081    vert->GetData()->GetData(x1,y1,z1);
00082    
00083    float x2=0.;
00084    float y2=0.;
00085    float z2=0.;
00086    end->GetData()->GetData(x2,y2,z2);
00087    TLine *l = new TLine(x1,y1,x2,y2);
00088    l->Draw();
00089 
00090    float xtext = (x1+x2)/2.;
00091    float ytext = (y1+y2)/2.;
00092    char dist[10];
00093    sprintf(dist,"d=%.1f",metric);
00094    TText *txt = new TText();
00095    txt->SetTextSize(.02);
00096    txt->DrawText(xtext,ytext,dist);
00097 
00098    if(next!=0){
00099 //      cout<<"going on to next edge"<<endl;
00100       next->DrawThisEdge(vert,t); 
00101    }
00102 
00103 }
00104 
00105 #endif //DCEDGE_H

Generated on Mon Feb 15 11:06:36 2010 for loon by  doxygen 1.3.9.1