pro spd_ui_draw_object::makeZAxisModel,zrange,zAxis,xplotpos,yplotpos,framecolor,framethick,model=model,palette=palette,majorNum=majorTickNum,minorNum=minorTickNum
compile_opt idl2,hidden
edgeTickMargin = .01
roundingfactor = 1d-15
zstack = .1
thick = 10
majorTickNum = 0
minorTickNum = 0
zAxis->getProperty, $
tickNum=majorTickNum, $
minorTickNum=minorTickNum,$
annotationStyle=annotationStyle, $
annotateTextObject=annotateTextObject, $
annotationOrientation=annotationOrientation,$
annotateExponent=annotateExponent,$
labelTextObject=labelTextObject,$
subtitleTextObject=subtitleTextObject,$
labelOrientation=labelOrientation,$
labelMargin=labelMargin,$
lazylabels=lazylabels,$
scaling=scaling,$
placement=placement,$
margin=margin,$
autoTicks=autoTicks,$
logMinorTickType=logMinorTickType
model = obj_new('IDLgrModel')
palette = obj_new('IDLgrPalette')
getctpath,colortablepath
palette->loadCt,zAxis->getColorTableNumber(),file=colortablepath
if placement eq 0 then begin
marginNorm1 = self->pt2Norm(margin,1)
marginNorm2 = self->pt2Norm(margin+thick,1)
pt1 = [0.,1. + marginNorm1/(yplotpos[1]-yplotpos[0]),zstack]
pt2 = [1.,1. + marginNorm1/(yplotpos[1]-yplotpos[0]),zstack]
pt3 = [1.,1. + marginNorm2/(yplotpos[1]-yplotpos[0]),zstack]
pt4 = [0.,1. + marginNorm2/(yplotpos[1]-yplotpos[0]),zstack]
location = pt1
xsize = pt3[0]-pt1[0]
ysize = pt3[1]-pt1[1]
endif else if placement eq 1 then begin
marginNorm1 = self->pt2Norm(margin,1)
marginNorm2 = self->pt2Norm(margin+thick,1)
pt1 = [0.,0. - marginNorm1/(yplotpos[1]-yplotpos[0]),zstack]
pt2 = [1.,0. - marginNorm1/(yplotpos[1]-yplotpos[0]),zstack]
pt3 = [1.,0. - marginNorm2/(yplotpos[1]-yplotpos[0]),zstack]
pt4 = [0.,0. - marginNorm2/(yplotpos[1]-yplotpos[0]),zstack]
location = pt4
xsize = pt4[0]-pt2[0]
ysize = pt4[1]-pt2[1]
endif else if placement eq 2 then begin
marginNorm1 = self->pt2Norm(margin,0)
marginNorm2 = self->pt2Norm(margin+thick,0)
pt1 = [0. - marginNorm1/(xplotpos[1]-xplotpos[0]),0.,zstack]
pt2 = [0. - marginNorm1/(xplotpos[1]-xplotpos[0]),1.,zstack]
pt3 = [0. - marginNorm2/(xplotpos[1]-xplotpos[0]),1.,zstack]
pt4 = [0. - marginNorm2/(xplotpos[1]-xplotpos[0]),0.,zstack]
location = pt4
xsize = pt4[0]-pt2[0]
ysize = pt4[1]-pt2[1]
endif else if placement eq 3 then begin
marginNorm1 = self->pt2Norm(margin,0)
marginNorm2 = self->pt2Norm(margin+thick,0)
pt1 = [1. + marginNorm1/(xplotpos[1]-xplotpos[0]),0.,zstack]
pt2 = [1. + marginNorm1/(xplotpos[1]-xplotpos[0]),1.,zstack]
pt3 = [1. + marginNorm2/(xplotpos[1]-xplotpos[0]),1.,zstack]
pt4 = [1. + marginNorm2/(xplotpos[1]-xplotpos[0]),0.,zstack]
location = pt1
xsize = pt3[0]-pt1[0]
ysize = pt3[1]-pt1[1]
endif else begin
return
endelse
if ~keyword_set(self.postscript) then begin
poly = obj_new('IDLgrPolygon')
image = obj_new('IDLgrImage',indgen(1,256),palette=palette)
poly->setProperty,data=[[pt1],[pt2],[pt3],[pt4]],texture_map = image,texture_coord=[[0,0],[0,1],[1,1],[1,0]],/texture_interp,color=self->convertColor([255,255,255]),/double
endif else begin
poly = obj_new('IDLgrImage',indgen(1,256),palette=palette,location=location,dimensions=[xsize,ysize],depth_test_disable=2)
endelse
if majorTickNum lt 0 then begin
self.statusBar->update,'Illegal negative z axis major tick number, using 0 ticks'
self.historyWin->update,'Illegal negative z axis major tick number, using 0 ticks'
majorTickNum = 0
endif
if finite(zrange[0],/infinity,sign=-1) && $
finite(zrange[1],/infinity,sign=-1) && $
(scaling eq 1 || scaling eq 2) then begin
scaling = 0
zrange = [0D,0D]
endif
if ~finite(zrange[0]) || ~finite(zrange[1]) then begin
zrange = [0D,1D]
endif
if majorTickNum gt 0 then begin
self->goodTicks,0,zrange,scaling,majorTickNum, $
tickValues=tickValues,tickInterval=tickInterval,$
/nozero,minorTickNum=minorTickNumRecommended,$
nicest=keyword_set(autoticks),$
logMinorTickType=logMinorTickType
if n_elements(tickValues) lt 2 && $
majorTickNum ge 2 && $
scaling eq 1 then begin
self->logFixTicks,$
zrange,$
tickValues=tickValues,$
tickInterval=tickInterval,minorTickNum=minorTickNumRecommended
ticksFixed = 1
endif
if keyword_set(autoticks) && $
n_elements(minorTickNumRecommended) gt 0 && $
minorTickNumRecommended ge 0 then begin
minorTickNum = minorTickNumRecommended
endif
if n_elements(tickValues) gt 0 then begin
while tickValues[0] gt edgeTickMargin do begin
tickValues = [tickValues[0]-tickInterval,tickValues]
endwhile
while tickValues[n_elements(tickValues)-1] lt (1-edgeTickMargin) do begin
tickValues = [tickValues,tickValues[n_elements(tickValues)-1]+tickInterval]
endwhile
tickValuesForMinors = tickValues
idx = where(tickValues le 1. and tickValues ge 0,c)
if c gt 0 then begin
tickValues = tickValues[idx]
endif else begin
tickValues = tickValues[0]
noMajors=1
endelse
endif else begin
noMajors = 1
endelse
majorTickNum = n_elements(tickValues)
endif else begin
tickValues = [0D,1D]
tickValuesForMinors = tickValues
tickInterval = 1
endelse
if keyword_set(ticksFixed) && annotateExponent eq 0 then begin
annotateExponent = 2
endif
data = {timeAxis:0,formatid:annotationStyle,scaling:scaling,range:zrange,exponent:annotateExponent}
if placement eq 0 then begin
if annotationOrientation eq 0 then begin
annobaseline = [1,0,0]
annoupdir = [0,1,0]
annoalignment = [.5,0.0]
endif else begin
annobaseline = [0,1,0]
annoupdir = [-1,0,0]
annoalignment = [0.0,.5]
endelse
loc = [0D, [1. + marginNorm2/(yplotpos[1]-yplotpos[0])],zstack+.1]
ticklen = self->pt2norm(thick,1)/(yplotpos[1]-yplotpos[0])
tickDir = 0
textpos = 1
dir = 0
endif else if placement eq 1 then begin
if annotationOrientation eq 0 then begin
annobaseline = [1,0,0]
annoupdir = [0,1,0]
annoalignment = [.5,1.0]
endif else begin
annobaseline = [0,1,0]
annoupdir = [-1,0,0]
annoalignment = [1.0,.5]
endelse
loc = [0D, [0. - marginNorm2/(yplotpos[1]-yplotpos[0])],zstack+.1]
ticklen = self->pt2norm(thick,1)/(yplotpos[1]-yplotpos[0])
tickDir = 1
textpos = 0
dir = 0
endif else if placement eq 2 then begin
if annotationOrientation eq 0 then begin
annobaseline = [1,0,0]
annoupdir = [0,1,0]
annoalignment = [1.0,.5]
endif else begin
annobaseline = [0,1,0]
annoupdir = [-1,0,0]
annoalignment = [.5,0.0]
endelse
loc = [[0. - marginNorm2/(xplotpos[1]-xplotpos[0])],0D,zstack+.1]
ticklen = self->pt2norm(thick,1)/(xplotpos[1]-xplotpos[0])
tickDir = 1
textpos = 0
dir = 1
endif else if placement eq 3 then begin
if annotationOrientation eq 0 then begin
annobaseline = [1,0,0]
annoupdir = [0,1,0]
annoalignment = [0.0,.5]
endif else begin
annobaseline = [0,1,0]
annoupdir = [-1,0,0]
annoalignment = [.5,1.0]
endelse
loc = [[1. + marginNorm2/(xplotpos[1]-xplotpos[0])],0D,zstack+.1]
ticklen = self->pt2norm(thick,1)/(xplotpos[1]-xplotpos[0])
tickDir = 0
textpos = 1
dir = 1
endif
if majorTickNum gt 0 && ~keyword_set(nomajors) then begin
borderpos = [[pt4],[pt1],[pt2],[pt3]]
if minorTickNum ne 0 then begin
self->makeMinorTicks,zrange,scaling,minorTickNum,tickValuesForMinors,tickInterval,logMinorTickType,minorValues=minorTickValues,fail=fail
if ~fail then begin
axis_minor = obj_new('IDLgrAxis',dir, $
range=[0D,1D], $
location=loc, $
minor=0,$
tickLen = ticklen/2,$
tickdir=tickDir,$
tickValues=minorTickValues,$
subTickLen=0,$
thick=framethick,$
tickfrmtdata=data,$
tickformat='formatannotation',$
color=self->convertColor(frameColor),$
/notext,$
/exact)
model->add,axis_minor
endif
endif
if data.exponent eq 0 && (scaling eq 0 || scaling eq 1) then begin
for i = 0,n_elements(tickValues)-1 do begin
if (data.range[1]-data.range[0]) eq 0 then begin
val = data.range[0]
endif else begin
val = (tickValues[i] + data.range[0]/(data.range[1]-data.range[0]))*(data.range[1]-data.range[0])
relativecuttoff = (data.range[1]-data.range[0])*roundingfactor
if val le relativecuttoff && val ge -relativecuttoff then begin
val = 0
endif
endelse
if scaling eq 1 then begin
val = 10^val
endif
spd_ui_usingexponent,val,data,type=type
if type ne 0 && scaling eq 0 then begin
data.exponent = 2
break
endif else if type ne 0 && scaling eq 1 then begin
data.exponent = 3
break
endif
endfor
endif
if ~keyword_set(nomajors) then begin
axis1 = obj_new('IDLgrAxis',dir, $
range=[0D,1D], $
location=loc, $
minor=0,$
tickLen = ticklen,$
tickdir=tickDir,$
textpos=textpos,$
tickValues=tickValues,$
thick=framethick,$
tickfrmtdata=data,$
tickformat='formatannotation',$
color=self->convertColor(frameColor),$
textBaseLine = annobaseline,$
textupdir = annoupdir, $
textalignments = annoalignment, $
/use_text_color,$
/exact)
endif else begin
axis1 = obj_new('IDLgrAxis',dir, $
range=[0D,1D], $
location=loc, $
minor=0,$
subTickLen=0.0,$
tickLen = ticklen,$
tickdir=tickDir,$
textpos=textpos,$
major=0,$
thick=framethick,$
tickfrmtdata=data,$
tickformat='formatannotation',$
color=self->convertColor(frameColor),$
textBaseLine = annobaseline,$
textupdir = annoupdir, $
textalignments = annoalignment, $
/use_text_color,$
/exact)
endelse
axis1->getProperty,tickText=tickObj
annofont = annotateTextObject->getGrFont()
annotateTextObject->getProperty,color=annocolor,size=size
annoFont->setProperty,size=self->getZoom()*size
tickObj->setProperty,font=annofont,color=self->convertColor(annocolor)
model->add,axis1
endif else begin
borderpos = [[pt4],[pt1],[pt2],[pt3],[pt4]]
endelse
if obj_valid(labelTextObject) then begin
labeltextObject->getproperty, value=titletext, size=titlesize
if keyword_set(lazylabels) then begin
titletext = strjoin(strsplit(titletext,'_',/extract),'!c')
endif
titlesplit = strsplit(titletext,'!c|!C',/regex,/extract,count=numlines)
titlespace = (titlesize+1)*numlines
endif else titlespace = 0
if obj_valid(subtitleTextObject) then begin
subtitletextObject->getproperty, value=subtitletext, size=subtitlesize
if keyword_set(lazylabels) then begin
subtitletext = strjoin(strsplit(subtitletext,'_',/extract),'!c')
endif
subtitlesplit = strsplit(subtitletext,'!c|!C',/regex,/extract,count=numsublines)
subtitlespace = (subtitlesize+1)*numsublines
endif else subtitlespace=0
titlepadding = self->pt2norm(10.,1)
if obj_valid(labelTextObject) then begin
if placement eq 0 then begin
if labelOrientation eq 0 then begin
pos = [.5,1.+self->pt2norm(margin+thick+labelmargin+subtitlespace,1)/(yplotpos[1]-yplotpos[0]),zstack+.1]
justify = 0
endif else begin
pos = [.5-titlepadding,1.+self->pt2norm(margin+thick+labelmargin,1)/(yplotpos[1]-yplotpos[0]),zstack+.1]
justify = -1
endelse
offset = 1
endif else if placement eq 1 then begin
if labelOrientation eq 0 then begin
pos = [.5,0.-self->pt2norm(margin+thick+labelmargin,1)/(yplotpos[1]-yplotpos[0]),zstack+.1]
justify = 0
endif else begin
pos = [.5-titlepadding,0.-self->pt2norm(margin+thick+labelmargin,1)/(yplotpos[1]-yplotpos[0]),zstack+.1]
justify = -1
endelse
offset = -1
endif else if placement eq 2 then begin
if labelOrientation eq 0 then begin
pos = [0.-self->pt2norm(margin+thick+labelmargin,0)/(xplotpos[1]-xplotpos[0]),.5+titlepadding,zstack+.1]
offset = 1
justify = 1
endif else begin
pos = [0.-self->pt2norm(margin+thick+labelmargin+subtitlespace,0)/(xplotpos[1]-xplotpos[0]),.5,zstack+.1]
offset = 0
justify = -1
endelse
endif else if placement eq 3 then begin
pos = [1.+self->pt2norm(margin+thick+labelmargin,0)/(xplotpos[1]-xplotpos[0]),.5+titlepadding,zstack+.1]
if labelOrientation eq 0 then begin
offset = 1
justify = -1
endif else begin
offset = 0
justify = 1
endelse
endif
labelObj = self->getTextObject(labelTextObject,pos,offset,labelOrientation,justify=justify,/enable_formatting)
if keyword_set(lazylabels) then begin
labelObj->getproperty, strings=labelval
if n_elements(labelval) eq 1 then begin
labelval = strjoin(strsplit(labelval,'_',/extract),'!c')
labelobj->setproperty, strings=labelval
endif
endif
model->add,labelObj
endif
if obj_valid(subtitleTextObject) then begin
if placement eq 0 then begin
if labelOrientation eq 0 then begin
pos = [.5,1.+self->pt2norm(margin+thick+labelmargin,1)/(yplotpos[1]-yplotpos[0]),zstack+.1]
justify = 0
endif else begin
pos = [.5,1.+self->pt2norm(margin+thick+labelmargin,1)/(yplotpos[1]-yplotpos[0]),zstack+.1]
justify = 1
endelse
offset = 1
endif else if placement eq 1 then begin
if labelOrientation eq 0 then begin
pos = [.5,0.-self->pt2norm(margin+thick+labelmargin+titlespace,1)/(yplotpos[1]-yplotpos[0]),zstack+.1]
justify = 0
endif else begin
pos = [.5,0.-self->pt2norm(margin+thick+labelmargin,1)/(yplotpos[1]-yplotpos[0]),zstack+.1]
justify = 1
endelse
offset = -1
endif else if placement eq 2 then begin
pos = [0.-self->pt2norm(margin+thick+labelmargin,0)/(xplotpos[1]-xplotpos[0]),.5,zstack+.1]
if labelOrientation eq 0 then begin
offset = -1
justify = 1
endif else begin
offset = 0
justify = -1
endelse
endif else if placement eq 3 then begin
if labelOrientation eq 0 then begin
pos = [1.+self->pt2norm(margin+thick+labelmargin,0)/(xplotpos[1]-xplotpos[0]),.5,zstack+.1]
offset = -1
justify = -1
endif else begin
pos = [1.+self->pt2norm(margin+thick+labelmargin+titlespace,0)/(xplotpos[1]-xplotpos[0]),.5,zstack+.1]
offset = 0
justify = 1
endelse
endif
sublabelObj = self->getTextObject(subtitleTextObject,pos,offset,labelOrientation,justify=justify,/enable_formatting)
if keyword_set(lazylabels) then begin
sublabelObj->getproperty, strings=labelval
if n_elements(labelval) eq 1 then begin
labelval = strjoin(strsplit(labelval,'_',/extract),'!c')
sublabelobj->setproperty, strings=labelval
endif
endif
model->add,sublabelObj
endif
border = obj_new('IDLgrPolyLine',borderpos,color=self->convertColor(frameColor),thick=framethick,/double)
model->add,border
model->add,poly
end