#include "RooFit.h"
#include "RooGraphEdge.h"
#include "RooGraphEdge.h"
#include "TLine.h"
#include "TArrow.h"
#include "TList.h"
#include "Riostream.h"
#include <fstream>
ClassImp(RooGraphEdge)
RooGraphEdge::RooGraphEdge()
{
fn1 = 0;
fn2 = 0;
fes = "aLine";
}
RooGraphEdge::RooGraphEdge(RooGraphNode *n1, RooGraphNode *n2)
{
fn1 = n1;
fn2 = n2;
fes = "aLine";
}
RooGraphEdge::RooGraphEdge(RooGraphNode *n1, RooGraphNode *n2, TString es)
{
fn1 = n1;
fn2 = n2;
fes = es;
}
void RooGraphEdge::print()
{
cout << fn1->GetName() << ", " << fn2->GetName() << endl;
}
void RooGraphEdge::read(ifstream &file)
{
TString ies;
TString firstnode;
TString secondnode;
file.seekg(4, ios::cur);
file >> ies >> firstnode >> secondnode;
char eol;
file.get(eol);
fes = ies;
ffirstnode = firstnode;
fsecondnode = secondnode;
}
void RooGraphEdge::Set1stNode(RooGraphNode *n1)
{
fn1 = n1;
}
void RooGraphEdge::Set2ndNode(RooGraphNode *n2)
{
fn2 = n2;
}
void RooGraphEdge::Connect()
{
double x1 = fn1->GetX1();
double y1 = fn1->GetY1();
double x2 = fn2->GetX1();
double y2 = fn2->GetY1();
if (fes=="aLine"){
TLine *l = new TLine(x1,y1,x2,y2);
l->Draw();
}
if (fes=="Arrow"){
TArrow *a = new TArrow(x1,y1,x2,y2,0.02F,"|>");
a->Draw();
}
}
void RooGraphEdge::Connect(int color)
{
double x1 = fn1->GetX1();
double y1 = fn1->GetY1();
double x2 = fn2->GetX1();
double y2 = fn2->GetY1();
if (fes=="aLine"){
TLine *l = new TLine(x1,y1,x2,y2);
l->SetLineColor(color);
l->Draw();
}
if (fes=="Arrow"){
TArrow *a = new TArrow(x1,y1,x2,y2,0.02F,"|>");
a->SetLineColor(color);
a->Draw();
}
}
void RooGraphEdge::Connect(RooGraphNode *n1, RooGraphNode *n2)
{
fn1 = n1;
fn2 = n2;
double x1 = fn1->GetX1();
double y1 = fn1->GetY1();
double x2 = fn2->GetX1();
double y2 = fn2->GetY1();
if (fes=="aLine"){
TLine *l = new TLine(x1,y1,x2,y2);
l->Draw();
}
if (fes=="Arrow"){
TArrow *a = new TArrow(x1,y1,x2,y2,0.02F,"|>");
a->Draw();
}
}
double RooGraphEdge::GetInitialDistance()
{
const double x1 = fn1->GetX1();
const double y1 = fn1->GetY1();
const double x2 = fn2->GetX1();
const double y2 = fn2->GetY1();
double ilength = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
return ilength;
}
TObject *RooGraphEdge::GetType(TList *padlist)
{
TObject *obj = padlist->First();
while(obj != 0)
{
if (obj->InheritsFrom("TLine"))
{
TLine *line = dynamic_cast<TLine*>(obj);
double x1 = line->GetX1();
double y1 = line->GetY1();
double x2 = line->GetX2();
double y2 = line->GetY2();
double X1 = fn1->GetX1();
double Y1 = fn1->GetY1();
double X2 = fn2->GetX1();
double Y2 = fn2->GetY1();
if (x1==X1&&y1==Y1&&x2==X2&&y2==Y2)
{ obj = line; break; }
}
if (obj->InheritsFrom("TArrow"))
{
TArrow *arrow = dynamic_cast<TArrow*>(obj);
double x1 = arrow->GetX1();
double y1 = arrow->GetY1();
double x2 = arrow->GetX2();
double y2 = arrow->GetY2();
double X1 = fn1->GetX1();
double Y1 = fn1->GetY1();
double X2 = fn2->GetX1();
double Y2 = fn2->GetY1();
if (x1==X1&&y1==Y1&&x2==X2&&y2==Y2)
{ obj = arrow; break; }
}
obj = padlist->After(obj);
}
return obj;
}
double RooGraphEdge::GetX1()
{
const double x1 = fn1->GetX1();
return x1;
}
double RooGraphEdge::GetY1()
{
const double y1 = fn1->GetY1();
return y1;
}
double RooGraphEdge::GetX2()
{
const double x2 = fn2->GetX1();
return x2;
}
double RooGraphEdge::GetY2()
{
const double y2 = fn2->GetY1();
return y2;
}
void RooGraphEdge::SwitchNodes()
{
RooGraphNode *n1 = fn1;
RooGraphNode *n2 = fn2;
fn1 = n2;
fn2 = n1;
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.