00001 #ifndef Fireworks_Core_FWEventItem_h 00002 #define Fireworks_Core_FWEventItem_h 00003 // -*- C++ -*- 00004 // 00005 // Package: Core 00006 // Class : FWEventItem 00007 // 00016 // 00017 // Original Author: Chris Jones 00018 // Created: Thu Jan 3 14:02:21 EST 2008 00019 // $Id: FWEventItem.h,v 1.50 2012/06/26 22:13:03 wmtan Exp $ 00020 // 00021 00022 // system include files 00023 #include <string> 00024 #include <vector> 00025 #include "Reflex/Type.h" 00026 #include <boost/shared_ptr.hpp> 00027 #include <sigc++/connection.h> 00028 00029 // user include files 00030 #include "Fireworks/Core/interface/FWDisplayProperties.h" 00031 #include "Fireworks/Core/interface/FWPhysicsObjectDesc.h" 00032 #include "Fireworks/Core/interface/FWModelChangeSignal.h" 00033 #include "Fireworks/Core/interface/FWItemChangeSignal.h" 00034 00035 #include "Fireworks/Core/interface/FWModelFilter.h" 00036 #include "Fireworks/Core/interface/FWItemValueGetter.h" 00037 00038 #include "Fireworks/Core/interface/Context.h" 00039 00040 // forward declarations 00041 class TClass; 00042 class FWModelChangeManager; 00043 class FWSelectionManager; 00044 class FWGeometry; 00045 class TVirtualCollectionProxy; 00046 class FWItemAccessorBase; 00047 class FWProxyBuilderConfiguration; 00048 class FWConfiguration; 00049 00050 namespace edm { 00051 class EventBase; 00052 } 00053 namespace fireworks { 00054 class Context; 00055 } 00056 00057 class FWEventItem 00058 { 00059 public: 00060 struct ModelInfo { 00061 FWDisplayProperties m_displayProperties; 00062 bool m_isSelected; 00063 ModelInfo(const FWDisplayProperties& iProps, bool iIsSelected) : 00064 m_displayProperties(iProps), 00065 m_isSelected(iIsSelected) { 00066 } 00067 00068 const FWDisplayProperties& displayProperties() const { 00069 return m_displayProperties; 00070 } 00071 bool isSelected() const { 00072 return m_isSelected; 00073 } 00074 }; 00075 00076 FWEventItem(fireworks::Context* iContext, 00077 unsigned int iItemId, 00078 boost::shared_ptr<FWItemAccessorBase> iAccessor, 00079 const FWPhysicsObjectDesc& iDesc, const FWConfiguration* pbConf = 0); 00080 virtual ~FWEventItem(); 00081 00082 // ---------- const member functions --------------------- 00083 #if !defined(__CINT__) && !defined(__MAKECINT__) 00084 template<class T> 00085 void get(const T*& oData) const { 00086 oData=reinterpret_cast<const T*>(data(typeid(T))); 00087 } 00088 #endif 00089 const void* data(const std::type_info&) const; 00090 const FWDisplayProperties& defaultDisplayProperties() const; 00091 00093 int layer() const; 00095 bool isInFront() const; 00097 bool isInBack() const; 00098 00099 const std::string& filterExpression() const; 00102 unsigned int id() const; 00103 const std::string& name() const; 00104 const TClass* type() const; 00106 const std::string& purpose() const; 00107 00108 const std::string& moduleLabel() const; 00109 const std::string& productInstanceLabel() const; 00110 const std::string& processName() const; 00111 00112 const TClass* modelType() const; 00113 ModelInfo modelInfo(int iIndex) const; //return copy for now since want to be able to change visibility 00114 size_t size() const; 00115 const void* modelData(int iIndex) const; 00116 std::string modelName(int iIndex) const; 00117 00119 const FWItemValueGetter& valueGetter() const { return m_interestingValueGetter; } 00120 bool haveInterestingValue() const; 00121 const std::string& modelInterestingValueAsString(int iIndex) const; 00122 00123 bool isCollection() const; 00124 00125 //convenience methods 00126 00127 const fireworks::Context& context () const { 00128 return *m_context; 00129 } 00130 00131 FWModelChangeManager* changeManager() const { 00132 return m_context->modelChangeManager(); 00133 } 00134 FWSelectionManager* selectionManager() const { 00135 return m_context->selectionManager(); 00136 } 00137 00138 FWColorManager* colorManager() const { 00139 return m_context->colorManager(); 00140 } 00141 00142 bool hasEvent() const { 00143 return 0 != m_event; 00144 } 00145 00146 // hackery methods 00147 const edm::EventBase *getEvent () const { 00148 return m_event; 00149 } 00150 00151 00153 bool hasError() const; 00155 const std::string& errorMessage() const; 00156 00157 // ---------- static member functions -------------------- 00158 00159 static int minLayerValue(); 00160 static int maxLayerValue(); 00161 00162 // ---------- member functions --------------------------- 00163 void setEvent(const edm::EventBase* iEvent); 00164 00165 const FWGeometry* getGeom() const; 00166 FWProxyBuilderConfiguration* getConfig() const { return m_proxyBuilderConfig; } 00167 00168 void setLabels(const std::string& iModule, 00169 const std::string& iProductInstance, 00170 const std::string& iProcess); 00171 void setName(const std::string& iName); 00172 void setDefaultDisplayProperties(const FWDisplayProperties&); 00174 void setFilterExpression(const std::string& ); 00175 00177 void selectItem(); 00178 void unselectItem(); 00179 void toggleSelectItem(); 00180 bool itemIsSelected() const; 00181 00183 void moveToFront(); 00184 void moveToBack(); 00185 void moveToLayer(int layer); 00186 00187 void proxyConfigChanged(); 00188 00189 void unselect(int iIndex) const; 00190 void select(int iIndex) const; 00191 void toggleSelect(int iIndex) const; 00192 void setDisplayProperties(int iIndex, const FWDisplayProperties&) const; 00193 00194 void destroy() const; 00196 mutable FWModelChangeSignal changed_; 00197 00199 mutable FWItemChangeSignal itemChanged_; 00200 00204 mutable FWItemChangeSignal preItemChanged_; 00205 00208 mutable FWItemChangeSignal defaultDisplayPropertiesChanged_; 00209 00211 mutable FWItemChangeSignal filterChanged_; 00212 00215 mutable FWItemChangeSignal goingToBeDestroyed_; 00216 private: 00217 //FWEventItem(const FWEventItem&); // stop default 00218 00219 //const FWEventItem& operator=(const FWEventItem&); // stop default 00220 void setData(const Reflex::Object& ) const; 00221 00222 void getPrimaryData() const; 00223 void runFilter(); 00224 void handleChange(); 00225 // ---------- member data -------------------------------- 00226 const fireworks::Context* m_context; 00227 unsigned int m_id; 00228 std::string m_name; 00229 const TClass* m_type; 00230 std::string m_purpose; 00231 boost::shared_ptr<FWItemAccessorBase> m_accessor; 00232 FWDisplayProperties m_displayProperties; 00233 int m_layer; 00234 mutable std::vector<ModelInfo> m_itemInfos; 00235 00236 //This will probably moved to a FWEventItemRetriever class 00237 std::string m_moduleLabel; 00238 std::string m_productInstanceLabel; 00239 std::string m_processName; 00240 const edm::EventBase* m_event; 00241 Reflex::Type m_wrapperType; 00242 FWItemValueGetter m_interestingValueGetter; 00243 00244 FWModelFilter m_filter; 00245 mutable bool m_printedErrorThisEvent; 00246 mutable std::string m_errorMessage; 00247 00248 bool m_isSelected; 00249 00250 00251 FWProxyBuilderConfiguration* m_proxyBuilderConfig; 00252 }; 00253 00254 00255 #endif