diff --git a/public/avoid.wasm b/public/avoid.wasm
new file mode 100644
index 0000000..0018725
Binary files /dev/null and b/public/avoid.wasm differ
diff --git a/public/index.html b/public/index.html
index df2105d..55d8718 100644
--- a/public/index.html
+++ b/public/index.html
@@ -23,6 +23,7 @@
const skinBinary = await r2.arrayBuffer();
return [ netJson, skinBinary ];
}
+ window.avoidWasm = 'avoid.wasm';
diff --git a/src/App.vue b/src/App.vue
index 09bbb28..16a56a5 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -10,8 +10,13 @@ import Render from '@/components/render';
import RightNav from '@/components/right-nav.vue';
import { onMounted, watch } from 'vue';
import { setDefaultCss } from './hook/css';
+import { useI18n } from 'vue-i18n';
+const { t } = useI18n();
+
+import { AvoidLib } from '@/lib/avoid';
import { globalLookup, globalSetting } from './hook/global';
+import { ElLoading } from 'element-plus';
// 监听 globalSetting 并录入 localStorage
watch(
@@ -27,19 +32,56 @@ onMounted(async () => {
// 设置 css 宏,纠正样式
setDefaultCss();
+ const loading = new ElLoading.service({
+ lock: true,
+ text: t('loading'),
+ background: 'rgba(0, 0, 0, 0.7)'
+ });
+
// 初始化载入 netlist 的 json 文件
- const [ netJson, skinBinary ] = await window.readNetFile();
+ const [ netJson, skinBinary ] = await window.readNetFile();
+
+ // 载入 avoid lib
+ const wasmBinaryResponse = await fetch(window.avoidWasm);
+ const wasmBinary = await wasmBinaryResponse.arrayBuffer();
+ await AvoidLib.load({ wasmBinary });
+ const Avoid = AvoidLib.getInstance();
+ globalLookup.Avoid = Avoid;
+
+
+ const router = new Avoid.Router(Avoid.PolyLineRouting);
+ const srcPt = new Avoid.Point(1.2, 0.5);
+ const dstPt = new Avoid.Point(1.5, 4);
+ const srcConnEnd = new Avoid.ConnEnd(srcPt);
+ const dstConnEnd = new Avoid.ConnEnd(dstPt);
+ const connRef = new Avoid.ConnRef(router);
+
+
+ function connCallback(connRefPtr) {
+ const connRef = Avoid.wrapPointer(connRefPtr, Avoid.ConnRef);
+ console.log(`Connector ${connRef.id()} needs rerouting!`);
+ const route = connRef.displayRoute();
+ console.log('New path: ');
+ for (let i = 0; i < route.size(); i++) {
+ console.log(`(${route.get_ps(i).x}, ${route.get_ps(i).y})`);
+ }
+ }
+
+ connRef.setCallback(connCallback, connRef);
+ // Force inital callback:
+ router.processTransaction();
+
const render = globalLookup.netlistRender;
const skinManager = globalLookup.skinManager;
skinManager.load(skinBinary);
-
render.load(netJson);
+
const layout = await render.createLayout();
const svg = await render.render(layout, '#netlist');
-
- console.log(svg);
+
+ loading.close();
});
diff --git a/src/hook/global.js b/src/hook/global.js
index ece5821..f842c60 100644
--- a/src/hook/global.js
+++ b/src/hook/global.js
@@ -22,6 +22,10 @@ export const globalLookup = {
*/
netlistRender: new NetlistRender(),
+ /**
+ * @type {Avoid}
+ */
+ Avoid: undefined
};
function loadSetting() {
diff --git a/src/hook/render/cell.js b/src/hook/render/cell.js
index 2b8d983..20eb19f 100644
--- a/src/hook/render/cell.js
+++ b/src/hook/render/cell.js
@@ -239,6 +239,9 @@ async function dragStart(event, manager, rootRender) {
context.elkGraph.children = nodes;
context.elkGraph.edges = edges;
+ context.elkGraph.layoutOptions = {
+ 'elk.algorithm': 'layered'
+ };
}
/**
diff --git a/src/hook/render/index.js b/src/hook/render/index.js
index e6f9513..5f5ce67 100644
--- a/src/hook/render/index.js
+++ b/src/hook/render/index.js
@@ -9,6 +9,7 @@ import { InstantiationRender } from './instantiation';
import { CellRender } from './cell';
import { ConnectionRender } from './connection';
import { WireRender } from './wire';
+import { pinkLog } from '../utils';
export class NetlistRender {
/**
@@ -113,10 +114,8 @@ export class NetlistRender {
const start = performance.now();
const layoutGraph = await this.elk.layout(graph);
const timecost = (performance.now() - start).toFixed(3);
- console.log(
- `%c 布局计算耗时 ${timecost} ms`,
- 'background-color: #CB81DA; color: white; padding: 3px; border-radius: 3px;'
- );
+
+ pinkLog(`布局计算耗时 ${timecost} ms`);
return layoutGraph;
}
diff --git a/src/hook/utils.js b/src/hook/utils.js
new file mode 100644
index 0000000..70c42f2
--- /dev/null
+++ b/src/hook/utils.js
@@ -0,0 +1,5 @@
+const pinkLogStyle = 'background-color: #CB81DA; color: white; padding: 3px; border-radius: 3px;';
+
+export function pinkLog(message) {
+ console.log('%c' + message, pinkLogStyle);
+}
\ No newline at end of file
diff --git a/src/i18n/ar.json b/src/i18n/ar.json
index 9d780dd..44904d9 100644
--- a/src/i18n/ar.json
+++ b/src/i18n/ar.json
@@ -14,5 +14,6 @@
"usermanual.click-move": "انقر + اسحب",
"usermanual.move-view": "عرض الجوال",
"usermanual.scale-view": "تكبير/تصغير العرض",
- "usermanual.scale-view-more": "تكبير العرض (مقياس أكبر)"
+ "usermanual.scale-view-more": "تكبير العرض (مقياس أكبر)",
+ "loading": "جاري التحميل"
}
\ No newline at end of file
diff --git a/src/i18n/de.json b/src/i18n/de.json
index 1ea9544..df284d2 100644
--- a/src/i18n/de.json
+++ b/src/i18n/de.json
@@ -14,5 +14,6 @@
"usermanual.click-move": "Klicken + Ziehen",
"usermanual.move-view": "Mobile Ansicht",
"usermanual.scale-view": "Ansicht zoomen",
- "usermanual.scale-view-more": "Ansicht vergrößern (größerer Maßstab)"
+ "usermanual.scale-view-more": "Ansicht vergrößern (größerer Maßstab)",
+ "loading": "Laden"
}
\ No newline at end of file
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 78f761d..cd779fe 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -3,7 +3,7 @@
"general-setting": "General",
"appearance-setting": "Appearance",
"current-version": "current version",
- "copyright": "The copyright of this software belongs to Digital-IDE project team. Welcome to Star.",
+ "copyright": "The copyright of this software belongs to