/// <summary> /// Raises the <see cref="E:System.Windows.Forms.UserControl.Load" /> event. /// Sets all the properties up but only if the form is not in designer mode, /// because OpenGL calls in the Designer cause errors. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); _rect = new Rectangle(0, 0, this.Size.Width, this.Size.Height); this.MakeCurrent(); if (!(IsInDesignerMode())) { _shaders = new Shaders(Resources.LineShader_vert, Resources.LineShader_frag, Resources.TextShader_vert, Resources.TextShader_frag); _textInstance = new TextInstance(_shaders); _graphPane = new GraphPane(_rect, _textInstance); _graphPane.ReSize(new GLRectangleF(0, 0, (int)_rect.Width, (int)_rect.Height)); _textInstance.GenerateFontImage(_graphPane.Rect); GL.ClearColor(1.0f, 1.0f, 1.0f, 0.0f); _zoomPanState = new ZoomPanState(ref _graphPane); _FrameTimer.Tick += FrameTimer_Tick; _FrameTimer.Interval = 25; _FrameTimer.Start(); _stopwatch = new Stopwatch(); _stopwatch2 = new Stopwatch(); _stopwatch.Reset(); _stopwatch2.Reset(); _stopwatch.Start(); } }
/// <summary> /// drawing method to override /// </summary> /// <param name="zoomPanState">State of the zoom pan.</param> public virtual void InitDraw(ZoomPanState zoomPanState) { if (_rect.Width <= 1 || _rect.Height <= 1) { return; } DrawPaneFrame(); }
/// <summary> /// Sets up the transformation matrices of each YAxis. /// </summary> /// <param name="pane">The pane.</param> /// <param name="zoomPanState">State of the zoom pan.</param> /// <param name="tempXAxis">The temporary x axis.</param> internal void SetUpScales(GraphPane pane, ZoomPanState zoomPanState, XAxis tempXAxis) { foreach (YAxis axis in this) { Matrix4 translationToCorner = Matrix4.CreateTranslation(-1, -1, 0); //Default Translation, damit (0,0) im unteren linken Eck ist Matrix4 translationToScaleMin = Matrix4.CreateTranslation(-(float)tempXAxis.Scale.Min, -(float)axis.Scale.Min, 0); //Skalierung der X Achse Matrix4 scale = Matrix4.CreateScale((float)(2 / (tempXAxis.Scale.Max - tempXAxis.Scale.Min)), (float)(2 / (axis.Scale.Max - axis.Scale.Min)), 1); axis.TraFo = translationToScaleMin * scale * translationToCorner;//store the result into its axis } }
/// <summary> /// Draws an empty <see cref="global::CPHControl"/> so the screen is not black /// if there are no points /// </summary> /// <param name="zoomPanState">State of the zoom pan.</param> public override void InitDraw(ZoomPanState zoomPanState) { base.InitDraw(zoomPanState); _chart.Rect = CalcChartRect(); _chart.pGL_Border.Draw(_chart.Rect); _yAxisList.SetUpScales(this, zoomPanState, this.PXAxis); _xAxis.Draw(this, _chart); _yAxisList.Draw(this, _chart); }
/// <summary> /// Draws the whole <see cref="global::CPHControl"/> one part after the other. /// </summary> /// <param name="zoomPanState">State of the zoom and pan.</param> public override void Draw(ZoomPanState zoomPanState) { base.Draw(zoomPanState); _chart.Rect = CalcChartRect(); _chart.pGL_Border.Draw(_chart.Rect); _textInstance.DrawTimes(this, _frameTime, _runTime); _yAxisList.SetUpScales(this, zoomPanState, this.PXAxis); _curveList.Draw(this); _xAxis.Draw(this, _chart); _yAxisList.Draw(this, _chart); _legend.Draw(this); }