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 ",
438 fprintf(fl,
"%10.9f %04hx %04hx %04hx %04hx\n",
453 gROOT->ProcessLine(
TString::Format(
"gROOT->SaveObjectAs((TASPaletteEditor*)0x%zx,\"%s\",\"%s\");",(
size_t)
this,fn,
"q"));
477 if (fscanf(fl,
"%u\n", &numPoints)) {;}
481 if (fscanf(fl,
"%lf %hx %hx %hx %hx\n",
505 if (dirsav) dirsav->
cd();
685 numPt =
id == 0 ? 12 : 13;
710 newPalette->
fColorRed[
pt] = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
717 newPalette->
fColorGreen[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
718 newPalette->
fColorBlue[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
726 newPalette->
fColorBlue[
pt] = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
730 newPalette->
fColorRed[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
731 newPalette->
fColorGreen[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
739 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
741 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
743 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
828 for (
Int_t rp = 0; rp < ramp; rp++) {
883 if (newDelta < 0.001 || oldDelta < 0.001)
907 grad.npoints = (*fPalette)->fNumPoints - 2;
908 grad.type = GRADIENT_Left2Right;
909 grad.color =
new ARGB32[grad.npoints];
910 grad.offset =
new double[grad.npoints];
912 grad.offset[
pt] = ((*fPalette)->fPoints[
pt + 1] - (*fPalette)->fPoints[1]) /
913 ((*fPalette)->fPoints[(*fPalette)->fNumPoints - 2] - (*fPalette)->fPoints[1]);
914 grad.color[
pt] = (((ARGB32)((*fPalette)->fColorBlue[
pt + 1] & 0xff00)) >> 8) |
915 (((ARGB32)((*fPalette)->fColorGreen[
pt + 1] & 0xff00)) ) |
916 (((ARGB32)((*fPalette)->fColorRed[
pt + 1] & 0xff00)) << 8) |
917 (((ARGB32)((*fPalette)->fColorAlpha[
pt + 1] & 0xff00)) << 16);
921 SCL_DO_COLOR, ASA_ARGB32, 0,
923 delete [] grad.color;
924 delete [] grad.offset;
928 destroy_asimage(&grad_im);
948 fY1 =
gPad->GetUymin();
949 fY2 =
gPad->GetUymax();
971 oldX =
gPad->XtoAbsPixel(fX1);
984 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[]
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 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.
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Describe directory structure in memory.
virtual Bool_t cd()
Change current directory to "this" directory.
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
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=1) override
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
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
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.