CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/Fireworks/Core/interface/FWGeometryTableManagerBase.h

Go to the documentation of this file.
00001 #ifndef Fireworks_Core_FWGeometryTableManagerBase_h
00002 #define Fireworks_Core_FWGeometryTableManagerBase_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Core
00006 // Class  :     FWGeometryTableManagerBase
00007 // 
00016 //
00017 // Original Author:  Alja Mrak-Tadel, Matevz Tadel
00018 //         Created:  Thu Jan 27 14:50:40 CET 2011
00019 // $Id: FWGeometryTableManagerBase.h,v 1.7 2012/05/10 23:57:52 amraktad Exp $
00020 //
00021 
00022 #include <sigc++/sigc++.h>
00023 
00024 #include "Fireworks/Core/interface/FWGeometryTableViewBase.h"
00025 
00026 #include "Fireworks/TableWidget/interface/FWTableManagerBase.h"
00027 #include "Fireworks/TableWidget/interface/FWTextTreeCellRenderer.h"
00028 #include "Fireworks/TableWidget/interface/FWTextTableCellRenderer.h"
00029 #include "Fireworks/TableWidget/interface/FWTableCellRendererBase.h"
00030 
00031 #include "TGeoNode.h"
00032 
00033 class FWTableCellRendererBase;
00034 class TGeoNode;
00035 class TEvePointSet;
00036 
00037 class FWGeometryTableManagerBase : public FWTableManagerBase
00038 {
00039    friend class FWGeometryTableViewBase;
00040 
00041 public:
00042    //   enum   ESelectionState { kNone, kSelected, kHighlighted, kFiltered };
00043 
00044    enum Bits
00045    {
00046       kExpanded        =  BIT(0),
00047 
00048       kVisNodeSelf     =  BIT(1),
00049       kVisNodeChld     =  BIT(2),
00050 
00051       kHighlighted   =  BIT(3),
00052       kSelected      =  BIT(4)
00053    };
00054 
00055    struct NodeInfo
00056    {
00057       NodeInfo():m_node(0), m_parent(-1), m_color(0), m_level(-1), 
00058                  m_flags(kVisNodeSelf|kVisNodeChld) {}  
00059 
00060       NodeInfo(TGeoNode* n, Int_t p, Color_t col, Char_t l, UChar_t f = kVisNodeSelf|kVisNodeChld ):m_node(n), m_parent(p), m_color(col), m_level(l), 
00061                  m_flags(f) {}  
00062 
00063       TGeoNode*   m_node;
00064       Int_t       m_parent;
00065       Color_t     m_color;
00066       UChar_t     m_level;
00067       UChar_t     m_flags;
00068       UChar_t     m_transparency;
00069 
00070 
00071       const char* name() const;
00072       //  const char* nameIndent() const;
00073 
00074       void setBit(UChar_t f)    { m_flags  |= f;}
00075       void resetBit(UChar_t f)  { m_flags &= ~f; }
00076       void setBitVal(UChar_t f, bool x) { x ? setBit(f) : resetBit(f);}
00077  
00078       bool testBit(UChar_t f) const  { return (m_flags & f) == f; }
00079       bool testBitAny(UChar_t f) const  { return (m_flags & f) != 0; }
00080 
00081       void switchBit(UChar_t f) { testBit(f) ? resetBit(f) : setBit(f); }
00082    };
00083 
00084 
00085    typedef std::vector<NodeInfo> Entries_v;
00086    typedef Entries_v::iterator Entries_i;
00087    
00088    int m_highlightIdx;
00089 
00090    //private: 
00091    // AMT: this could be a common base class with FWCollectionSummaryModelCellRenderer ..
00092    class ColorBoxRenderer : public FWTableCellRendererBase
00093    { 
00094    public:
00095       ColorBoxRenderer();
00096       virtual ~ColorBoxRenderer();
00097   
00098       virtual UInt_t width() const { return m_width; }
00099       virtual UInt_t height() const { return m_height; }
00100       void setData(Color_t c, bool);
00101       virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight);
00102 
00103       UInt_t  m_width;
00104       UInt_t  m_height;
00105       Pixel_t m_color;      
00106       bool    m_isSelected;
00107       TGGC*   m_colorContext;
00108    };
00109 
00110 protected:
00111    virtual bool nodeIsParent(const NodeInfo&) const { return false; }
00112    //   virtual ESelectionState nodeSelectionState(int idx) const;
00113 
00114 public:
00115    FWGeometryTableManagerBase();
00116    virtual ~FWGeometryTableManagerBase();
00117    //   virtual std::string& cellName(const NodeInfo& ) const { return &std::string("ddd");} 
00118    virtual const char* cellName(const NodeInfo& ) const { return 0;} 
00119 
00120    // virtual functions of FWTableManagerBase
00121    
00122    virtual int unsortedRowNumber(int unsorted) const;
00123    virtual int numberOfRows() const;
00124    virtual std::vector<std::string> getTitles() const;
00125 
00126    virtual const std::string title() const;
00127 
00128    //int selectedRow() const;
00129    //int selectedColumn() const;
00130    //virtual bool rowIsSelected(int row) const;
00131 
00132    std::vector<int> rowToIndex() { return m_row_to_index; }
00133 
00134    //   void setSelection(int row, int column, int mask); 
00135    virtual void implSort(int, bool) {}
00136 
00137    bool nodeImported(int idx) const;
00138    // geo stuff
00139 
00140    NodeInfo* getSelected();
00141 
00142    Entries_v& refEntries() {return m_entries;}
00143   NodeInfo& refEntry(int i) {return m_entries[i];}
00144 
00145    void loadGeometry( TGeoNode* , TObjArray*);
00146 
00147    void setBackgroundToWhite(bool);
00148    void getNodePath(int, std::string&) const;
00149 
00150    int getLevelOffset() const { return m_levelOffset; }
00151    void setLevelOffset(int x) { m_levelOffset =x; }
00152 
00153    void setDaughtersSelfVisibility(bool);
00154 
00155    void getNodeMatrix(const NodeInfo& nodeInfo, TGeoHMatrix& mat) const;
00156 
00157    
00158    virtual void setVisibility(NodeInfo&, bool );
00159    virtual void setVisibilityChld(NodeInfo&, bool);
00160    virtual void setDaughtersSelfVisibility(int selectedIdx, bool v);
00161 
00162    virtual bool getVisibilityChld(const NodeInfo& nodeInfo) const;
00163    virtual bool getVisibility (const NodeInfo& nodeInfo) const;
00164 
00165    static  void getNNodesTotal(TGeoNode* geoNode, int& off);
00166 
00167    void showEditor(int);
00168    void cancelEditor(bool);
00169    void setCellValueEditor(TGTextEntry *editor);
00170    void applyTransparencyFromEditor();
00171    // protected:
00172    FWGeometryTableManagerBase(const FWGeometryTableManagerBase&); // stop default
00173    const FWGeometryTableManagerBase& operator=(const FWGeometryTableManagerBase&); // stop default
00174 
00175    
00176    bool firstColumnClicked(int row, int xPos);
00177    //   void changeSelection(int iRow, int iColumn);
00178 
00179    void redrawTable(bool setExpand = false);
00180 
00181    virtual void recalculateVisibility() = 0;
00182 
00183   
00184    virtual bool cellDataIsSortable() const { return false ; }
00185    // ---------- member data --------------------------------
00186    
00187    
00188    // table stuff
00189    mutable TGGC* m_highlightContext; 
00190    mutable FWTextTreeCellRenderer m_renderer;  
00191    mutable ColorBoxRenderer       m_colorBoxRenderer;  
00192 
00193    std::vector<int>  m_row_to_index;
00194    
00195    Entries_v          m_entries;
00196 
00197    int m_levelOffset;
00198    
00199    TGTextEntry* m_editor;
00200    int m_editTransparencyIdx;
00201 };
00202 
00203 
00204 
00205 inline void FWGeometryTableManagerBase::getNNodesTotal(TGeoNode* geoNode, int& off)
00206 {   
00207    int nD =  geoNode->GetNdaughters();
00208    off += nD;
00209    for (int i = 0; i < nD; ++i )
00210    {
00211       getNNodesTotal(geoNode->GetDaughter(i), off);
00212    }
00213 }
00214 
00215 #endif