文档对象


文档对象是系统内置的脚本对象之一,提供对当前图形文档的访问接口。文档对象的名称为:document。

reload#

reload : v1.0.0

从磁盘文件重新加载图形

bool reload(void)
document.reload();

redraw#

redraw : v1.0.0

重新绘制当前的图形

bool redraw(void)
document.redraw();

load#

load : v1.0.0

加载指定的图形文件

bool load(const QString& fileName)
document.load("d:\\sample.g");

gotoHomeGraph#

gotoHomeGraph : v1.0.0

打开主画面

void gotoHomeGraph(void)
document.gotoHomeGraph();

gotoPreviousGraph#

gotoPreviousGraph : v1.0.0

打开上一幅图形

void gotoPreviousGraph(void)
document.gotoPreviousGraph();

gotoNextGraph#

gotoNextGraph : v1.0.0

打开下一幅图形

void gotoNextGraph(void)
document.gotoNextGraph();

setAttributeById#

setAttributeById : v1.0.0

设置图元属性,第一个参数为图元编号,第二个参数为图元属性名称,第三个参数为属性值

图元属性请参阅《电力系统图形描述规范》

bool  setAttributeById(const QString& id,const QString& attrName,const QString& attrValue)

修改矩形外观的脚本如下(图元编号按照实际修改):

//修改线色
document.setAttributeById('1000001','lc','green');
//修改线宽
document.setAttributeById('1000001','lw','4');
//修改填充色
document.setAttributeById('1000001','fc','red');
//修改填充样式
document.setAttributeById('1000001','fm','1');
//重绘使修改生效
document.redraw();

setTextById#

setTextById : v1.0.0

设置图元文本,第一个参数为图元编号,第二个参数为文本。

bool  setTextById(const QString& id,const QString& text)

修改文本图元的脚本如下(图元编号按照实际修改):

document.setTextById('9000008','李四');
document.redraw();

getAttributeById#

getAttributeById : v1.0.0

获取图元属性,第一个参数为图元编号,第二个参数为图元属性名称。

QString		getAttributeById(const QString& id, const QString& attrName)

增大圆半径的脚本如下(图元编号按照实际修改):

var r = document.getAttributeById('2000001','r');
var newR = eval(r) + 10;
document.setAttributeById('2000001','r',newR);
document.redraw();

减小圆半径的脚本如下(图元编号按照实际修改):

var r = document.getAttributeById('2000001','r');
var newR = eval(r) - 10;
if( newR < 10 )
    newR = 10;
document.setAttributeById('2000001','r',newR);
document.redraw();

getTextById#

getTextById : v1.0.0

获取图元文本,第一个参数为文本图元编号。

QString  getTextById(const QString& id)

读取文本并显示的脚本如下(图元编号按照实际修改):

var name = document.getTextById('9000008');
window.showMessage('title',name);