|
|
|
@ -15,6 +15,8 @@ import type { ILayerNode } from "./Type";
|
|
|
|
|
/** 针对图层的数据转换器(Data层->View层)
|
|
|
|
|
* @description 该类用于将图层的Data层数据转换为图层的View层数据,便于Undo操作
|
|
|
|
|
* 如:当图纸颜色被改变时(此时Undo只会撤销Data层数据),通过该类可以更新View层数据,实现UI状态的同步改变
|
|
|
|
|
* 比如,LayerCMD中有个方法UpdateColor,该方法用于更新图层的UI颜色(View层)
|
|
|
|
|
* 再调用DataToViewForLayer中的UpdateColor方法,使得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)
|
|
|
|
|
{
|
|
|
|
|