/// <summary> /// Find displacement factor in z direction to calculate the positions. /// </summary> /// <param name="childs"></param> /// <returns></returns> public static float FindOutDisplacementFactorDepth(List <GameObject> childs) { float displacementFactorDepth = 0.0f; float prevDisplacementFactorDepth = 0.0f; Vector3 childSize; SqQualifier lastSQQualifier = SqQualifier.DIRECTORY; foreach (GameObject child in childs) { childSize = child.GetComponentInChildren <Renderer>().bounds.size; if (childSize.z >= displacementFactorDepth) { lastSQQualifier = child.GetComponent <BaseInformation>().GetQualifier(); prevDisplacementFactorDepth = displacementFactorDepth; displacementFactorDepth = childSize.z; } else { if (childSize.z >= prevDisplacementFactorDepth) { prevDisplacementFactorDepth = childSize.z; } } } if (SqQualifier.DIRECTORY == lastSQQualifier || SqQualifier.PROJECT == lastSQQualifier || SqQualifier.SUB_PROJECT == lastSQQualifier || SqQualifier.UNDEFINED == lastSQQualifier) { return((displacementFactorDepth * 0.5f) + (prevDisplacementFactorDepth * 0.5f) + 0.1f); } return(displacementFactorDepth + 0.1f); }
/// <summary> /// Set all specific values. /// </summary> /// <param name="treeComponent"></param> public virtual void UpdateValues(TreeComponent treeComponent) { this.id = treeComponent.ID; this.key = treeComponent.Key; this.componentName = treeComponent.Name; this.qualifier = treeComponent.Qualifier; this.metrics = treeComponent.Metrics; }
/// <summary> /// This is the constructor normaly used to instanciate a fully fledged obj /// </summary> /// <param name="component">SqComponent from the SQ API response</param> protected TreeComponent(SqComponent component) { ID = component.id; Key = component.key; Name = component.name.Split('/').Last(); Path = component.path; Qualifier = QualifierForString(component.qualifier); Metrics = TransformToTreeMetrics(component.measures); }
/// <summary> /// Update the Information in this Component. This is necessary because a folder /// is generated for a file to insert and later the folder component /// with the information is inserted. /// </summary> /// <param name="component">Component that is used to update</param> /// <returns>Updated component</returns> public virtual TreeComponent UpdateComponent(TreeComponent component) { if (component != null && Name == component.Name) { ID = component.ID; Key = component.Key; Name = component.Name; Path = component.Path; Qualifier = component.Qualifier; Metrics = component.Metrics; return(this); } return(null); }