#include #include #include #include #include #include #include #include #include #include #include #include #include "IDelaunay2D.hxx" class IQuitPanel : public TGMainFrame { private: TGTextButton *fButton1; TGLayoutHints *fLayout1; void QuitProgram(void); enum {QuitButton}; public: IQuitPanel(const TGWindow *p, UInt_t w, UInt_t h); ~IQuitPanel(); Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); }; IQuitPanel::IQuitPanel(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p,w,h) { // Create a main frame with a number of different buttons. fButton1 = new TGTextButton(this, "&Quit", QuitButton); fLayout1 = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX | kLHintsExpandY); AddFrame(fButton1, fLayout1); MapSubwindows(); Layout(); SetWindowName("Button Control"); SetIconName("Button Control "); MapWindow(); } IQuitPanel::~IQuitPanel(void) { delete fButton1; delete fLayout1; } Bool_t IQuitPanel::ProcessMessage(Long_t msg, Long_t parm1, Long_t) { // Process events generated by the buttons in the frame. switch (GET_MSG(msg)) { case kC_COMMAND: switch (GET_SUBMSG(msg)) { case kCM_BUTTON: printf("text button id %ld pressed\n", parm1); if( parm1 == QuitButton ) QuitProgram(); default: break; } } gROOT->Reset(); return kTRUE; } COMET::IDelaunay2D* gDelaunay = NULL; void IQuitPanel::QuitProgram(void) { delete gDelaunay; exit(0); } int main(int argc, char **argv) { int points = 2; if (argc>1) { std::istringstream arg(argv[1]); arg >> points; } //Initialize GUI TApplication theApp("App",&argc,argv); TCanvas* mainCanvas = new TCanvas ("gMainCanvas","Tracks",200,10,1000,1200); new IQuitPanel(gClient->GetRoot(), 100, 150); mainCanvas = new TCanvas ("gMainCanvas","Tracks",200,10,1000,1200); TH2F *drawRegion = new TH2F("drawRegion","Triangulation", 800,0,+20, 800,0,+20); drawRegion->SetStats(false); gDelaunay = new COMET::IDelaunay2D; TRandom ran; std::cout << "Triangulation started " << std::endl; #ifdef FIXED_POINTS // Add points at the same X. double xFixed = ran.Gaus(); for (int i=0; i<10; ++i) { double y = ran.Gaus(); gDelaunay->AddPoint(new COMET::IMeshXYPoint(xFixed,y)); } // Add points at the same Y. for (int i=0; i<10; ++i) { double y = ran.Gaus(); gDelaunay->AddPoint(new COMET::IMeshXYPoint(y,xFixed)); } #endif gDelaunay->AddPoint(new COMET::IMeshXYPoint(10,10)); gDelaunay->AddPoint(new COMET::IMeshXYPoint(4,10)); gDelaunay->AddPoint(new COMET::IMeshXYPoint(10,4)); gDelaunay->AddPoint(new COMET::IMeshXYPoint(12,12)); // Add the requested number of points. for (int i=0; iAddPoint(new COMET::IMeshXYPoint(x,y)); } for (int i=0; iAddPoint(new COMET::IMeshXYPoint(x,y)); } gDelaunay->Close(); std::cout << "Triangulation finished " << std::endl; if (points>100000) { std::cout << "Exiting without drawing (to many points)." << std::endl; exit(0); } gDelaunay->SetMarkerStyle(8); gDelaunay->SetMarkerColor(2); gDelaunay->SetLineColor(4); drawRegion->Draw(); gDelaunay->Draw(); theApp.Run(); }