主题
获取节点坐标 - GetNodeCoordinates
函数简介
获取指定节点的坐标信息,返回JSON字符串。
接口名称
GetNodeCoordinatesDLL调用
c
int64_t GetNodeCoordinates(int64_t instance, int64_t graphPtr, char* name);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| graphPtr | 长整数型 | 图的指针,由 CreateGraph 或 CreateGraphFromCoordinates 返回。 |
| name | 字符串 | 节点名称。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
std::string coords = ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph(graphPtr);
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
long graphPtr = ola.CreateGraphFromCoordinates(@"[{"name":"A","x":0,"y":0},{"name":"B","x":100,"y":0},{"name":"C","x":50,"y":80}]", true, 200.0, true);
if (graphPtr != 0) {
string coords = ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph(graphPtr);
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
graph_ptr = ola.CreateGraphFromCoordinates(r'[{"name":"A","x":0,"y":0},{"name":"B","x":100,"y":0},{"name":"C","x":50,"y":80}]', True, 200.0, True)
if graph_ptr != 0:
coords = ola.GetNodeCoordinates(graph_ptr, "A")
ola.DeleteGraph(graph_ptr)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph(graphPtr);
}cpp
var ola = com("OlaPlug.OlaSoft")
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph(graphPtr)
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph(graphPtr)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
long graphPtr = ola.CreateGraphFromCoordinates(“[{\“name\“:\“A\“,\“x\“:0,\“y\“:0},{\“name\“:\“B\“,\“x\“:100,\“y\“:0},{\“name\“:\“C\“,\“x\“:50,\“y\“:80}]“, true, 200.0, true);
if (graphPtr != 0) {
ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph (graphPtr)
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph(graphPtr);
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph(graphPtr)
}cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
ola.GetNodeCoordinates(graphPtr, "A");
ola.DeleteGraph(graphPtr);
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long graphPtr = CreateGraphFromCoordinates(instance, "[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", 1, 200.0, 1);
if (graphPtr != 0) {
GetNodeCoordinates(instance, graphPtr, "A");
DeleteGraph(instance, graphPtr);
}csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
long graphPtr = CreateGraphFromCoordinates(instance, @"[{"name":"A","x":0,"y":0},{"name":"B","x":100,"y":0},{"name":"C","x":50,"y":80}]", 1, 200.0, 1);
if (graphPtr != 0) {
GetNodeCoordinates(instance, graphPtr, "A");
DeleteGraph(instance, graphPtr);
}python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
long graphPtr = CreateGraphFromCoordinates(instance, b'[{"name":"A","x":0,"y":0},{"name":"B","x":100,"y":0},{"name":"C","x":50,"y":80}]', 1, 200.0, 1);
if (graphPtr != 0) {
GetNodeCoordinates(instance, graphPtr, "A");
DeleteGraph(instance, graphPtr);
}返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 返回节点坐标信息的JSON字符串指针,格式为:。 |
json
{"name": "节点名", "x": 坐标X, "y": 坐标Y}节点不存在返回0。
返回的字符串指针需要调用 FreeStringPtr 释放内存。
