test
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"
15 
22 
24 
28 
29 #include <boost/bind.hpp>
30 
31 CmsShowCommonPopup::CmsShowCommonPopup(CmsShowCommon* model, const TGWindow* p, UInt_t w, UInt_t h) :
32  TGTransientFrame(gClient->GetDefaultRoot(),p,w,h),
33  m_common(model),
34  m_backgroundButton(0),
35  m_gammaSlider(0),
36  m_gammaButton(0),
37  m_colorRnrCtxHighlightWidget(0),
38  m_colorRnrCtxSelectWidget(0),
39  m_combo(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  TGCompositeFrame* vf2 = new TGVerticalFrame(this);
54  AddFrame(vf2, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
55  //==============================================================================
56  // scales
57  //
58  {
59  TGLabel* xx = new TGLabel(vf2, "GlobalScales ", fTextGC->GetGC());
60  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft, 2,2,4,4));
61  }
63  vf2->AddFrame(scaleEditor);
64  //==============================================================================
65  // Projections
66  //
67  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX, 4,8,3,3));
68  {
69  TGLabel* xx = new TGLabel(vf2, "Projections ", fTextGC->GetGC());
70  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft, 2,2,4,4));
71  }
72  vf2->AddFrame(new TGLabel(vf2, "Track behavior when crossing y=0 in RhoZ view:"),
73  new TGLayoutHints(kLHintsLeft, 2,2,0,0));
76 
77  //==============================================================================
78  // general colors
79  //
80 
81  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX, 4,8,8,2));
82  {
83  TGLabel* xx = new TGLabel(vf2, "General Colors ", fTextGC->GetGC());
84  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft,2,2,4,4));
85  }
86  {
87  TGCompositeFrame *hf = new TGHorizontalFrame(vf2);
88  vf2->AddFrame(hf, new TGLayoutHints(kLHintsExpandX));
89 
90  m_backgroundButton = new TGTextButton(hf, "Black/White Background");
91  hf->AddFrame(m_backgroundButton, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2));
92  m_backgroundButton->Connect("Clicked()", "CmsShowCommonPopup", this, "switchBackground()");
93 
95  }
96 
97  TGFont* smallFont = 0;
98  FontStruct_t defaultFontStruct = m_backgroundButton->GetDefaultFontStruct();
99  try
100  {
101  TGFontPool *pool = gClient->GetFontPool();
102  TGFont* defaultFont = pool->GetFont(defaultFontStruct);
103  FontAttributes_t attributes = defaultFont->GetFontAttributes();
104  smallFont = pool->GetFont(attributes.fFamily, 8, attributes.fWeight, attributes.fSlant);
105  }
106  catch(...)
107  {
108  // Ignore exceptions.
109  }
110 
111 
112  // color palette swapping
113  if (1) {
114  const TGCompositeFrame* f = static_cast<const TGCompositeFrame*>(makeSetter(vf2, &m_common->m_palette));
115  // MTXXXX combo is at(0) (label on right!) and there is a tgframeelement in between!
116  // for (int i = 0; i < f->GetList()->GetEntries(); ++i)
117  // printf("QWE %d %s\n", i, ((TGFrameElement*)f->GetList()->At(i))->fFrame->ClassName());
118  // m_combo = static_cast<TGComboBox*>(f->GetList()->At(1));
119  m_combo = static_cast<TGComboBox*>(static_cast<TGFrameElement*>(f->GetList()->At(0))->fFrame);
120  m_common->m_palette.changed_.connect(boost::bind(&CmsShowCommonPopup::setPaletteGUI, this));
121 
122  TGCompositeFrame *hf = new TGHorizontalFrame(vf2);
123  vf2->AddFrame(hf, new TGLayoutHints(kLHintsExpandX));
124  {
125  TGButton *butt;
126  butt = new TGTextButton(hf, "Permute Colors");
127  butt->SetToolTipText("Randomize assigned collection colors");
128  hf->AddFrame(butt, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,2,2,2));
129  butt->Connect("Clicked()", "CmsShowCommonPopup", this, "permuteColors()");
130 
131 
132  butt = new TGTextButton(hf, "Randomize Colors");
133  butt->SetToolTipText("Randomize collection colors from full palette");
134  hf->AddFrame(butt, new TGLayoutHints(kLHintsNormal, 0, 0, 2,2));
135  butt->Connect("Clicked()", "CmsShowCommonPopup", this, "randomizeColors()");
136  }
137  }
138 
139  // rnrCtx colorset
140  {
141  int hci, sci;
142  getColorSetColors(hci, sci);
143  TGHorizontalFrame* top = new TGHorizontalFrame(vf2);
144  vf2->AddFrame(top);
145  {
146  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
147  top->AddFrame(hf);
148 
149  m_colorRnrCtxHighlightWidget = new FWColorSelect(hf, "Highlight", 0, m_common->colorManager(), 3);
150  hf->AddFrame(m_colorRnrCtxHighlightWidget);
152  m_colorRnrCtxHighlightWidget->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeSelectionColorSet(Color_t)");
153 
154  TGHorizontalFrame* lf = new TGHorizontalFrame(hf, 45, 16, kFixedSize);
155  TGLabel* label = new TGLabel(lf, "Higlight");
156  label->SetTextFont(smallFont);
157  lf->AddFrame(label);
158  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft|kLHintsCenterY));
159  }
160 
161  {
162  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
163  top->AddFrame(hf);
164 
165  m_colorRnrCtxSelectWidget = new FWColorSelect(hf, "Selection", 0, m_common->colorManager(), 1);
166  hf->AddFrame(m_colorRnrCtxSelectWidget);
168  m_colorRnrCtxSelectWidget->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeSelectionColorSet(Color_t)");
169 
170  TGHorizontalFrame* lf = new TGHorizontalFrame(hf, 45, 16, kFixedSize);
171  TGLabel* label = new TGLabel(lf, "Selection");
172  label->SetTextFont(smallFont);
173  lf->AddFrame(label);
174  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft|kLHintsCenterY));
175  }
176  }
177  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX, 4,8,8,2));
178 
179  //==============================================================================
180  // geom colors
181  //
182 
183  {
184  TGLabel* xx = new TGLabel(vf2, "DetectorColors ", fTextGC->GetGC());
185  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft,2,2,8,0));
186  }
187 
188  TGHSlider* transpWidget2D = 0;
189  TGHSlider* transpWidget3D = 0;
190  TGCompositeFrame* top = new TGVerticalFrame(vf2);
191  vf2->AddFrame(top, new TGLayoutHints(kLHintsNormal, 2, 2, 2, 0));
192 
193  {
194  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
195  hf->AddFrame(new TGLabel(hf, "Tansparency 2D:"), new TGLayoutHints(kLHintsBottom, 2, 2, 3, 3));
196  transpWidget2D = new TGHSlider(hf, 100, kSlider1);
197  hf->AddFrame( transpWidget2D);
198  top->AddFrame(hf,new TGLayoutHints( kLHintsNormal, 0, 0, 2, 2));
199  }
200  {
201  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
202  hf->AddFrame(new TGLabel(hf, "Tansparency 3D:") , new TGLayoutHints(kLHintsBottom,2, 2, 2, 2 ));
203  transpWidget3D = new TGHSlider(hf, 100, kSlider1);
204  hf->AddFrame( transpWidget3D);
205  top->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 10));
206  }
208  names[kFWPixelBarrelColorIndex ] = "Pixel Barrel";
209  names[kFWPixelEndcapColorIndex ] = "Pixel Endcap" ;
210  names[kFWTrackerBarrelColorIndex ] = "Tracker Barrel";
211  names[kFWTrackerEndcapColorIndex ] = "Tracker Endcap";
212  names[kFWMuonBarrelLineColorIndex] = "Muon Barrel";
213  names[kFWMuonEndcapLineColorIndex] = "Muon Endcap";
214  int i = 0;
215  for (int k = 0; k < 3; ++k)
216  {
217  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
218  top->AddFrame(hf);
219 
220  for (int j = 0; j < 2; ++j)
221  {
222  m_colorSelectWidget[i] = new FWColorSelect(hf, names[i].c_str(), 0, m_common->colorManager(), i);
223  hf->AddFrame(m_colorSelectWidget[i]);
225  m_colorSelectWidget[i]->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeGeomColor(Color_t)");
226 
227  TGHorizontalFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
228  TGLabel* label = new TGLabel(lf, m_colorSelectWidget[i]->label().c_str());
229  label->SetTextFont(smallFont);
230  lf->AddFrame(label);
231  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0));
232 
233  ++i;
234  }
235  }
236  //==============================================================================
237 
238  transpWidget2D->SetRange(0, 100);
239  transpWidget2D->SetPosition(m_common->colorManager()->geomTransparency(true));
240  transpWidget2D->Connect("PositionChanged(Int_t)", "CmsShowCommonPopup", this, "changeGeomTransparency2D(Int_t)");
241 
242  transpWidget3D->SetRange(0, 100);
243  transpWidget3D->SetPosition(m_common->colorManager()->geomTransparency(false));
244  transpWidget3D->Connect("PositionChanged(Int_t)", "CmsShowCommonPopup", this, "changeGeomTransparency3D(Int_t)");
245 
246  SetWindowName("Common Preferences");
247  MapSubwindows();
248  Resize(GetDefaultSize());
249  Layout();
250  CenterOnParent(kTRUE, TGTransientFrame::kTopRight);
251 }
252 
253 
255 {}
256 
257 //==============================================================================
258 
259 void
261 
262 void
264 
265 void
267 
268 void
270 {
271  TGColorSelect *cs = (TGColorSelect *) gTQSender;
272  FWGeomColorIndex cidx = FWGeomColorIndex(cs->WidgetId());
273  m_common->setGeomColor(cidx, iColor);
274 }
275 
276 
277 void
279 {
280  TGColorSelect *cs = (TGColorSelect *) gTQSender;
281 
282  //printf("~~~~~ changeSelectionColorSet sel[%d] idx[%d]\n", cs->WidgetId(), idx);
283  for (TEveElement::List_i it = gEve->GetViewers()->BeginChildren(); it != gEve->GetViewers()->EndChildren(); ++it)
284  {
285  TGLViewer* v = ((TEveViewer*)(*it))->GetGLViewer();
286 
287  TGLColorSet& colorset = m_common->colorManager()->isColorSetDark() ? v->RefDarkColorSet():v->RefLightColorSet();
288  colorset.Selection(cs->WidgetId()).SetColor(idx);
289  colorset.Selection(cs->WidgetId()+1).SetColor(idx); // implied selected/higlighted
290  }
291 }
292 
293 
294 void
296 {
297  m_common->setGeomTransparency(iTransp, true);
298 }
299 
300 void
302 {
303  m_common->setGeomTransparency(iTransp, false);
304 }
305 
306 
307 /* Called by FWGUIManager when change background. */
308 void
310 {
311  for (int i = 0 ; i < kFWGeomColorSize; ++i)
312  m_colorSelectWidget[i]->SetColorByIndex(m_common->colorManager()->geomColor(FWGeomColorIndex(i)), kFALSE);
313 
314  int hci, sci;
315  getColorSetColors(hci, sci);
316  // printf("=============== colorSetChanged() dark ? [%d] %d %d \n",m_common->colorManager()->isColorSetDark(), hci, sci);
319 }
320 
321 void CmsShowCommonPopup::getColorSetColors (int& hci, int& sci)
322 {
323  TGLColorSet& colorset = m_common->colorManager()->isColorSetDark() ?
325  {
326  TGLColor& glc = colorset.Selection(3);
327  hci = TColor::GetColor(glc.GetRed(), glc.GetGreen(), glc.GetBlue());
328  // printf("getSHcolors HIGH %d %d %d , [%d]\n", glc.GetRed(), glc.GetGreen(), glc.GetBlue(), hci);
329  }
330  {
331  TGLColor& glc = colorset.Selection(1);
332  sci = TColor::GetColor(glc.GetRed(), glc.GetGreen(), glc.GetBlue());
333  // printf("getSHcolors SEL %d %d %d , [%d]\n", glc.GetRed(), glc.GetGreen(), glc.GetBlue(), sci);
334  }
335 }
336 
337 TGFrame*
338 CmsShowCommonPopup::makeSetter(TGCompositeFrame* frame, FWParameterBase* param)
339 {
340  std::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor(param) );
341  ptr->attach(param, this);
342 
343  TGFrame* pframe = ptr->build(frame);
344  frame->AddFrame(pframe, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
345 
346  m_setters.push_back(ptr);
347  return pframe;
348 }
349 
350 
351 
352 void
354 {
355  m_common->setPalette();
356 
357  for (int i = 0 ; i < kFWGeomColorSize; ++i) {
359  // m_common->m_geomColors[i]->set(cm->geomColor(FWGeomColorIndex(i)));
361  }
362 }
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]
TGLColorSet m_lightColorSet
auto_ptr< ClusterSequence > cs
static const HistoName names[]
Color_t geomTransparency(bool projected) const
const double w
Definition: UKUtility.cc:23
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void SetColorByIndex(Color_t iColor)
FWBoolParameter m_drawBreakPoints
Definition: CmsShowCommon.h:91
FWColorManager * colorManager() const
Definition: Context.h:65
FWGeomColorIndex
sigc::signal< void, T > changed_
const FWColorManager * colorManager() const
Bool_t isColorSetDark() const
TGTextButton * m_backgroundButton
FWLongParameter m_gamma
Definition: CmsShowCommon.h:95
void setGeomTransparency(int val, bool projected)
void changeGeomTransparency2D(int)
void changeGeomTransparency3D(int)
void randomizeColors()
void changeGeomColor(Color_t)
void getColorSetColors(int &hci, int &sci)
std::vector< std::shared_ptr< FWParameterSetterBase > > m_setters
int j
Definition: DBlmapReader.cc:9
double f[11][100]
CmsShowCommon * m_common
void setGeomColor(FWGeomColorIndex, Color_t)
fireworks::Context * m_context
Definition: CmsShowCommon.h:88
void switchBackground()
globcontrol glc
Definition: vlib.cc:6
TGFrame * makeSetter(TGCompositeFrame *frame, FWParameterBase *param)
std::auto_ptr< FWViewEnergyScale > m_energyScale
void permuteColors()
static std::shared_ptr< FWParameterSetterBase > makeSetterFor(FWParameterBase *)
FWColorSelect * m_colorRnrCtxHighlightWidget
TGLColorSet m_darkColorSet
FWColorSelect * m_colorRnrCtxSelectWidget
FWEnumParameter m_trackBreak
Definition: CmsShowCommon.h:90
Color_t geomColor(FWGeomColorIndex) const
FWEnumParameter m_palette
Definition: CmsShowCommon.h:96