![]() |
![]() |
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.45 2010/09/07 15:46:46 yana 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 00048 namespace edm { 00049 class EventBase; 00050 } 00051 namespace fireworks { 00052 class Context; 00053 } 00054 00055 class FWEventItem 00056 { 00057 00058 public: 00059 struct ModelInfo { 00060 FWDisplayProperties m_displayProperties; 00061 bool m_isSelected; 00062 ModelInfo(const FWDisplayProperties& iProps, bool iIsSelected) : 00063 m_displayProperties(iProps), 00064 m_isSelected(iIsSelected) { 00065 } 00066 00067 const FWDisplayProperties& displayProperties() const { 00068 return m_displayProperties; 00069 } 00070 bool isSelected() const { 00071 return m_isSelected; 00072 } 00073 }; 00074 00075 FWEventItem(fireworks::Context* iContext, 00076 unsigned int iItemId, 00077 boost::shared_ptr<FWItemAccessorBase> iAccessor, 00078 const FWPhysicsObjectDesc& iDesc); 00079 //virtual ~FWEventItem(); 00080 00081 // ---------- const member functions --------------------- 00082 #if !defined(__CINT__) && !defined(__MAKECINT__) 00083 template<class T> 00084 void get(const T*& oData) const { 00085 oData=reinterpret_cast<const T*>(data(typeid(T))); 00086 } 00087 #endif 00088 const void* data(const std::type_info&) const; 00089 const FWDisplayProperties& defaultDisplayProperties() const; 00090 00092 int layer() const; 00094 bool isInFront() const; 00096 bool isInBack() const; 00097 00098 const std::string& filterExpression() const; 00101 unsigned int id() const; 00102 const std::string& name() const; 00103 const TClass* type() const; 00105 const std::string& purpose() const; 00106 00107 const std::string& moduleLabel() const; 00108 const std::string& productInstanceLabel() const; 00109 const std::string& processName() const; 00110 00111 const TClass* modelType() const; 00112 ModelInfo modelInfo(int iIndex) const; //return copy for now since want to be able to change visibility 00113 size_t size() const; 00114 const void* modelData(int iIndex) const; 00115 std::string modelName(int iIndex) const; 00116 00118 bool haveInterestingValue() const; 00119 double modelInterestingValue(int iIndex) const; 00120 const std::string& modelInterestingValueAsString(int iIndex) const; 00121 00122 bool isCollection() const; 00123 00124 //convenience methods 00125 00126 const fireworks::Context& context () const { 00127 return *m_context; 00128 } 00129 00130 FWModelChangeManager* changeManager() const { 00131 return m_context->modelChangeManager(); 00132 } 00133 FWSelectionManager* selectionManager() const { 00134 return m_context->selectionManager(); 00135 } 00136 00137 FWColorManager* colorManager() const { 00138 return m_context->colorManager(); 00139 } 00140 00141 bool hasEvent() const { 00142 return 0 != m_event; 00143 } 00144 00145 // hackery methods 00146 const edm::EventBase *getEvent () const { 00147 return m_event; 00148 } 00149 00150 00152 bool hasError() const; 00154 const std::string& errorMessage() const; 00155 00156 // ---------- static member functions -------------------- 00157 00158 static int minLayerValue(); 00159 static int maxLayerValue(); 00160 00161 // ---------- member functions --------------------------- 00162 void setEvent(const edm::EventBase* iEvent); 00163 00164 const FWGeometry* getGeom() const; 00165 00166 void setLabels(const std::string& iModule, 00167 const std::string& iProductInstance, 00168 const std::string& iProcess); 00169 void setName(const std::string& iName); 00170 void setDefaultDisplayProperties(const FWDisplayProperties&); 00172 void setFilterExpression(const std::string& ); 00173 00175 void selectItem(); 00176 void unselectItem(); 00177 void toggleSelectItem(); 00178 bool itemIsSelected() const; 00179 00181 void moveToFront(); 00182 void moveToBack(); 00183 void moveToLayer(int layer); 00184 00185 void unselect(int iIndex) const; 00186 void select(int iIndex) const; 00187 void toggleSelect(int iIndex) const; 00188 void setDisplayProperties(int iIndex, const FWDisplayProperties&) const; 00189 00190 void destroy() const; 00192 mutable FWModelChangeSignal changed_; 00193 00195 mutable FWItemChangeSignal itemChanged_; 00196 00200 mutable FWItemChangeSignal preItemChanged_; 00201 00204 mutable FWItemChangeSignal defaultDisplayPropertiesChanged_; 00205 00207 mutable FWItemChangeSignal filterChanged_; 00208 00211 mutable FWItemChangeSignal goingToBeDestroyed_; 00212 private: 00213 //FWEventItem(const FWEventItem&); // stop default 00214 00215 //const FWEventItem& operator=(const FWEventItem&); // stop default 00216 void setData(const Reflex::Object& ) const; 00217 00218 void getPrimaryData() const; 00219 void runFilter(); 00220 void handleChange(); 00221 // ---------- member data -------------------------------- 00222 const fireworks::Context* m_context; 00223 unsigned int m_id; 00224 std::string m_name; 00225 const TClass* m_type; 00226 std::string m_purpose; 00227 boost::shared_ptr<FWItemAccessorBase> m_accessor; 00228 FWDisplayProperties m_displayProperties; 00229 int m_layer; 00230 mutable std::vector<ModelInfo> m_itemInfos; 00231 00232 //This will probably moved to a FWEventItemRetriever class 00233 std::string m_moduleLabel; 00234 std::string m_productInstanceLabel; 00235 std::string m_processName; 00236 const edm::EventBase* m_event; 00237 ROOT::Reflex::Type m_wrapperType; 00238 FWItemValueGetter m_interestingValueGetter; 00239 00240 FWModelFilter m_filter; 00241 mutable bool m_printedErrorThisEvent; 00242 mutable std::string m_errorMessage; 00243 00244 bool m_isSelected; 00245 }; 00246 00247 00248 #endif