33 #include "RConfigure.h"
36 # define X_DISPLAY_MISSING 1
40 #include "Windows4root.h"
45 # include <afterbase.h>
47 # include <win32/config.h>
48 # include <win32/afterbase.h>
50 # include <afterimage.h>
57 "ROOT palette file",
"*.pal.root",
58 "ASCII palette file",
"*.pal.txt",
63 0x0000, 0x7000, 0x0000, 0x0000, 0x0000,
64 0xffff, 0xffff, 0x7000, 0x8000, 0xffff
67 0x0000, 0x0000, 0x0000, 0xffff, 0xffff,
68 0xffff, 0x0000, 0x0000, 0x8000, 0xffff
71 0x0000, 0x7000, 0xffff, 0xffff, 0x0000,
72 0x0000, 0x0000, 0x0000, 0xa000, 0xffff
92 fPaletteList =
new TList;
96 fPaletteList->Add(fPalette);
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);
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;
200 fMinValue = fMaxValue = *image->alt.vector;
201 for (pixel = 1; pixel < numPixel; pixel++) {
202 if (fMinValue > *(data + pixel)) fMinValue = *(data + pixel);
203 if (fMaxValue < *(data + pixel)) fMaxValue = *(data + pixel);
206 fHisto =
new TH1D(
"Statistics",
"Pixel histogram of unzoomed image ",
207 numBins, fMinValue, fMaxValue);
208 for (pixel = 0; pixel < numPixel; pixel++)
209 fHisto->Fill(*(data + pixel));
211 fHisto->Draw(
"HIST");
212 fHisto->GetXaxis()->SetLabelFont(63);
213 fHisto->GetXaxis()->SetLabelSize(10);
214 fHisto->GetYaxis()->SetLabelFont(63);
215 fHisto->GetYaxis()->SetLabelSize(10);
217 fLimitLine[0] =
new LimitLine(fMinValue + fPalette->fPoints[1] * (fMaxValue - fMinValue),
218 0, fHisto->GetMaximum(),
this);
219 fLimitLine[0]->Draw();
220 fLimitLine[1] =
new LimitLine(fMinValue + fPalette->fPoints[fPalette->fNumPoints - 2] *
221 (fMaxValue - fMinValue), 0, fHisto->GetMaximum(),
this);
222 fLimitLine[1]->Draw();
229 fComboBox->AddEntry(
"Rainbow", 0);
230 fComboBox->AddEntry(
"Grey", 1);
231 fComboBox->AddEntry(
"Hot", 2);
232 fComboBox->AddEntry(
"Cold", 3);
233 fComboBox->AddEntry(
"Bowlerhat", 4);
234 fComboBox->AddEntry(
"", 5);
242 fPaintPalette =
new PaintPalette(&fPalette, attImage);
243 fPaintPalette->Draw();
248 SetWindowName(
"Palette Editor");
249 SetIconName(
"Palette Editor");
438 fprintf(fl,
"%10.9f %04hx %04hx %04hx %04hx\n",
449 snprintf(fn,512,
"%s%s", fi.
fFilename,
".pal.root");
453 gROOT->ProcessLine(
Form(
"gROOT->SaveObjectAs((TASPaletteEditor*)0x%lx,\"%s\",\"%s\");",(
ULong_t)
this,fn,
"q"));
477 if (fscanf(fl,
"%u\n", &numPoints)) {;}
481 if (fscanf(fl,
"%lf %hx %hx %hx %hx\n",
492 snprintf(fn,512,
"%s%s", fi.
fFilename,
".pal.root");
505 if (dirsav) dirsav->
cd();
685 numPt =
id == 0 ? 12 : 13;
688 for (pt = 1; pt <
Int_t(numPt - 1); pt++) {
701 for (pt = 1; pt <
Int_t(numPt - 1); pt++) {
702 newPalette->
fColorRed[
pt] = 0xffff * (pt - 1) / (numPt - 3);
703 newPalette->
fColorGreen[
pt] = 0xffff * (pt - 1) / (numPt - 3);
704 newPalette->
fColorBlue[
pt] = 0xffff * (pt - 1) / (numPt - 3);
709 for (pt = 1; pt <
Int_t(numPt - 1) / 2; pt++) {
710 newPalette->
fColorRed[
pt] = 0xffff * (pt - 1) / ((numPt - 3) / 2);
715 for (; pt <
Int_t(numPt - 1); pt++) {
717 newPalette->
fColorGreen[
pt] = 0xffff * (pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
718 newPalette->
fColorBlue[
pt] = 0xffff * (pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
723 for (pt = 1; pt <
Int_t(numPt - 1) / 2; pt++) {
726 newPalette->
fColorBlue[
pt] = 0xffff * (pt - 1) / ((numPt - 3) / 2);
729 for (; pt <
Int_t(numPt - 1); pt++) {
730 newPalette->
fColorRed[
pt] = 0xffff * (pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
731 newPalette->
fColorGreen[
pt] = 0xffff * (pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
737 for (pt = 1; pt <
Int_t(numPt + 1) / 2; pt++) {
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);
936 :
TLine(x, y1, x, y2)
948 fY1 =
gPad->GetUymin();
949 fY2 =
gPad->GetUymax();
971 oldX =
gPad->XtoAbsPixel(fX1);
984 fX1 = fX2 =
gPad->AbsPixeltoX(oldX);
virtual void SetLineWidth(Width_t lwidth)
This is a GUI window to edit a color palette.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
static const ASVisual * GetVisual()
Return visual.
void CloseWindow()
Close editor.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
void InsertNewPalette(TImagePalette *newPalette)
The newPalette is inserted in the list of palettes (fPaletteList) and fPalette is set to the newPalet...
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
PaintPalette * fPaintPalette
void Paint(Option_t *option)
Actually paint the paletter.
void InvertPalette()
The palette is inverted.
virtual void Modify()
Change current line attributes if necessary.
void UpdateScreen(Bool_t histoUpdate)
All widgets of the screen are updated with the current palette.
TCanvas * GetCanvas() const
EImageQuality GetImageQuality() const
virtual ~TASPaletteEditor()
Palette editor destructor. Deletes all frames and their layout hints.
TGRadioButton * fRamps[3]
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
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 Paint(Option_t *option="")
Paint this line with its current attributes.
Edit the palette via a GUI.
void Paint(Option_t *option)
Paint the limit lines.
Bool_t ProcessMessage(Long_t msg, Long_t param1, Long_t param2)
Process all editor mouse events.
void SetRamp(Long_t ramp)
The palette is repeated up to 4 times.
LimitLine * fLimitLine[2]
virtual void SetLineColor(Color_t lcolor)
virtual void SetX2(Double_t x2)
static UShort_t gBlueRainbow[12]
virtual TObject * Before(const TObject *obj) const
Returns the object before object obj.
TGCheckButton * fStepButton
void LogPalette()
The anchor points are rescaled by a log operation.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
char * Form(const char *fmt,...)
virtual void SetPalette(const TImagePalette *palette)
Set a new palette for the image.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
void SetStep()
Create a step palette.
void NewPalette(Long_t id)
A new palette is created, depending on the id.
TGTextButton * fUnDoButton
virtual void SetX1(Double_t x1)
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
virtual void Modified(Bool_t flag=1)=0
LimitLine(Coord_t x, Coord_t y1, Coord_t y2, TASPaletteEditor *gui)
The blue limit line in the pixel value histogram.
TGTextButton * fReDoButton
Describe directory structure in memory.
TRootEmbeddedCanvas * fPaletteCanvas
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
A class to define a conversion from pixel values to pixel color.
void UpdateRange()
Updates the range of the palette.
Mother of all ROOT objects.
TGCheckButton * fAutoUpdate
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
void ExpPalette()
The anchor points are rescaled by a exp operation.
RooCmdArg Layout(Double_t xmin, Double_t xmax=0.99, Double_t ymin=0.95)
static const char * gFileTypes[]
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
static UShort_t gGreenRainbow[12]
virtual void Add(TObject *obj)
ClassImp(TASPaletteEditor) TASPaletteEditor
Palette editor constructor.
TRootEmbeddedCanvas * fHistCanvas
virtual void Update()
Update canvas pad buffers.
static UShort_t gRedRainbow[12]
virtual void CloseWindow()
Closes the window and deletes itself.
void Open()
Opens either a ROOT file or an ASCII file and reads a palette.
void LinPalette()
The anchor points are rescaled to be linar.
void Save()
Saves the current palette either into a ROOT file or in an ASCII file.
void Modified(Bool_t flag=1)
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.
const char Int_t const char * image