GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Style.cpp
Go to the documentation of this file.
1 // $Id: TGo4Style.cpp 2039 2018-02-13 11:56:17Z adamczew $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum f�r Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4Style.h"
15 
16 #include "TStyle.h"
17 #include "TColor.h"
18 
19 #include "TGo4Picture.h"
20 #include "TGo4MdiArea.h"
21 #include "TGo4ViewPanel.h"
22 #include "TGo4QSettings.h"
23 
24 #include <QColorDialog>
25 
26 //#include "Riostream.h"
27 
28 TGo4Style::TGo4Style( QWidget* parent, const char* name, Qt::WindowFlags fl ) :
29  QWidget( parent, fl ), fbMenuLock(false), fbSettingPanelData(false)
30 {
31  setObjectName( name ? name : "Go4Style");
32  setupUi(this);
33 
34  connect(TGo4MdiArea::Instance(), SIGNAL(panelSignal(TGo4ViewPanel*, TPad*, int)),
35  this, SLOT(panelSlot(TGo4ViewPanel*, TPad*, int)));
36 
37 
38  for(int i=GO4NAMEDPAL_MIN; i<=GO4NAMEDPAL_MAX+2; ++i) // need two indices more for Go4_None and Go4_Default
39  {
40  PaletteComboBox->addItem("dummy");
41  }
42  PaletteComboBox->setItemText(Go4_None, "unnamed palette");
43  PaletteComboBox->setItemText(Go4_Default, "ClassicDefault");
44  PaletteComboBox->setItemText(Go4_DeepSea, "DeepSea");
45  PaletteComboBox->setItemText(Go4_GreyScale, "GreyScale");
46  PaletteComboBox->setItemText(Go4_DarkBodyRadiator, "DarkBodyRadiator");
47  PaletteComboBox->setItemText(Go4_BlueYellow, "BlueYellow");
48  PaletteComboBox->setItemText(Go4_RainBow, "RainBow");
49  PaletteComboBox->setItemText(Go4_InvertedDarkBodyRadiator,"InvertedDarkBodyRadiator");
50 // below for ROOT 6 only. This is all handled by indices of init loop above
51  PaletteComboBox->setItemText(Go4_Bird, "Bird");
52  PaletteComboBox->setItemText(Go4_Cubehelix, "Cubehelix");
53  PaletteComboBox->setItemText(Go4_GreenRedViolet, "GreenRedViolet");
54  PaletteComboBox->setItemText(Go4_BlueRedYellow, "BlueRedYellow");
55  PaletteComboBox->setItemText(Go4_Ocean, "Ocean");
56  PaletteComboBox->setItemText(Go4_ColorPrintableOnGrey, "ColorPrintableOnGrey");
57  PaletteComboBox->setItemText(Go4_Alpine, "Alpine");
58  PaletteComboBox->setItemText(Go4_Aquamarine, "Aquamarine");
59  PaletteComboBox->setItemText(Go4_Army, "Army");
60  PaletteComboBox->setItemText(Go4_Atlantic, "Atlantic");
61  PaletteComboBox->setItemText(Go4_Aurora, "Aurora");
62  PaletteComboBox->setItemText(Go4_Avocado, "Avocado");
63  PaletteComboBox->setItemText(Go4_Beach, "Beach");
64  PaletteComboBox->setItemText(Go4_BlackBody, "BlackBody");
65  PaletteComboBox->setItemText(Go4_BlueGreenYellow, "BlueGreenYellow");
66  PaletteComboBox->setItemText(Go4_BrownCyan, "BrownCyan");
67  PaletteComboBox->setItemText(Go4_CMYK, "CMYK");
68  PaletteComboBox->setItemText(Go4_Candy, "Candy");
69  PaletteComboBox->setItemText(Go4_Cherry, "Cherry");
70  PaletteComboBox->setItemText(Go4_Coffee, "Coffee");
71  PaletteComboBox->setItemText(Go4_DarkRainBow, "DarkRainBow");
72  PaletteComboBox->setItemText(Go4_DarkTerrain, "DarkTerrain");
73  PaletteComboBox->setItemText(Go4_Fall, "Fall");
74  PaletteComboBox->setItemText(Go4_FruitPunch, "FruitPunch");
75  PaletteComboBox->setItemText(Go4_Fuchsia, "Fuchsia");
76  PaletteComboBox->setItemText(Go4_GreyYellow, "GreyYellow");
77  PaletteComboBox->setItemText(Go4_GreenBrownTerrain, "GreenBrownTerrain");
78  PaletteComboBox->setItemText(Go4_GreenPink, "GreenPink");
79  PaletteComboBox->setItemText(Go4_Island, "Island");
80  PaletteComboBox->setItemText(Go4_Lake, "Lake");
81  PaletteComboBox->setItemText(Go4_LightTemperature, "LightTemperature");
82  PaletteComboBox->setItemText(Go4_LightTerrain, "LightTerrain");
83  PaletteComboBox->setItemText(Go4_Mint, "Mint");
84  PaletteComboBox->setItemText(Go4_Neon, "Neon");
85  PaletteComboBox->setItemText(Go4_Pastel, "Pastel");
86  PaletteComboBox->setItemText(Go4_Pearl, "Pearl");
87  PaletteComboBox->setItemText(Go4_Pigeon, "Pigeon");
88  PaletteComboBox->setItemText(Go4_Plum, "Plum");
89  PaletteComboBox->setItemText(Go4_RedBlue, "RedBlue");
90  PaletteComboBox->setItemText(Go4_Rose, "Rose");
91  PaletteComboBox->setItemText(Go4_Rust, "Rust");
92  PaletteComboBox->setItemText(Go4_SandyTerrain, "SandyTerrain");
93  PaletteComboBox->setItemText(Go4_Sienna, "Sienna");
94  PaletteComboBox->setItemText(Go4_Solar, "Solar");
95  PaletteComboBox->setItemText(Go4_SouthWest, "SouthWest");
96  PaletteComboBox->setItemText(Go4_StarryNight, "StarryNight");
97  PaletteComboBox->setItemText(Go4_Sunset, "Sunset");
98  PaletteComboBox->setItemText(Go4_TemperatureMap, "TemperatureMap");
99  PaletteComboBox->setItemText(Go4_Thermometer, "Thermometer");
100  PaletteComboBox->setItemText(Go4_Valentine, "Valentine");
101  PaletteComboBox->setItemText(Go4_VisibleSpectrum, "VisibleSpectrum");
102  PaletteComboBox->setItemText(Go4_WaterMelon, "WaterMelon");
103  PaletteComboBox->setItemText(Go4_Cool, "Cool");
104  PaletteComboBox->setItemText(Go4_Copper, "Copper");
105  PaletteComboBox->setItemText(Go4_GistEarth, "GistEarth");
106  PaletteComboBox->setItemText(Go4_Viridis, "Viridis");
107 
108  // here defaults from settings:
109  int min,max,def;
110  go4sett->getPaletteOpt(min,def,max);
111  //std::cout<<"TGo4Style - Palette options are "<<min<<":"<<def<<":"<<max << std::endl;
112 
113  SetPaletteRange(min,def,max);
114 }
115 
116 void TGo4Style::SetPaletteRange(int min, int def, int max)
117 {
118  Palette->setMinimum(min);
119  Palette->setMaximum(max);
120  Palette->setValue(def);
121  def=Palette->value(); // spinbox automatic limiting of range
122  //gStyle->SetPalette(def,0,0);
123  gStyle->SetPalette(def);
124  SetPalette(def);
125  RefreshPaletteText(min,max);
126 }
127 
128 void TGo4Style::RefreshPaletteText(int min, int max)
129 {
130  // mark unavailable entries in palette selection box:
131  QString label;
132  const QString notavailable = "not avail:";
133  for (int pt = 0; pt <= GO4NAMEDPAL_MAX + 2 - GO4NAMEDPAL_MIN; ++pt) { // need two indices more for Go4_None and Go4_Default
134  int ix = DecodePalette((Go4_Palette_t)pt);
135  if (ix < 0)
136  continue;
137  label = PaletteComboBox->itemText(pt);
138  label.remove(notavailable); // clear any old markers
139  if ((ix < min) || (ix > max)) {
140  label.prepend(notavailable);
141  }
142  PaletteComboBox->setItemText(pt, label);
143  }
144 }
145 
147 {
148  QColor c = QColorDialog::getColor();
149  if (!c.isValid()) return;
150  Int_t color = TColor::GetColor(c.red(), c.green(), c.blue());
152  if (panel!=0)
153  panel->ChangeDrawOption(101, color, 0);
154 }
155 
157 {
158  //std::cout<<"TGo4Style::SetPalette "<<t << std::endl;
160  if (panel != 0)
161  panel->ChangeDrawOption(100, t, 0);
162  if (!fbMenuLock) // try to avoid feedback of qt signals between widget slots
163  {
164  fbMenuLock = true;
165  PaletteComboBox->setCurrentIndex(CodePalette(t));
166  fbMenuLock = false;
167  }
168 }
169 
170 
172 {
173  //std::cout<<"TGo4Style::SetNamedPalette "<<i << std::endl;
174  int ix = DecodePalette((Go4_Palette_t) i);
175  if (ix<0) return;
176  // range check of current preferences here:
177  if(ix< Palette->minimum())
178  {
179  ix=Palette->minimum();
180  PaletteComboBox->setCurrentIndex(CodePalette(ix)); // show correct palette name here.
181  }
182  if(ix> Palette->maximum())
183  {
184  ix=Palette->maximum();
185  PaletteComboBox->setCurrentIndex(CodePalette(ix)); // show correct palette name here.
186  }
187  if (!fbMenuLock) // try to avoid feedback of qt signals between widget slots
188  {
189  fbMenuLock = true;
190  Palette->setValue(ix);
191  fbMenuLock = false;
192  }
193 }
194 
196 {
197  Go4_Palette_t rev;
198  if(i==1)
199  rev=Go4_Default;
200  else if(i<GO4NAMEDPAL_MIN || i > GO4NAMEDPAL_MAX)
201  rev=Go4_None;
202  else
203  rev= (Go4_Palette_t) (i +2 -GO4NAMEDPAL_MIN); // account Go4_None and Go4_Default offset
204  return rev;
205 }
206 
208 {
209  if (key==Go4_None) return -1;
210  if (key==Go4_Default) return 1; // old default rainbow index
211  return (key-2 + GO4NAMEDPAL_MIN ); // account Go4_None and Go4_Default offset
212 }
213 
215 {
216  if (fbSettingPanelData) return;
217 
219  if (panel)
220  panel->ChangeDrawOption(18, nlvl, 0);
221 }
222 
223 void TGo4Style::panelSlot(TGo4ViewPanel* panel, TPad* pad, int signalid)
224 {
225  switch (signalid) {
228  break;
231  TGo4Picture* padopt = panel->GetPadOptions(pad);
232  if (padopt==0) break;
233 
234  int nlvl = padopt->GetHisContour();
235 
236  fbSettingPanelData = true;
237 
238  ContourSpin->setValue(nlvl>0 ? nlvl : 20);
239 
240  fbSettingPanelData = false;
241 
242  break;
243  }
244  default:
245  break;
246  }
247 }
248 
249 
virtual void SetContourLevels(int nlvl)
Definition: TGo4Style.cpp:214
TGo4Style(QWidget *parent=0, const char *name=0, Qt::WindowFlags fl=0)
Definition: TGo4Style.cpp:28
static TGo4MdiArea * Instance()
Definition: TGo4MdiArea.cpp:27
virtual void SetNamedPalette(int i)
Definition: TGo4Style.cpp:171
Go4_Palette_t CodePalette(int i)
Definition: TGo4Style.cpp:195
virtual void SetPalette(int t)
Definition: TGo4Style.cpp:156
bool fbMenuLock
Definition: TGo4Style.h:152
virtual void panelSlot(TGo4ViewPanel *panel, TPad *pad, int signalid)
Definition: TGo4Style.cpp:223
virtual void SetPaletteRange(int min, int def, int max)
Definition: TGo4Style.cpp:116
#define GO4NAMEDPAL_MAX
Definition: TGo4Style.h:29
TGo4QSettings * go4sett
TGo4ViewPanel * GetActivePanel()
Definition: TGo4MdiArea.cpp:64
virtual void SetPadColor()
Definition: TGo4Style.cpp:146
virtual TGo4Picture * GetPadOptions(TPad *pad)
Go4_Palette_t
Definition: TGo4Style.h:47
Int_t GetHisContour() const
int DecodePalette(Go4_Palette_t key)
Definition: TGo4Style.cpp:207
void getPaletteOpt(int &min, int &def, int &max)
void RefreshPaletteText(int min, int max)
Definition: TGo4Style.cpp:128
virtual void ChangeDrawOption(int kind, int value, const char *drawopt)
#define GO4NAMEDPAL_MIN
Definition: TGo4Style.h:26
bool fbSettingPanelData
Definition: TGo4Style.h:154