Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | 18x 18x 18x 18x 60x 60x 17x 43x 60x 4x 4x 4x 8x 2x 2x 4x 11x 11x 11x 11x 11x 11x 11x 11x 11x 18x | import { Vector3 } from "three"
import { CcState, CodeMapNode, Node } from "../../../codeCharta.model"
import { selectedColorMetricDataSelector } from "../../../state/selectors/accumulatedData/metricData/selectedColorMetricData.selector"
import { getMarkingColor, isLeaf } from "../../codeMapHelper"
import { TreeMapHelper, getBuildingColor, getIncomingEdgePoint, isNodeFlat, isVisible, treeMapSize } from "../treeMapLayout/treeMapHelper"
function calculateSize(node: CodeMapNode, metricName: string) {
// TODO if it is same as countNodes in treeMapHelper.ts
// TODO from Ruben: This function is frequently used (even during sorting).
// As such, it's best to use memoization to reduce the computational overhead.
// That way there's no need to change the calling places of this function and it's still fast.
let totalSize = node.attributes[metricName] || 0
if (totalSize === 0 && node.children && node.children.length > 0) {
for (const child of node.children) {
totalSize += calculateSize(child, metricName)
}
}
return totalSize
}
function mergeDirectories(node: CodeMapNode, metricName: string): CodeMapNode {
let mergedNode = node
const nodeSize = calculateSize(node, metricName)
for (const child of node.children) {
if (!isLeaf(child)) {
const childSize = calculateSize(child, metricName)
Iif (nodeSize === childSize) {
const nodeName = mergedNode.name
mergedNode = child
mergedNode.name = `${nodeName}/${child.name}`
break
}
}
}
return mergedNode
}
function buildNodeFrom(layoutNode: CodeMapNode, heightScale: number, maxHeight: number, state: CcState, isDeltaState: boolean): Node {
const isNodeLeaf = !(layoutNode.children && layoutNode.children.length > 0)
const flattened: boolean = isNodeFlat(layoutNode, state)
const heightValue: number = TreeMapHelper.getHeightValue(state, layoutNode, maxHeight, flattened)
const height = Math.abs(
isNodeLeaf ? Math.max(heightScale * heightValue, TreeMapHelper.MIN_BUILDING_HEIGHT) : TreeMapHelper.FOLDER_HEIGHT
)
const length = layoutNode.rect.height
const x0 = layoutNode.rect.topLeft.x
const y0 = layoutNode.rect.topLeft.y
const z0 = layoutNode.zOffset * TreeMapHelper.FOLDER_HEIGHT
return {
name: layoutNode.name,
id: layoutNode.id,
width: layoutNode.rect.width,
height,
length,
depth: layoutNode.zOffset,
mapNodeDepth: 100,
x0,
z0,
y0,
isLeaf: isNodeLeaf,
attributes: layoutNode.attributes,
edgeAttributes: layoutNode.edgeAttributes,
deltas: layoutNode.deltas,
heightDelta: layoutNode.deltas?.[state.dynamicSettings.heightMetric]
? heightScale * layoutNode.deltas[state.dynamicSettings.heightMetric]
: 0,
visible: isVisible(layoutNode, isNodeLeaf, state, flattened),
path: layoutNode.path,
link: layoutNode.link,
markingColor: getMarkingColor(layoutNode, state.fileSettings.markedPackages),
flat: flattened,
color: getBuildingColor(layoutNode, state, selectedColorMetricDataSelector(state), isDeltaState, flattened),
incomingEdgePoint: getIncomingEdgePoint(layoutNode.rect.width, height, length, new Vector3(x0, z0, y0), treeMapSize),
outgoingEdgePoint: getIncomingEdgePoint(layoutNode.rect.width, height, length, new Vector3(x0, z0, y0), treeMapSize)
}
}
export const StreetViewHelper = {
calculateSize,
mergeDirectories,
buildNodeFrom
}
|