32#include "RConfigure.h"
38# define X_DISPLAY_MISSING 1
42#include "Windows4root.h"
46# include <afterbase.h>
48# define X_DISPLAY_MISSING 1
49# include <afterbase.h>
51# include <afterimage.h>
58 "ROOT palette file",
"*.pal.root",
59 "ASCII palette file",
"*.pal.txt",
64 0x0000, 0x7000, 0x0000, 0x0000, 0x0000,
65 0xffff, 0xffff, 0x7000, 0x8000, 0xffff
68 0x0000, 0x0000, 0x0000, 0xffff, 0xffff,
69 0xffff, 0x0000, 0x0000, 0x8000, 0xffff
72 0x0000, 0x7000, 0xffff, 0xffff, 0x0000,
73 0x0000, 0x0000, 0x0000, 0xa000, 0xffff
114 button->
SetToolTipText(
"Save the palette in a ROOT or an ASCII file");
118 button->
SetToolTipText(
"Read a palette from a ROOT or an ASCII file");
122 button->
SetToolTipText(
"Create a new palette (not yet implemented)");
132 fAutoUpdate->SetToolTipText(
"Automatic update of the image (without Apply button)");
136 fUnDoButton->SetToolTipText(
"Undo the last modification (repeatable)");
140 fReDoButton->SetToolTipText(
"Undo the last undo operation (repeatable)");
144 button->
SetToolTipText(
"Apply a log operation to the anchor points of the palette");
148 button->
SetToolTipText(
"Apply a exp operation to the anchor points of the palette");
152 button->
SetToolTipText(
"Make the distance of all anchor points constant");
160 fStepButton->SetToolTipText(
"Apply a step function to the palette");
171 fRamps[0]->SetToolTipText(
"Repeat the palette once");
175 fRamps[1]->SetToolTipText(
"Repeat the palette twice");
179 fRamps[2]->SetToolTipText(
"Repeat the palette four times");
182 fRamps[0]->Associate(
this);
183 fRamps[1]->Associate(
this);
184 fRamps[2]->Associate(
this);
191 const ASImage *image = ((
TASImage*)attImage)->GetImage();
192 if (image && image->alt.vector) {
195 Int_t numPixel = image->width * image->height;
196 Int_t numBins = numPixel / 20;
197 numBins = (numBins < 10) ? 10 : (numBins > 200) ? 200 : numBins;
201 for (pixel = 1; pixel < numPixel; pixel++) {
206 fHisto =
new TH1D(
"Statistics",
"Pixel histogram of unzoomed image ",
208 for (pixel = 0; pixel < numPixel; pixel++)
209 fHisto->Fill(*(data + pixel));
212 fHisto->GetXaxis()->SetLabelFont(63);
213 fHisto->GetXaxis()->SetLabelSize(10);
214 fHisto->GetYaxis()->SetLabelFont(63);
215 fHisto->GetYaxis()->SetLabelSize(10);
218 0,
fHisto->GetMaximum(),
this);
435 FILE *fl = fopen(fn.
Data(),
"w");
438 fprintf(fl,
"%u\n",
fPalette->fNumPoints);
470 FILE *fl = fopen(fn.
Data(),
"r");
474 if (fscanf(fl,
"%u\n", &numPoints) != 1)
475 Error(
"Open",
"Failure reading num points from %s", fn.
Data());
480 Error(
"Open",
"Failure reading point %u from %s",
pt, fn.
Data());
491 if (!fsave || !fsave->IsOpen()) {
562 off = (
fPalette->fNumPoints - 2) / 2;
627 delta * (
pt - 1) / (
fPalette->fNumPoints - 3);
679 numPt =
id == 0 ? 12 : 13;
704 newPalette->
fColorRed[
pt] = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
711 newPalette->
fColorGreen[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
712 newPalette->
fColorBlue[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
720 newPalette->
fColorBlue[
pt] = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
724 newPalette->
fColorRed[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
725 newPalette->
fColorGreen[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
733 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
735 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
737 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
822 for (
Int_t rp = 0; rp < ramp; rp++) {
877 if (newDelta < 0.001 || oldDelta < 0.001)
901 grad.npoints = (*fPalette)->fNumPoints - 2;
902 grad.type = GRADIENT_Left2Right;
903 grad.color =
new ARGB32[grad.npoints];
904 grad.offset =
new double[grad.npoints];
906 grad.offset[
pt] = ((*fPalette)->fPoints[
pt + 1] - (*fPalette)->fPoints[1]) /
907 ((*fPalette)->fPoints[(*fPalette)->fNumPoints - 2] - (*fPalette)->fPoints[1]);
908 grad.color[
pt] = (((ARGB32)((*fPalette)->fColorBlue[
pt + 1] & 0xff00)) >> 8) |
909 (((ARGB32)((*fPalette)->fColorGreen[
pt + 1] & 0xff00)) ) |
910 (((ARGB32)((*fPalette)->fColorRed[
pt + 1] & 0xff00)) << 8) |
911 (((ARGB32)((*fPalette)->fColorAlpha[
pt + 1] & 0xff00)) << 16);
915 SCL_DO_COLOR, ASA_ARGB32, 0,
917 delete [] grad.color;
918 delete [] grad.offset;
922 destroy_asimage(&grad_im);
Handle_t Window_t
Window handle.
double Coord_t
Pad world coordinates (double).
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short).
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
static UShort_t gRedRainbow[12]
static UShort_t gBlueRainbow[12]
static UShort_t gGreenRainbow[12]
static const char * gFileTypes[]
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
static const ASVisual * GetVisual()
Return visual.
static void Image2Drawable(ASImage *im, Drawable_t wid, Int_t x, Int_t y, Int_t xsrc=0, Int_t ysrc=0, UInt_t wsrc=0, UInt_t hsrc=0, Option_t *opt="")
Draw asimage on drawable.
void Paint(Option_t *option="") override
Paint the limit lines.
LimitLine(Coord_t x, Coord_t y1, Coord_t y2, TASPaletteEditor *gui)
The blue limit line in the pixel value histogram.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to an event at (px,py).
void Paint(Option_t *option="") override
Actually paint the paletter.
void UpdateScreen(Bool_t histoUpdate)
All widgets of the screen are updated with the current palette.
PaintPalette * fPaintPalette
void UpdateRange()
Updates the range of the palette.
TGTextButton * fUnDoButton
TImagePalette * fPalette
current palette
TGCheckButton * fStepButton
TGTextButton * fReDoButton
Double_t fMinValue
min value of image
void Open()
Opens either a ROOT file or an ASCII file and reads a palette.
TList * fPaletteList
list of palettes for undo and redo
void ExpPalette()
The anchor points are rescaled by a exp operation.
void InsertNewPalette(TImagePalette *newPalette)
The newPalette is inserted in the list of palettes (fPaletteList) and fPalette is set to the newPalet...
void CloseWindow() override
Close editor.
TGRadioButton * fRamps[3]
TASPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h)
Palette editor constructor.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t param1, Longptr_t param2) override
Process all editor mouse events.
TRootEmbeddedCanvas * fHistCanvas
canvas to draw the histogram
TH1D * fHisto
histogram of image pixels
~TASPaletteEditor() override
Palette editor destructor. Deletes all frames and their layout hints.
void Save()
Saves the current palette either into a ROOT file or in an ASCII file.
TGCheckButton * fAutoUpdate
void NewPalette(Long_t id)
A new palette is created, depending on the id.
void LinPalette()
The anchor points are rescaled to be linar.
LimitLine * fLimitLine[2]
void SetRamp(Long_t ramp)
The palette is repeated up to 4 times.
void InvertPalette()
The palette is inverted.
void SetStep()
Create a step palette.
Double_t fMaxValue
max value of image
void LogPalette()
The anchor points are rescaled by a log operation.
TRootEmbeddedCanvas * fPaletteCanvas
canvas to draw the current palette
virtual const TImagePalette & GetPalette() const
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Describe directory structure in memory.
virtual Bool_t cd()
Change current directory to "this" directory.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
void Layout() override
Layout the elements of the composite frame.
TList * fList
container of frame elements
This class creates a file selection dialog.
char * fFilename
selected file name
const char ** fFileTypes
file types used to filter selectable files
Bool_t fOverwrite
if true overwrite the file with existing name on save
void MapWindow() override
map window
A composite frame with a border and a title.
TGMainFrame(const TGMainFrame &)=delete
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
void SetWindowName(const char *name=nullptr) override
Set window name. This is typically done via the window manager.
Yield an action as soon as it is clicked.
This layout hint must be used for the TGXYLayout manager!
Is a layout manager where the position and the size of each widget in the frame are defined by X / Y ...
1-D histogram with a double per channel (see TH1 documentation)
A class to define a conversion from pixel values to pixel color.
UShort_t * fColorRed
[fNumPoints] red color at each anchor point
Double_t * fPoints
[fNumPoints] value of each anchor point [0..1]
UShort_t * fColorGreen
[fNumPoints] green color at each anchor point
UShort_t * fColorBlue
[fNumPoints] blue color at each anchor point
UInt_t fNumPoints
number of anchor points
UShort_t * fColorAlpha
[fNumPoints] alpha at each anchor point
Double_t fY1
Y of 1st point.
Double_t fX1
X of 1st point.
Double_t fX2
X of 2nd point.
void Paint(Option_t *option="") override
Paint this line with its current attributes.
Double_t fY2
Y of 2nd point.
virtual void CloseWindow()
Closes the window and deletes itself.
TPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h)
Constructor.
This class creates a TGCanvas in which a TCanvas is created.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const char * Data() const
TString & Append(const char *cs)
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.