00001
00002
00003
00004
00005 #include "gui/DisplayControl.h"
00006 #include "gui/DisplayRep.h"
00007 #include "control/PrintControl.h"
00008 #include "gui/GUI.h"
00009
00010 #if defined(_DEBUG) && defined (_WIN32)
00011 # include <CRTDBG.H>
00012 #endif
00013
00014
00015
00016
00017
00018 class SimpleBox
00019 {
00020 public:
00021 SimpleBox(double a, double b, const std::string& name)
00022 :m_a(a), m_b(b), m_name(name){}
00023 ~SimpleBox(){}
00024 double a()const{return m_a;}
00025 double b()const{return m_b;}
00026 const std::string& name()const{return m_name;}
00027 private:
00028 double m_a, m_b;
00029 std::string m_name;
00030 };
00031
00032
00033
00034 class SimpleBoxRep : public gui::DisplayRep
00035 {
00036 public:
00037 SimpleBoxRep(const SimpleBox* pbox):m_pbox(pbox){}
00038 void update()
00039 {
00040 set_color("blue");
00041 double a = m_pbox->a(), b = m_pbox->b();
00042 move_to(Hep3Vector( a, a, a));
00043 line_to(Hep3Vector( a, b, a));
00044 line_to(Hep3Vector( b, b, a));
00045 line_to(Hep3Vector( b, a, a));
00046 line_to(Hep3Vector( a, a, a));
00047 line_to(Hep3Vector( a, a, b));
00048 line_to(Hep3Vector( a, b, b));
00049 line_to(Hep3Vector( b, b, b));
00050 line_to(Hep3Vector( b, a, b));
00051 line_to(Hep3Vector( a, a, b));
00052 move_to(Hep3Vector( a, b, a));
00053 line_to(Hep3Vector( a, b, b));
00054 move_to(Hep3Vector( b, a, a));
00055 line_to(Hep3Vector( b, a, b));
00056 move_to(Hep3Vector( b, b, a));
00057 line_to(Hep3Vector( b, b, b));
00058 double c = 0.5*(a+b); move_to(Hep3Vector(c,c,c));
00059 drawText(m_pbox->name());
00060 set_color("black");
00061 }
00062 private:
00063 const SimpleBox* m_pbox;
00064 };
00065
00066
00067
00068
00069 int main(int, char** )
00070 {
00071
00072
00073 Menu menu;
00074 GUI* gui = GUI::createGUI();
00075 DisplayControl display(menu, gui->graphicsWindow());
00076 PrintControl printer(gui->textWindow("test"));
00077
00078
00079 SimpleBox box1(10,20, "1");
00080 SimpleBox box2(30,40, "2");
00081 SimpleBox box3(-10,-20, "3");
00082
00083
00084
00085 display.add(new SimpleBoxRep(&box1), "box 1");
00086 display.add(new SimpleBoxRep(&box2), "box 2");
00087 display.add(new SimpleBoxRep(&box3));
00088
00089
00090
00091 menu.run();
00092
00093 #if defined(_DEBUG) && defined (_WIN32)
00094
00095 _CrtSetDbgFlag( _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) | _CRTDBG_LEAK_CHECK_DF);
00096 delete gui;
00097 #endif
00098
00099 return 0;
00100 }
00101
00102 void WARNING(const char* s){std::cerr << s << std::endl;}
00103 void FATAL(const char* s){std::cerr << s << std::endl; exit(-1);}
00104
00105 #ifdef WIN32
00106 extern "C" int UserMain(int argc, char* argv[])
00107 { return main(argc, argv); }
00108 #endif
00109