CEDRIC  Revision_backup-2009-02
ParticleTreeWidget.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright (C) 2008 Boris Iven, Max Hermann
4  *
5  * This file is part of the "CEDRIC Event Display" application.
6  *
7  *****************************************************************************/
8 
9 #ifndef PARTICLETREEWIDGET_H
10 #define PARTICLETREEWIDGET_H
11 
12 #include <QtGui/QTreeWidget>
13 #include <Phast.h>
14 #include <osg/ref_ptr>
15 #include <osg/Node>
16 #include <osg/Vec3>
17 
18 #include <map>
19 
20 #include "PhastNode.h"
21 class PhastScene;
22 
23 // #define PARTICLETREEWIDGET_COLORS_AS_TEXT // <--- show only id's instead of color
24 
31 class ParticleTreeWidget : public QTreeWidget
32 {
33  Q_OBJECT
34 public:
35 
36  enum ItemDataRoles //user roles must be >= 32
37  {
40  };
41 
43  {
44  COL_INDEX = 0,
47 
48  // track momentum (if PaTrack::hasMom())
51 
52  // Rich information (accessed via PaPid and track)
53  COL_RICHINFO, // "yes"/"no" if rich info is available
56 
57  // particle information (if associated particle is given)
58  COL_PARTICLE, // associated particle (if any)
59  COL_NVERTEX, // int PaParticle::NVertex()
60  COL_NCALORIM, // int PaParticle::NCalorim()
61  COL_PARTICLE_TYPE, // PaParticle::PID(), particle ID in GEANT3 notation
62  COL_IS_BEAM, // bool PaParticle::IsBeam()
63  COL_IS_MUPRIM, // bool PaParticle::IsMuPrim()
64 
65  // additional track info
72 
74  };
75 
76  ParticleTreeWidget( QWidget* parent = 0 );
77 
79  void updateContent( const PaEvent& event, PhastScene* scene );
80 
81 signals:
83  void updateNeeded();
85  void particleActivated( int index );
86 
87 public slots:
89  void highlight( int uid );
92  {
93  for( int i=0; i < columnCount(); ++i )
94  resizeColumnToContents( i );
95  }
96 
97 protected slots:
99  void updateItem( QTreeWidgetItem* item, int col );
100 
101  // REMARK: only one of the following two functions get connected!
103  void onItemActivated( QTreeWidgetItem* item, int col );
105  void onCurrentItemChanged( QTreeWidgetItem* item, QTreeWidgetItem* );
106 
107 protected:
108  QColor getPIDColor( int PID );
109 
110 
111 private slots:
113  void highlight( QTreeWidgetItem* item, QTreeWidgetItem* unHighlightMe );
114 
115 private:
116  QMap<int, QTreeWidgetItem*> m_UID2ItemMap;
117 
118  bool m_Lock;
119 };
120 
121 #endif /*PARTICLETREEWIDGET_H_*/
void updateItem(QTreeWidgetItem *item, int col)
Called when item was changed by user.
Definition: ParticleTreeWidget.cpp:341
void autoResizeColumns()
Resize columns to fit content (just calls QTreeWidget::resizeColumnToContents() for every column) ...
Definition: ParticleTreeWidget.h:91
ParticleTreeWidget(QWidget *parent=0)
Definition: ParticleTreeWidget.cpp:53
void highlight(int uid)
Highlight in widget.
Definition: ParticleTreeWidget.cpp:304
Definition: ParticleTreeWidget.h:45
Definition: ParticleTreeWidget.h:58
Definition: ParticleTreeWidget.h:61
ColumnType
Definition: ParticleTreeWidget.h:42
void updateContent(const PaEvent &event, PhastScene *scene)
Fill this tree widget based on PaEvent and PhastScene content.
Definition: ParticleTreeWidget.cpp:119
Definition: ParticleTreeWidget.h:68
Definition: ParticleTreeWidget.h:63
Definition: ParticleTreeWidget.h:70
Definition: ParticleTreeWidget.h:50
Definition: ParticleTreeWidget.h:59
Definition: ParticleTreeWidget.h:39
The event's particles in a QTreeWidget, relates PaParticles (model) and OSG (graphical) representatio...
Definition: ParticleTreeWidget.h:31
Definition: ParticleTreeWidget.h:55
Definition: ParticleTreeWidget.h:38
Definition: PID.h:20
Definition: ParticleTreeWidget.h:71
Definition: ParticleTreeWidget.h:49
Definition: ParticleTreeWidget.h:66
Definition: ParticleTreeWidget.h:69
void updateNeeded()
Views must be updated (e.g. due to color/alpha change)
void onItemActivated(QTreeWidgetItem *item, int col)
Slot for signal itemActivated(), just translates to signal particleActivated(int) ...
Definition: ParticleTreeWidget.cpp:316
Definition: ParticleTreeWidget.h:53
Definition: ParticleTreeWidget.h:46
QColor getPIDColor(int PID)
Definition: ParticleTreeWidget.cpp:112
Scenegraph holding static and dynamic Phast geometry.
Definition: PhastScene.h:32
Definition: ParticleTreeWidget.h:73
Definition: ParticleTreeWidget.h:60
Definition: ParticleTreeWidget.h:44
void particleActivated(int index)
User has selected another particle from the widget (e.g. usefull for FilterVis updates) ...
Definition: ParticleTreeWidget.h:67
Definition: ParticleTreeWidget.h:54
Definition: ParticleTreeWidget.h:62
void onCurrentItemChanged(QTreeWidgetItem *item, QTreeWidgetItem *)
Slot for signal currentItemChanged(), just translates to signal particleActivated(int) ...
Definition: ParticleTreeWidget.cpp:329
ItemDataRoles
Definition: ParticleTreeWidget.h:36