CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CmsShowCommonPopup.cc
Go to the documentation of this file.
1 #include "TGFont.h"
2 #include "TGButton.h"
3 #include "TGLabel.h"
4 #include "TGSlider.h"
5 #include "TGComboBox.h"
6 #include "TGClient.h"
7 #include "TG3DLine.h"
8 #include "TGResourcePool.h"
9 #include "TGLUtil.h"
10 #include "TGLViewer.h"
11 #include "TEveManager.h"
12 #include "TEveViewer.h"
13 #include "TColor.h"
14 
21 
23 
25 
26 
27 
28 
29 
30 
31 
33  TGTransientFrame(gClient->GetDefaultRoot(),p,w,h),
34  m_common(model),
35  m_backgroundButton(0),
36  m_gammaSlider(0),
37  m_gammaButton(0),
38  m_colorRnrCtxHighlightWidget(0),
39  m_colorRnrCtxSelectWidget(0)
40 {
41  SetCleanup(kDeepCleanup);
42 
43  TGGC *fTextGC;
44  const TGFont *font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
45  if (!font)
46  font = gClient->GetResourcePool()->GetDefaultFont();
47  GCValues_t gval;
48  gval.fMask = kGCBackground | kGCFont | kGCForeground;
49  gval.fFont = font->GetFontHandle();
50  fTextGC = gClient->GetGC(&gval, kTRUE);
51 
52 
53  TGFont* smallFont = 0;
54  FontStruct_t defaultFontStruct = m_backgroundButton->GetDefaultFontStruct();
55  try
56  {
57  TGFontPool *pool = gClient->GetFontPool();
58  TGFont* defaultFont = pool->GetFont(defaultFontStruct);
59  FontAttributes_t attributes = defaultFont->GetFontAttributes();
60  smallFont = pool->GetFont(attributes.fFamily, 8, attributes.fWeight, attributes.fSlant);
61  }
62  catch(...)
63  {
64  // Ignore exceptions.
65  }
66 
67  TGCompositeFrame* vf2 = new TGVerticalFrame(this);
68  AddFrame(vf2, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
69  //==============================================================================
70  // scales
71  //
72  {
73  TGLabel* xx = new TGLabel(vf2, "GlobalScales ", fTextGC->GetGC());
74  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft ,2,2,4,4));
75  }
77  vf2->AddFrame(scaleEditor);
78  //==============================================================================
79  // Projections
80  //
81  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX,4 ,8, 3, 3));
82  {
83  TGLabel* xx = new TGLabel(vf2, "Projections ", fTextGC->GetGC());
84  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft ,2,2,4,4));
85  }
86  vf2->AddFrame(new TGLabel(vf2, "Track behaviour when crossing y=0 in RhoZ-view:"), new TGLayoutHints(kLHintsLeft ,2,2,0,0));
89 
90  //==============================================================================
91  // general colors
92  //
93 
94  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX ,4 ,8, 8, 2));
95  {
96  TGLabel* xx = new TGLabel(vf2, "General Colors ", fTextGC->GetGC());
97  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft,2,2,4,4));
98  }
99  m_backgroundButton = new TGTextButton(vf2, "Black/White Background");
100  vf2->AddFrame(m_backgroundButton);
101  makeSetter(vf2, &m_common->m_gamma);
102 
103  // rnrCtx colorset
104  {
105  int hci, sci;
106  getColorSetColors(hci, sci);
107  TGHorizontalFrame* top = new TGHorizontalFrame(vf2);
108  vf2->AddFrame(top);
109  {
110  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
111  top->AddFrame(hf);
112 
113  m_colorRnrCtxHighlightWidget = new FWColorSelect(hf, "highlight", 0, m_common->colorManager(), 3);
114  hf->AddFrame(m_colorRnrCtxHighlightWidget);
116  m_colorRnrCtxHighlightWidget->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeSelectionColorSet(Color_t)");
117 
118  TGFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
119  TGLabel* label = new TGLabel(lf, "Higlight");
120  label->SetTextFont(smallFont);
121  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0));
122  }
123 
124  {
125  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
126  top->AddFrame(hf);
127 
128  m_colorRnrCtxSelectWidget = new FWColorSelect(hf, "selectioyn", 0, m_common->colorManager(), 1);
129  hf->AddFrame(m_colorRnrCtxSelectWidget);
131  m_colorRnrCtxSelectWidget->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeSelectionColorSet(Color_t)");
132 
133  TGFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
134  TGLabel* label = new TGLabel(lf, "Selection");
135  label->SetTextFont(smallFont);
136  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0));
137  }
138  }
139 
140  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX ,4 ,8, 8, 2));
141 
142  //==============================================================================
143  // geom colors
144  //
145 
146  {
147  TGLabel* xx = new TGLabel(vf2, "DetectorColors ", fTextGC->GetGC());
148  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft,2,2,8,0));
149  }
150 
151  TGHSlider* transpWidget2D = 0;
152  TGHSlider* transpWidget3D = 0;
153  TGCompositeFrame* top = new TGVerticalFrame(vf2);
154  vf2->AddFrame(top, new TGLayoutHints(kLHintsNormal, 2, 2, 2, 0));
155 
156  {
157  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
158  hf->AddFrame(new TGLabel(hf, "Tansparency 2D:"), new TGLayoutHints(kLHintsBottom, 2, 2, 3, 3));
159  transpWidget2D = new TGHSlider(hf, 100, kSlider1);
160  hf->AddFrame( transpWidget2D);
161  top->AddFrame(hf,new TGLayoutHints( kLHintsNormal, 0, 0, 2, 2));
162  }
163  {
164  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
165  hf->AddFrame(new TGLabel(hf, "Tansparency 3D:") , new TGLayoutHints(kLHintsBottom,2, 2, 2, 2 ));
166  transpWidget3D = new TGHSlider(hf, 100, kSlider1);
167  hf->AddFrame( transpWidget3D);
168  top->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 10));
169  }
170  std::string names[kFWGeomColorSize];
171  names[kFWPixelBarrelColorIndex ] = "Pixel Barrel";
172  names[kFWPixelEndcapColorIndex ] = "Pixel Endcap" ;
173  names[kFWTrackerBarrelColorIndex ] = "Tracker Barrel";
174  names[kFWTrackerEndcapColorIndex ] = "Tracker Endcap";
175  names[kFWMuonBarrelLineColorIndex] = "Muon Barrel";
176  names[kFWMuonEndcapLineColorIndex] = "Muon Endcap";
177  int i = 0;
178  for (int k = 0; k < 3; ++k)
179  {
180  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
181  top->AddFrame(hf);
182 
183  for (int j = 0 ; j < 2; ++j)
184  {
185  m_colorSelectWidget[i] = new FWColorSelect(hf, names[i].c_str(), 0, m_common->colorManager(), i);
186  hf->AddFrame(m_colorSelectWidget[i]);
188  m_colorSelectWidget[i]->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeGeomColor(Color_t)");
189 
190  TGFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
191  TGLabel* label = new TGLabel(lf, m_colorSelectWidget[i]->label().c_str());
192  label->SetTextFont(smallFont);
193  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0));
194 
195  ++i;
196  }
197  }
198  //==============================================================================
199 
200  m_backgroundButton->Connect("Clicked()", "CmsShowCommonPopup", this, "switchBackground()");
201 
202  transpWidget2D->SetRange(0, 100);
203  transpWidget2D->SetPosition(m_common->colorManager()->geomTransparency(true));
204  transpWidget2D->Connect("PositionChanged(Int_t)", "CmsShowCommonPopup", this, "changeGeomTransparency2D(Int_t)");
205 
206  transpWidget3D->SetRange(0, 100);
207  transpWidget3D->SetPosition(m_common->colorManager()->geomTransparency(false));
208  transpWidget3D->Connect("PositionChanged(Int_t)", "CmsShowCommonPopup", this, "changeGeomTransparency3D(Int_t)");
209 
210  SetWindowName("Common Preferences");
211  MapSubwindows();
212  Resize(GetDefaultSize());
213  Layout();
214  CenterOnParent(kTRUE, TGTransientFrame::kTopRight);
215 }
216 
217 
218 
220 {
221 }
222 
223 void
225 {
227 }
228 
229 
230 void
232 {
233  TGColorSelect *cs = (TGColorSelect *) gTQSender;
234  FWGeomColorIndex cidx = FWGeomColorIndex(cs->WidgetId());
235  m_common->setGeomColor(cidx, iColor);
236 }
237 
238 
239 void
241 {
242  TGColorSelect *cs = (TGColorSelect *) gTQSender;
243 
244  //printf("~~~~~ changeSelectionColorSet sel[%d] idx[%d]\n", cs->WidgetId(), idx);
245  for (TEveElement::List_i it = gEve->GetViewers()->BeginChildren(); it != gEve->GetViewers()->EndChildren(); ++it)
246  {
247  TGLViewer* v = ((TEveViewer*)(*it))->GetGLViewer();
248 
249  TGLColorSet& colorset = m_common->colorManager()->isColorSetDark() ? v->RefDarkColorSet():v->RefLightColorSet();
250  colorset.Selection(cs->WidgetId()).SetColor(idx);
251  colorset.Selection(cs->WidgetId()+1).SetColor(idx); // implied selected/higlighted
252 
253  }
254 }
255 
256 
257 void
259 {
260  m_common->setGeomTransparency(iTransp, true);
261 }
262 
263 void
265 {
266  m_common->setGeomTransparency(iTransp, false);
267 }
268 
269 
270 /* Called by FWGUIManager when change background. */
271 void
273 {
274  for (int i = 0 ; i < kFWGeomColorSize; ++i)
275  m_colorSelectWidget[i]->SetColorByIndex(m_common->colorManager()->geomColor(FWGeomColorIndex(i)), kFALSE);
276 
277  int hci, sci;
278  getColorSetColors(hci, sci);
279  //printf("=============== colorSetChanged() dark ? [%d] %d %d \n",m_common->colorManager()->isColorSetDark(), hci, sci);
282 }
283 
284 void CmsShowCommonPopup::getColorSetColors (int& hci, int& sci)
285 {
286  TGLColorSet& colorset = m_common->colorManager()->isColorSetDark() ? gEve->GetDefaultGLViewer()->RefDarkColorSet():
287  gEve->GetDefaultGLViewer()->RefLightColorSet();
288  {
289  TGLColor& glc = colorset.Selection(3);
290  hci = TColor::GetColor(glc.GetRed(), glc.GetGreen(), glc.GetBlue());
291  // printf("getSHcolors HIGH %d %d %d , [%d]\n", glc.GetRed(), glc.GetGreen(), glc.GetBlue(), hci);
292  }{
293  TGLColor& glc = colorset.Selection(1);
294  sci = TColor::GetColor(glc.GetRed(), glc.GetGreen(), glc.GetBlue());
295  // printf("getSHcolors SEL %d %d %d , [%d]\n", glc.GetRed(), glc.GetGreen(), glc.GetBlue(), sci);
296  }
297 }
298 
299 void
300 CmsShowCommonPopup::makeSetter(TGCompositeFrame* frame, FWParameterBase* param)
301 {
302  boost::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor(param) );
303  ptr->attach(param, this);
304 
305  TGFrame* pframe = ptr->build(frame);
306  frame->AddFrame(pframe, new TGLayoutHints(kLHintsExpandX, 0, 0, 2,2));
307 
308  m_setters.push_back(ptr);
309 }
void changeSelectionColorSet(Color_t)
CmsShowCommonPopup(CmsShowCommon *, const TGWindow *p=0, UInt_t w=1, UInt_t h=1)
int i
Definition: DBlmapReader.cc:9
FWColorSelect * m_colorSelectWidget[kFWGeomColorSize]
auto_ptr< ClusterSequence > cs
Color_t geomTransparency(bool projected) const
void SetColorByIndex(Color_t iColor)
FWBoolParameter m_drawBreakPoints
Definition: CmsShowCommon.h:82
void makeSetter(TGCompositeFrame *frame, FWParameterBase *param)
FWGeomColorIndex
static boost::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
const FWColorManager * colorManager() const
Bool_t isColorSetDark() const
TGTextButton * m_backgroundButton
FWLongParameter m_gamma
Definition: CmsShowCommon.h:86
void setGeomTransparency(int val, bool projected)
void changeGeomTransparency2D(int)
void changeGeomTransparency3D(int)
void changeGeomColor(Color_t)
list attributes
Definition: asciidump.py:415
void getColorSetColors(int &hci, int &sci)
int j
Definition: DBlmapReader.cc:9
CmsShowCommon * m_common
void setGeomColor(FWGeomColorIndex, Color_t)
void switchBackground()
globcontrol glc
Definition: vlib.cc:6
int k[5][pyjets_maxn]
std::vector< boost::shared_ptr< FWParameterSetterBase > > m_setters
unsigned int UInt_t
Definition: FUTypes.h:12
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::auto_ptr< FWViewEnergyScale > m_energyScale
Definition: CmsShowCommon.h:94
FWColorSelect * m_colorRnrCtxHighlightWidget
FWColorSelect * m_colorRnrCtxSelectWidget
FWEnumParameter m_trackBreak
Definition: CmsShowCommon.h:81
Color_t geomColor(FWGeomColorIndex) const
static const HistoName names[]
mathSSE::Vec4< T > v
T w() const