00001 //---------------------------------------------------------------------- 00002 // The Motion Strategy Library (MSL) 00003 //---------------------------------------------------------------------- 00004 // 00005 // Copyright (c) 1998-2000 Iowa State University and Steve LaValle. 00006 // All Rights Reserved. 00007 // 00008 // Permission to use, copy, and distribute this software and its 00009 // documentation is hereby granted free of charge, provided that 00010 // (1) it is not a component of a commercial product, and 00011 // (2) this notice appears in all copies of the software and 00012 // related documentation. 00013 // 00014 // Iowa State University and the author make no representations 00015 // about the suitability or fitness of this software for any purpose. 00016 // It is provided "as is" without express or implied warranty. 00017 //---------------------------------------------------------------------- 00018 00019 #include <math.h> 00020 #include <stdio.h> 00021 #include <fstream.h> 00022 00023 #include "gui.h" 00024 #include "defs.h" 00025 00026 #include <LEDA/REDEFINE_NAMES.h> 00027 00028 00030 // 00031 // Gui class 00032 // 00034 00035 Gui::Gui(Render *render) { 00036 R = render; 00037 00038 FilePath = R->FilePath; 00039 } 00040 00041 00042 void Gui::Init() 00043 { 00044 // Perform Render initialization 00045 R->Init(); 00046 } 00047 00048 00049 00050 void Gui::Start() 00051 { 00052 // Perform initialization 00053 Init(); 00054 00055 // Enter the event processing loop 00056 MainLoop(); 00057 } 00058 00059 00060 00061 void Gui::HandleEvents() 00062 { 00063 double x,y; 00064 int val,e; 00065 window *wp = NULL; 00066 00067 e = get_event(wp,val,x,y); 00068 00069 if (e == button_press_event) { 00070 // The Gui window buttons 00071 if (wp == W) 00072 ButtonHandle(val); 00073 // The Render control window buttons 00074 if ((R->RenderCtlWindowOn)&&(wp == R->RenderCtlWindow)) { 00075 R->ButtonHandle(val); 00076 R->RenderCtlWindow->redraw_panel(); 00077 } 00078 } 00079 } 00080 00081 00082 00083 void Gui::MainLoop() 00084 { 00085 if (R->ControlFreak) { // Does the renderer NEED to be in control? 00086 R->MainLoop(this); // Give a pointer to this Gui 00087 // It is the responsibility of Render to handle Gui events 00088 } 00089 else { 00090 Finished = false; 00091 while (!Finished) { 00092 R->HandleEvents(); // Handle events in the renderer 00093 HandleEvents(); 00094 } 00095 } 00096 00097 R->Terminate(); // If we ever get here (some control freaks don't allow it) 00098 } 00099 00100 00101 #include <LEDA/UNDEFINE_NAMES.h> 00102