public static void drawRotor(Graphics g, double openAngle, Vector center, Vector dim, double grade, GridCalculator grid, Pen framePen, Pen linePen) { g.SetClip(VectorRect.FromCenterSize(center, dim).rectangle); if (double.IsNaN(grade) || double.IsInfinity(grade)) { grade = 0; } if (grade < 0) { grade = 0; } if (grade > 1.0) { grade = 1.0; } double phi0 = (90 + openAngle / 2) * Math.PI / 180; double phi1 = (90 - openAngle / 2) * Math.PI / 180; double a = 0.3; double rad = (dim.y - 1) / (1.0 - a * Math.Sin(phi1)); Vector rotc = center + Vector.V(0, rad - (dim.y - 1) / 2); drawArc(g, rotc, phi0, phi1, rad, framePen); drawArc(g, rotc, phi0, phi1, rad * a, framePen); double phid = phi1 + grade * (phi0 - phi1); if (grid != null) { for (int i = 0; i < grid.gridLength; i++) { double alpha = -Math.PI / 2 + grid.grid[i].screen * Math.PI / 180; Vector vout = Vector.V(rad, 0).rot(alpha); Vector vin = Vector.V(rad * ((grid.grid[i].isMajor) ? (0.8) : (0.9)), 0).rot(alpha); drawLine(g, rotc + vin, rotc + vout, framePen); } } drawLine(g, rotc - Vector.V(rad * a, 0).rot(phid), rotc - Vector.V(rad * 0.95, 0).rot(phid), linePen); drawLine(g, rotc - Vector.V(rad * a, 0).rot(phi0), rotc - Vector.V(rad, 0).rot(phi0), framePen); drawLine(g, rotc - Vector.V(rad * a, 0).rot(phi1), rotc - Vector.V(rad, 0).rot(phi1), framePen); g.ResetClip(); }
private void reGrid() { double xmin = _attackMin; double xmax = _attackMin + _attack + _decay + ((_holdFix) ? Math.Sqrt(_holdMin * _holdMax) : _hold) + _fade; double ymin = min(0, _attackLevel, _holdLevel); double ymax = max(0, _attackLevel, _holdLevel); if (ymax == ymin) { ymin = -0.1; ymax = 0.1; } double yext = max(_attackLevelMax, _holdLevelMax) - min(_attackLevelMin, _holdLevelMin); double dy = ymax - ymin; ymin -= dy * 0.1; ymax += dy * 0.1; ymin = Math.Floor(ymin * 10) / 10; ymax = Math.Ceiling(ymax * 10) / 10; double fontheight = _scaleFont.GetHeight(); if (gridX == null) { gridX = new GridCalculator(0, 1, 1, _attackMin, 0.1, xmin, xmax, true, 0, _shapeDim.Width, fontheight); } else { gridX.reStructure(xmin, xmax, 0, _shapeDim.Width); } if (gridY == null) { gridY = new GridCalculator(_attackLevelMin, _attackLevelMax, yext / 20, 1, 10, ymin, ymax, false, 0, _shapeDim.Height, fontheight); } else { gridY.reStructure(ymin, ymax, 0, _shapeDim.Height); } }
void drawTo(Graphics g) { GraphicsUtil.TextPosition titlePos = new GraphicsUtil.TextPosition(); GraphicsUtil.TextPosition valuePos = new GraphicsUtil.TextPosition(); VectorRect bar = new VectorRect(); VectorRect handle = new VectorRect(); Vector vlow = Vector.Zero; Vector vhigh = Vector.Zero; getPositions(ref titlePos, ref valuePos, ref bar, ref handle, ref vlow, ref vhigh); double hlen = 0; if (_showScale) { if (_slideDirection == SlideDirection.Horizontal) { hlen = (vhigh.x - vlow.x) / scale; if (grid == null) { grid = new GridCalculator(_minVal, _maxVal, 1e-12, 1e-12, 1.1, _minVal, _maxVal, _logScale, 0, hlen, (double)_scaleFont.Height * _lableLength); } else if (grid.high != hlen) { grid.reScreen(0, hlen); } } else { hlen = (vlow.y - vhigh.y) / scale; if (grid == null) { grid = new GridCalculator(_minVal, _maxVal, 1e-12, 1e-12, 1.1, _minVal, _maxVal, _logScale, 0, hlen, (double)_scaleFont.Height); grid.showEndLables = true; } else if (grid.high != hlen) { grid.reScreen(0, hlen); } } } // Title if (_showTitle && (_title != null) && (_title.Length > 0)) { titlePos.drawText(g, _titleFont, titleBrush, _title); } // Value if (_showValue) { String s = String.Format(getFormat(), _val); if ((unit != null) && (unit.Length > 0)) { s = s + " " + unit; } valuePos.drawText(g, _valueFont, valueBrush, s); } g.DrawRectangle(penSlide, bar.rectangle); g.FillRectangle(brushSlideMark, handle.rectangle); g.DrawRectangle(penSlideMark, handle.rectangle); if (_showScale) { GraphicsUtil.drawLine(g, vlow, vhigh, scalePen); Vector vr = 0.5 * _slideScaleWidth * scale * ((vhigh - vlow).norm).vrot90(); Vector vtext = Vector.Zero; if (_slideDirection == SlideDirection.Horizontal) { vtext = Vector.V(0, _slideScaleWidth / 2 * scale); } else { vtext = Vector.V(_slideScaleWidth / 2 * scale, 0); } for (int i = 0; i < grid.gridLength; i++) { Vector vpos = vlow + (vhigh - vlow) * grid.grid[i].screen / hlen; if (grid.grid[i].isMajor) { GraphicsUtil.drawLine(g, vpos - vr, vpos + vr, scalePen); } else { GraphicsUtil.drawLine(g, vpos - vr / 2, vpos + vr / 2, scalePen); } if (_showScaleValues && grid.grid[i].show && (grid.grid[i].name.Length > 0)) { if (_slideDirection == SlideDirection.Horizontal) { GraphicsUtil.drawText(g, vpos + vtext, _scaleFont, scale, grid.grid[i].name, 0, 2, 0, 1, Vector.V(1, 0), scaleFontBrush); } else { GraphicsUtil.drawText(g, vpos + vtext, _scaleFont, scale, grid.grid[i].name, 0, 2, -1, 0, Vector.V(1, 0), scaleFontBrush); } } } } }