forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveSecondarySelectable.cxx
119 lines (104 loc) · 3.5 KB
/
TEveSecondarySelectable.cxx
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
// @(#)root/eve:$Id$
// Author: Matevz Tadel 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveSecondarySelectable.h"
#include "TEveElement.h"
#include "TGLSelectRecord.h"
/** \class TEveSecondarySelectable
\ingroup TEve
Semi-abstract interface for classes supporting secondary-selection.
Element class that inherits from this, should also implement the
following virtual methods from TEveElement:
~~~ {.cpp}
virtual void UnSelected();
virtual void UnHighlighted();
~~~
and clear corresponding selection-set from there.
To support tooltips for sub-elements, implement:
~~~ {.cpp}
virtual TString TEveElement::GetHighlightTooltip();
~~~
and return tooltip for the entry in the fHighlightedSet.
There should always be a single entry there.
See TEveDigitSet for an example.
*/
ClassImp(TEveSecondarySelectable);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveSecondarySelectable::TEveSecondarySelectable() :
fAlwaysSecSelect(kFALSE)
{
}
////////////////////////////////////////////////////////////////////////////////
/// Process secondary GL selection and populate selected set accordingly.
void TEveSecondarySelectable::ProcessGLSelection(TGLSelectRecord& rec)
{
if (rec.GetHighlight())
ProcessGLSelectionInternal(rec, fHighlightedSet);
else
ProcessGLSelectionInternal(rec, fSelectedSet);
}
////////////////////////////////////////////////////////////////////////////////
/// Process secondary GL selection and populate given set accordingly.
void TEveSecondarySelectable::ProcessGLSelectionInternal(TGLSelectRecord& rec,
SelectionSet_t& sset)
{
Int_t id = (rec.GetN() > 1) ? (Int_t) rec.GetItem(1) : -1;
if (sset.empty())
{
if (id >= 0)
{
sset.insert(id);
rec.SetSecSelResult(TGLSelectRecord::kEnteringSelection);
}
}
else
{
if (id >= 0)
{
if (rec.GetMultiple())
{
if (sset.find(id) == sset.end())
{
sset.insert(id);
rec.SetSecSelResult(TGLSelectRecord::kModifyingInternalSelection);
}
else
{
sset.erase(id);
if (sset.empty())
rec.SetSecSelResult(TGLSelectRecord::kLeavingSelection);
else
rec.SetSecSelResult(TGLSelectRecord::kModifyingInternalSelection);
}
}
else
{
if (sset.size() != 1 || sset.find(id) == sset.end())
{
sset.clear();
sset.insert(id);
rec.SetSecSelResult(TGLSelectRecord::kModifyingInternalSelection);
}
}
}
else
{
if (!rec.GetMultiple())
{
sset.clear();
rec.SetSecSelResult(TGLSelectRecord::kLeavingSelection);
}
}
}
if (rec.GetSecSelResult() != TGLSelectRecord::kNone)
{
dynamic_cast<TEveElement*>(this)->StampColorSelection();
}
}