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)");
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");
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 ",
436 FILE *fl = fopen(fn.
Data(),
"w");
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()) {
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);
943 fY1 =
gPad->GetUymin();
944 fY2 =
gPad->GetUymax();
966 oldX =
gPad->XtoAbsPixel(fX1);
979 fX1 = fX2 =
gPad->AbsPixeltoX(oldX);
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 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 void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
virtual void SetLabelFont(Style_t font=62)
Set labels' font.
virtual void SetPalette(const TImagePalette *palette)
Set a new palette for the image.
EImageQuality GetImageQuality() const
virtual const TImagePalette & GetPalette() const
virtual void Modify()
Change current line attributes if necessary.
void Update() override
Update canvas pad buffers.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
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 AddEntry(TGString *s, Int_t id)
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
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.
Defines top level windows that interact with the system Window Manager.
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)
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
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
Use the TLine constructor to create a simple line.
virtual void SetX2(Double_t x2)
void Paint(Option_t *option="") override
Paint this line with its current attributes.
virtual void SetX1(Double_t x1)
TObject * After(const TObject *obj) const override
Returns the object after object obj.
TObject * Before(const TObject *obj) const override
Returns the object before object obj.
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Edit the palette via a GUI.
virtual void CloseWindow()
Closes the window and deletes itself.
This class creates a TGCanvas in which a TCanvas is created.
TCanvas * GetCanvas() const
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)
virtual void Modified(Bool_t flag=1)=0
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.