그룹 도형

SpreadJS는 개별 셰이프를 셰이프 그룹으로 그룹화하는 작업을 지원합니다. 이 그룹 셰이프는 셰이프 그룹을 간편하고 빠르게 선택 및 편집하는 작업을 관리하는 데 사용됩니다.

설명
app.vue
index.html

도형을 이동하지만 관련 위치를 유지하고, 크기 비율을 유지하면서 크기를 조정하고 동일한 각도로 회전할 수 있습니다.

다음과 같은 코드를 사용하여 여러 도형을 그룹화하거나 그룹 해제할 수 있습니다:

    var shape1 = sheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
    var shape2 = sheet.shapes.addConnector("shape2", GC.Spread.Sheets.Shapes.ConnectorType.elbow, 200, 50, 300, 200);
    var shapes = [shape1, shape2];
    var groupShape = sheet.shapes.group(shapes)
    sheet.shapes.ungroup(groupShape);
도형을 이동하지만 관련 위치를 유지하고, 크기 비율을 유지하면서 크기를 조정하고 동일한 각도로 회전할 수 있습니다. 다음과 같은 코드를 사용하여 여러 도형을 그룹화하거나 그룹 해제할 수 있습니다:
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> </gc-spread-sheets> <div class="options-container"> <div class="option-row"> Try selecting the shapes in Spread and grouping/ungrouping them to see how the selection area changes. </div> <br/> <div class="option-row"> *the cube and the cylinder are already grouped. </div> <hr /> <div class="option-row"> <label>Group Selected Shapes</label> <input type="button" :disabled="!canGroup" value="Group" @click="group"> <br /> <label>Ungroup Selected Shapes</label> <input type="button" :disabled="canGroup" value="Ungroup" @click="ungroup"> </div> </div> </div> </template> <script setup> import GC from "@mescius/spread-sheets"; import { ref } from 'vue'; import "@mescius/spread-sheets-vue"; import '@mescius/spread-sheets-shapes'; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); const refSpread = ref(null); const canGroup = ref(true); function initSpread(spread) { refSpread.value = spread; let sheet = spread.getSheet(0); let rectangle = sheet.shapes.add("rectangle", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 60, 150, 150); let rectangleStyle = rectangle.style(); rectangleStyle.fill.color = "#F4F8EB"; rectangleStyle.line.color = "#82bc00"; rectangle.style(rectangleStyle); let oval = sheet.shapes.add("oval", GC.Spread.Sheets.Shapes.AutoShapeType.oval, 400, 60, 150, 150); let ovalStyle = oval.style(); ovalStyle.fill.color = "#e3e3e3"; ovalStyle.line.color = "#e3e3e3"; oval.style(ovalStyle); let cube = sheet.shapes.add("cube", GC.Spread.Sheets.Shapes.AutoShapeType.cube, 100, 240, 150, 150); let can = sheet.shapes.add("can", GC.Spread.Sheets.Shapes.AutoShapeType.can, 400, 240, 150, 150); let shapes = [cube, can]; sheet.shapes.group(shapes); spread.bind(GC.Spread.Sheets.Events.ShapeSelectionChanged, function () { let activeSheet = spread.getActiveSheet(); let shapes = activeSheet.shapes.all(), activeShapes = []; for (let i = 0; i < shapes.length; i++) { let shape = shapes[i]; if (shape.isSelected()) { activeShapes.push(shape); } } if (activeShapes.length === 1 && activeShapes[0] instanceof GC.Spread.Sheets.Shapes.GroupShape) { canGroup.value = false; } else { canGroup.value = true; } }); } function group() { let spread = refSpread.value; let activeSheet = spread.getActiveSheet(); let activeShape = activeSheet.shapes.all().filter(function (sp) { return sp.isSelected(); }); if (activeShape.length > 1) { var groupShape = activeSheet.shapes.group(activeShape); groupShape.isSelected(true); canGroup.value = false; } } function ungroup() { let spread = refSpread.value; let activeSheet = spread.getActiveSheet(); let activeShape = activeSheet.shapes.all().filter(function (sp) { return sp.isSelected(); }); if (activeShape.length > 0) { activeShape.forEach(function (shape) { activeSheet.shapes.ungroup(shape); }); canGroup.value = true; } } </script> <style scoped> .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: calc(100% - 280px); height: 100%; overflow: hidden; float: left; } .options-container { float: right; width: 280px; padding: 12px; height: 100%; box-sizing: border-box; background: #fbfbfb; overflow: auto; } .option-row { font-size: 14px; padding-left: 5px; } .divide-line { width: 100%; height: 1px; background: #cbcbcb; margin-top: 10px; margin-bottom: 3px; } .title { text-align: center; font-weight: bold; } label { display: block; margin-top: 15px; margin-bottom: 5px; } p { padding: 2px 10px; background-color: #F4F8EB; } input { padding: 4px 6px; width: 160px; } input[type=button] { margin-top: 6px; display: block; } select { width: 160px; margin-left: 10px; display: inline; } textarea { width: 160px; margin-left: 10px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } #app { height: 100%; } </style>
<!DOCTYPE html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>SpreadJS VUE</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/spread/source/data/inventory-tracker.js" type="text/javascript"></script> <script src="$DEMOROOT$/ko/vue3/node_modules/systemjs/dist/system.src.js"></script> <script src="./systemjs.config.js"></script> <script src="./compiler.js" type="module"></script> <script> var System = SystemJS; System.import("./src/app.js"); System.import('$DEMOROOT$/ko/lib/vue3/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
(function (global) { SystemJS.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, packageConfigPaths: [ './node_modules/*/package.json', "./node_modules/@mescius/*/package.json", "./node_modules/@babel/*/package.json", "./node_modules/@vue/*/package.json" ], map: { 'vue': "npm:vue/dist/vue.esm-browser.js", 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js", '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js', '@mescius/spread-sheets-shapes': 'npm:@mescius/spread-sheets-shapes/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js' }, meta: { '*.css': { loader: 'systemjs-plugin-css' }, '*.vue': { loader: "../plugin-vue/index.js" } } }); })(this);