【问题标题】:How to display an image with SVG in FICO Xpress Workbench如何在 FICO Xpress Workbench 中使用 SVG 显示图像
【发布时间】:2020-09-06 16:37:03
【问题描述】:

我正在生成一个 SVG 图像来表示一个图形。对于每个节点,我想显示一个图像。如文档中所述,要使用图像,我需要使用svgaddfilesvgaddimage

我写了这段代码(我只复制有趣的行)

 svgsetgraphviewbox(0, 0,max(i in V_zero_n_plus_one)X(i)+10, max(i in V_zero_n_plus_one)Y(i)+10)
 svgsetgraphscale(5)
 svgsetgraphpointsize(5)

 svgaddgroup("Customers", "Customers", SVG_BLACK)

 svgaddgroup("Depot", "Depot", SVG_BROWN)
 svgaddpoint(X(0), Y(0))
 svgaddtext(X(0)+0.5, Y(0)-0.5, "Depot")

 svgaddfile("./city2.jpg", "city.png")
 svgaddimage("city.png", X(0)+0.5, Y(0)-0.5, 20, 20)

 svgaddgroup("Routes", "Delivery routes")
 
svgsave("vrp.svg")
 svgrefresh
 svgwaitclose("Close browser window to terminate model execution.", 1)

我得到以下图像:

图像为 512x512。我究竟做错了什么?天呐

【问题讨论】:

    标签: svg mosel


    【解决方案1】:

    当您在从 Workbench 运行时使用“svgwaitclose”中的选项“1”时,上传图形文件似乎存在时间问题(此选项意味着由 mmsvg 运行的底层 HTTP 服务器已停止SVG 文件上传后立即执行)。 您可以使用此表单:

    svgwaitclose("Close browser window to terminate model execution.")   ! NB: the second argument defaults to value 0
    

    或在此语句之前添加一个小延迟:

    sleep(2000)       ! Wait for 2 seconds
    svgwaitclose("Close browser window to terminate model execution.", 1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-12
      • 1970-01-01
      • 2020-08-09
      相关资源
      最近更新 更多