Browse Source

feat: 调整点位坐标根据角度旋转位置;

liujia 5 days ago
parent
commit
b04901e

+ 1 - 10
src/components/DetectionAreaView/index.vue

@@ -316,15 +316,6 @@ const convertedCoordinates = computed(() => {
 })
 
 const getTargetStyle = (target: TargetPoint) => {
-  const radarFurniture: RadarFurniture = {
-    x: target.x,
-    y: target.y,
-    width: 0,
-    height: 0,
-  }
-
-  const canvasRect = convert_furniture_r2c(radarFurniture, radarPosition)
-
   const colorPalette = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple']
 
   const colorIndex = target.id < colorPalette.length ? target.id : colorPalette.length - 1
@@ -336,7 +327,7 @@ const getTargetStyle = (target: TargetPoint) => {
     height: '18px',
     background: color,
     borderRadius: '50%',
-    transform: `translate3d(${canvasRect.left}px, ${canvasRect.top}px, 0) translate(-50%, -50%)`,
+    transform: `translate3d(${target.displayX}px, ${target.displayY}px, 0) translate(-50%, -50%)`,
     display: 'flex',
     alignItems: 'center',
     justifyContent: 'center',

+ 33 - 48
src/components/RadarEditor/index.vue

@@ -2,16 +2,18 @@
   <div class="radarEditor" :class="{ disabled: props.disabled }">
     <DetectionAreaView :coordinates="coordinates" :direction="angle" mode="edit">
       <template #furnitures>
-        <EditableFurniture
-          v-for="item in roomStore.localFurnitureItems"
-          :key="item.nanoid"
-          :item="item"
-          :angle="angle"
-          :coordinates="coordinates"
-          :canvas-size="500"
-          :disabled="disabled"
-          @update="handleFurnitureUpdate"
-        />
+        <template v-if="showFurniture">
+          <EditableFurniture
+            v-for="item in roomStore.localFurnitureItems"
+            :key="item.nanoid"
+            :item="item"
+            :angle="angle"
+            :coordinates="coordinates"
+            :canvas-size="500"
+            :disabled="disabled"
+            @update="handleFurnitureUpdate"
+          />
+        </template>
       </template>
 
       <template #subregion>
@@ -38,15 +40,15 @@
           size="small"
           @change="modeRadioChange"
         >
-          <a-radio-button :value="1">配置面板</a-radio-button>
-          <a-radio-button :value="2">信息面板</a-radio-button>
+          <a-radio-button :value="1">家具配置</a-radio-button>
+          <a-radio-button :value="2">子区域配置</a-radio-button>
         </a-radio-group>
         <!-- <a-button type="link" size="small" @click="syncCoordinates">同步坐标</a-button> -->
       </div>
 
       <div v-if="modeRadio === 1" class="config">
         <div class="panel">
-          <div class="panel-hd">家具操作</div>
+          <div class="panel-hd">家具</div>
           <div class="panel-ct">
             <div class="furnitureTool">
               <a-radio-group v-model:value="sideRadio" size="small">
@@ -79,46 +81,20 @@
             </div>
           </div>
 
-          <div class="panel-hd">区域操作</div>
-          <div class="panel-ct">
-            <div class="subregionTool">
-              <div v-if="roomStore.localSubRegions.length === 0">
-                暂无区域,<a-button type="link" size="small" @click="createSubregion"
-                  >新建区域</a-button
-                >
-              </div>
-              <template v-else>
-                <span>已创建 {{ roomStore.localSubRegions.length }} 个区域</span>
-                <a-button
-                  v-if="roomStore.localSubRegions.length < 6"
-                  type="link"
-                  size="small"
-                  @click="createSubregion"
-                  >继续创建</a-button
-                >
-                <a-switch
-                  v-model:checked="showSubregion"
-                  size="small"
-                  style="margin-left: 20px"
-                  checked-children="显示"
-                  un-checked-children="隐藏"
-                />
-              </template>
-            </div>
-          </div>
-        </div>
-      </div>
-
-      <div v-if="modeRadio === 2" class="info">
-        <div class="panel">
           <div class="panel-hd">
             <div
-              >家具列表
+              >已添加的家具
               <span v-if="roomStore.localFurnitureItems.length"
                 >({{ roomStore.localFurnitureItems.length }})</span
               ></div
             >
             <a-space>
+              <a-switch
+                v-model:checked="showFurniture"
+                size="small"
+                checked-children="显示"
+                un-checked-children="隐藏"
+              />
               <a-popconfirm
                 v-if="roomStore.localFurnitureItems.length"
                 title="确定清空家具吗?"
@@ -213,7 +189,7 @@
                       </div> -->
 
                       <div class="mapConfig-item">
-                        <label class="mapConfig-item-label">x/y:</label>
+                        <label class="mapConfig-item-label">距离雷达:</label>
                         <div class="mapConfig-item-content">
                           <a-space>
                             <a-input-number
@@ -251,16 +227,24 @@
             <div v-else class="list-empty">暂无家具</div>
           </div>
         </div>
+      </div>
 
+      <div v-if="modeRadio === 2" class="info">
         <div class="panel">
           <div class="panel-hd">
             <div
-              >区域列表
+              >已添加的子区域
               <span v-if="roomStore.localSubRegions.length"
                 >({{ roomStore.localSubRegions.length }})</span
               ></div
             >
             <a-space>
+              <a-switch
+                v-model:checked="showSubregion"
+                size="small"
+                checked-children="显示"
+                un-checked-children="隐藏"
+              />
               <a-popconfirm
                 v-if="roomStore.localSubRegions.length"
                 title="确定清空子区域吗?"
@@ -546,6 +530,7 @@ const handleSubregionUpdate = (item: LocalSubRegionItem[]) => {
 
 const showPanel = ref(true)
 const showSubregion = ref(false)
+const showFurniture = ref(true)
 
 onUnmounted(() => {
   // 组件销毁时清除缓存

+ 4 - 6
src/views/device/detail/index.vue

@@ -518,8 +518,8 @@ const subscribePoint = () => {
               y,
               z,
               id,
-              displayX: point.x - Number(detailState.value.xxStart),
-              displayY: point.y - Number(detailState.value.yyEnd),
+              displayX: point.x,
+              displayY: point.y,
               lastX: x,
               lastY: y,
             }
@@ -533,10 +533,8 @@ const subscribePoint = () => {
             targets[id].z = z
             targets[id].lastX = x
             targets[id].lastY = y
-            // targets[id].displayX = x
-            // targets[id].displayY = y
-            targets[id].displayX = point.x - Number(detailState.value.xxStart)
-            targets[id].displayY = point.y - Number(detailState.value.yyEnd)
+            targets[id].displayX = point.x
+            targets[id].displayY = point.y
             // console.log(`🔄 更新目标点: id=${id}, x=${x}, y=${y}`, targets[id])
           } else {
             // 距离太小,忽略本次更新