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 
54 
55  TGCompositeFrame* vf2 = new TGVerticalFrame(this);
56  AddFrame(vf2, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
57  //==============================================================================
58  // scales
59  //
60  {
61  TGLabel* xx = new TGLabel(vf2, "GlobalScales ", fTextGC->GetGC());
62  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft ,2,2,4,4));
63  }
65  vf2->AddFrame(scaleEditor);
66  //==============================================================================
67  // Projections
68  //
69  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX,4 ,8, 3, 3));
70  {
71  TGLabel* xx = new TGLabel(vf2, "Projections ", fTextGC->GetGC());
72  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft ,2,2,4,4));
73  }
74  vf2->AddFrame(new TGLabel(vf2, "Track behaviour when crossing y=0 in RhoZ-view:"), new TGLayoutHints(kLHintsLeft ,2,2,0,0));
77 
78  //==============================================================================
79  // general colors
80  //
81 
82  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX ,4 ,8, 8, 2));
83  {
84  TGLabel* xx = new TGLabel(vf2, "General Colors ", fTextGC->GetGC());
85  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft,2,2,4,4));
86  }
87  m_backgroundButton = new TGTextButton(vf2, "Black/White Background");
88  vf2->AddFrame(m_backgroundButton);
89  makeSetter(vf2, &m_common->m_gamma);
90 
91  TGFont* smallFont = 0;
92  FontStruct_t defaultFontStruct = m_backgroundButton->GetDefaultFontStruct();
93  try
94  {
95  TGFontPool *pool = gClient->GetFontPool();
96  TGFont* defaultFont = pool->GetFont(defaultFontStruct);
97  FontAttributes_t attributes = defaultFont->GetFontAttributes();
98  smallFont = pool->GetFont(attributes.fFamily, 8, attributes.fWeight, attributes.fSlant);
99  }
100  catch(...)
101  {
102  // Ignore exceptions.
103  }
104 
105  // rnrCtx colorset
106  {
107  int hci, sci;
108  getColorSetColors(hci, sci);
109  TGHorizontalFrame* top = new TGHorizontalFrame(vf2);
110  vf2->AddFrame(top);
111  {
112  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
113  top->AddFrame(hf);
114 
115  m_colorRnrCtxHighlightWidget = new FWColorSelect(hf, "highlight", 0, m_common->colorManager(), 3);
116  hf->AddFrame(m_colorRnrCtxHighlightWidget);
118  m_colorRnrCtxHighlightWidget->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeSelectionColorSet(Color_t)");
119 
120  TGHorizontalFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
121  TGLabel* label = new TGLabel(lf, "Higlight");
122  label->SetTextFont(smallFont);
123  lf->AddFrame(label);
124  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0));
125  }
126 
127  {
128  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
129  top->AddFrame(hf);
130 
131  m_colorRnrCtxSelectWidget = new FWColorSelect(hf, "selectioyn", 0, m_common->colorManager(), 1);
132  hf->AddFrame(m_colorRnrCtxSelectWidget);
134  m_colorRnrCtxSelectWidget->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeSelectionColorSet(Color_t)");
135 
136  TGHorizontalFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
137  TGLabel* label = new TGLabel(lf, "Selection");
138  label->SetTextFont(smallFont);
139  lf->AddFrame(label);
140  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0));
141  }
142  }
143 
144  vf2->AddFrame(new TGHorizontal3DLine(vf2), new TGLayoutHints(kLHintsExpandX ,4 ,8, 8, 2));
145 
146  //==============================================================================
147  // geom colors
148  //
149 
150  {
151  TGLabel* xx = new TGLabel(vf2, "DetectorColors ", fTextGC->GetGC());
152  vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft,2,2,8,0));
153  }
154 
155  TGHSlider* transpWidget2D = 0;
156  TGHSlider* transpWidget3D = 0;
157  TGCompositeFrame* top = new TGVerticalFrame(vf2);
158  vf2->AddFrame(top, new TGLayoutHints(kLHintsNormal, 2, 2, 2, 0));
159 
160  {
161  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
162  hf->AddFrame(new TGLabel(hf, "Tansparency 2D:"), new TGLayoutHints(kLHintsBottom, 2, 2, 3, 3));
163  transpWidget2D = new TGHSlider(hf, 100, kSlider1);
164  hf->AddFrame( transpWidget2D);
165  top->AddFrame(hf,new TGLayoutHints( kLHintsNormal, 0, 0, 2, 2));
166  }
167  {
168  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
169  hf->AddFrame(new TGLabel(hf, "Tansparency 3D:") , new TGLayoutHints(kLHintsBottom,2, 2, 2, 2 ));
170  transpWidget3D = new TGHSlider(hf, 100, kSlider1);
171  hf->AddFrame( transpWidget3D);
172  top->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 10));
173  }
175  names[kFWPixelBarrelColorIndex ] = "Pixel Barrel";
176  names[kFWPixelEndcapColorIndex ] = "Pixel Endcap" ;
177  names[kFWTrackerBarrelColorIndex ] = "Tracker Barrel";
178  names[kFWTrackerEndcapColorIndex ] = "Tracker Endcap";
179  names[kFWMuonBarrelLineColorIndex] = "Muon Barrel";
180  names[kFWMuonEndcapLineColorIndex] = "Muon Endcap";
181  int i = 0;
182  for (int k = 0; k < 3; ++k)
183  {
184  TGHorizontalFrame* hf = new TGHorizontalFrame(top);
185  top->AddFrame(hf);
186 
187  for (int j = 0 ; j < 2; ++j)
188  {
189  m_colorSelectWidget[i] = new FWColorSelect(hf, names[i].c_str(), 0, m_common->colorManager(), i);
190  hf->AddFrame(m_colorSelectWidget[i]);
192  m_colorSelectWidget[i]->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeGeomColor(Color_t)");
193 
194  TGHorizontalFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
195  TGLabel* label = new TGLabel(lf, m_colorSelectWidget[i]->label().c_str());
196  label->SetTextFont(smallFont);
197  lf->AddFrame(label);
198  hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0));
199 
200  ++i;
201  }
202  }
203  //==============================================================================
204 
205  m_backgroundButton->Connect("Clicked()", "CmsShowCommonPopup", this, "switchBackground()");
206 
207  transpWidget2D->SetRange(0, 100);
208  transpWidget2D->SetPosition(m_common->colorManager()->geomTransparency(true));
209  transpWidget2D->Connect("PositionChanged(Int_t)", "CmsShowCommonPopup", this, "changeGeomTransparency2D(Int_t)");
210 
211  transpWidget3D->SetRange(0, 100);
212  transpWidget3D->SetPosition(m_common->colorManager()->geomTransparency(false));
213  transpWidget3D->Connect("PositionChanged(Int_t)", "CmsShowCommonPopup", this, "changeGeomTransparency3D(Int_t)");
214 
215  SetWindowName("Common Preferences");
216  MapSubwindows();
217  Resize(GetDefaultSize());
218  Layout();
219  CenterOnParent(kTRUE, TGTransientFrame::kTopRight);
220 }
221 
222 
223 
225 {
226 }
227 
228 void
230 {
232 }
233 
234 
235 void
237 {
238  TGColorSelect *cs = (TGColorSelect *) gTQSender;
239  FWGeomColorIndex cidx = FWGeomColorIndex(cs->WidgetId());
240  m_common->setGeomColor(cidx, iColor);
241 }
242 
243 
244 void
246 {
247  TGColorSelect *cs = (TGColorSelect *) gTQSender;
248 
249  //printf("~~~~~ changeSelectionColorSet sel[%d] idx[%d]\n", cs->WidgetId(), idx);
250  for (TEveElement::List_i it = gEve->GetViewers()->BeginChildren(); it != gEve->GetViewers()->EndChildren(); ++it)
251  {
252  TGLViewer* v = ((TEveViewer*)(*it))->GetGLViewer();
253 
254  TGLColorSet& colorset = m_common->colorManager()->isColorSetDark() ? v->RefDarkColorSet():v->RefLightColorSet();
255  colorset.Selection(cs->WidgetId()).SetColor(idx);
256  colorset.Selection(cs->WidgetId()+1).SetColor(idx); // implied selected/higlighted
257 
258  }
259 }
260 
261 
262 void
264 {
265  m_common->setGeomTransparency(iTransp, true);
266 }
267 
268 void
270 {
271  m_common->setGeomTransparency(iTransp, false);
272 }
273 
274 
275 /* Called by FWGUIManager when change background. */
276 void
278 {
279  for (int i = 0 ; i < kFWGeomColorSize; ++i)
280  m_colorSelectWidget[i]->SetColorByIndex(m_common->colorManager()->geomColor(FWGeomColorIndex(i)), kFALSE);
281 
282  int hci, sci;
283  getColorSetColors(hci, sci);
284  //printf("=============== colorSetChanged() dark ? [%d] %d %d \n",m_common->colorManager()->isColorSetDark(), hci, sci);
287 }
288 
289 void CmsShowCommonPopup::getColorSetColors (int& hci, int& sci)
290 {
291  TGLColorSet& colorset = m_common->colorManager()->isColorSetDark() ? gEve->GetDefaultGLViewer()->RefDarkColorSet():
292  gEve->GetDefaultGLViewer()->RefLightColorSet();
293  {
294  TGLColor& glc = colorset.Selection(3);
295  hci = TColor::GetColor(glc.GetRed(), glc.GetGreen(), glc.GetBlue());
296  // printf("getSHcolors HIGH %d %d %d , [%d]\n", glc.GetRed(), glc.GetGreen(), glc.GetBlue(), hci);
297  }{
298  TGLColor& glc = colorset.Selection(1);
299  sci = TColor::GetColor(glc.GetRed(), glc.GetGreen(), glc.GetBlue());
300  // printf("getSHcolors SEL %d %d %d , [%d]\n", glc.GetRed(), glc.GetGreen(), glc.GetBlue(), sci);
301  }
302 }
303 
304 void
305 CmsShowCommonPopup::makeSetter(TGCompositeFrame* frame, FWParameterBase* param)
306 {
307  boost::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor(param) );
308  ptr->attach(param, this);
309 
310  TGFrame* pframe = ptr->build(frame);
311  frame->AddFrame(pframe, new TGLayoutHints(kLHintsExpandX, 0, 0, 2,2));
312 
313  m_setters.push_back(ptr);
314 }
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
static const HistoName names[]
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
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::auto_ptr< FWViewEnergyScale > m_energyScale
Definition: CmsShowCommon.h:94
FWColorSelect * m_colorRnrCtxHighlightWidget
FWColorSelect * m_colorRnrCtxSelectWidget
T w() const
FWEnumParameter m_trackBreak
Definition: CmsShowCommon.h:81
Color_t geomColor(FWGeomColorIndex) const