CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Core/interface/FWProxyBuilderBase.h

Go to the documentation of this file.
00001 #ifndef Fireworks_Core_FWProxyBuilderBase_h
00002 #define Fireworks_Core_FWProxyBuilderBase_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Core
00006 // Class  :     FWProxyBuilderBase
00007 // 
00016 //
00017 // Original Author:  Chris Jones, Matevz Tadel, Alja Mrak-Tadel
00018 //         Created:  Thu Mar 18 14:12:12 CET 2010
00019 // $Id: FWProxyBuilderBase.h,v 1.16 2010/10/22 14:34:45 amraktad Exp $
00020 //
00021 
00022 // system include files
00023 #include "sigc++/connection.h"
00024 
00025 // user include files
00026 
00027 // user include files
00028 #include "Fireworks/Core/interface/FWEvePtr.h"
00029 #include "Fireworks/Core/interface/FWViewType.h"
00030 #include "Fireworks/Core/interface/FWProxyBuilderFactory.h"
00031 #include "Fireworks/Core/interface/FWModelChangeSignal.h"
00032 #include "Fireworks/Core/interface/FWModelIdFromEveSelector.h"
00033 #include "Fireworks/Core/interface/FWViewContext.h"
00034 
00035 // forward declarations
00036 
00037 class FWEventItem;
00038 class TEveElementList;
00039 class TEveElement;
00040 class FWModelId;
00041 class FWInteractionList;
00042 
00043 namespace fireworks {
00044    class Context;
00045 }
00046 
00047 class FWProxyBuilderBase
00048 {
00049 public:
00050 
00051    struct Product
00052    {
00053       FWViewType::EType     m_viewType;
00054       const FWViewContext*  m_viewContext;
00055       TEveElementList*      m_elements;
00056       sigc::connection      m_scaleConnection;
00057 
00058       Product(FWViewType::EType t, const FWViewContext* c);
00059       ~Product();
00060    };
00061 
00062    FWProxyBuilderBase();
00063    virtual ~FWProxyBuilderBase();
00064 
00065    // ---------- const member functions ---------------------
00066 
00067    const fireworks::Context& context() const;
00068    const FWEventItem* item() const {
00069       return m_item;
00070    }
00071    // ---------- static member functions --------------------
00073    static std::string typeOfBuilder();
00074 
00078    static bool representsSubPart();
00079    // ---------- member functions ---------------------------
00080    void setItem(const FWEventItem* iItem);
00081    void setHaveWindow(bool iFlag);
00082    void build();
00083 
00084    void modelChanges(const FWModelIds&);
00085    void itemChanged(const FWEventItem*);
00086    void scaleChanged(const FWViewContext*);
00087 
00088    virtual bool canHandle(const FWEventItem&);//note pass FWEventItem to see if type and container match
00089 
00090 
00091    virtual void setInteractionList(FWInteractionList*, const std::string&);
00092    virtual void itemBeingDestroyed(const FWEventItem*);
00093 
00094    // const member functions   
00095    virtual bool haveSingleProduct() const { return true; }
00096    virtual bool havePerViewProduct(FWViewType::EType) const { return false; }
00097    virtual bool willHandleInteraction() const { return false; }
00098 
00099    TEveElementList* createProduct(FWViewType::EType, const FWViewContext*);
00100    void removePerViewProduct(FWViewType::EType, const FWViewContext* vc);
00101 
00102    bool getHaveWindow() const { return m_haveWindow; }
00103    void setupElement(TEveElement* el, bool color = true) const;
00104    void setupAddElement(TEveElement* el, TEveElement* parent,  bool set_color = true) const;
00105    int  layer() const;
00106 
00107  
00108 protected:   
00109    // Override this if visibility changes can cause (re)-creation of proxies.
00110    // Returns true if new proxies were created.
00111    virtual bool visibilityModelChanges(const FWModelId&, TEveElement*, FWViewType::EType,
00112                                        const FWViewContext*);
00113 
00114    // Override this if you need special handling of selection or other changes.
00115    virtual void localModelChanges(const FWModelId& iId, TEveElement* iCompound,
00116                                   FWViewType::EType viewType, const FWViewContext* vc);
00117 
00118    virtual void modelChanges(const FWModelIds&, Product*);
00119 
00120    virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) {};
00121 
00122    FWProxyBuilderBase(const FWProxyBuilderBase&); // stop default
00123    const FWProxyBuilderBase& operator=(const FWProxyBuilderBase&); // stop default
00124 
00125    virtual void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*);
00126    virtual void buildViewType(const FWEventItem* iItem, TEveElementList*, FWViewType::EType, const FWViewContext*);
00127 
00128    virtual void clean();
00129    virtual void cleanLocal();
00130 
00131    void increaseComponentTransparency(unsigned int index, TEveElement* holder,
00132                                       const std::string& name, Char_t transpOffset);
00133 
00134    // utility
00135    TEveCompound* createCompound(bool set_color=true, bool propagate_color_to_all_children=false) const;
00136 
00137    // ---------- member data --------------------------------
00138    typedef std::vector<Product*>::iterator Product_it;
00139 
00140    std::vector<Product*> m_products;
00141 
00142 private:
00143    void cleanProduct(Product* p);
00144    void setProjectionLayer(float);
00145 
00146    // ---------- member data --------------------------------
00147 
00148    FWInteractionList*    m_interactionList;
00149 
00150    const FWEventItem* m_item;
00151 
00152    bool m_modelsChanged;
00153    bool m_haveWindow;
00154    bool m_mustBuild;
00155 
00156    float m_layer;
00157 };
00158 
00159 #endif