hanbaoshan
2020-09-09 bde62ab8f0de2c0bd6dbf0c4c15f043dbe2ad8de
样式调整,区域比例修改
4个文件已修改
174 ■■■■■ 已修改文件
src/components/player/index.vue 168 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/subComponents/eChartsBar.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/cameraAccess/components/CameraInfo.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/cameraAccess/index/App.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/player/index.vue
@@ -1,6 +1,6 @@
<template>
  <div class="video-player">
    <canvas v-show="showArea" id="area-canvas" ref="areaCanvas"  width="960" height="540"></canvas>
    <canvas v-show="showArea" id="area-canvas" ref="areaCanvas" width="960" height="540"></canvas>
    <video ref="videoPlayer" :poster="poster" preload="auto" muted></video>
    <div class="controls">
      <!-- 全屏 -->
@@ -68,10 +68,10 @@
      },
      //showProportion: 3.2,
      //showProportionY: 3.58,
      showProportion: 1.036,
      showProportionY: 1.039,
      // showProportion: 1.666,
      // showProportionY: 1.666,
      // showProportion: 1.036,
      // showProportionY: 1.039,
      showProportion: 1,
      showProportionY: 1,
      canvas: null,
      ctx: null,
      canvasWidth: 0,
@@ -187,26 +187,6 @@
        //   v.name
        // );
        _this.canvas.style.cursor = "default";
        if (e && _this.ctx.isPointInStroke(e.offsetX, e.offsetY)) {
          // 如果传入了事件坐标,就用isPointInStroke判断一下
          // 如果当前环境覆盖了该坐标,就将图形的index放到数组里
          // 当鼠标移入之后将当前的模式切换为选中模式
          _this.type = "0";
          _this.delCursor.type = "1";
          _this.delCursor.index = i;
          // 将当前元素标红
          _this.ctx.strokeStyle = "red";
          _this.ctx.beginPath();
          _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion);
          _this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion);
          _this.ctx.stroke();
          _this.showRemarks(
            v.location[0].x / _this.showProportion,
            v.location[0].y / _this.showProportion,
            v.name
          );
          _this.canvas.style.cursor = "pointer";
        }
      });
      _this.canvasData.rect.forEach(function (v, i) {
        _this.ctx.strokeStyle = "yellow";
@@ -223,35 +203,10 @@
        //   v.name
        // );
        _this.canvas.style.cursor = "default";
        if (e && _this.ctx.isPointInPath(e.offsetX, e.offsetY)) {
          // 如果传入了事件坐标,就用isPointInStroke判断一下
          // 当鼠标移入之后将当前的模式切换为选中模式
          _this.type = "0";
          _this.delCursor.type = "2";
          _this.delCursor.index = i;
          // 将当前元素标红
          _this.ctx.strokeStyle = "red";
          _this.ctx.beginPath();
          _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion);
          _this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion);
          _this.ctx.lineTo(v.location[2].x / _this.showProportion, v.location[2].y / _this.showProportion);
          _this.ctx.lineTo(v.location[3].x / _this.showProportion, v.location[3].y / _this.showProportion);
          _this.ctx.lineTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion);
          _this.ctx.stroke();
          _this.showRemarks(
            v.location[0].x / _this.showProportion,
            v.location[0].y / _this.showProportion,
            v.name
          );
          _this.canvas.style.cursor = "pointer";
        }
      });
      _this.canvasData.arrow.forEach(function (v, i) {
        _this.ctx.strokeStyle = "yellow";
        // _this.ctx.beginPath()
        // _this.ctx.moveTo(v.location[0].x / 2, v.location[0].y / 2)
        // _this.ctx.lineTo(v.location[1].x / 2, v.location[1].y / 2)
        // _this.ctx.stroke()
        _this.drawArrow(
          _this.ctx,
          v.location[0].x / _this.showProportion,
@@ -261,43 +216,15 @@
          20,
          30,
          "yellow"
        ); // 绘制方法
        _this.showRemarks(
          v.location[0].x / _this.showProportion,
          v.location[0].y / _this.showProportion,
          v.name
        );
        );
        // 绘制方法
        // _this.showRemarks(
        //   v.location[0].x / _this.showProportion,
        //   v.location[0].y / _this.showProportion,
        //   v.name
        // );
        _this.canvas.style.cursor = "default";
        if (e && _this.ctx.isPointInStroke(e.offsetX, e.offsetY)) {
          // 如果传入了事件坐标,就用isPointInStroke判断一下
          // 如果当前环境覆盖了该坐标,就将图形的index放到数组里
          // 当鼠标移入之后将当前的模式切换为选中模式
          _this.type = "0";
          _this.delCursor.type = "4";
          _this.delCursor.index = i;
          // 将当前元素标红
          _this.ctx.strokeStyle = "red";
          //   _this.ctx.beginPath()
          //   _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportion)
          //   _this.ctx.lineTo(v.location[1].x / _this.showProportion, v.location[1].y / _this.showProportion)
          //   _this.ctx.stroke()
          _this.drawArrow(
            _this.ctx,
            v.location[0].x / _this.showProportion,
            v.location[0].y / _this.showProportion,
            v.location[1].x / _this.showProportion,
            v.location[1].y / _this.showProportion,
            20,
            30,
            "red"
          ); // 绘制方法
          _this.showRemarks(
            v.location[0].x / _this.showProportion,
            v.location[0].y / _this.showProportion,
            v.name
          );
          _this.canvas.style.cursor = "pointer";
        }
      });
      _this.canvasData.polygon.forEach(function (v, i) {
        if (v.location.length === 0) {
@@ -317,31 +244,52 @@
        //   v.name
        // );
        _this.canvas.style.cursor = "default";
        if (e && _this.ctx.isPointInPath(e.offsetX, e.offsetY)) {
          // 如果传入了事件坐标,就用isPointInStroke判断一下
          // 如果当前环境覆盖了该坐标,就将图形的index放到数组里
          // 当鼠标移入之后将当前的模式切换为选中模式
          _this.type = "0";
          _this.delCursor.type = "5";
          _this.delCursor.index = i;
          // 将当前元素标红
          _this.ctx.strokeStyle = "red";
          _this.ctx.beginPath();
          _this.ctx.moveTo(v.location[0].x / _this.showProportion, v.location[0].y / _this.showProportionY);
          for (let i = 1; i < v.location.length; i++) {
            _this.ctx.lineTo(v.location[i].x / _this.showProportion, v.location[i].y / _this.showProportionY);
          }
          _this.ctx.closePath();
          _this.ctx.stroke();
          _this.showRemarks(
            v.location[v.location.length - 1].x / _this.showProportion,
            v.location[v.location.length - 1].y / _this.showProportionY,
            v.name
          );
          _this.canvas.style.cursor = "pointer";
        }
      });
    },
    // 箭头绘制函数
    drawArrow(ctx, fromX, fromY, toX, toY, theta=30, headlen=10, width=1, color="yellow") {
      // ctx:Canvas绘图环境
      // fromX, fromY:起点坐标(也可以换成p1,只不过它是一个数组)
      // toX, toY:终点坐标 (也可以换成p2,只不过它是一个数组)
      // theta:三角斜边一直线夹角
      // headlen:三角斜边长度
      // width:箭头线宽度
      // color:箭头颜色
      // theta = typeof theta !== "undefined" ? theta : 30;
      // headlen = typeof theta !== "undefined" ? headlen : 10;
      // width = typeof width !== "undefined" ? width : 1;
      // color = typeof color !== "undefined" ? color : "yellow";
      // 计算各角度和对应的P2,P3坐标
      let angle = (Math.atan2(fromY - toY, fromX - toX) * 180) / Math.PI;
      let angle1 = ((angle + theta) * Math.PI) / 180;
      let angle2 = ((angle - theta) * Math.PI) / 180;
      let topX = headlen * Math.cos(angle1);
      let topY = headlen * Math.sin(angle1);
      let botX = headlen * Math.cos(angle2);
      let botY = headlen * Math.sin(angle2);
      ctx.save();
      ctx.beginPath();
      let arrowX = fromX - topX;
      let arrowY = fromY - topY;
      ctx.moveTo(arrowX, arrowY);
      ctx.moveTo(fromX, fromY);
      ctx.lineTo(toX, toY);
      arrowX = toX + topX;
      arrowY = toY + topY;
      ctx.moveTo(arrowX, arrowY);
      ctx.lineTo(toX, toY);
      arrowX = toX + botX;
      arrowY = toY + botY;
      ctx.lineTo(arrowX, arrowY);
      ctx.strokeStyle = color;
      ctx.lineWidth = width;
      ctx.stroke();
      ctx.restore();
    },
    // 回显图形备注
    showRemarks(x, y, remarks) {
      this.ctx.moveTo(x, y - 10); // 因为放大之后是y-20,所以缩小版的为y-10
src/components/subComponents/eChartsBar.vue
@@ -73,7 +73,7 @@
        },
        grid: {
          top: 10,
          right: 40,
          right: 50,
          bottom: 20,
          left: 40,
        },
src/pages/cameraAccess/components/CameraInfo.vue
@@ -77,7 +77,7 @@
                  :value="item"
                ></el-option>
              </el-select>
              <span class="player-btn" @click="togglePlayer">
              <span class="player-btn" @click="togglePlayer" style="cursor:pointer;">
                <i
                  class="el-icon-video-play"
                  style="font-size:26px; vertical-align:middle; color:#409eff"
src/pages/cameraAccess/index/App.vue
@@ -80,7 +80,7 @@
  box-sizing: border-box;
  overflow-y: hidden;
  height: 100%;
  min-width: 1433px;
  min-width: 1602px;
}
.resize-save {
  position: absolute;