Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:31

0001 #ifndef Fireworks_Core_FWEventItem_h
0002 #define Fireworks_Core_FWEventItem_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Core
0006 // Class  :     FWEventItem
0007 //
0008 /**\class FWEventItem FWEventItem.h Fireworks/Core/interface/FWEventItem.h
0009 
0010    Description: Stand in for a top level item in an Event
0011 
0012    Usage:
0013     <usage>
0014 
0015  */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Thu Jan  3 14:02:21 EST 2008
0019 //
0020 
0021 // system include files
0022 #include <string>
0023 #include <vector>
0024 #include "FWCore/Reflection/interface/TypeWithDict.h"
0025 #include <memory>
0026 #include <sigc++/connection.h>
0027 
0028 // user include files
0029 #include "Fireworks/Core/interface/FWDisplayProperties.h"
0030 #include "Fireworks/Core/interface/FWPhysicsObjectDesc.h"
0031 #include "Fireworks/Core/interface/FWModelChangeSignal.h"
0032 #include "Fireworks/Core/interface/FWItemChangeSignal.h"
0033 
0034 #include "Fireworks/Core/interface/FWModelFilter.h"
0035 #include "Fireworks/Core/interface/FWItemValueGetter.h"
0036 
0037 #include "Fireworks/Core/interface/Context.h"
0038 
0039 // forward declarations
0040 class TClass;
0041 class FWModelChangeManager;
0042 class FWSelectionManager;
0043 class FWGeometry;
0044 class TVirtualCollectionProxy;
0045 class FWItemAccessorBase;
0046 class FWProxyBuilderConfiguration;
0047 class FWConfiguration;
0048 
0049 namespace edm {
0050   class EventBase;
0051 }
0052 namespace fireworks {
0053   class Context;
0054 }
0055 
0056 class FWEventItem {
0057 public:
0058   struct ModelInfo {
0059     FWDisplayProperties m_displayProperties;
0060     bool m_isSelected;
0061     ModelInfo(const FWDisplayProperties& iProps, bool iIsSelected)
0062         : m_displayProperties(iProps), m_isSelected(iIsSelected) {}
0063 
0064     const FWDisplayProperties& displayProperties() const { return m_displayProperties; }
0065     bool isSelected() const { return m_isSelected; }
0066   };
0067 
0068   FWEventItem(fireworks::Context* iContext,
0069               unsigned int iItemId,
0070               std::shared_ptr<FWItemAccessorBase> iAccessor,
0071               const FWPhysicsObjectDesc& iDesc,
0072               const FWConfiguration* pbConf = nullptr);
0073   virtual ~FWEventItem();
0074 
0075   // ---------- const member functions ---------------------
0076 #if !defined(__CINT__) && !defined(__MAKECINT__)
0077   template <class T>
0078   void get(const T*& oData) const {
0079     oData = reinterpret_cast<const T*>(data(typeid(T)));
0080   }
0081 #endif
0082   const void* data(const std::type_info&) const;
0083   const FWDisplayProperties& defaultDisplayProperties() const;
0084 
0085   /** objects with a larger layer number are drawn on top of objects with a lower number */
0086   int layer() const;
0087   ///returns true if item is in front of all other items
0088   bool isInFront() const;
0089   ///returns true if item is behind all other items
0090   bool isInBack() const;
0091 
0092   const std::string& filterExpression() const;
0093   /**Unique ID for the item. This number starts at 0 and increments by one for each
0094       new item.*/
0095   unsigned int id() const;
0096   const std::string& name() const;
0097   const TClass* type() const;
0098   /** Since the same C++ type can be used for multiple purposes, this string disambiguates them.*/
0099   const std::string& purpose() const;
0100 
0101   const std::string& moduleLabel() const;
0102   const std::string& productInstanceLabel() const;
0103   const std::string& processName() const;
0104 
0105   const TClass* modelType() const;
0106   ModelInfo modelInfo(int iIndex) const;  //return copy for now since want to be able to change visibility
0107   size_t size() const;
0108   const void* modelData(int iIndex) const;
0109   std::string modelName(int iIndex) const;
0110 
0111   ///one value from the model which is normally used for the popup
0112   const FWItemValueGetter& valueGetter() const { return m_interestingValueGetter; }
0113   bool haveInterestingValue() const;
0114   const std::string& modelInterestingValueAsString(int iIndex) const;
0115 
0116   bool isCollection() const;
0117 
0118   void resetColor();
0119   //convenience methods
0120 
0121   const fireworks::Context& context() const { return *m_context; }
0122 
0123   FWModelChangeManager* changeManager() const { return m_context->modelChangeManager(); }
0124   FWSelectionManager* selectionManager() const { return m_context->selectionManager(); }
0125 
0126   FWColorManager* colorManager() const { return m_context->colorManager(); }
0127 
0128   bool hasEvent() const { return nullptr != m_event; }
0129 
0130   // hackery methods
0131   const edm::EventBase* getEvent() const { return m_event; }
0132 
0133   ///returns true if failed to get data for this event
0134   bool hasError() const;
0135   ///returns error string if there was a problem this event
0136   const std::string& errorMessage() const;
0137 
0138   // ---------- static member functions --------------------
0139 
0140   static int minLayerValue();
0141   static int maxLayerValue();
0142 
0143   // ---------- member functions ---------------------------
0144   void setEvent(const edm::EventBase* iEvent);
0145 
0146   void setData(const edm::ObjectWithDict&) const;
0147 
0148   void getPrimaryData() const;
0149   const FWGeometry* getGeom() const;
0150   FWProxyBuilderConfiguration* getConfig() const { return m_proxyBuilderConfig; }
0151 
0152   void setLabels(const std::string& iModule, const std::string& iProductInstance, const std::string& iProcess);
0153   void setName(const std::string& iName);
0154   void setDefaultDisplayProperties(const FWDisplayProperties&);
0155   /**Throws an FWExpresionException if there is a problem with the expression */
0156   void setFilterExpression(const std::string&);
0157 
0158   /**Select the item (i.e. container) itself*/
0159   void selectItem();
0160   void unselectItem();
0161   void toggleSelectItem();
0162   bool itemIsSelected() const;
0163 
0164   /**change layering*/
0165   void moveToFront();
0166   void moveToBack();
0167   void moveToLayer(int layer);
0168 
0169   void proxyConfigChanged(bool k = false);
0170 
0171   void unselect(int iIndex) const;
0172   void select(int iIndex) const;
0173   void toggleSelect(int iIndex) const;
0174   void setDisplayProperties(int iIndex, const FWDisplayProperties&) const;
0175 
0176   void destroy() const;
0177   /** connect to this signal if you want to know when models held by the item change */
0178   mutable FWModelChangeSignal changed_;
0179 
0180   /** connect to this signal if you want to know when the data underlying the item changes */
0181   mutable FWItemChangeSignal itemChanged_;
0182 
0183   /** connect to this signal if you want to know immediately when the data underlying the item changes
0184       only intended to be used by the FWSelectionManager
0185     */
0186   mutable FWItemChangeSignal preItemChanged_;
0187 
0188   /** connect to this signal if you want to know that the default display properties of the item have changed.
0189       This is only useful if you are displaying these properties and not just the underlying models.*/
0190   mutable FWItemChangeSignal defaultDisplayPropertiesChanged_;
0191 
0192   /** connect to this signal if you want to know that the filter being applied to the item was changed. */
0193   mutable FWItemChangeSignal filterChanged_;
0194 
0195   /** connect to this signal if you need to know that this item is going to be destroyed.
0196     */
0197   mutable FWItemChangeSignal goingToBeDestroyed_;
0198 
0199 private:
0200   //FWEventItem(const FWEventItem&); // stop default
0201 
0202   //const FWEventItem& operator=(const FWEventItem&); // stop default
0203 
0204   void runFilter();
0205   void handleChange();
0206   // ---------- member data --------------------------------
0207   const fireworks::Context* m_context;
0208   unsigned int m_id;
0209   std::string m_name;
0210   const TClass* m_type;
0211   std::string m_purpose;
0212   std::shared_ptr<FWItemAccessorBase> m_accessor;
0213   FWDisplayProperties m_displayProperties;
0214   int m_layer;
0215   mutable std::vector<ModelInfo> m_itemInfos;
0216 
0217   //This will probably moved to a FWEventItemRetriever class
0218   std::string m_moduleLabel;
0219   std::string m_productInstanceLabel;
0220   std::string m_processName;
0221   const edm::EventBase* m_event;
0222   edm::TypeWithDict m_wrapperType;
0223   FWItemValueGetter m_interestingValueGetter;
0224 
0225   FWModelFilter m_filter;
0226   mutable bool m_printedErrorThisEvent;
0227   mutable std::string m_errorMessage;
0228 
0229   bool m_isSelected;
0230   Color_t m_origColor;
0231 
0232   FWProxyBuilderConfiguration* m_proxyBuilderConfig;
0233 };
0234 
0235 #endif