All files / app/codeCharta codeCharta.model.ts

100% Statements 40/40
100% Branches 26/26
100% Functions 9/9
100% Lines 40/40

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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386                                    161x 161x 161x 161x     161x 161x 161x 161x 161x                                                                                                       161x 161x 161x     161x 161x 161x                                                                                                                                                                                                                                             161x 161x 161x     161x 161x 161x 161x 161x                   161x 161x 161x 161x 161x                                                                                                                                                                                                                                             161x 306x 5x         301x 1x         300x     161x 39x 1x   38x 1x     37x                          
import { Vector3 } from "three"
import { ExportCCFile } from "./codeCharta.api.model"
import { FileState } from "./model/files/files"
import { CustomConfig } from "./model/customConfig/customConfig.api.model"
import Rectangle from "./util/algorithm/streetLayout/rectangle"
 
export type Scaling = {
    x: number
    y: number
    z: number
}
 
export interface NameDataPair {
    fileName: string
    fileSize: number
    content: ExportCCFile
}
 
export enum LayoutAlgorithm {
    SquarifiedTreeMap = "Squarified TreeMap",
    StreetMap = "StreetMap",
    TreeMapStreet = "TreeMapStreet"
}
 
export enum SharpnessMode {
    Standard = "High",
    PixelRatioNoAA = "Low",
    PixelRatioFXAA = "Medium",
    PixelRatioAA = "Best"
}
 
export interface CCFile {
    map: CodeMapNode
    settings: {
        fileSettings: FileSettings
    }
    fileMeta: FileMeta
}
 
export interface FileCount {
    all?: number
    added: number
    removed: number
    changed: number
}
 
interface squarifiedNode {
    name: string
    id?: number
    type: NodeType
    children?: CodeMapNode[]
    attributes?: KeyValuePair
    edgeAttributes?: {
        [key: string]: EdgeMetricCount
    }
    link?: string
    path?: string
    isExcluded?: boolean
    isFlattened?: boolean
    deltas?: {
        [key: string]: number
    }
    fixedPosition?: FixedPosition
    fileCount?: FileCount
}
 
interface streetNode {
    value?: number
    rect?: Rectangle
    zOffset?: number
}
export interface CodeMapNode extends squarifiedNode, streetNode {}
 
export interface FixedPosition {
    left: number
    top: number
    width: number
    height: number
}
 
export enum NodeType {
    FILE = "File",
    FOLDER = "Folder"
}
 
export enum SortingOption {
    NAME = "Name",
    NUMBER_OF_FILES = "Number of Files"
}
 
export interface ColorLabelOptions {
    positive: boolean
    negative: boolean
    neutral: boolean
}
 
export interface FileMeta {
    fileName: string
    fileChecksum: string
    apiVersion: string
    projectName: string
    exportedFileSize: number
    repoCreationDate?: string
}
 
export interface Settings {
    fileSettings: FileSettings
    dynamicSettings: DynamicSettings
    appSettings: AppSettings
}
 
export interface FileSettings {
    attributeTypes: AttributeTypes
    attributeDescriptors: AttributeDescriptors
    blacklist: Array<BlacklistItem>
    edges: Edge[]
    markedPackages: MarkedPackage[]
}
 
export interface PrimaryMetrics {
    areaMetric: string
    heightMetric: string
    edgeMetric: string
    colorMetric: string
}
 
export interface DynamicSettings extends PrimaryMetrics {
    colorMode: ColorMode
    sortingOption: SortingOption
    colorRange: ColorRange
    distributionMetric: string
    focusedNodePath: string[]
    searchPattern: string
    margin: number
}
 
export interface AppSettings {
    amountOfTopLabels: number
    amountOfEdgePreviews: number
    edgeHeight: number
    scaling: Scaling
    hideFlatBuildings: boolean
    invertHeight: boolean
    invertArea: boolean
    isWhiteBackground: boolean
    mapColors: MapColors
    isPresentationMode: boolean
    showOnlyBuildingsWithEdges: boolean
    isEdgeMetricVisible: boolean
    resetCameraIfNewFileIsLoaded: boolean
    isLoadingMap: boolean
    isLoadingFile: boolean
    sortingOrderAscending: boolean
    isSearchPanelPinned: boolean
    showMetricLabelNameValue: boolean
    showMetricLabelNodeName: boolean
    layoutAlgorithm: LayoutAlgorithm
    maxTreeMapFiles: number
    sharpnessMode: SharpnessMode
    experimentalFeaturesEnabled: boolean
    screenshotToClipboardEnabled: boolean
    colorLabels: ColorLabelOptions
    isColorMetricLinkedToHeightMetric: boolean
    enableFloorLabels: boolean
}
 
export interface MapColors {
    positive: string
    neutral: string
    negative: string
    selected: string
    positiveDelta: string
    negativeDelta: string
    base: string
    flat: string
    markingColors: string[]
    outgoingEdge: string
    incomingEdge: string
    labelColorAndAlpha: { rgb: string; alpha: number }
}
 
export interface ColorRange {
    /** null means to be reset */
    from: number | null
    /** null means to be reset */
    to: number | null
}
 
export interface AttributeTypes {
    nodes?: { [key: string]: AttributeTypeValue }
    edges?: { [key: string]: AttributeTypeValue }
}
 
export interface AttributeDescriptors {
    [key: string]: AttributeDescriptor
}
 
export interface AttributeDescriptor {
    title: string
    description: string
    hintLowValue: string
    hintHighValue: string
    link: string
    direction?: number
}
 
export enum AttributeTypeValue {
    absolute = "absolute",
    relative = "relative"
}
 
export enum ColorMode {
    trueGradient = "trueGradient",
    weightedGradient = "weightedGradient",
    focusedGradient = "focusedGradient",
    absolute = "absolute"
}
 
export interface Edge {
    fromNodeName: string
    toNodeName: string
    attributes: KeyValuePair
    visible?: EdgeVisibility
}
 
export enum EdgeVisibility {
    none = "none",
    from = "from",
    to = "to",
    both = "both"
}
 
export interface EdgeMetricCount {
    incoming: number
    outgoing: number
}
 
export interface BlacklistItem {
    path: string
    type: BlacklistType
    nodeType?: NodeType
}
 
export type BlacklistType = "flatten" | "exclude"
 
export interface MarkedPackage {
    path: string
    color: string
}
 
export interface EdgeMetricData {
    name: string
    maxValue: number
    minValue: number
    values: number[]
}
 
export interface NodeMetricData {
    name: string
    maxValue: number
    minValue: number
    values: number[]
}
 
export interface MetricData {
    nodeMetricData: NodeMetricData[]
    edgeMetricData: EdgeMetricData[]
}
 
export interface LocalStorageCustomConfigs {
    version: string
    customConfigs: [string, CustomConfig][]
}
 
export interface LocalStorageScenarios {
    version: string
    scenarios: [string, RecursivePartial<Scenario>][]
}
 
export interface Scenario {
    name: string
    area: {
        areaMetric: string
        margin: number
    }
    height: {
        heightMetric: string
        heightSlider: Vector3
        labelSlider: number
    }
    color: {
        colorMetric: string
        colorRange: ColorRange
        mapColors: MapColors
    }
    camera: {
        camera: Vector3
        cameraTarget: Vector3
    }
    edge: {
        edgeMetric: string
        edgePreview: number
        edgeHeight: number
    }
}
 
export type RecursivePartial<T> = { [P in keyof T]?: RecursivePartial<T[P]> }
 
export interface KeyValuePair {
    [key: string]: number
}
 
export interface Node {
    name: string
    id: number
    width: number
    height: number
    length: number
    depth: number
    mapNodeDepth: number
    x0: number
    z0: number
    y0: number
    isLeaf: boolean
    deltas?: KeyValuePair
    attributes: KeyValuePair
    edgeAttributes: {
        [key: string]: EdgeMetricCount
    }
    heightDelta: number
    visible: boolean
    path: string
    link: string
    markingColor: string | void
    flat: boolean
    color: string
    incomingEdgePoint: Vector3
    outgoingEdgePoint: Vector3
}
 
export interface CcState {
    fileSettings: FileSettings
    dynamicSettings: DynamicSettings
    appSettings: AppSettings
    files: FileState[]
    appStatus: AppStatus
}
 
export function stateObjectReplacer(_, valueToReplace) {
    if (valueToReplace instanceof Map) {
        return {
            dataType: "Map",
            value: [...valueToReplace.entries()]
        }
    }
    if (valueToReplace instanceof Set) {
        return {
            dataType: "Set",
            value: [...valueToReplace]
        }
    }
    return valueToReplace
}
 
export function stateObjectReviver(_, valueToRevive) {
    if (valueToRevive?.dataType === "Map") {
        return new Map(valueToRevive.value)
    }
    if (valueToRevive?.dataType === "Set") {
        return new Set(valueToRevive.value)
    }
 
    return valueToRevive
}
 
export interface AppStatus {
    currentFilesAreSampleFiles: boolean
    hoveredNodeId: number | null
    selectedBuildingId: number | null
    rightClickedNodeData: {
        nodeId: number
        xPositionOfRightClickEvent: number
        yPositionOfRightClickEvent: number
    } | null
}