GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4Style.cpp
Go to the documentation of this file.
1// $Id$
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 fuer 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#include "TPad.h"
19
20#include "TGo4Picture.h"
21#include "TGo4MdiArea.h"
22#include "TGo4ViewPanel.h"
23#include "TGo4QSettings.h"
24
25#include <QColorDialog>
26
27TGo4Style::TGo4Style(QWidget *parent, const char *name, Qt::WindowFlags fl) :
28 QWidget( parent, fl ), fbMenuLock(false), fbSettingPanelData(false)
29{
30 setObjectName(name ? name : "Go4Style");
31 setupUi(this);
32
33 QObject::connect(Palette, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4Style::SetPalette);
34 QObject::connect(PaletteComboBox, QOverload<int>::of(&QComboBox::activated), this, &TGo4Style::SetNamedPalette);
35 QObject::connect(ContourSpin, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4Style::SetContourLevels);
36 QObject::connect(PadColor, &QPushButton::clicked, this, &TGo4Style::SetPadColor);
37
39
40 for(int i=GO4NAMEDPAL_MIN; i<=GO4NAMEDPAL_MAX+2; ++i) // need two indices more for Go4_None and Go4_Default
41 {
42 PaletteComboBox->addItem("dummy");
43 }
44 PaletteComboBox->setItemText(Go4_None, "unnamed palette");
45 PaletteComboBox->setItemText(Go4_Default, "ClassicDefault");
46 PaletteComboBox->setItemText(Go4_DeepSea, "DeepSea");
47 PaletteComboBox->setItemText(Go4_GreyScale, "GreyScale");
48 PaletteComboBox->setItemText(Go4_DarkBodyRadiator, "DarkBodyRadiator");
49 PaletteComboBox->setItemText(Go4_BlueYellow, "BlueYellow");
50 PaletteComboBox->setItemText(Go4_RainBow, "RainBow");
51 PaletteComboBox->setItemText(Go4_InvertedDarkBodyRadiator,"InvertedDarkBodyRadiator");
52// below for ROOT 6 only. This is all handled by indices of init loop above
53 PaletteComboBox->setItemText(Go4_Bird, "Bird");
54 PaletteComboBox->setItemText(Go4_Cubehelix, "Cubehelix");
55 PaletteComboBox->setItemText(Go4_GreenRedViolet, "GreenRedViolet");
56 PaletteComboBox->setItemText(Go4_BlueRedYellow, "BlueRedYellow");
57 PaletteComboBox->setItemText(Go4_Ocean, "Ocean");
58 PaletteComboBox->setItemText(Go4_ColorPrintableOnGrey, "ColorPrintableOnGrey");
59 PaletteComboBox->setItemText(Go4_Alpine, "Alpine");
60 PaletteComboBox->setItemText(Go4_Aquamarine, "Aquamarine");
61 PaletteComboBox->setItemText(Go4_Army, "Army");
62 PaletteComboBox->setItemText(Go4_Atlantic, "Atlantic");
63 PaletteComboBox->setItemText(Go4_Aurora, "Aurora");
64 PaletteComboBox->setItemText(Go4_Avocado, "Avocado");
65 PaletteComboBox->setItemText(Go4_Beach, "Beach");
66 PaletteComboBox->setItemText(Go4_BlackBody, "BlackBody");
67 PaletteComboBox->setItemText(Go4_BlueGreenYellow, "BlueGreenYellow");
68 PaletteComboBox->setItemText(Go4_BrownCyan, "BrownCyan");
69 PaletteComboBox->setItemText(Go4_CMYK, "CMYK");
70 PaletteComboBox->setItemText(Go4_Candy, "Candy");
71 PaletteComboBox->setItemText(Go4_Cherry, "Cherry");
72 PaletteComboBox->setItemText(Go4_Coffee, "Coffee");
73 PaletteComboBox->setItemText(Go4_DarkRainBow, "DarkRainBow");
74 PaletteComboBox->setItemText(Go4_DarkTerrain, "DarkTerrain");
75 PaletteComboBox->setItemText(Go4_Fall, "Fall");
76 PaletteComboBox->setItemText(Go4_FruitPunch, "FruitPunch");
77 PaletteComboBox->setItemText(Go4_Fuchsia, "Fuchsia");
78 PaletteComboBox->setItemText(Go4_GreyYellow, "GreyYellow");
79 PaletteComboBox->setItemText(Go4_GreenBrownTerrain, "GreenBrownTerrain");
80 PaletteComboBox->setItemText(Go4_GreenPink, "GreenPink");
81 PaletteComboBox->setItemText(Go4_Island, "Island");
82 PaletteComboBox->setItemText(Go4_Lake, "Lake");
83 PaletteComboBox->setItemText(Go4_LightTemperature, "LightTemperature");
84 PaletteComboBox->setItemText(Go4_LightTerrain, "LightTerrain");
85 PaletteComboBox->setItemText(Go4_Mint, "Mint");
86 PaletteComboBox->setItemText(Go4_Neon, "Neon");
87 PaletteComboBox->setItemText(Go4_Pastel, "Pastel");
88 PaletteComboBox->setItemText(Go4_Pearl, "Pearl");
89 PaletteComboBox->setItemText(Go4_Pigeon, "Pigeon");
90 PaletteComboBox->setItemText(Go4_Plum, "Plum");
91 PaletteComboBox->setItemText(Go4_RedBlue, "RedBlue");
92 PaletteComboBox->setItemText(Go4_Rose, "Rose");
93 PaletteComboBox->setItemText(Go4_Rust, "Rust");
94 PaletteComboBox->setItemText(Go4_SandyTerrain, "SandyTerrain");
95 PaletteComboBox->setItemText(Go4_Sienna, "Sienna");
96 PaletteComboBox->setItemText(Go4_Solar, "Solar");
97 PaletteComboBox->setItemText(Go4_SouthWest, "SouthWest");
98 PaletteComboBox->setItemText(Go4_StarryNight, "StarryNight");
99 PaletteComboBox->setItemText(Go4_Sunset, "Sunset");
100 PaletteComboBox->setItemText(Go4_TemperatureMap, "TemperatureMap");
101 PaletteComboBox->setItemText(Go4_Thermometer, "Thermometer");
102 PaletteComboBox->setItemText(Go4_Valentine, "Valentine");
103 PaletteComboBox->setItemText(Go4_VisibleSpectrum, "VisibleSpectrum");
104 PaletteComboBox->setItemText(Go4_WaterMelon, "WaterMelon");
105 PaletteComboBox->setItemText(Go4_Cool, "Cool");
106 PaletteComboBox->setItemText(Go4_Copper, "Copper");
107 PaletteComboBox->setItemText(Go4_GistEarth, "GistEarth");
108 PaletteComboBox->setItemText(Go4_Viridis, "Viridis");
109
110 // here defaults from settings:
111 int min,max,def;
112 go4sett->getPaletteOpt(min,def,max);
113
114 SetPaletteRange(min,def,max);
115}
116
117void TGo4Style::SetPaletteRange(int min, int def, int max)
118{
119 Palette->setMinimum(min);
120 Palette->setMaximum(max);
121 Palette->setValue(def);
122 def = Palette->value(); // spinbox automatic limiting of range
123 // gStyle->SetPalette(def,0,0);
124 gStyle->SetPalette(def);
125 SetPalette(def);
126 RefreshPaletteText(min, max);
127}
128
129void TGo4Style::RefreshPaletteText(int min, int max)
130{
131 // mark unavailable entries in palette selection box:
132 QString label;
133 const QString notavailable = "not avail:";
134 for (int pt = 0; pt <= GO4NAMEDPAL_MAX + 2 - GO4NAMEDPAL_MIN; ++pt) { // need two indices more for Go4_None and Go4_Default
135 int ix = DecodePalette((Go4_Palette_t)pt);
136 if (ix < 0)
137 continue;
138 label = PaletteComboBox->itemText(pt);
139 label.remove(notavailable); // clear any old markers
140 if ((ix < min) || (ix > max)) {
141 label.prepend(notavailable);
142 }
143 PaletteComboBox->setItemText(pt, label);
144 }
145}
146
148{
149 QColor c = QColorDialog::getColor();
150 if (!c.isValid()) return;
151 Int_t color = TColor::GetColor(c.red(), c.green(), c.blue());
153 if (panel)
154 panel->ChangeDrawOption(101, color, nullptr);
155}
156
158{
160 if (panel)
161 panel->ChangeDrawOption(100, t, nullptr);
162 if (!fbMenuLock) { // try to avoid feedback of qt signals between widget slots
163 fbMenuLock = true;
164 PaletteComboBox->setCurrentIndex(CodePalette(t));
165 fbMenuLock = false;
166 }
167}
168
170{
171 int ix = DecodePalette((Go4_Palette_t)i);
172 if (ix < 0)
173 return;
174 // range check of current preferences here:
175 if (ix < Palette->minimum()) {
176 ix = Palette->minimum();
177 PaletteComboBox->setCurrentIndex(CodePalette(ix)); // show correct palette name here.
178 }
179 if (ix > Palette->maximum()) {
180 ix = Palette->maximum();
181 PaletteComboBox->setCurrentIndex(CodePalette(ix)); // show correct palette name here.
182 }
183 if (!fbMenuLock) // try to avoid feedback of qt signals between widget slots
184 {
185 fbMenuLock = true;
186 Palette->setValue(ix);
187 fbMenuLock = false;
188 }
189}
190
192{
193 Go4_Palette_t rev;
194 if (i == 1)
195 rev = Go4_Default;
196 else if (i < GO4NAMEDPAL_MIN || i > GO4NAMEDPAL_MAX)
197 rev = Go4_None;
198 else
199 rev = (Go4_Palette_t)(i + 2 - GO4NAMEDPAL_MIN); // account Go4_None and Go4_Default offset
200 return rev;
201}
202
204{
205 if (key == Go4_None) return -1;
206 if (key == Go4_Default) return 1; // old default rainbow index
207 return key - 2 + GO4NAMEDPAL_MIN; // account Go4_None and Go4_Default offset
208}
209
211{
212 if (fbSettingPanelData) return;
213
215 if (panel)
216 panel->ChangeDrawOption(18, nlvl, nullptr);
217}
218
219void TGo4Style::panelSlot(TGo4ViewPanel *panel, TPad *pad, int signalid)
220{
221 switch (signalid) {
224 break;
227 TGo4Picture *padopt = panel->GetPadOptions(pad);
228 if (!padopt) break;
229
230 int nlvl = padopt->GetHisContour();
231
232 fbSettingPanelData = true;
233
234 ContourSpin->setValue(nlvl>0 ? nlvl : 20);
235
236 fbSettingPanelData = false;
237
238 break;
239 }
240 default:
241 break;
242 }
243}
TGo4QSettings * go4sett
#define GO4NAMEDPAL_MIN
Translate the ROOT palette styles to indices of dropdown menu here: In simplest case this is just an ...
Definition TGo4Style.h:24
#define GO4NAMEDPAL_MAX
Definition TGo4Style.h:26
Go4_Palette_t
Definition TGo4Style.h:29
@ Go4_GreenPink
Definition TGo4Style.h:65
@ Go4_Viridis
Definition TGo4Style.h:93
@ Go4_StarryNight
Definition TGo4Style.h:83
@ Go4_CMYK
Definition TGo4Style.h:54
@ Go4_GreenBrownTerrain
Definition TGo4Style.h:64
@ Go4_Rose
Definition TGo4Style.h:77
@ Go4_Cubehelix
Definition TGo4Style.h:39
@ Go4_VisibleSpectrum
Definition TGo4Style.h:88
@ Go4_ColorPrintableOnGrey
Definition TGo4Style.h:43
@ Go4_LightTerrain
Definition TGo4Style.h:69
@ Go4_None
Definition TGo4Style.h:30
@ Go4_Aurora
Definition TGo4Style.h:48
@ Go4_Default
Definition TGo4Style.h:31
@ Go4_Island
Definition TGo4Style.h:66
@ Go4_Ocean
Definition TGo4Style.h:42
@ Go4_FruitPunch
Definition TGo4Style.h:61
@ Go4_Coffee
Definition TGo4Style.h:57
@ Go4_Army
Definition TGo4Style.h:46
@ Go4_Pigeon
Definition TGo4Style.h:74
@ Go4_DarkTerrain
Definition TGo4Style.h:59
@ Go4_Alpine
Definition TGo4Style.h:44
@ Go4_BlueYellow
Definition TGo4Style.h:35
@ Go4_BlackBody
Definition TGo4Style.h:51
@ Go4_GistEarth
Definition TGo4Style.h:92
@ Go4_BlueRedYellow
Definition TGo4Style.h:41
@ Go4_Plum
Definition TGo4Style.h:75
@ Go4_WaterMelon
Definition TGo4Style.h:89
@ Go4_Thermometer
Definition TGo4Style.h:86
@ Go4_Solar
Definition TGo4Style.h:81
@ Go4_DarkBodyRadiator
Definition TGo4Style.h:34
@ Go4_Fall
Definition TGo4Style.h:60
@ Go4_DarkRainBow
Definition TGo4Style.h:58
@ Go4_InvertedDarkBodyRadiator
Definition TGo4Style.h:37
@ Go4_Candy
Definition TGo4Style.h:55
@ Go4_Mint
Definition TGo4Style.h:70
@ Go4_SandyTerrain
Definition TGo4Style.h:79
@ Go4_Sienna
Definition TGo4Style.h:80
@ Go4_BlueGreenYellow
Definition TGo4Style.h:52
@ Go4_Aquamarine
Definition TGo4Style.h:45
@ Go4_Copper
Definition TGo4Style.h:91
@ Go4_Valentine
Definition TGo4Style.h:87
@ Go4_Rust
Definition TGo4Style.h:78
@ Go4_RainBow
Definition TGo4Style.h:36
@ Go4_LightTemperature
Definition TGo4Style.h:68
@ Go4_Beach
Definition TGo4Style.h:50
@ Go4_GreenRedViolet
Definition TGo4Style.h:40
@ Go4_Pearl
Definition TGo4Style.h:73
@ Go4_GreyScale
Definition TGo4Style.h:33
@ Go4_Avocado
Definition TGo4Style.h:49
@ Go4_Neon
Definition TGo4Style.h:71
@ Go4_BrownCyan
Definition TGo4Style.h:53
@ Go4_TemperatureMap
Definition TGo4Style.h:85
@ Go4_RedBlue
Definition TGo4Style.h:76
@ Go4_Pastel
Definition TGo4Style.h:72
@ Go4_Bird
Definition TGo4Style.h:38
@ Go4_Sunset
Definition TGo4Style.h:84
@ Go4_GreyYellow
Definition TGo4Style.h:63
@ Go4_Cherry
Definition TGo4Style.h:56
@ Go4_Cool
Definition TGo4Style.h:90
@ Go4_Lake
Definition TGo4Style.h:67
@ Go4_DeepSea
Definition TGo4Style.h:32
@ Go4_Atlantic
Definition TGo4Style.h:47
@ Go4_Fuchsia
Definition TGo4Style.h:62
@ Go4_SouthWest
Definition TGo4Style.h:82
@ panel_Activated
Definition QGo4Widget.h:90
@ panel_ActiveUpdated
Definition QGo4Widget.h:93
void panelSignal(TGo4ViewPanel *, TPad *, int)
static TGo4MdiArea * Instance()
TGo4ViewPanel * GetActivePanel()
Picture cconfiguration in Go4.
Definition TGo4Picture.h:40
Int_t GetHisContour() const
virtual void SetPadColor()
virtual void SetPalette(int t)
virtual void SetNamedPalette(int i)
bool fbMenuLock
Definition TGo4Style.h:128
TGo4Style(QWidget *parent=nullptr, const char *name=nullptr, Qt::WindowFlags fl=Qt::Widget)
Definition TGo4Style.cpp:27
virtual void panelSlot(TGo4ViewPanel *panel, TPad *pad, int signalid)
virtual void SetPaletteRange(int min, int def, int max)
Set default palette and minimum maximum indices.
void RefreshPaletteText(int min, int max)
Change selection menu entries according to index range.
int DecodePalette(Go4_Palette_t key)
Transform combobox index to ROOT palette index.
virtual void SetContourLevels(int nlvl)
Go4_Palette_t CodePalette(int i)
Transform ROOT palette index in named palette combobox index.
bool fbSettingPanelData
Definition TGo4Style.h:129
virtual void ChangeDrawOption(int kind, int value, const char *drawopt)
virtual TGo4Picture * GetPadOptions(TPad *pad)