public void DrawAxisLabel() { Vector3d p1; Vector3d pp; //double len = DrawingConst.AxisLength; double wh = Math.Min(DC.ViewWidth, DC.ViewHeight) / 2; double len = DC.DevSizeToWoldSize(wh - AXIS_MARGIN) * DC.WorldScale; DrawTextOption opt = default; // X軸 p1 = new Vector3d(len, 0, 0) / DC.WorldScale; pp = DC.WorldPointToDevPoint(p1); DrawTextScrn(DrawTools.FONT_SMALL, DC.GetBrush(DrawTools.BRUSH_AXIS_LABEL_X), pp, Vector3d.UnitX, -Vector3d.UnitY, "X", 0.6, opt); // Y軸 p1 = new Vector3d(0, len, 0) / DC.WorldScale; pp = DC.WorldPointToDevPoint(p1); DrawTextScrn(DrawTools.FONT_SMALL, DC.GetBrush(DrawTools.BRUSH_AXIS_LABEL_Y), pp, Vector3d.UnitX, -Vector3d.UnitY, "Y", 0.6, opt); // Z軸 p1 = new Vector3d(0, 0, len) / DC.WorldScale; pp = DC.WorldPointToDevPoint(p1); DrawTextScrn(DrawTools.FONT_SMALL, DC.GetBrush(DrawTools.BRUSH_AXIS_LABEL_Z), pp, Vector3d.UnitX, -Vector3d.UnitY, "Z", 0.6, opt); }
private void DrawTextScrn(int font, DrawBrush brush, Vector3d a, Vector3d dir, DrawTextOption opt, string s) { if (brush.GdiBrush == null) { return; } if (DC.Font(font) == null) { return; } if (opt.Option != 0) { Vector3d sz = MeasureText(font, s); if ((opt.Option | DrawTextOption.H_CENTER) != 0) { double slen = sz.X / 2; Vector3d ud = Vector3d.UnitX; if (!dir.IsZero()) { ud = dir.UnitVector(); } a = a - (ud * slen); } } double angle = 0; if (!(dir.X == 0 && dir.Y == 0)) { angle = CadMath.Angle2D(dir); } angle = CadMath.Rad2Deg(angle); DC.GdiGraphics.TranslateTransform((int)a.X, (int)a.Y); DC.GdiGraphics.RotateTransform((float)angle); Font f = DC.Font(font); Brush b = brush.GdiBrush; DC.GdiGraphics.DrawString(s, f, b, 0, 0); DC.GdiGraphics.ResetTransform(); }
public void DrawText(int font, DrawBrush brush, Vector3d a, Vector3d xdir, Vector3d ydir, DrawTextOption opt, string s) { Vector3d pa = DC.WorldPointToDevPoint(a); Vector3d d = DC.WorldVectorToDevVector(xdir); DrawTextScrn(font, brush, pa, d, opt, s); }
private void DrawTextScrn(int font, DrawBrush brush, Vector3d a, Vector3d xdir, Vector3d ydir, string s, double imgScale, DrawTextOption opt) { Start2D(); FontTex tex = mFontFaceW.CreateTexture(s); Vector3d xv = xdir.UnitVector() * tex.ImgW * imgScale; Vector3d yv = ydir.UnitVector() * tex.ImgH * imgScale; if ((opt.Option & DrawTextOption.H_CENTER) != 0) { a -= (xv / 2); } if (xv.IsZero() || yv.IsZero()) { return; } GL.Color4(brush.Color4()); mFontRenderer.Render(tex, a, xv, yv); End2D(); }
public void DrawText(int font, DrawBrush brush, Vector3d a, Vector3d xdir, Vector3d ydir, DrawTextOption opt, string s) { a *= DC.WorldScale; FontTex tex = mFontFaceW.CreateTexture(s); Vector3d xv = xdir.UnitVector() * tex.ImgW * 0.15; Vector3d yv = ydir.UnitVector() * tex.ImgH * 0.15; if (xv.IsZero() || yv.IsZero()) { return; } if ((opt.Option & DrawTextOption.H_CENTER) != 0) { a -= (xv / 2); } GL.Color4(brush.Color4()); mFontRenderer.Render(tex, a, xv, yv); }
private void DrawCompassPers() { PushMatrixes(); double size = 80; double vw = DC.ViewWidth; double vh = DC.ViewHeight; double cx = size / 2 + 8; double cy = size / 2 + 20; double left = -cx; double right = vw - cx; double top = cy; double bottom = -(vh - cy); double arrowLen = 20; double arrowW2 = 10; Matrix4d prjm = Matrix4d.CreatePerspectiveOffCenter(left, right, bottom, top, 100, 10000); GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref prjm); GL.MatrixMode(MatrixMode.Modelview); Vector3d lookAt = Vector3d.Zero; Vector3d eye = -DC.ViewDir * 220; Matrix4d mdlm = Matrix4d.LookAt(eye, lookAt, DC.UpVector); GL.LoadMatrix(ref mdlm); Vector3d p0; Vector3d p1; GL.LineWidth(1); p0 = Vector3d.UnitX * -size; p1 = Vector3d.UnitX * size; DrawArrowRaw(DC.GetPen(DrawTools.PEN_COMPASS_X), p0, p1, ArrowTypes.CROSS, ArrowPos.END, arrowLen, arrowW2); p0 = Vector3d.UnitY * -size; p1 = Vector3d.UnitY * size; DrawArrowRaw(DC.GetPen(DrawTools.PEN_COMPASS_Y), p0, p1, ArrowTypes.CROSS, ArrowPos.END, arrowLen, arrowW2); p0 = Vector3d.UnitZ * -size; p1 = Vector3d.UnitZ * size; DrawArrowRaw(DC.GetPen(DrawTools.PEN_COMPASS_Z), p0, p1, ArrowTypes.CROSS, ArrowPos.END, arrowLen, arrowW2); GL.LineWidth(1); double fontScale = 0.6; DrawTextOption opt = default; double fw = FontTexW * fontScale; double fh = FontTexH * fontScale; double fw2 = fw / 2; double fh2 = fh / 2; Vector3d p; p = Vector3d.UnitX * size; p = WorldPointToDevPoint(p, vw, vh, mdlm, prjm); p.X = p.X - fw2; p.Y = p.Y + fh2 - 2; DrawTextScrn(DrawTools.FONT_SMALL, DC.GetBrush(DrawTools.BRUSH_COMPASS_LABEL_X), p, Vector3d.UnitX, -Vector3d.UnitY, "X", fontScale, opt); p = Vector3d.UnitY * size; p = WorldPointToDevPoint(p, vw, vh, mdlm, prjm); p.X = p.X - fw2; p.Y = p.Y + fh2 - 2; DrawTextScrn(DrawTools.FONT_SMALL, DC.GetBrush(DrawTools.BRUSH_COMPASS_LABEL_Y), p, Vector3d.UnitX, -Vector3d.UnitY, "Y", fontScale, opt); p = Vector3d.UnitZ * size; p = WorldPointToDevPoint(p, vw, vh, mdlm, prjm); p.X = p.X - fw2; p.Y = p.Y + fh2 - 2; DrawTextScrn(DrawTools.FONT_SMALL, DC.GetBrush(DrawTools.BRUSH_COMPASS_LABEL_Z), p, Vector3d.UnitX, -Vector3d.UnitY, "Z", fontScale, opt); PopMatrixes(); }