123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <!-- 画板 -->
- <template>
- <div class="base-map">
- <canvas
- v-loading="loading"
- id="floorMap4"
- :width="canvasWidth"
- :height="canvasHeight"
- tabindex="0"
- ></canvas>
- </div>
- </template>
- <script>
- import { SGraphView, SGraphScene } from "@persagy-web/graph";
- import { SFloorParser, getJsonz, SZoneParser } from "@persagy-web/big/lib";
- import { SColor } from "@persagy-web/draw";
- import { eventScene } from "./addEventClass/eventScene";
- const map1 = require("../../../public/assets/map/1.json");
- export default {
- data() {
- return {
- canvasWidth: 0,
- canvasHeight: 0,
- view: null,
- scene: null,
- dataKey: "base/f2a4b3d10d3511eb9a1da1ce4aece47c.jsonz",
- mapUrl: "/image-service/common/file_get?systemId=revit&key=",
- loading: false,
- isShowColumn: false,
- isShowWall: false,
- isShowVirtualWall: false,
- isShowDoor: false,
- isShowWindow: false,
- isSpaceSelectable: true,
- selectItem: null,
- };
- },
- methods: {
-
- init() {
- this.clearImg();
- this.view ? (this.view.scene = this.scene) : null;
-
- setTimeout(() => {
- this.parserData(map1.EntityList[0].Elements);
- });
- },
-
- parserData(data) {
- let parser = new SFloorParser();
- parser.parseData(data);
- parser.spaceList.forEach((t) => {
-
-
-
- t.visible = this.isSpaceSelectable;
-
- t.showBaseName = false;
-
- t.strokeColor = new SColor("#F0F3F7");
-
- t.fillColor = new SColor("#F0F3F7");
-
- t.lineWidth = 1;
- t.connect("onMouseDown", this, this.onMousedown);
- t.connect("onMouseUp", this, this.onMouseup);
- t.connect("onMouseLeave", this, this.onMouseleave);
- t.connect("onMouseEnter", this, this.onMouseenter);
-
- this.scene.addItem(t);
- });
- parser.wallList.forEach((t) => {
-
- t.visible = this.isShowWall;
- this.scene.addItem(t);
- });
- parser.virtualWallList.forEach((t) => {
-
- t.visible = this.isShowVirtualWall;
- this.scene.addItem(t);
- });
- parser.doorList.forEach((t) => {
-
- t.visible = this.isShowDoor;
- this.scene.addItem(t);
- });
- parser.columnList.forEach((t) => {
-
- t.visible = this.isShowColumn;
- this.scene.addItem(t);
- });
- parser.casementList.forEach((t) => {
-
- t.visible = this.isShowWindow;
- this.scene.addItem(t);
- });
-
- if (this.view) {
- this.view.DragMove = true;
- this.view.fitSceneToView();
- }
- },
-
- onMousedown(item, e) {
- const DefaltColor = "#F0F3F7";
- const clickColor = "#7ed321";
-
- if (this.selectItem) {
- this.selectItem.fillColor = new SColor(DefaltColor);
- this.selectItem.strokeColor = new SColor(DefaltColor);
- }
-
- if (item) {
-
- if (this.selectItem) {
- if (this.selectItem != item) {
-
- const oldSelectItem = this.selectItem;
- oldSelectItem.fillColor = new SColor(DefaltColor);
- oldSelectItem.strokeColor = new SColor(DefaltColor);
-
- const newSelectItem = item;
- newSelectItem.fillColor = new SColor(clickColor);
- newSelectItem.strokeColor = new SColor(clickColor);
- this.selectItem = newSelectItem;
- } else {
-
- const oldSelectItem = this.selectItem;
- oldSelectItem.fillColor = new SColor(DefaltColor);
- oldSelectItem.strokeColor = new SColor(DefaltColor);
- this.selectItem = null;
- }
- } else {
-
- this.selectItem = item;
- this.selectItem.fillColor = new SColor(clickColor);
- this.selectItem.strokeColor = new SColor(clickColor);
- }
- } else {
- this.selectItem = null;
- }
- },
-
- onMouseup(item, e) {},
-
- onMouseenter(item, e) {
- if (this.selectItem && item == this.selectItem) return;
- item.fillColor = new SColor("#E1F2FF");
- item.strokeColor = new SColor("#E1F2FF");
- },
-
- onMouseleave(item, e) {
- if (this.selectItem && item == this.selectItem) return;
- item.fillColor = new SColor("#F0F3F7");
- item.strokeColor = new SColor("#F0F3F7");
- },
-
- clearImg() {
- this.scene = new eventScene();
- this.scene.vueOnMouseDown = this.onMousedown;
- if (this.view) {
- this.view.update();
- }
- },
- },
- created() {
- this.clearImg();
- },
- mounted() {
-
- this.canvasWidth = 800;
- this.canvasHeight = 600;
-
- this.view = new SGraphView("floorMap4");
- if (this.scene) {
- this.view.scene = this.scene;
- this.init();
- }
- },
- };
- </script>
|