获取节点坐标 - GetNodeCoordinates
函数简介
获取指定节点的坐标信息,返回JSON字符串。
接口名称
GetNodeCoordinates
DLL调用
int64_t GetNodeCoordinates(int64_t instance, int64_t graphPtr, char* name);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| graphPtr | 长整数型 | 图的指针,由 CreateGraph 或 CreateGraphFromCoordinates 返回 |
| name | 字符串 | 节点名称 |
示例
// 创建OLA实例
int64_t instance = CreateCOLAPlugInterFace();
int64_t g = CreateGraphFromCoordinates(instance,
"[{\"name\":\"A\",\"x\":0,\"y\":0}]", false, 0.0, true);
int64_t sp = GetNodeCoordinates(instance, g, "A");
if (sp) {
printf("%s\n", (char*)sp);
FreeStringPtr(sp);
}
DeleteGraph(instance, g);
DestroyCOLAPlugInterFace(instance);
返回值
返回节点坐标信息的JSON字符串指针,格式为:
{"name": "节点名", "x": 坐标X, "y": 坐标Y}
节点不存在返回0。
返回的字符串指针需要调用 FreeStringPtr 释放内存。
