!2841 优化: 图层中组的结构与数据处理

pull/2844/head
张子涵 3 months ago committed by ChenX
parent f299d55119
commit 6f3b0bce57

@ -45,7 +45,7 @@ export class LayerCMD
CommandWrap(() =>
{
if (node)
ViewToDataForLayer.AppendLayer(node);
ViewToDataForLayer.AppendLayerFolder(node);
}, CommandNames.AppendLayerFolder);
};

@ -354,7 +354,7 @@ export class LayerManager extends React.Component<{}, {}>
</div>
{/* 视口 */}
{
layerStore.isShowViewportOff &&
layerStore.isShowViewportOff && !data.children &&
<div className="layer-list-item" onMouseDown={e =>
{
this.ClickInnerEvent(e);
@ -548,7 +548,11 @@ export class LayerManager extends React.Component<{}, {}>
}, 'openfile');
return;
}
app.Editor.ModalManage.RenderModal(DeleteDialog, { selected, RemoveLayer: LayerCMD.RemoveLayer });
// 空文件夹删除时,无需弹窗确认
if (selected.children && selected.children.length === 0)
LayerCMD.RemoveLayer(selected);
else
app.Editor.ModalManage.RenderModal(DeleteDialog, { selected, RemoveLayer: LayerCMD.RemoveLayer });
this.ClickInnerEvent(e);
}}>
<Icon icon="trash" size={20} />

@ -15,6 +15,8 @@ import type { ILayerNode } from "./Type";
/** (Data->View)
* @description DataView便Undo
* (UndoData)ViewUI
* LayerCMDUpdateColorUI(View)
* DataToViewForLayerUpdateColor使layerTableRecord(Data)
*/
export class DataToViewForLayer
{
@ -46,17 +48,20 @@ export class DataToViewForLayer
for (let i = 0; i < lNodes.length; i++)
{
const lNode = lNodes[i];
if (!layerTable.Has(lNode.name))
{
console.log(`Layer ${lNode.name} not found in layer table`);
continue;
}
const layer = layerTable.GetAt(lNode.name) as LayerTableRecord;
names.push(lNode.name);
// 文件夹
if (lNode.children)
{
const node: ILayerNode = { name: layer.Name, children: [], isOff: layer.IsOff, isLock: layer.IsLocked, visible: true, selected: false, changeable: false, expanded: true };
const isOff = !TreeAction.FindNode(lNode.children, (child: LayerNode) =>
{
const layer = layerTable.GetAt(child.name) as LayerTableRecord;
return layer.IsOff === false;
});
const isLock = !TreeAction.FindNode(lNode.children, (child: LayerNode) =>
{
const layer = layerTable.GetAt(child.name) as LayerTableRecord;
return layer.IsLocked === false;
});
const node: ILayerNode = { name: lNode.name, children: [], isOff, isLock, visible: true, selected: false, changeable: false, expanded: true };
nodes.push(node);
// 下钻
if (lNode.children.length > 0)
@ -65,6 +70,13 @@ export class DataToViewForLayer
// 文件
else
{
if (!layerTable.Has(lNode.name))
{
console.log(`Layer ${lNode.name} not found in layer table`);
continue;
}
names.push(lNode.name);
const layer = layerTable.GetAt(lNode.name) as LayerTableRecord;
const node: ILayerNode = { name: lNode.name, colorIndex: layer.ColorIndex, isOff: layer.IsOff, isLock: layer.IsLocked, visible: true, selected: false, changeable: false, isCurrent: false };
if (layerTable.Current === layer.Id)
{
@ -127,6 +139,13 @@ export class ViewToDataForLayer
UpdateTableCurrent();
}
/** 创建图层文件夹 */
static AppendLayerFolder(node: ILayerNode)
{
// Root
UpdateTableRoot();
}
/** 删除图层 */
static RemoveLayer(node: ILayerNode, moveWhere: string)
{

Loading…
Cancel
Save