public static void SyncTimeArea(TimeArea from, TimeArea to) { to.SetDrawRectHack(from.drawRect); to.m_Scale = new Vector2(from.m_Scale.x, to.m_Scale.y); to.m_Translation = new Vector2(from.m_Translation.x, to.m_Translation.y); to.EnforceScaleAndRange(); }
public static void DrawRangeOfClip(Rect rect, float startOfClipPixel, float endOfClipPixel) { Color color = (!EditorGUIUtility.isProSkin) ? Color.gray.AlphaMultiplied(0.32f) : Color.gray.RGBMultiplied(0.3f).AlphaMultiplied(0.5f); Color color2 = (!EditorGUIUtility.isProSkin) ? Color.white.RGBMultiplied(0.4f) : Color.white.RGBMultiplied(0.4f); if (startOfClipPixel > rect.xMin) { Rect rect2 = new Rect(rect.xMin, rect.yMin, Mathf.Min(startOfClipPixel - rect.xMin, rect.width), rect.height); Vector3[] array = new Vector3[] { new Vector3(rect2.xMin, rect2.yMin), new Vector3(rect2.xMax, rect2.yMin), new Vector3(rect2.xMax, rect2.yMax), new Vector3(rect2.xMin, rect2.yMax) }; AnimationWindowUtility.DrawRect(array, color); TimeArea.DrawVerticalLine(array[1].x, array[1].y, array[2].y, color2); AnimationWindowUtility.DrawLine(array[1], array[2] + new Vector3(0f, -1f, 0f), color2); } Rect rect3 = new Rect(Mathf.Max(endOfClipPixel, rect.xMin), rect.yMin, rect.width, rect.height); Vector3[] array2 = new Vector3[] { new Vector3(rect3.xMin, rect3.yMin), new Vector3(rect3.xMax, rect3.yMin), new Vector3(rect3.xMax, rect3.yMax), new Vector3(rect3.xMin, rect3.yMax) }; AnimationWindowUtility.DrawRect(array2, color); TimeArea.DrawVerticalLine(array2[0].x, array2[0].y, array2[3].y, color2); AnimationWindowUtility.DrawLine(array2[0], array2[3] + new Vector3(0f, -1f, 0f), color2); }
public TracingTimeline(GraphView graphView, GraphToolState windowGraphToolState) { m_GraphView = graphView; m_WindowGraphToolState = windowGraphToolState; m_TimeArea = new TimeArea(); m_Overlay = new AnimEditorOverlay() { PlayHeadColor = new Color(0.2117647F, 0.6039216F, 0.8F) }; m_State = new TimelineState(m_TimeArea); m_Overlay.state = m_State; var debugger = ((Stencil)m_WindowGraphToolState?.WindowState.GraphModel?.Stencil)?.Debugger; IGraphTrace trace = debugger?.GetGraphTrace(m_WindowGraphToolState?.WindowState.GraphModel, m_WindowGraphToolState.TracingControlState.CurrentTracingTarget); if (trace?.AllFrames != null && trace.AllFrames.Count > 0) { int firstFrame = trace.AllFrames[0].Frame; int lastFrame = trace.AllFrames[trace.AllFrames.Count - 1].Frame; m_TimeArea.SetShownRange( firstFrame - k_MinTimeVisibleOnTheRight, lastFrame + k_MinTimeVisibleOnTheRight); } }
private void CheckArea() { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider) { if (hit.collider.tag == "AreaClock") { if (current_area != null) { current_area.isSelected = false; //current_area.ButtonOFF(); } current_area = hit.collider.gameObject.GetComponent <TimeArea>(); current_area.isSelected = true; } } else { if (current_area != null) { current_area.isSelected = false; current_area.ButtonOFF(); } current_area = null; } }
public float ValueToPixel(float value) { TimeArea timeArea = this.state.timeArea; float num = timeArea.m_Scale.y * -1f; float num2 = timeArea.shownArea.yMin * num * -1f; return(value * num + num2); }
public float MousePositionToValue(Event evt) { float num2 = this.m_ContentRect.height - evt.mousePosition.y; TimeArea timeArea = this.state.timeArea; float num3 = timeArea.m_Scale.y * -1f; float num4 = (timeArea.shownArea.yMin * num3) * -1f; return((num2 - num4) / num3); }
public float ValueToPixel(float value) { TimeArea timeArea = state.timeArea; float pixelPerValue = timeArea.m_Scale.y * -1f; float zeroValuePixel = timeArea.shownArea.yMin * pixelPerValue * -1f; float pixelValue = value * pixelPerValue + zeroValuePixel; return(pixelValue); }
public static void DrawEndOfClip(Rect rect, float endOfClipPixel) { Rect rect2 = new Rect(Mathf.Max(endOfClipPixel, rect.xMin), rect.yMin, rect.width, rect.height); Vector3[] corners = new Vector3[] { new Vector3(rect2.xMin, rect2.yMin), new Vector3(rect2.xMax, rect2.yMin), new Vector3(rect2.xMax, rect2.yMax), new Vector3(rect2.xMin, rect2.yMax) }; Color color = !EditorGUIUtility.isProSkin ? Color.gray.AlphaMultiplied(0.32f) : Color.gray.RGBMultiplied((float)0.3f).AlphaMultiplied(0.5f); Color color2 = !EditorGUIUtility.isProSkin ? Color.white.RGBMultiplied((float)0.4f) : Color.white.RGBMultiplied((float)0.4f); DrawRect(corners, color); TimeArea.DrawVerticalLine(corners[0].x, corners[0].y, corners[3].y, color2); DrawLine(corners[0], corners[3] + new Vector3(0f, -1f, 0f), color2); }
public void DoTimeRulerGUI(Rect rect, float frameTime) { if (this.m_TimeArea != null && Event.current.type == EventType.Repaint) { GUI.BeginClip(rect); float num = 0f; rect.y = num; rect.x = num; GUI.Box(rect, GUIContent.none, EditorStyles.toolbarButton); Color textColor = ProfilerTimelineGUI.styles.timelineTick.normal.textColor; textColor.a *= 0.75f; this.PrepareTicks(); if (Event.current.type == EventType.Repaint) { HandleUtility.ApplyWireMaterial(); if (Application.platform == RuntimePlatform.WindowsEditor) { GL.Begin(7); } else { GL.Begin(1); } for (int i = 0; i < this.m_HTicks.tickLevels; i++) { float num2 = this.m_HTicks.GetStrengthOfLevel(i) * 0.8f; float[] ticksAtLevel = this.m_HTicks.GetTicksAtLevel(i, true); for (int j = 0; j < ticksAtLevel.Length; j++) { float time = ticksAtLevel[j]; float x = this.m_TimeArea.TimeToPixel(time, rect); float num3 = rect.height * Mathf.Min(1f, num2) * 0.7f; Color color = new Color(1f, 1f, 1f, num2 / 0.5f) * textColor; TimeArea.DrawVerticalLineFast(x, rect.height - num3 + 0.5f, rect.height - 0.5f, color); } } GL.End(); } int num4 = 60; int levelWithMinSeparation = this.m_HTicks.GetLevelWithMinSeparation((float)num4); float[] ticksAtLevel2 = this.m_HTicks.GetTicksAtLevel(levelWithMinSeparation, false); for (int k = 0; k < ticksAtLevel2.Length; k++) { float time2 = ticksAtLevel2[k]; float num5 = Mathf.Floor(this.m_TimeArea.TimeToPixel(time2, rect)); string text = this.FormatTickLabel(time2, levelWithMinSeparation); GUI.Label(new Rect(num5 + 3f, -3f, (float)num4, 20f), text, ProfilerTimelineGUI.styles.timelineTick); } this.DrawOutOfRangeOverlay(rect, frameTime); this.DrawRangeSelectionOverlay(rect); GUI.EndClip(); } }
public float MousePositionToValue(Event evt) { float height = m_ContentRect.height; float valuePixel = height - evt.mousePosition.y; TimeArea timeArea = state.timeArea; float pixelPerValue = timeArea.m_Scale.y * -1f; float zeroValuePixel = timeArea.shownArea.yMin * pixelPerValue * -1f; float value = (valuePixel - zeroValuePixel) / pixelPerValue; return(value); }
void DrawGrid(Rect rect, float frameTime) { if (m_TimeArea == null || Event.current.type != EventType.Repaint) { return; } GUI.BeginClip(rect); rect.x = rect.y = 0; Color tickColor = styles.timelineTick.normal.textColor; tickColor.a = 0.1f; HandleUtility.ApplyWireMaterial(); if (Application.platform == RuntimePlatform.WindowsEditor) { GL.Begin(GL.QUADS); } else { GL.Begin(GL.LINES); } PrepareTicks(); // Draw tick markers of various sizes for (int l = 0; l < m_HTicks.tickLevels; l++) { var strength = m_HTicks.GetStrengthOfLevel(l) * .9f; if (strength > TimeArea.kTickRulerFatThreshold) { var ticks = m_HTicks.GetTicksAtLevel(l, true); for (int i = 0; i < ticks.Length; i++) { // Draw line var time = ticks[i]; var x = m_TimeArea.TimeToPixel(time, rect); TimeArea.DrawVerticalLineFast(x, 0, rect.height, tickColor); } } } GL.End(); GUI.EndClip(); }
private UnitHour GetBudgetUnit(TimeArea t, IEnumerable <MonthBudget> budgets) { var res = new UnitHour { Title = t.Title, Hours = 0.0 }; foreach (MonthBudget b in budgets) { if (t.BeginDate <= b.Month && t.EndDate >= b.Month) { res.Hours += b.Hours; } } return(res); }
private UnitHour GetActualUnit(TimeArea t, IEnumerable <HourLog> logs) { var res = new UnitHour { Title = t.Title, Hours = 0.0 }; foreach (HourLog l in logs) { if (t.BeginDate <= l.LogDate && t.EndDate >= l.LogDate) { res.Hours += l.LogHours; } } return(res); }
private void DrawOutOfRangeOverlay(Rect rect, float frameTime) { Color outOfRangeColor = ProfilerTimelineGUI.styles.outOfRangeColor; Color frameDelimiterColor = ProfilerTimelineGUI.styles.frameDelimiterColor; float num = this.m_TimeArea.TimeToPixel(0f, rect); float num2 = this.m_TimeArea.TimeToPixel(frameTime, rect); if (num > rect.xMin) { Rect rect2 = Rect.MinMaxRect(rect.xMin, rect.yMin, Mathf.Min(num, rect.xMax), rect.yMax); EditorGUI.DrawRect(rect2, outOfRangeColor); TimeArea.DrawVerticalLine(rect2.xMax, rect2.yMin, rect2.yMax, frameDelimiterColor); } if (num2 < rect.xMax) { Rect rect3 = Rect.MinMaxRect(Mathf.Max(num2, rect.xMin), rect.yMin, rect.xMax, rect.yMax); EditorGUI.DrawRect(rect3, outOfRangeColor); TimeArea.DrawVerticalLine(rect3.xMin, rect3.yMin, rect3.yMax, frameDelimiterColor); } }
public void DrawMajorTicks(Rect position, float frameRate) { Color color = Handles.color; GUI.BeginGroup(position); if ((int)Event.current.type != 7) { GUI.EndGroup(); return; } TimeArea.InitStyles(); this.SetTickMarkerRanges(); this.hTicks.SetTickStrengths(3f, 80f, true); Color textColor = TimeArea.styles.TimelineTick.normal.textColor; textColor.a = 0.3f; Handles.color = (textColor); for (int i = 0; i < this.hTicks.tickLevels; i++) { float strengthOfLevel = this.hTicks.GetStrengthOfLevel(i); if (strengthOfLevel > 0.5f) { float[] ticksAtLevel = this.hTicks.GetTicksAtLevel(i, true); for (int j = 0; j < ticksAtLevel.Length; j++) { if (ticksAtLevel[j] >= 0f) { int num = Mathf.RoundToInt(ticksAtLevel[j] * frameRate); float num2 = this.FrameToPixel((float)num, frameRate, position); Handles.DrawLine(new Vector3(num2, 0f, 0f), new Vector3(num2, position.height, 0f)); if (strengthOfLevel > 0.8f) { Handles.DrawLine(new Vector3(num2 + 1f, 0f, 0f), new Vector3(num2 + 1f, position.height, 0f)); } } } } } GUI.EndGroup(); Handles.color = (color); }
void InitializeTimeArea() { if (m_TimeArea == null) { time_draging = false; timeAreaRect.height = WindowConstants.timeAreaHeight; m_TimeArea = new TimeArea(false) { hRangeLocked = false, vRangeLocked = true, margin = 0, scaleWithWindow = true, hSlider = true, vSlider = false, hBaseRangeMin = 0.0f, hRangeMin = 0.0f, rect = timeAreaRect, }; } rangeX1 = 0; rangeX2 = 60; }
private void DrawGrid(Rect rect, float frameTime) { if (this.m_TimeArea != null && Event.current.type == EventType.Repaint) { GUI.BeginClip(rect); float num = 0f; rect.y = num; rect.x = num; Color textColor = ProfilerTimelineGUI.styles.timelineTick.normal.textColor; textColor.a = 0.1f; HandleUtility.ApplyWireMaterial(); if (Application.platform == RuntimePlatform.WindowsEditor) { GL.Begin(7); } else { GL.Begin(1); } this.PrepareTicks(); for (int i = 0; i < this.m_HTicks.tickLevels; i++) { float num2 = this.m_HTicks.GetStrengthOfLevel(i) * 0.9f; if (num2 > 0.5f) { float[] ticksAtLevel = this.m_HTicks.GetTicksAtLevel(i, true); for (int j = 0; j < ticksAtLevel.Length; j++) { float time = ticksAtLevel[j]; float x = this.m_TimeArea.TimeToPixel(time, rect); TimeArea.DrawVerticalLineFast(x, 0f, rect.height, textColor); } } } GL.End(); GUI.EndClip(); } }
void DrawOutOfRangeOverlay(Rect rect, float frameTime) { var color = styles.outOfRangeColor; var lineColor = styles.frameDelimiterColor; var frameStartPixel = m_TimeArea.TimeToPixel(0f, rect); var frameEndPixel = m_TimeArea.TimeToPixel(frameTime, rect); // Rect shaded shape drawn before selected frame if (frameStartPixel > rect.xMin) { var startRect = Rect.MinMaxRect(rect.xMin, rect.yMin, Mathf.Min(frameStartPixel, rect.xMax), rect.yMax); EditorGUI.DrawRect(startRect, color); TimeArea.DrawVerticalLine(startRect.xMax, startRect.yMin, startRect.yMax, lineColor); } // Rect shaded shape drawn after selected frame if (frameEndPixel < rect.xMax) { var endRect = Rect.MinMaxRect(Mathf.Max(frameEndPixel, rect.xMin), rect.yMin, rect.xMax, rect.yMax); EditorGUI.DrawRect(endRect, color); TimeArea.DrawVerticalLine(endRect.xMin, endRect.yMin, endRect.yMax, lineColor); } }
public static void DrawVerticalSplitLine(Vector2 start, Vector2 end) { TimeArea.DrawVerticalLine(start.x, start.y, end.y, !EditorGUIUtility.isProSkin ? Color.white.RGBMultiplied(0.6f) : Color.white.RGBMultiplied(0.15f)); }
public static void DrawPlayHead(float positionX, float minY, float maxY, float alpha) { TimeArea.DrawVerticalLine(positionX, minY, maxY, Color.red.AlphaMultiplied(alpha)); }
static void CreateConsumers() { string xmlFolderName = "Data"; string AppPath = @"C:\Users\flori\Desktop\GitHubClones\flori2212\EnergieverbrauchDerSchule\ConsumerBeispielAktuell\ConsumerBeispiel\ConsumerBeispiel\bin\Debug"; ConsumerBeispiel.Service.DataService.Instance.XmlFolderPath = AppPath + "\\" + xmlFolderName; ConsumerBeispiel.Service.DataService.Instance.Initialize(); Guid dg1_guid = Guid.NewGuid(); Guid dg2_guid = Guid.NewGuid(); Guid d1_guid = Guid.NewGuid(); Guid d2_guid = Guid.NewGuid(); Guid dc1_guid = Guid.NewGuid(); Guid dc2_guid = Guid.NewGuid(); Guid r1_guid = Guid.NewGuid(); Guid r2_guid = Guid.NewGuid(); Guid ta1_guid = Guid.NewGuid(); Guid ta2_guid = Guid.NewGuid(); DeviceGroup dg1 = new DeviceGroup(); dg1.ID = dg1_guid; dg1.Name = "Beleuchtung"; DeviceGroup dg2 = new DeviceGroup(); dg2.ID = dg2_guid; dg2.Name = "Technik"; ConsumerBeispiel.Service.DataService.Instance.DeviceGroups.Add(dg1); ConsumerBeispiel.Service.DataService.Instance.DeviceGroups.Add(dg2); Device d1 = new Device(); d1.Name = "Neonlampe"; d1.Power = 56; d1.Description = "-"; d1.ID = d1_guid; d1.DeviceGroupID = dg1_guid; Device d2 = new Device(); d2.Name = "Lampe"; d2.Power = 30; d2.Description = "rund"; d2.ID = d2_guid; d2.DeviceGroupID = dg2_guid; ConsumerBeispiel.Service.DataService.Instance.Devices.Add(d1); ConsumerBeispiel.Service.DataService.Instance.Devices.Add(d2); DataCollector dc1 = new DataCollector(); dc1.ID = dc1_guid; dc1.Names = "Nathan, Arhant"; dc1.Grade = "9b"; DataCollector dc2 = new DataCollector(); dc2.ID = dc2_guid; dc2.Names = "Lukas, Finn"; dc2.Grade = "9c"; ConsumerBeispiel.Service.DataService.Instance.DataCollectors.Add(dc1); ConsumerBeispiel.Service.DataService.Instance.DataCollectors.Add(dc2); Room r1 = new Room(); r1.ID = r1_guid; r1.Floor = "0"; r1.RoomNumber = "003"; Room r2 = new Room(); r2.ID = r2_guid; r2.Floor = "1"; r2.RoomNumber = "114"; ConsumerBeispiel.Service.DataService.Instance.Rooms.Add(r1); ConsumerBeispiel.Service.DataService.Instance.Rooms.Add(r2); TimeArea ta1 = new TimeArea(); ta1.ID = ta1_guid; ta1.Name = "Immer an"; ta1.PercentOfTheYeahr = 100; ta1.TimePerDayInMinutes = 500; ta1.ActiveDaysPerWeek = 7; ta1.ActiveInHolydays = true; TimeArea ta2 = new TimeArea(); ta2.ID = ta2_guid; ta2.Name = "Nur an Schultagen"; ta2.PercentOfTheYeahr = 50; ta2.TimePerDayInMinutes = 500; ta2.ActiveDaysPerWeek = 5; ta2.ActiveInHolydays = false; ConsumerBeispiel.Service.DataService.Instance.TimeAreas.Add(ta1); ConsumerBeispiel.Service.DataService.Instance.TimeAreas.Add(ta2); for (int i = 0; i < 20; i++) { Random r = new Random(); Consumer c = new Consumer(); Guid c_guid = Guid.NewGuid(); c.ID = c_guid; c.RoomID = r2_guid; c.DeviceID = d1_guid; c.TimeAreaID = ta2_guid; c.DataCollectorID = dc1_guid; c.DeviceCount = r.Next(1, 10); ConsumerBeispiel.Service.DataService.Instance.Consumers.Add(c); Console.WriteLine("Durchgang 1: " + i + " (" + c_guid + ")"); System.Threading.Thread.Sleep(100); } Console.WriteLine(); for (int i = 0; i < 20; i++) { Random r = new Random(); Consumer c = new Consumer(); Guid c_guid = Guid.NewGuid(); c.ID = c_guid; c.RoomID = r2_guid; c.DeviceID = d2_guid; c.TimeAreaID = ta2_guid; c.DataCollectorID = dc2_guid; c.DeviceCount = r.Next(1, 10); ConsumerBeispiel.Service.DataService.Instance.Consumers.Add(c); Console.WriteLine("Durchgang 2: " + i + " (" + c_guid + ")"); System.Threading.Thread.Sleep(100); } Console.WriteLine(); for (int i = 0; i < 20; i++) { Random r = new Random(); Consumer c = new Consumer(); Guid c_guid = Guid.NewGuid(); c.ID = c_guid; c.RoomID = r1_guid; c.DeviceID = d2_guid; c.TimeAreaID = ta2_guid; c.DataCollectorID = dc2_guid; c.DeviceCount = r.Next(1, 10); ConsumerBeispiel.Service.DataService.Instance.Consumers.Add(c); Console.WriteLine("Durchgang 3: " + i + " (" + c_guid + ")"); System.Threading.Thread.Sleep(100); } Console.WriteLine(); ConsumerBeispiel.Service.DataService.Instance.SaveAllData(); }
private void Start() { current_area = null; }
public void DoTimeRulerGUI(Rect rect, float frameTime) { if (m_TimeArea == null || Event.current.type != EventType.Repaint) { return; } GUI.BeginClip(rect); rect.x = rect.y = 0; GUI.Box(rect, GUIContent.none, EditorStyles.toolbarButton); var baseColor = styles.timelineTick.normal.textColor; baseColor.a *= 0.75f; PrepareTicks(); // Tick lines if (Event.current.type == EventType.Repaint) { HandleUtility.ApplyWireMaterial(); if (Application.platform == RuntimePlatform.WindowsEditor) { GL.Begin(GL.QUADS); } else { GL.Begin(GL.LINES); } for (int l = 0; l < m_HTicks.tickLevels; l++) { var strength = m_HTicks.GetStrengthOfLevel(l) * .8f; var ticks = m_HTicks.GetTicksAtLevel(l, true); for (int i = 0; i < ticks.Length; i++) { // Draw line var time = ticks[i]; var x = m_TimeArea.TimeToPixel(time, rect); var height = rect.height * Mathf.Min(1, strength) * TimeArea.kTickRulerHeightMax; var color = new Color(1, 1, 1, strength / TimeArea.kTickRulerFatThreshold) * baseColor; TimeArea.DrawVerticalLineFast(x, rect.height - height + 0.5f, rect.height - 0.5f, color); } } GL.End(); } // Tick labels var labelWidth = k_TickLabelSeparation; int labelLevel = m_HTicks.GetLevelWithMinSeparation(labelWidth); float[] labelTicks = m_HTicks.GetTicksAtLevel(labelLevel, false); for (int i = 0; i < labelTicks.Length; i++) { var time = labelTicks[i]; float labelpos = Mathf.Floor(m_TimeArea.TimeToPixel(time, rect)); string label = FormatTickLabel(time, labelLevel); GUI.Label(new Rect(labelpos + 3, -3, labelWidth, 20), label, styles.timelineTick); } // Outside current frame coloring DrawOutOfRangeOverlay(rect, frameTime); // Range selection coloring DrawRangeSelectionOverlay(rect); GUI.EndClip(); }