/**
* Plan Generator - Generate 2D assembly and parts plans in SVG format
* Also handles PDF export
*/
// Constants for drawing
const DRAWING_SCALE = 0.1; // 1mm = 0.1px
const MARGIN = 50;
const LABEL_OFFSET = 15;
const ARROW_SIZE = 8;
/**
* Generate SVG for assembly view (front elevation)
*/
export function generateAssemblyPlan(config, modules = []) {
const { widthMm, heightMm, plinthHeightMm, doorType, installationType } = config;
const bodyHeight = heightMm - plinthHeightMm;
const svgWidth = widthMm * DRAWING_SCALE + MARGIN * 2;
const svgHeight = heightMm * DRAWING_SCALE + MARGIN * 2;
let svg = `';
return svg;
}
/**
* Generate SVG for side view
*/
export function generateSidePlan(config) {
const { heightMm, depthMm, plinthHeightMm } = config;
const bodyHeight = heightMm - plinthHeightMm;
const svgWidth = depthMm * DRAWING_SCALE + MARGIN * 2;
const svgHeight = heightMm * DRAWING_SCALE + MARGIN * 2;
let svg = `';
return svg;
}
/**
* Generate SVG for top view
*/
export function generateTopPlan(config, modules = []) {
const { widthMm, depthMm } = config;
const svgWidth = widthMm * DRAWING_SCALE + MARGIN * 2;
const svgHeight = depthMm * DRAWING_SCALE + MARGIN * 2;
let svg = `';
return svg;
}
/**
* Generate a dimension line with arrows and text
*/
function generateDimensionLine(x, y, length, label, direction = 'horizontal') {
let svg = '';
if (direction === 'horizontal') {
// Line
svg += ``;
// Arrows
svg += ``;
svg += ``;
// Label
svg += `${label}`;
} else {
// Line
svg += ``;
// Arrows
svg += ``;
svg += ``;
// Label (rotated)
svg += `${label}`;
}
return svg;
}
/**
* Generate all plans for a configuration
*/
export function generateAllPlans(config, modules = [], colors = {}) {
return {
assembly: generateAssemblyPlan(config, modules),
side: generateSidePlan(config),
top: generateTopPlan(config, modules),
metadata: {
generatedAt: new Date().toISOString(),
config: {
widthMm: config.widthMm,
heightMm: config.heightMm,
depthMm: config.depthMm,
installationType: config.installationType,
doorType: config.doorType,
moduleCount: modules.length
}
}
};
}
/**
* Generate HTML page with all plans for PDF export
*/
export function generatePDFHtml(config, modules = [], cuttingList = null) {
const plans = generateAllPlans(config, modules);
let html = `
Plans Armoire
Spécifications
Largeur:${config.widthMm} mm
Hauteur:${config.heightMm} mm
Profondeur:${config.depthMm} mm
Plinthe:${config.plinthHeightMm} mm
Type:${config.installationType === 'niche' ? 'Encastrée' : 'Libre'}
Portes:${config.doorType === 'sliding' ? 'Coulissantes' : 'Battantes'}
Vue de face (Élévation)
${plans.assembly}
Vue de côté
${plans.side}
Vue de dessus
${plans.top}
`;
// Cutting list page
if (cuttingList) {
html += `
Liste de débitage
Résumé
Nombre de pièces:${cuttingList.summary.totalPieces}
Surface totale:${cuttingList.summary.totalSurfaceM2.toFixed(2)} m²
Chant plaqué:${cuttingList.summary.edgeBandingMl} ml
Finitions:${cuttingList.summary.finishCount}
`;
for (const group of cuttingList.byFinish) {
html += `
Finition: ${group.finishLabel}
| Description |
Largeur |
Hauteur |
Ép. |
Qté |
Surface |
`;
for (const piece of group.pieces) {
html += `
| ${piece.description} |
${piece.widthMm} mm |
${piece.heightMm} mm |
${piece.thicknessMm} mm |
${piece.quantity} |
${piece.surfaceM2.toFixed(3)} m² |
`;
}
html += `
| Sous-total |
${group.pieceCount} |
${group.totalSurfaceM2.toFixed(2)} m² |
`;
}
html += `
`;
}
html += `
`;
return html;
}
export default {
generateAssemblyPlan,
generateSidePlan,
generateTopPlan,
generateAllPlans,
generatePDFHtml
};