33 #include "RConfigure.h" 36 # define X_DISPLAY_MISSING 1 40 #include "Windows4root.h" 44 # include <afterbase.h> 46 # include <win32/config.h> 47 # include <win32/afterbase.h> 49 # include <afterimage.h> 56 "ROOT palette file",
"*.pal.root",
57 "ASCII palette file",
"*.pal.txt",
62 0x0000, 0x7000, 0x0000, 0x0000, 0x0000,
63 0xffff, 0xffff, 0x7000, 0x8000, 0xffff
66 0x0000, 0x0000, 0x0000, 0xffff, 0xffff,
67 0xffff, 0x0000, 0x0000, 0x8000, 0xffff
70 0x0000, 0x7000, 0xffff, 0xffff, 0x0000,
71 0x0000, 0x0000, 0x0000, 0xa000, 0xffff
91 fPaletteList =
new TList;
95 fPaletteList->Add(fPalette);
113 button->
SetToolTipText(
"Save the palette in a ROOT or an ASCII file");
117 button->
SetToolTipText(
"Read a palette from a ROOT or an ASCII file");
121 button->
SetToolTipText(
"Create a new palette (not yet implemented)");
131 fAutoUpdate->SetToolTipText(
"Automatic update of the image (without Apply button)");
135 fUnDoButton->SetToolTipText(
"Undo the last modification (repeatable)");
139 fReDoButton->SetToolTipText(
"Undo the last undo operation (repeatable)");
143 button->
SetToolTipText(
"Apply a log operation to the anchor points of the palette");
147 button->
SetToolTipText(
"Apply a exp operation to the anchor points of the palette");
151 button->
SetToolTipText(
"Make the distance of all anchor points constant");
159 fStepButton->SetToolTipText(
"Apply a step function to the palette");
170 fRamps[0]->SetToolTipText(
"Repeat the palette once");
174 fRamps[1]->SetToolTipText(
"Repeat the palette twice");
178 fRamps[2]->SetToolTipText(
"Repeat the palette four times");
181 fRamps[0]->Associate(
this);
182 fRamps[1]->Associate(
this);
183 fRamps[2]->Associate(
this);
190 const ASImage *image = ((
TASImage*)attImage)->GetImage();
191 if (image && image->alt.vector) {
194 Int_t numPixel = image->width * image->height;
195 Int_t numBins = numPixel / 20;
196 numBins = (numBins < 10) ? 10 : (numBins > 200) ? 200 : numBins;
199 fMinValue = fMaxValue = *image->alt.vector;
200 for (pixel = 1; pixel < numPixel; pixel++) {
201 if (fMinValue > *(data + pixel)) fMinValue = *(data + pixel);
202 if (fMaxValue < *(data + pixel)) fMaxValue = *(data + pixel);
205 fHisto =
new TH1D(
"Statistics",
"Pixel histogram of unzoomed image ",
206 numBins, fMinValue, fMaxValue);
207 for (pixel = 0; pixel < numPixel; pixel++)
208 fHisto->Fill(*(data + pixel));
210 fHisto->Draw(
"HIST");
211 fHisto->GetXaxis()->SetLabelFont(63);
212 fHisto->GetXaxis()->SetLabelSize(10);
213 fHisto->GetYaxis()->SetLabelFont(63);
214 fHisto->GetYaxis()->SetLabelSize(10);
216 fLimitLine[0] =
new LimitLine(fMinValue + fPalette->fPoints[1] * (fMaxValue - fMinValue),
217 0, fHisto->GetMaximum(),
this);
218 fLimitLine[0]->
Draw();
219 fLimitLine[1] =
new LimitLine(fMinValue + fPalette->fPoints[fPalette->fNumPoints - 2] *
220 (fMaxValue - fMinValue), 0, fHisto->GetMaximum(),
this);
221 fLimitLine[1]->
Draw();
228 fComboBox->AddEntry(
"Rainbow", 0);
229 fComboBox->AddEntry(
"Grey", 1);
230 fComboBox->AddEntry(
"Hot", 2);
231 fComboBox->AddEntry(
"Cold", 3);
232 fComboBox->AddEntry(
"Bowlerhat", 4);
233 fComboBox->AddEntry(
"", 5);
242 fPaintPalette->Draw();
247 SetWindowName(
"Palette Editor");
248 SetIconName(
"Palette Editor");
437 fprintf(fl,
"%10.9f %04hx %04hx %04hx %04hx\n",
452 gROOT->ProcessLine(
Form(
"gROOT->SaveObjectAs((TASPaletteEditor*)0x%lx,\"%s\",\"%s\");",(
ULong_t)
this,fn,
"q"));
476 if (fscanf(fl,
"%u\n", &numPoints)) {;}
480 if (fscanf(fl,
"%lf %hx %hx %hx %hx\n",
504 if (dirsav) dirsav->
cd();
684 numPt =
id == 0 ? 12 : 13;
687 for (pt = 1; pt <
Int_t(numPt - 1); pt++) {
700 for (pt = 1; pt <
Int_t(numPt - 1); pt++) {
701 newPalette->
fColorRed[
pt] = 0xffff * (pt - 1) / (numPt - 3);
702 newPalette->
fColorGreen[
pt] = 0xffff * (pt - 1) / (numPt - 3);
703 newPalette->
fColorBlue[
pt] = 0xffff * (pt - 1) / (numPt - 3);
708 for (pt = 1; pt <
Int_t(numPt - 1) / 2; pt++) {
709 newPalette->
fColorRed[
pt] = 0xffff * (pt - 1) / ((numPt - 3) / 2);
714 for (; pt <
Int_t(numPt - 1); pt++) {
716 newPalette->
fColorGreen[
pt] = 0xffff * (pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
717 newPalette->
fColorBlue[
pt] = 0xffff * (pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
722 for (pt = 1; pt <
Int_t(numPt - 1) / 2; pt++) {
725 newPalette->
fColorBlue[
pt] = 0xffff * (pt - 1) / ((numPt - 3) / 2);
728 for (; pt <
Int_t(numPt - 1); pt++) {
729 newPalette->
fColorRed[
pt] = 0xffff * (pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
730 newPalette->
fColorGreen[
pt] = 0xffff * (pt - (numPt - 1) / 2) / ((numPt - 3) / 2);
736 for (pt = 1; pt <
Int_t(numPt + 1) / 2; pt++) {
738 = 0xffff * (pt - 1) / ((numPt - 3) / 2);
740 = 0xffff * (pt - 1) / ((numPt - 3) / 2);
742 = 0xffff * (pt - 1) / ((numPt - 3) / 2);
827 for (
Int_t rp = 0; rp < ramp; rp++) {
882 if (newDelta < 0.001 || oldDelta < 0.001)
906 grad.npoints = (*fPalette)->fNumPoints - 2;
907 grad.type = GRADIENT_Left2Right;
908 grad.color =
new ARGB32[grad.npoints];
909 grad.offset =
new double[grad.npoints];
911 grad.offset[
pt] = ((*fPalette)->fPoints[
pt + 1] - (*fPalette)->fPoints[1]) /
912 ((*fPalette)->fPoints[(*fPalette)->fNumPoints - 2] - (*fPalette)->fPoints[1]);
913 grad.color[
pt] = (((ARGB32)((*fPalette)->fColorBlue[
pt + 1] & 0xff00)) >> 8) |
914 (((ARGB32)((*fPalette)->fColorGreen[
pt + 1] & 0xff00)) ) |
915 (((ARGB32)((*fPalette)->fColorRed[
pt + 1] & 0xff00)) << 8) |
916 (((ARGB32)((*fPalette)->fColorAlpha[
pt + 1] & 0xff00)) << 16);
920 SCL_DO_COLOR, ASA_ARGB32, 0,
922 delete [] grad.color;
923 delete [] grad.offset;
927 destroy_asimage(&grad_im);
935 :
TLine(x, y1, x, y2)
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Double_t fMinValue
min value of image
Double_t * fPoints
[fNumPoints] value of each anchor point [0..1]
This is a GUI window to edit a color palette.
Double_t fX1
X of 1st point.
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 * Last() const
Return the last object in the list. Returns 0 when list is empty.
TImagePalette * fPalette
current palette
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
TH1D * fHisto
histogram of image pixels
EImageQuality GetImageQuality() const
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
PaintPalette * fPaintPalette
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
void Paint(Option_t *option)
Actually paint the paletter.
Double_t fX2
X of 2nd point.
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.
UShort_t * fColorRed
[fNumPoints] red color at each anchor point
virtual ~TASPaletteEditor()
Palette editor destructor. Deletes all frames and their layout hints.
TGRadioButton * fRamps[3]
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)
Set the line color.
virtual void SetX2(Double_t x2)
static UShort_t gBlueRainbow[12]
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
TGCheckButton * fStepButton
void LogPalette()
The anchor points are rescaled by a log operation.
Double_t fY1
Y of 1st point.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual TObject * Before(const TObject *obj) const
Returns the object before object obj.
TList * fPaletteList
list of palettes for undo and redo
UShort_t * fColorAlpha
[fNumPoints] alpha at each anchor point
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.
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
UInt_t fNumPoints
number of anchor points
void NewPalette(Long_t id)
A new palette is created, depending on the id.
UShort_t * fColorBlue
[fNumPoints] blue color at each anchor point
TGTextButton * fUnDoButton
virtual void SetX1(Double_t x1)
virtual void Modified(Bool_t flag=1)=0
virtual Bool_t IsOpen() const
Returns kTRUE in case file is open and kFALSE if file is not open.
LimitLine(Coord_t x, Coord_t y1, Coord_t y2, TASPaletteEditor *gui)
The blue limit line in the pixel value histogram.
TCanvas * GetCanvas() const
TGTextButton * fReDoButton
Describe directory structure in memory.
TRootEmbeddedCanvas * fPaletteCanvas
canvas to draw the current palette
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
UShort_t * fColorGreen
[fNumPoints] green color at each anchor point
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)
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
Double_t fY2
Y of 2nd point.
TRootEmbeddedCanvas * fHistCanvas
canvas to draw the histogram
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.
Double_t fMaxValue
max value of image
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.