fix(sensor-placement): refine drawing export and editor density
This commit is contained in:
@@ -12,8 +12,6 @@ interface DrawingOptions {
|
||||
rows: SensorPointRow[];
|
||||
network: string;
|
||||
networkData: NetworkDrawingData;
|
||||
mapCanvas?: HTMLCanvasElement | null;
|
||||
mapAttribution?: string | null;
|
||||
dirty: boolean;
|
||||
width?: number;
|
||||
}
|
||||
@@ -123,8 +121,6 @@ export const renderEngineeringDrawing = async ({
|
||||
rows,
|
||||
network,
|
||||
networkData,
|
||||
mapCanvas,
|
||||
mapAttribution,
|
||||
dirty,
|
||||
width = A3_LANDSCAPE_WIDTH,
|
||||
}: DrawingOptions): Promise<HTMLCanvasElement> => {
|
||||
@@ -161,15 +157,6 @@ export const renderEngineeringDrawing = async ({
|
||||
);
|
||||
context.fillStyle = "#fbfcfd";
|
||||
context.fillRect(mapBox.x, mapBox.y, mapBox.width, mapBox.height);
|
||||
if (mapCanvas) {
|
||||
context.drawImage(
|
||||
mapCanvas,
|
||||
mapBox.x,
|
||||
mapBox.y,
|
||||
mapBox.width,
|
||||
mapBox.height,
|
||||
);
|
||||
}
|
||||
|
||||
const nodes = networkData.nodes
|
||||
.map(parseNode)
|
||||
@@ -184,40 +171,38 @@ export const renderEngineeringDrawing = async ({
|
||||
mapBox.y + mapBox.height - ((y - minY) / (maxY - minY)) * mapBox.height,
|
||||
});
|
||||
|
||||
if (!mapCanvas) {
|
||||
context.strokeStyle = "#45677a";
|
||||
context.lineWidth = px(5);
|
||||
for (const link of networkData.links) {
|
||||
const [, , startId, endId] = link.split(":");
|
||||
const start = nodesById.get(startId);
|
||||
const end = nodesById.get(endId);
|
||||
if (!start || !end) continue;
|
||||
if (
|
||||
Math.max(start.x, end.x) < minX ||
|
||||
Math.min(start.x, end.x) > maxX ||
|
||||
Math.max(start.y, end.y) < minY ||
|
||||
Math.min(start.y, end.y) > maxY
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const startPoint = toCanvas(start.x, start.y);
|
||||
const endPoint = toCanvas(end.x, end.y);
|
||||
context.beginPath();
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
context.strokeStyle = "#45677a";
|
||||
context.lineWidth = px(5);
|
||||
for (const link of networkData.links) {
|
||||
const [, , startId, endId] = link.split(":");
|
||||
const start = nodesById.get(startId);
|
||||
const end = nodesById.get(endId);
|
||||
if (!start || !end) continue;
|
||||
if (
|
||||
Math.max(start.x, end.x) < minX ||
|
||||
Math.min(start.x, end.x) > maxX ||
|
||||
Math.max(start.y, end.y) < minY ||
|
||||
Math.min(start.y, end.y) > maxY
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const startPoint = toCanvas(start.x, start.y);
|
||||
const endPoint = toCanvas(end.x, end.y);
|
||||
context.beginPath();
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
context.fillStyle = "#668697";
|
||||
for (const node of nodes) {
|
||||
if (node.x < minX || node.x > maxX || node.y < minY || node.y > maxY) {
|
||||
continue;
|
||||
}
|
||||
const point = toCanvas(node.x, node.y);
|
||||
context.beginPath();
|
||||
context.arc(point.x, point.y, px(4), 0, Math.PI * 2);
|
||||
context.fill();
|
||||
context.fillStyle = "#668697";
|
||||
for (const node of nodes) {
|
||||
if (node.x < minX || node.x > maxX || node.y < minY || node.y > maxY) {
|
||||
continue;
|
||||
}
|
||||
const point = toCanvas(node.x, node.y);
|
||||
context.beginPath();
|
||||
context.arc(point.x, point.y, px(4), 0, Math.PI * 2);
|
||||
context.fill();
|
||||
}
|
||||
|
||||
rows.forEach((row) => {
|
||||
@@ -263,20 +248,6 @@ export const renderEngineeringDrawing = async ({
|
||||
context.strokeStyle = "#111827";
|
||||
context.lineWidth = px(4);
|
||||
context.strokeRect(mapBox.x, mapBox.y, mapBox.width, mapBox.height);
|
||||
if (mapCanvas && mapAttribution) {
|
||||
context.fillStyle = "#334155";
|
||||
drawText(
|
||||
context,
|
||||
`底图来源:${mapAttribution}`,
|
||||
mapBox.x + mapBox.width - px(16),
|
||||
mapBox.y + mapBox.height - px(18),
|
||||
px(18),
|
||||
500,
|
||||
"right",
|
||||
"rgba(255,255,255,0.96)",
|
||||
px(6),
|
||||
);
|
||||
}
|
||||
|
||||
for (let index = 0; index <= 4; index += 1) {
|
||||
const ratio = index / 4;
|
||||
|
||||
Reference in New Issue
Block a user