32#include "RConfigure.h"
38# define X_DISPLAY_MISSING 1
42#include "Windows4root.h"
46# include <afterbase.h>
48# include <win32/config.h>
49# include <win32/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
103 button->SetToolTipText(
"Apply the palette to the image");
107 button->SetToolTipText(
"Same as Apply and Cancel button");
111 button->SetToolTipText(
"Close this window");
115 button->SetToolTipText(
"Save the palette in a ROOT or an ASCII file");
119 button->SetToolTipText(
"Read a palette from a ROOT or an ASCII file");
123 button->SetToolTipText(
"Create a new palette (not yet implemented)");
128 button->SetToolTipText(
"Edit a palette (not yet implemented)");
133 fAutoUpdate->SetToolTipText(
"Automatic update of the image (without Apply button)");
137 fUnDoButton->SetToolTipText(
"Undo the last modification (repeatable)");
141 fReDoButton->SetToolTipText(
"Undo the last undo operation (repeatable)");
145 button->SetToolTipText(
"Apply a log operation to the anchor points of the palette");
149 button->SetToolTipText(
"Apply a exp operation to the anchor points of the palette");
153 button->SetToolTipText(
"Make the distance of all anchor points constant");
157 button->SetToolTipText(
"Invert the order of the colors");
161 fStepButton->SetToolTipText(
"Apply a step function to the palette");
172 fRamps[0]->SetToolTipText(
"Repeat the palette once");
176 fRamps[1]->SetToolTipText(
"Repeat the palette twice");
180 fRamps[2]->SetToolTipText(
"Repeat the palette four times");
183 fRamps[0]->Associate(
this);
184 fRamps[1]->Associate(
this);
185 fRamps[2]->Associate(
this);
192 const ASImage *image = ((
TASImage*)attImage)->GetImage();
193 if (image && image->alt.vector) {
196 Int_t numPixel = image->width * image->height;
197 Int_t numBins = numPixel / 20;
198 numBins = (numBins < 10) ? 10 : (numBins > 200) ? 200 : numBins;
207 fHisto =
new TH1D(
"Statistics",
"Pixel histogram of unzoomed image ",
213 fHisto->GetXaxis()->SetLabelFont(63);
214 fHisto->GetXaxis()->SetLabelSize(10);
215 fHisto->GetYaxis()->SetLabelFont(63);
216 fHisto->GetYaxis()->SetLabelSize(10);
219 0,
fHisto->GetMaximum(),
this);
436 FILE *fl = fopen(fn.
Data(),
"w");
439 fprintf(fl,
"%u\n",
fPalette->fNumPoints);
471 FILE *fl = fopen(fn.
Data(),
"r");
475 if (fscanf(fl,
"%u\n", &numPoints) != 1)
476 Error(
"Open",
"Failure reading num points from %s", fn.
Data());
481 Error(
"Open",
"Failure reading point %u from %s",
pt, fn.
Data());
492 if (!fsave || !fsave->IsOpen()) {
563 off = (
fPalette->fNumPoints - 2) / 2;
628 delta * (
pt - 1) / (
fPalette->fNumPoints - 3);
680 numPt =
id == 0 ? 12 : 13;
705 newPalette->
fColorRed[
pt] = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
712 newPalette->
fColorGreen[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
713 newPalette->
fColorBlue[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
721 newPalette->
fColorBlue[
pt] = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
725 newPalette->
fColorRed[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
726 newPalette->
fColorGreen[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
734 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
736 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
738 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
823 for (
Int_t rp = 0; rp < ramp; rp++) {
878 if (newDelta < 0.001 || oldDelta < 0.001)
902 grad.npoints = (*fPalette)->fNumPoints - 2;
903 grad.type = GRADIENT_Left2Right;
904 grad.color =
new ARGB32[grad.npoints];
905 grad.offset =
new double[grad.npoints];
907 grad.offset[
pt] = ((*fPalette)->fPoints[
pt + 1] - (*fPalette)->fPoints[1]) /
908 ((*fPalette)->fPoints[(*fPalette)->fNumPoints - 2] - (*fPalette)->fPoints[1]);
909 grad.color[
pt] = (((ARGB32)((*fPalette)->fColorBlue[
pt + 1] & 0xff00)) >> 8) |
910 (((ARGB32)((*fPalette)->fColorGreen[
pt + 1] & 0xff00)) ) |
911 (((ARGB32)((*fPalette)->fColorRed[
pt + 1] & 0xff00)) << 8) |
912 (((ARGB32)((*fPalette)->fColorAlpha[
pt + 1] & 0xff00)) << 16);
916 SCL_DO_COLOR, ASA_ARGB32, 0,
918 delete [] grad.color;
919 delete [] grad.offset;
923 destroy_asimage(&grad_im);
Handle_t Window_t
Window handle.
static UShort_t gRedRainbow[12]
static UShort_t gBlueRainbow[12]
static UShort_t gGreenRainbow[12]
static const char * gFileTypes[]
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t SetLineWidth
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t SetLineColor
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t button
Option_t Option_t TPoint TPoint const char y1
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.
This is a GUI window to edit a color palette.
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 Modify()
Change current line attributes if necessary.
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.