00001 // -*- C++ -*- 00002 // 00003 // Package: Core 00004 // Class : FWViewManagerBase 00005 // 00006 // Implementation: 00007 // <Notes on implementation> 00008 // 00009 // Original Author: 00010 // Created: Sat Jan 5 10:56:17 EST 2008 00011 // $Id: FWViewManagerBase.cc,v 1.15 2010/06/18 10:17:16 yana Exp $ 00012 // 00013 00014 // system include files 00015 #include "TClass.h" 00016 #include "TROOT.h" 00017 #include <assert.h> 00018 #include <iostream> 00019 #include <boost/bind.hpp> 00020 00021 // user include files 00022 #include "Fireworks/Core/interface/FWViewManagerBase.h" 00023 #include "Fireworks/Core/interface/FWModelChangeManager.h" 00024 #include "Fireworks/Core/interface/FWColorManager.h" 00025 00026 00027 // 00028 // constants, enums and typedefs 00029 // 00030 00031 // 00032 // static data member definitions 00033 // 00034 00035 // 00036 // constructors and destructor 00037 // 00038 FWViewManagerBase::FWViewManagerBase() : 00039 m_context(0), 00040 m_changeManager(0), 00041 m_colorManager(0) 00042 { 00043 } 00044 00045 // FWViewManagerBase::FWViewManagerBase(const FWViewManagerBase& rhs) 00046 // { 00047 // // do actual copying here; 00048 // } 00049 00050 FWViewManagerBase::~FWViewManagerBase() 00051 { 00052 } 00053 00054 // 00055 // assignment operators 00056 // 00057 // const FWViewManagerBase& FWViewManagerBase::operator=(const FWViewManagerBase& rhs) 00058 // { 00059 // //An exception safe implementation is 00060 // FWViewManagerBase temp(rhs); 00061 // swap(rhs); 00062 // 00063 // return *this; 00064 // } 00065 00066 // 00067 // member functions 00068 // 00069 void* 00070 FWViewManagerBase::createInstanceOf(const TClass* iBaseClass, 00071 const char* iNameOfClass) 00072 { 00073 //create proxy builders 00074 Int_t error; 00075 assert(iBaseClass !=0); 00076 00077 //does the class already exist? 00078 TClass *c = TClass::GetClass( iNameOfClass ); 00079 if(0==c) { 00080 //try to load a macro of that name 00081 00082 //How can I tell if this succeeds or failes? error and value are always 0! 00083 // I could not make the non-compiled mechanism to work without seg-faults 00084 // Int_t value = 00085 gROOT->LoadMacro( (std::string(iNameOfClass)+".C+").c_str(), &error ); 00086 c = TClass::GetClass( iNameOfClass ); 00087 if(0==c ) { 00088 std::cerr <<"failed to find "<< iNameOfClass << std::endl; 00089 return 0; 00090 } 00091 } 00092 void* inst = c->New(); 00093 void* baseClassInst = c->DynamicCast(iBaseClass,inst); 00094 if(0==baseClassInst) { 00095 std::cerr<<"conversion to "<<iBaseClass->ClassName() << " for class " << iNameOfClass << " failed"<<std::endl; 00096 return 0; 00097 } 00098 return baseClassInst; 00099 } 00100 00101 void 00102 FWViewManagerBase::modelChangesComingSlot() 00103 { 00104 //forward call to the virtual function 00105 this->modelChangesComing(); 00106 } 00107 void 00108 FWViewManagerBase::modelChangesDoneSlot() 00109 { 00110 //forward call to the virtual function 00111 this->modelChangesDone(); 00112 } 00113 void 00114 FWViewManagerBase::colorsChangedSlot() 00115 { 00116 this->colorsChanged(); 00117 } 00118 00119 00120 void 00121 FWViewManagerBase::setChangeManager(FWModelChangeManager* iCM) 00122 { 00123 assert(0!=iCM); 00124 m_changeManager = iCM; 00125 m_changeManager->changeSignalsAreComing_.connect(boost::bind(&FWViewManagerBase::modelChangesComing,this)); 00126 m_changeManager->changeSignalsAreDone_.connect(boost::bind(&FWViewManagerBase::modelChangesDone,this)); 00127 } 00128 00129 void 00130 FWViewManagerBase::setColorManager(FWColorManager* iCM) 00131 { 00132 assert(0!= iCM); 00133 m_colorManager = iCM; 00134 m_colorManager->colorsHaveChanged_.connect(boost::bind(&FWViewManagerBase::colorsChanged,this)); 00135 //make sure to pickup any changes that occurred earlier 00136 colorsChanged(); 00137 } 00138 00139 // 00140 // const member functions 00141 // 00142 00143 FWModelChangeManager& 00144 FWViewManagerBase::changeManager() const 00145 { 00146 assert(m_changeManager != 0); 00147 return *m_changeManager; 00148 } 00149 00150 FWColorManager& 00151 FWViewManagerBase::colorManager() const 00152 { 00153 assert(m_colorManager !=0); 00154 return *m_colorManager; 00155 } 00156 00157 00158 // 00159 // static member functions 00160 //