📄 transform.class
字号:
/* transform
Class for managing a base transform that is used repeatedly as
the basis for other transforms.
*/
*! version 1.0.0 30jul2002
version 8
class {
alpha = 0
beta = 1
transform = .transformstyle.new, style(linear)
dimension = .dimension.new, set(x)
}, inherit(mapping)
/* -------------------------------------------------------------------------*/
program define new
if `"`0'"' != `""' {
.set `0'
}
end
program define set
syntax , [ DIMension(string) ]
if "`dimension'" != "" {
.dimension.set `dimension'
}
end
/* -------------------------------------------------------------------------*/
/* Fetch current linear transform from the GDI layer's translation
*/
program define get_from_gdi
.alpha = `gdi(`.dimension.setting'alpha)'
.beta = `gdi(`.dimension.setting'beta)'
.transform.setstyle , style(`gdi(`.dimension.setting'transform)')
end
/* -------------------------------------------------------------------------*/
/* Translate the graphing area and set the result to the GDI, do NOT update
the stored transform. The supplied number should be in the scale of the
range.
*/
program define translate
capture confirm number `1'
if _rc {
di in red "transform.translate requires a numeric argument"
}
gdi `.dimension.setting'alpha = `.alpha' + `.beta' * `1'
end
/* -------------------------------------------------------------------------*/
/* Translate the graphing area, set the result to the GDI, AND update the
* stored alpha.
*/
program define translate_permanent
capture confirm number `1'
if _rc {
di in red "transform.translate requires a numeric argument"
}
.alpha = `.alpha' + `.beta' * `1'
gdi `.dimension.setting'alpha = `.alpha'
end
/*--------------------------------------------------------------------------*/
/* Resets the graphing area transform to the current settings for this
transform.
*/
program define reset
gdi `.dimension.setting'alpha = `.alpha'
gdi `.dimension.setting'beta = `.beta'
gdi `.dimension.setting'transform = `.transform.stylename'
end
/* -------------------------------------------------------------------------*/
/* Rescale the graphing area from the stored transform and set the result
to the GDI, do NOT update the stored transform.
Usage: rescale size_inches range_min range_max
Maps range_max - range_min onto the size. Assumes that the graphing area
has already been translated s.t. range_min will plot at 0.
*/
program define rescale
args size min max null
gdi `.dimension.setting'alpha = .alpha
gdi `.dimension.setting'beta = .beta
.gditransform.rescale `.dimension.setting' `size' `min' `max'
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -