Add drawing workspace feature
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
ad73ddec2b
commit
a5cc458252
78 files changed
+35740
-6
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { paperEntity, presentationEntities } from './presentation';
|
||||
import type { DrawingDocument, DrawingView, Entity, Point, Source } from './types';
|
||||
import { templateFrame } from './template';
|
||||
|
||||
/** Paper-space entities in actual paper mm (origin bottom-left), shared by SVG and DXF Layout1. */
|
||||
export function viewPaperEntities(doc:DrawingDocument,view:DrawingView):{entity:Entity;index:number}[] {
|
||||
const up=(p:Point):Point=>[p[0],p[1]+doc.paper.height];
|
||||
return presentationEntities(view).map(({entity,index})=>{
|
||||
const e=paperEntity(view,entity);
|
||||
if(e.kind==='line')return{index,entity:{...e,a:up(e.a),b:up(e.b)}};
|
||||
if(e.kind==='polyline')return{index,entity:{...e,points:e.points.map(up)}};
|
||||
if(e.kind==='hatch')return{index,entity:{...e,points:e.points.map(up),holes:e.holes?.map(loop=>loop.map(up))}};
|
||||
if(e.kind==='circle')return{index,entity:{...e,center:up(e.center)}};
|
||||
if(e.kind==='text')return{index,entity:{...e,point:up(e.point)}};
|
||||
throw new Error('Unexpected paper dimension');
|
||||
});
|
||||
}
|
||||
export function sheetFrame(doc:DrawingDocument):Entity[] {
|
||||
const out:Entity[]=templateFrame(doc),{width:w,height:h}=doc.paper,source:Source={member:'sheet',pier:doc.pier,index:0};
|
||||
const p=(x:number,y:number):Point=>[x,h-y];
|
||||
const line=(x0:number,y0:number,x1:number,y1:number)=>out.push({kind:'line',a:p(x0,y0),b:p(x1,y1),layer:'TEXT',source});
|
||||
const text=(x:number,y:number,t:string,size=2.3,align:'left'|'center'='left')=>out.push({kind:'text',point:p(x,y),text:t,height:size,align,layer:'TEXT',source});
|
||||
for(const view of doc.views){
|
||||
if(['section','schedule','heights'].includes(view.id))continue;
|
||||
text(view.slot.x,view.slot.y-3,`${view.title}${view.id==='keyplan'?'':` 1:${view.scale}`}${view.breaks?.length?' (생략)':''}`,3.0);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Reference in new issue
Block a user