FWProxyBuilderBase

Product

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
#ifndef Fireworks_Core_FWProxyBuilderBase_h
#define Fireworks_Core_FWProxyBuilderBase_h
// -*- C++ -*-
//
// Package:     Core
// Class  :     FWProxyBuilderBase
//
/**\class FWProxyBuilderBase FWProxyBuilderBase.h Fireworks/Core/interface/FWProxyBuilderBase.h

 Description: [one line class summary]

 Usage:
    <usage>

*/
//
// Original Author:  Chris Jones, Matevz Tadel, Alja Mrak-Tadel
//         Created:  Thu Mar 18 14:12:12 CET 2010
//

// system include files
#include "sigc++/connection.h"

// user include files

// user include files
#include "Fireworks/Core/interface/FWEvePtr.h"
#include "Fireworks/Core/interface/FWViewType.h"
#include "Fireworks/Core/interface/FWProxyBuilderFactory.h"
#include "Fireworks/Core/interface/FWModelChangeSignal.h"
#include "Fireworks/Core/interface/FWModelIdFromEveSelector.h"
#include "Fireworks/Core/interface/FWViewContext.h"

// forward declarations

class FWEventItem;
class TEveElementList;
class TEveElement;
class FWModelId;
class FWInteractionList;

namespace fireworks {
  class Context;
}

class FWProxyBuilderBase {
public:
  struct Product {
    FWViewType::EType m_viewType;
    const FWViewContext* m_viewContext;
    TEveElementList* m_elements;
    sigc::connection m_scaleConnection;

    Product(FWViewType::EType t, const FWViewContext* c);
    ~Product();
  };

  FWProxyBuilderBase();
  virtual ~FWProxyBuilderBase();

  // ---------- const member functions ---------------------

  const fireworks::Context& context() const;
  const FWEventItem* item() const { return m_item; }
  // ---------- static member functions --------------------
  ///Used by the plugin system to determine how the proxy uses the data from FWEventItem
  static std::string typeOfBuilder();

  ///Used by the plugin system to determine precidence of different proxy builders for same type
  /// this returns 'true' if the proxy builder is specialized to only show a sub-part of the object
  /// as opposed to showing the object as a whole
  static bool representsSubPart();
  // ---------- member functions ---------------------------
  virtual void setItem(const FWEventItem* iItem);
  void setHaveWindow(bool iFlag);
  void build();

  void modelChanges(const FWModelIds&);
  void itemChanged(const FWEventItem*);
  void scaleChanged(const FWViewContext*);

  virtual bool canHandle(const FWEventItem&);  //note pass FWEventItem to see if type and container match

  virtual void setInteractionList(FWInteractionList*, const std::string&);
  virtual void itemBeingDestroyed(const FWEventItem*);

  // const member functions
  virtual bool haveSingleProduct() const { return true; }
  virtual bool havePerViewProduct(FWViewType::EType) const { return false; }
  virtual bool willHandleInteraction() const { return false; }

  TEveElementList* createProduct(FWViewType::EType, const FWViewContext*);
  void removePerViewProduct(FWViewType::EType, const FWViewContext* vc);

  bool getHaveWindow() const { return m_haveWindow; }
  void setupElement(TEveElement* el, bool color = true) const;
  void setupAddElement(TEveElement* el, TEveElement* parent, bool set_color = true) const;
  int layer() const;

protected:
  // Override this if visibility changes can cause (re)-creation of proxies.
  // Returns true if new proxies were created.
  virtual bool visibilityModelChanges(const FWModelId&, TEveElement*, FWViewType::EType, const FWViewContext*);

  // Override this if you need special handling of selection or other changes.
  virtual void localModelChanges(const FWModelId& iId,
                                 TEveElement* iCompound,
                                 FWViewType::EType viewType,
                                 const FWViewContext* vc);

  virtual void modelChanges(const FWModelIds&, Product*);

  virtual void scaleProduct(TEveElementList* parent, FWViewType::EType, const FWViewContext* vc) {}

  FWProxyBuilderBase(const FWProxyBuilderBase&);                   // stop default
  const FWProxyBuilderBase& operator=(const FWProxyBuilderBase&);  // stop default

  virtual void build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext*);
  virtual void buildViewType(const FWEventItem* iItem, TEveElementList*, FWViewType::EType, const FWViewContext*);

  virtual void clean();
  virtual void cleanLocal();

  void increaseComponentTransparency(unsigned int index,
                                     TEveElement* holder,
                                     const std::string& name,
                                     Char_t transpOffset);

  // utility
  TEveCompound* createCompound(bool set_color = true, bool propagate_color_to_all_children = false) const;

  // ---------- member data --------------------------------
  typedef std::vector<Product*>::iterator Product_it;

  std::vector<Product*> m_products;

private:
  void cleanProduct(Product* p);
  void setProjectionLayer(float);

  // ---------- member data --------------------------------

  FWInteractionList* m_interactionList;

  const FWEventItem* m_item;

  bool m_modelsChanged;
  bool m_haveWindow;
  bool m_mustBuild;

  float m_layer;
};

#endif