00001 /*! 00002 * \file easel_manager.C 00003 * \brief Contains the implementation of the EaselManager class. 00004 * 00005 * \sa easel_manager.H 00006 * 00007 */ 00008 00009 #include "geom/world.H" 00010 #include "gest/vieweasel.H" 00011 00012 #include "easel_manager.H" 00013 00014 void 00015 EaselManager::make_new_easel(const VIEWptr &v) 00016 { 00017 00018 if(!cur_easel()){ 00019 00020 VIEW_EASELptr easel = new VIEW_EASEL(v); 00021 00022 assert(easel); 00023 00024 cur_easel_idx = easel_list.num(); 00025 easel_list += easel; 00026 00027 WORLD::message("Created new easel"); 00028 00029 } 00030 00031 } 00032 00033 void 00034 EaselManager::undisplay_cur_easel() 00035 { 00036 00037 if(cur_easel()) 00038 cur_easel()->removeEasel(); 00039 00040 cur_easel_idx = -1; 00041 00042 } 00043 00044 void 00045 EaselManager::next_easel() 00046 { 00047 00048 if(num_easels() == 0) 00049 return; 00050 00051 if(cur_easel()) 00052 cur_easel()->removeEasel(); 00053 00054 // Is this a no-op? 00055 cur_easel() = NULL; 00056 00057 // Gently find and set aside the easel 00058 // that will be the new one: 00059 long k = 0; // index of new one 00060 if(cur_easel()) 00061 k = (cur_easel_idx + 1) % num_easels(); 00062 00063 VIEW_EASELptr cur = easel(k); // new one 00064 00065 // Make sure next easel exists and was fetched properly: 00066 assert(cur); 00067 00068 // Now pretend there is no current easel: 00069 cur_easel_idx = -1; 00070 00071 // ... and tell the new one to take charge: 00072 cur->restoreEasel(); 00073 00074 // Whew! That generated camera callbacks, triggering 00075 // Draw_int::notify(), which tried to deactivate the current 00076 // easel. But there is no "current easel," get it?? (wink, wink). 00077 00078 // Enough of the charade. Back to business: 00079 cur_easel_idx = k; 00080 00081 } 00082 00083 void 00084 EaselManager::clear_easels() 00085 { 00086 00087 easel_list.clear(); 00088 cur_easel_idx = -1; 00089 00090 WORLD::message("cleared easels"); 00091 00092 }