优化:使用Ctrl+P一键打印,使用弹出式页面避免打印速度过慢

pull/1482/head
ChenX 3 years ago
parent a11c76b389
commit 1e4c317c73

@ -857,7 +857,7 @@ async function PrintImage3(ens: Entity[])
export function GetPrintWindow() export function GetPrintWindow()
{ {
const win = window.open(); const win = window.open('', '', 'status=1,menubar=yes,toolbar=yes');
if (!win) if (!win)
{ {
app.Editor.Prompt("无法弹出新的窗口,请允许新窗口弹出!(地址栏右侧)"); app.Editor.Prompt("无法弹出新的窗口,请允许新窗口弹出!(地址栏右侧)");
@ -977,7 +977,7 @@ export async function GetImgElement(ens: Entity[], isReset = true)
f.Reset(); f.Reset();
app.Viewer.CameraCtrl.ReadFile(f); app.Viewer.CameraCtrl.ReadFile(f);
app.Viewer.OnSize(); app.Viewer.OnSize();
app.Viewer.Render(); app.Viewer.UpdateRender();
} }
let div = document.createElement("div"); let div = document.createElement("div");

@ -89,7 +89,8 @@ export class OneKeyPrint implements Command
}); });
return; return;
} }
win.document.body.innerText = "正在生成图纸,请稍等..."; win.document.title = "按Ctrl+P打印";
win.document.body.innerText = "生成后请按Ctrl+P打印,正在生成图纸,请稍等...";
const frag = document.createDocumentFragment(); const frag = document.createDocumentFragment();
@ -101,14 +102,27 @@ export class OneKeyPrint implements Command
app.Viewer.CameraCtrl.WriteFile(f); app.Viewer.CameraCtrl.WriteFile(f);
let vpsbak = app.Viewer.ViewPorts; let vpsbak = app.Viewer.ViewPorts;
let i = 1;
let count = framesGrounps.size;
for (let [, { entitys }] of framesGrounps) for (let [, { entitys }] of framesGrounps)
{ {
let div = await GetImgElement(entitys, false); let div = await GetImgElement(entitys, false);
frag.append(div); frag.append(div);
win.document.body.innerText = `生成后请按Ctrl+P打印,正在生成图纸(${i}/${count}),请稍等...`;
i++;
} }
win.document.body.innerText = ""; win.document.body.innerText = "";
win.document.body.append(frag); win.document.body.append(frag);
// setTimeout(() =>
// {
// // chrome90如果自动调用这个,那么卡死
// // win.focus();
// // win.print();
// // win.close();
// }, 100);
//还原视图 //还原视图
[app.Viewer.Scene, sceneBak] = [sceneBak, app.Viewer.Scene]; [app.Viewer.Scene, sceneBak] = [sceneBak, app.Viewer.Scene];
app.Viewer.Renderer.setClearColor(clearColorBak); app.Viewer.Renderer.setClearColor(clearColorBak);

@ -194,7 +194,7 @@ export class ApplicationService
e.preventDefault(); e.preventDefault();
commandMachine.ExecCommand("COMANP"); commandMachine.ExecCommand("COMANP");
} }
if (app.Editor.KeyCtrl.KeyIsDown(KeyCode.ControlLeft)) if (app.Editor.KeyCtrl.KeyIsDown(KeyCode.ControlLeft) || app.Editor.KeyCtrl.KeyIsDown(KeyCode.ControlRight))
{ {
if (e.code === KeyCode.KeyZ) if (e.code === KeyCode.KeyZ)
{ {
@ -221,6 +221,12 @@ export class ApplicationService
{ {
commandMachine.ExecCommand(CommandNames.Save); commandMachine.ExecCommand(CommandNames.Save);
} }
else if (e.code === KeyCode.KeyP)
{
commandMachine.ExecCommand(CommandNames.OneKeyPrint);
e.preventDefault();
e.stopPropagation();
}
else if (e.code === KeyCode.KeyE) else if (e.code === KeyCode.KeyE)
{ {
if (app.Editor.KeyCtrl.KeyIsDown(KeyCode.AltLeft)) if (app.Editor.KeyCtrl.KeyIsDown(KeyCode.AltLeft))

@ -256,6 +256,7 @@ export enum KeyCode
CapsLock = "CapsLock", CapsLock = "CapsLock",
Control = "Control", Control = "Control",
ControlLeft = "ControlLeft", ControlLeft = "ControlLeft",
ControlRight = "ControlRight",
/** /**
* win * win

@ -16,7 +16,6 @@ import { ZINDEX } from '../../Common/ZIndex';
import { Entity } from '../../DatabaseServices/Entity/Entity'; import { Entity } from '../../DatabaseServices/Entity/Entity';
import { FileServer } from '../../DatabaseServices/FileServer'; import { FileServer } from '../../DatabaseServices/FileServer';
import { registerCommand } from '../../Editor/CommandRegister'; import { registerCommand } from '../../Editor/CommandRegister';
import { SelectSetBase } from '../../Editor/SelectBase';
import { CameraControlBtn, CameraControlBtnStore } from '../Components/CameraControlButton/CameraControlBtn'; import { CameraControlBtn, CameraControlBtnStore } from '../Components/CameraControlButton/CameraControlBtn';
import { MainContent } from '../Components/MainContent/MainContent'; import { MainContent } from '../Components/MainContent/MainContent';
import { MaterialContainer, MaterialContainerProps } from '../Components/MaterialContainer'; import { MaterialContainer, MaterialContainerProps } from '../Components/MaterialContainer';

Loading…
Cancel
Save