CMS 3D CMS Logo

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