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
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)");
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");
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;
202 for (pixel = 1; pixel < numPixel; pixel++) {
207 fHisto =
new TH1D(
"Statistics",
"Pixel histogram of unzoomed image ",
209 for (pixel = 0; pixel < numPixel; pixel++)
439 fprintf(fl,
"%10.9f %04hx %04hx %04hx %04hx\n",
454 gROOT->ProcessLine(
Form(
"gROOT->SaveObjectAs((TASPaletteEditor*)0x%zx,\"%s\",\"%s\");",(
size_t)
this,fn,
"q"));
478 if (fscanf(fl,
"%u\n", &numPoints)) {;}
482 if (fscanf(fl,
"%lf %hx %hx %hx %hx\n",
506 if (dirsav) dirsav->
cd();
686 numPt =
id == 0 ? 12 : 13;
711 newPalette->
fColorRed[
pt] = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
718 newPalette->
fColorGreen[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
719 newPalette->
fColorBlue[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
727 newPalette->
fColorBlue[
pt] = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
731 newPalette->
fColorRed[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
732 newPalette->
fColorGreen[
pt] = 0xffff * (
pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
740 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
742 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
744 = 0xffff * (
pt - 1) / ((numPt - 3) / 2);
829 for (
Int_t rp = 0; rp < ramp; rp++) {
884 if (newDelta < 0.001 || oldDelta < 0.001)
908 grad.npoints = (*fPalette)->fNumPoints - 2;
909 grad.type = GRADIENT_Left2Right;
910 grad.color =
new ARGB32[grad.npoints];
911 grad.offset =
new double[grad.npoints];
913 grad.offset[
pt] = ((*fPalette)->fPoints[
pt + 1] - (*fPalette)->fPoints[1]) /
914 ((*fPalette)->fPoints[(*fPalette)->fNumPoints - 2] - (*fPalette)->fPoints[1]);
915 grad.color[
pt] = (((ARGB32)((*fPalette)->fColorBlue[
pt + 1] & 0xff00)) >> 8) |
916 (((ARGB32)((*fPalette)->fColorGreen[
pt + 1] & 0xff00)) ) |
917 (((ARGB32)((*fPalette)->fColorRed[
pt + 1] & 0xff00)) << 8) |
918 (((ARGB32)((*fPalette)->fColorAlpha[
pt + 1] & 0xff00)) << 16);
922 SCL_DO_COLOR, ASA_ARGB32, 0,
924 delete [] grad.color;
925 delete [] grad.offset;
929 destroy_asimage(&grad_im);
949 fY1 =
gPad->GetUymin();
950 fY2 =
gPad->GetUymax();
972 oldX =
gPad->XtoAbsPixel(fX1);
985 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[]
char * Form(const char *fmt,...)
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)
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.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
void Paint(Option_t *option)
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
void CloseWindow()
Close editor.
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...
TGRadioButton * fRamps[3]
TASPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h)
Palette editor constructor.
TRootEmbeddedCanvas * fHistCanvas
canvas to draw the histogram
TH1D * fHisto
histogram of image pixels
void Save()
Saves the current palette either into a ROOT file or in an ASCII file.
TGCheckButton * fAutoUpdate
virtual ~TASPaletteEditor()
Palette editor destructor. Deletes all frames and their layout hints.
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.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t param1, Longptr_t param2)
Process all editor mouse events.
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 SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
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 a suite of consecutive data records (TKey instances) with a well defined format.
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=0)
Add frame to the composite frame using the specified layout hints.
virtual void Layout()
Layout the elements of the composite frame.
virtual void MapSubwindows()
Map all sub windows that are part 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
virtual void MapWindow()
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=0)
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)}
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
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.
virtual void Draw(Option_t *option="")
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)
virtual void SetX1(Double_t x1)
virtual void Paint(Option_t *option="")
Paint this line with its current attributes.
virtual void Add(TObject *obj)
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
virtual TObject * Before(const TObject *obj) const
Returns the object before object obj.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Mother of all ROOT objects.
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
virtual void Modified(Bool_t flag=1)=0