public static OpenTK.Vector2d GetProjectedPointOnCircle(OpenTK.Vector2d c, double r, OpenTK.Vector2d v) { OpenTK.Vector2d cv = v - c; double k = (r / cv.Length); return(cv * k + c); }
private void DrawCircleConstraint() { CircleConstraint circleConstraint = Constraint as CircleConstraint; var pt = circleConstraint.Point; var r = circleConstraint.R; int cnt = 36; OpenTK.Vector2d[] pts = new OpenTK.Vector2d[cnt]; for (int i = 0; i < cnt; i++) { double theta = i * (2.0 * Math.PI / cnt); double x = pt.X + r * Math.Cos(theta); double y = pt.Y + r * Math.Sin(theta); pts[i] = new OpenTK.Vector2d(x, y); } GL.LineWidth(2); GL.Color3(0.5, 0.5, 0.5); GL.Begin(PrimitiveType.Lines); for (int i = 0; i < cnt; i++) { var pt1 = pts[i]; var pt2 = pts[(i + 1) % cnt]; GL.Vertex2(pt1.X, pt1.Y); GL.Vertex2(pt2.X, pt2.Y); } GL.End(); }
public static bool IsCrossCircleCircle( OpenTK.Vector2d cPt0, double radius0, OpenTK.Vector2d cPt1, double radius1, out OpenTK.Vector2d pt0, out OpenTK.Vector2d pt1) { pt0 = new OpenTK.Vector2d(); pt1 = new OpenTK.Vector2d(); double sqDist = SquareLength(cPt0, cPt1); double dist = Math.Sqrt(sqDist); if (radius0 + radius1 < dist) { return(false); } if (Math.Abs(radius0 - radius1) > dist) { return(false); } if (dist < 1.0e-30) { return(false); } double ct = 0.5 * (sqDist + radius0 * radius0 - radius1 * radius1) / (radius0 * dist); System.Diagnostics.Debug.Assert(ct >= -1 && ct <= 1); double st = Math.Sqrt(1 - ct * ct); OpenTK.Vector2d e0 = (cPt1 - cPt0) * (1 / dist); OpenTK.Vector2d e1 = new OpenTK.Vector2d(e0.Y, -e0.X); pt0 = cPt0 + e0 * (radius0 * ct) + e1 * (radius0 * st); pt1 = cPt0 + e0 * (radius0 * ct) - e1 * (radius0 * st); return(true); }
public override double Get2ndDerivative(int iDof, int jDof, double[] x) { System.Diagnostics.Debug.Assert(x.Length == 2); if (iDof >= 2 || jDof >= 2) { throw new InvalidOperationException(); } OpenTK.Vector2d xVec = new OpenTK.Vector2d(x[0], x[1]); OpenTK.Vector2d rVec = xVec - Point; double r = rVec.Length; double[] rVec2 = { rVec.X, rVec.Y }; double value = 0; if (iDof == jDof) { value += -1.0 / r; } value += rVec2[iDof] * rVec2[jDof] / (r * r * r); if (Equality == EqualityType.LessEq) { value *= -1.0; } return(value); }
private int[] zoomLevels = new int[] { -5, 35 }; // Zoom levels avaiable #endregion Fields #region Constructors // Constructors public mgTools(double sFactor, double[] coordinates, int[] window, int zControl) { this.scaleSymbolsFactor = sFactor; this.zoomControl = zControl; this.sizeView = new OpenTK.Vector2d(window[0], window[1]); this.ratioView = this.sizeView.Y / this.sizeView.X; this.pointMinSpace = this.pointMinWindow = new OpenTK.Vector2d(coordinates[0], coordinates[1]); this.pointMaxSpace = new OpenTK.Vector2d(coordinates[2], coordinates[3]); this.sizeSpace = this.sizeWindow = this.pointMaxSpace - this.pointMinSpace; this.sizeSpace.X = this.sizeWindow.X = Math.Abs(this.sizeSpace.X); this.sizeSpace.Y = this.sizeWindow.Y = Math.Abs(this.sizeSpace.Y); this.sizeSpace.Y = this.sizeWindow.Y = this.sizeSpace.X * this.ratioView; this.pointMaxWindow.Y = this.pointMaxSpace.Y = this.pointMinSpace.Y + this.sizeSpace.Y; setCenterPoint(); this.pointCenterOriginal = this.pointCenter; this.shiftMap = OpenTK.Vector2d.Zero; this.pointDragCoordinates = OpenTK.Vector2d.Zero; this.pointZoomCoordinates = OpenTK.Vector2d.Zero; setZoomLevel(); }
public static bool CenterCircumcircle(OpenTK.Vector2d p0, OpenTK.Vector2d p1, OpenTK.Vector2d p2, out OpenTK.Vector2d center) { center = new OpenTK.Vector2d(); double area = TriArea(p0, p1, p2); if (Math.Abs(area) < 1.0e-10) { return(false); } double tmpVal = 1.0 / (area * area * 16.0); double dtmp0 = SquareLength(p1, p2); double dtmp1 = SquareLength(p0, p2); double dtmp2 = SquareLength(p0, p1); double etmp0 = tmpVal * dtmp0 * (dtmp1 + dtmp2 - dtmp0); double etmp1 = tmpVal * dtmp1 * (dtmp0 + dtmp2 - dtmp1); double etmp2 = tmpVal * dtmp2 * (dtmp0 + dtmp1 - dtmp2); center = new OpenTK.Vector2d( etmp0 * p0.X + etmp1 * p1.X + etmp2 * p2.X, etmp0 * p0.Y + etmp1 * p1.Y + etmp2 * p2.Y); return(true); }
public static double TriHeight(OpenTK.Vector2d v1, OpenTK.Vector2d v2, OpenTK.Vector2d v3) { double area = TriArea(v1, v2, v3); double len = Math.Sqrt(SquareLength(v2, v3)); return(area * 2.0 / len); }
public static double SquareLength(OpenTK.Vector2d iPt0, OpenTK.Vector2d iPt1) { OpenTK.Vector2d v = iPt1 - iPt0; double len = v.Length; return(len * len); }
public void Copy(IObject src) { Vertex2D srcVertex = src as Vertex2D; Point = new OpenTK.Vector2d(srcVertex.Point.X, srcVertex.Point.Y); srcVertex.Color.CopyTo(Color, 0); }
private int[] zoomLevels = new int[] { -5, 30 }; // Zoom levels avaiable #endregion Fields #region Constructors // Constructors public mgTools(double mapScale, double[] coordinates, int[] window, int zControl) { GraphicGlobals.scaleDataBase = mapScale; this.sizeView = new OpenTK.Vector2d(window[0], window[1]); this.ratioView = this.sizeView.Y / this.sizeView.X; this.shiftMap = new OpenTK.Vector2d(0, 0); this.pointMinSpace = this.pointMinWindow = new OpenTK.Vector2d(coordinates[0], coordinates[1]); this.pointMaxSpace = new OpenTK.Vector2d(coordinates[2], coordinates[3]); this.sizeSpace = this.sizeWindow = this.pointMaxSpace - this.pointMinSpace; this.sizeSpace.Y = this.sizeWindow.Y = this.sizeSpace.X * this.ratioView; this.pointMaxWindow.Y = this.pointMaxSpace.Y = this.pointMinSpace.Y + this.sizeSpace.Y; //this.pointMaxWindow.Y = this.pointMinWindow.Y + this.sizeSpace.Y * this.ratio; //this.sizeWindow = this.sizeSpace = this.pointMaxWindow - this.pointMinWindow; setCenterPoint(); this.zoomControl = zControl; setZoomLevel(); }
public CircleConstraint(OpenTK.Vector2d point, double r, EqualityType equality = EqualityType.Eq) { Equality = equality; Point = new OpenTK.Vector2d(point.X, point.Y); R = r; }
public LineConstraint(OpenTK.Vector2d point, OpenTK.Vector2d normal, EqualityType equality = EqualityType.Eq) { Equality = equality; Point = new OpenTK.Vector2d(point.X, point.Y); Normal = new OpenTK.Vector2d(normal.X, normal.Y); }
public Vertex2D() { Point = new OpenTK.Vector2d(); for (int i = 0; i < 3; i++) { Color[i] = 0.0; } }
public Vertex2D(OpenTK.Vector2d point) { Point = new OpenTK.Vector2d(point.X, point.Y); for (int i = 0; i < 3; i++) { Color[i] = 0.0; } }
public void DrawSelection(uint iDraw) { bool isBlend = GL.IsEnabled(EnableCap.Blend); bool isLineSmooth = GL.IsEnabled(EnableCap.LineSmooth); bool isTexture = GL.IsEnabled(EnableCap.Texture2D); GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.LineSmooth); GL.Disable(EnableCap.Texture2D); uint ndim = VertexArray.Dimension; GL.PushName(iDraw); // モデルの描画 GL.EnableClientState(ArrayCap.VertexArray); GL.VertexPointer((int)ndim, VertexPointerType.Double, 0, VertexArray.VertexCoordArray); for (int idp = 0; idp < DrawParts.Count; idp++) { CadObject2DDrawPart dp = DrawParts[idp]; double height = dp.Height; GL.PushName(idp); GL.Translate(0.0, 0.0, +height); dp.DrawElements(); if (dp.Type == CadElementType.Edge && dp.ShowMode == 2) { for (int icp = 0; icp < dp.CtrlPoints.Count; icp++) { OpenTK.Vector2d cp = dp.CtrlPoints[icp]; GL.PushName(icp); GL.Begin(PrimitiveType.Points); OpenGLUtils.GLVertex2(cp); GL.End(); GL.PopName(); } } GL.Translate(0.0, 0.0, -height); GL.PopName(); } GL.DisableClientState(ArrayCap.VertexArray); GL.PopName(); if (isBlend) { GL.Enable(EnableCap.Blend); } else { GL.Disable(EnableCap.Blend); } if (isTexture) { GL.Enable(EnableCap.Texture2D); } else { GL.Disable(EnableCap.Texture2D); } }
public static OpenTK.Vector2d GetNormal(OpenTK.Vector2d v1, OpenTK.Vector2d v2) { var tan = v1 - v2; tan = Normalize(tan); // n = e3 x t OpenTK.Vector2d normal = new OpenTK.Vector2d(-tan.Y, tan.X); return(normal); }
public static bool IsDirectionArc( OpenTK.Vector2d pt, OpenTK.Vector2d sPt, OpenTK.Vector2d ePt, OpenTK.Vector2d cPt, bool isLeftSide) { if (isLeftSide) { if (TriArea(sPt, cPt, ePt) > 0.0) { if (TriArea(sPt, cPt, pt) > 0.0 && TriArea(pt, cPt, ePt) > 0.0) { return(true); } else { return(false); } } else { if (TriArea(sPt, cPt, pt) > 0.0 || TriArea(pt, cPt, ePt) > 0.0) { return(true); } else { return(false); } } } else { if (TriArea(ePt, cPt, sPt) > 0.0) { if (TriArea(ePt, cPt, pt) > 0.0 && TriArea(pt, cPt, sPt) > 0.0) { return(true); } else { return(false); } } else { if (TriArea(ePt, cPt, pt) > 0.0 || TriArea(pt, cPt, sPt) > 0.0) { return(true); } else { return(false); } } } throw new InvalidOperationException(); //return true; }
public void MousePan(double movBeginX, double movBeginY, double movEndX, double movEndY) { double x = WindowCenter.X; double y = WindowCenter.Y; x += (movEndX - movBeginX) * InvScale; y += (movEndY - movBeginY) * InvScale; WindowCenter = new OpenTK.Vector2d(x, y); }
public static double SquareCircumradius(OpenTK.Vector2d p0, OpenTK.Vector2d p1, OpenTK.Vector2d p2) { double area = TriArea(p0, p1, p2); double dtmp0 = SquareLength(p1, p2); double dtmp1 = SquareLength(p0, p2); double dtmp2 = SquareLength(p0, p1); return(dtmp0 * dtmp1 * dtmp2 / (16.0 * area * area)); }
public static double FindNearestPointParameterLinePoint( OpenTK.Vector2d cPt, OpenTK.Vector2d sPt, OpenTK.Vector2d ePt) { OpenTK.Vector2d es = ePt - sPt; OpenTK.Vector2d sc = sPt - cPt; double a = SquareLength(es); double b = OpenTK.Vector2d.Dot(es, sc); return(-b / a); }
public double GetLineLength() { double[] co1 = World.GetVertexCoord(VertexCoordIds[0]); double[] co2 = World.GetVertexCoord(VertexCoordIds[1]); co1 = AddDisplacement(0, co1); co2 = AddDisplacement(1, co2); OpenTK.Vector2d v1 = new OpenTK.Vector2d(co1[0], co1[1]); OpenTK.Vector2d v2 = new OpenTK.Vector2d(co2[0], co2[1]); double l = (v2 - v1).Length; return(l); }
public double GetArea() { double[] co1 = World.GetVertexCoord(VertexCoordIds[0]); double[] co2 = World.GetVertexCoord(VertexCoordIds[1]); double[] co3 = World.GetVertexCoord(VertexCoordIds[2]); OpenTK.Vector2d v1 = new OpenTK.Vector2d(co1[0], co1[1]); OpenTK.Vector2d v2 = new OpenTK.Vector2d(co2[0], co2[1]); OpenTK.Vector2d v3 = new OpenTK.Vector2d(co3[0], co3[1]); double area = CadUtils.TriArea(v1, v2, v3); return(area); }
public bool IsIntersectSphere(OpenTK.Vector2d vec, double radius) { if (!IsntEmpty) { return(false); } if (vec.X < MinX - radius || vec.X > MaxX + radius || vec.Y < MinY - radius || vec.Y > MaxY + radius) { return(false); } return(true); }
public override double GetValue(double[] x) { System.Diagnostics.Debug.Assert(x.Length == 2); OpenTK.Vector2d xVec = new OpenTK.Vector2d(x[0], x[1]); OpenTK.Vector2d lineVec = xVec - Point; double value = -OpenTK.Vector2d.Dot(lineVec, Normal); if (Equality == EqualityType.LessEq) { value *= -1.0; } return(value); }
internal void Move(Vector2d offset) { Vector2d pos = Position + offset; foreach (pSprite s in SpriteCollection) { s.Position = new Vector2((float)pos.X, (float)pos.Y); if (s.Tag is Vector2) { s.Position += (Vector2)s.Tag; } } }
public static double GetDistancePointArc(OpenTK.Vector2d pt, OpenTK.Vector2d sPt1, OpenTK.Vector2d ePt1, OpenTK.Vector2d cPt1, double radius1, bool isLeftSide1) { double minDist = OpenTK.Vector2d.Distance(pt, sPt1); double d0 = OpenTK.Vector2d.Distance(pt, ePt1); minDist = (minDist < d0) ? minDist : d0; if (IsDirectionArc(GetProjectedPointOnCircle(cPt1, radius1, pt), sPt1, ePt1, cPt1, isLeftSide1)) { d0 = Math.Abs(OpenTK.Vector2d.Distance(pt, cPt1) - radius1); minDist = (d0 < minDist) ? d0 : minDist; } return(minDist); }
public bool IsInside(OpenTK.Vector2d vec) { if (!IsntEmpty) { return(false); } if (vec.X >= MinX && vec.X <= MaxX && vec.Y >= MinY && vec.Y <= MaxY) { return(true); } return(false); }
public bool DragPolyline(uint eId, OpenTK.Vector2d dist) { if (!IsElementId(CadElementType.Edge, eId)) { return(false); } if (GetEdgeCurveType(eId) != CurveType.CurveArc) // 2が指定されている { return(true); } Polyline.Drag(this, dist); return(true); }
public bool PreCompDragPolyline(uint eId, OpenTK.Vector2d pickPos) { if (!IsElementId(CadElementType.Edge, eId)) { return(false); } if (GetEdgeCurveType(eId) != CurveType.CurveArc) // 2が指定されている { return(true); } Polyline.SetCadEdge(this, eId, pickPos); return(true); }
public static bool IsCrossLineSegLineSeg( OpenTK.Vector2d sPt0, OpenTK.Vector2d ePt0, OpenTK.Vector2d sPt1, OpenTK.Vector2d ePt1) { double minX0 = (sPt0.X < ePt0.X) ? sPt0.X : ePt0.X; double maxX0 = (sPt0.X > ePt0.X) ? sPt0.X : ePt0.X; double maxX1 = (sPt1.X > ePt1.X) ? sPt1.X : ePt1.X; double minX1 = (sPt1.X < ePt1.X) ? sPt1.X : ePt1.X; double minY0 = (sPt0.Y < ePt0.Y) ? sPt0.Y : ePt0.Y; double maxY0 = (sPt0.Y > ePt0.Y) ? sPt0.Y : ePt0.Y; double maxY1 = (sPt1.Y > ePt1.Y) ? sPt1.Y : ePt1.Y; double minY1 = (sPt1.Y < ePt1.Y) ? sPt1.Y : ePt1.Y; double len = ((maxX0 - minX0) + (maxY0 - minY0) + (maxX1 - minX1) + (maxY1 - minY1)) * 0.0001; if (maxX1 + len < minX0) { return(false); } if (maxX0 + len < minX1) { return(false); } if (maxY1 + len < minY0) { return(false); } if (maxY0 + len < minY1) { return(false); } double area1 = TriArea(sPt0, ePt0, sPt1); double area2 = TriArea(sPt0, ePt0, ePt1); double area3 = TriArea(sPt1, ePt1, sPt0); double area4 = TriArea(sPt1, ePt1, ePt0); double a12 = area1 * area2; if (a12 > 0) { return(false); } double a34 = area3 * area4; if (a34 > 0) { return(false); } return(true); }
private void DrawLineConstraint() { LineConstraint lineConstraint = Constraint as LineConstraint; var pt = lineConstraint.Point; var normal = lineConstraint.Normal; var horizontal = new OpenTK.Vector2d(-normal.Y, normal.X); var pt1 = pt - horizontal * 1.0e+6; var pt2 = pt + horizontal * 1.0e+6; GL.LineWidth(2); GL.Color3(0.5, 0.5, 0.5); GL.Begin(PrimitiveType.Lines); GL.Vertex2(pt1.X, pt1.Y); GL.Vertex2(pt2.X, pt2.Y); GL.End(); }
public static bool IsCrossLineCircle( OpenTK.Vector2d cPt, double radius, OpenTK.Vector2d sPt, OpenTK.Vector2d ePt, out double t0, out double t1) { t0 = 0.0f; t1 = 0.0f; double minX = (sPt.X < ePt.X) ? sPt.X : ePt.X; if (cPt.X + radius < minX) { return(false); } double maxX = (sPt.X > ePt.X) ? sPt.X : ePt.X; if (cPt.X - radius > maxX) { return(false); } double minY = (sPt.Y < ePt.Y) ? sPt.Y : ePt.Y; if (cPt.Y + radius < minY) { return(false); } double maxY = (sPt.Y > ePt.Y) ? sPt.Y : ePt.Y; if (cPt.Y - radius > maxY) { return(false); } OpenTK.Vector2d es = ePt - sPt; OpenTK.Vector2d cs = cPt - sPt; double a = SquareLength(es); double b = OpenTK.Vector2d.Dot(es, cs); double c = SquareLength(cs) - radius * radius; double det = b * b - a * c; if (det < 0) { return(false); } t0 = (b - Math.Sqrt(det)) / a; t1 = (b + Math.Sqrt(det)) / a; return(true); }
private void centerOnPoint(OpenTK.Vector2d newCenter) { this.pointCenter = newCenter; this.pointMinWindow = pointCenter - this.sizeWindow / 2; this.pointMaxWindow = pointCenter + this.sizeWindow / 2; this.shiftWindow = this.pointMinWindow - this.pointMinSpace; this.shiftMap = (1 - GraphicGlobals.scaleZoom) * (this.pointMinSpace / GraphicGlobals.scaleZoom) - this.shiftWindow; }
public void zoomByWindow(OpenTK.Vector2d centralPoint, double distance) { OpenTK.Vector2d newSize = new OpenTK.Vector2d(distance, distance); while ((newSize.X < this.sizeWindow.X && newSize.Y < this.sizeWindow.Y) && zoomControl < zoomLevels[1]) { zoomIn(centralPoint); }; }
public void zoomByWindow(OpenTK.Vector2d iPoint, OpenTK.Vector2d fPoint) { OpenTK.Vector2d newSize = new OpenTK.Vector2d(); newSize.X = Math.Abs(fPoint.X - iPoint.X) / GraphicGlobals.scaleDataBase; newSize.Y = Math.Abs(fPoint.Y - iPoint.Y) / GraphicGlobals.scaleDataBase; while ((newSize.X < this.sizeWindow.X && newSize.Y < this.sizeWindow.Y) && zoomControl < zoomLevels[1]) { zoomIn(getCenter(iPoint / GraphicGlobals.scaleDataBase, fPoint / GraphicGlobals.scaleDataBase, newSize / 2)); }; }
private OpenTK.Vector2d getCenter(OpenTK.Vector2d iPoint, OpenTK.Vector2d fPoint, OpenTK.Vector2d halfSize) { OpenTK.Vector2d newCenter = new OpenTK.Vector2d(); if (iPoint.X > fPoint.X) { newCenter.X = fPoint.X + halfSize.X; } else { newCenter.X = iPoint.X + halfSize.X; } if (iPoint.Y > fPoint.Y) { newCenter.Y = fPoint.Y + halfSize.Y; } else { newCenter.Y = iPoint.Y + halfSize.Y; } return newCenter; }
public void moveByDrag() { OpenTK.Vector2d drag; drag = (GraphicGlobals.mouseCartesian - this.pointDragCoordinates); this.shiftMap += drag; this.pointMinWindow -= drag; this.pointMaxWindow -= drag; this.pointCenter -= drag; }
private void setZoomLevel() { switch (zoomControl) { case 30: GraphicGlobals.scaleZoom = 6000; break; case 29: GraphicGlobals.scaleZoom = 5500; break; case 28: GraphicGlobals.scaleZoom = 5000; break; case 27: GraphicGlobals.scaleZoom = 4500; break; case 26: GraphicGlobals.scaleZoom = 4000; break; case 25: GraphicGlobals.scaleZoom = 3600; break; case 24: GraphicGlobals.scaleZoom = 3200; break; case 23: GraphicGlobals.scaleZoom = 2800; break; case 22: GraphicGlobals.scaleZoom = 2400; break; case 21: GraphicGlobals.scaleZoom = 2000; break; case 20: GraphicGlobals.scaleZoom = 1800; break; case 19: GraphicGlobals.scaleZoom = 1600; break; case 18: GraphicGlobals.scaleZoom = 1400; break; case 17: GraphicGlobals.scaleZoom = 1200; break; case 16: GraphicGlobals.scaleZoom = 1000; break; case 15: GraphicGlobals.scaleZoom = 800; break; case 14: GraphicGlobals.scaleZoom = 600; break; case 13: GraphicGlobals.scaleZoom = 400; break; case 12: GraphicGlobals.scaleZoom = 200; break; case 11: GraphicGlobals.scaleZoom = 100; break; case 10: GraphicGlobals.scaleZoom = 80; break; case 9: GraphicGlobals.scaleZoom = 60; break; case 8: GraphicGlobals.scaleZoom = 40; break; case 7: GraphicGlobals.scaleZoom = 20; break; case 6: GraphicGlobals.scaleZoom = 10; break; case 5: GraphicGlobals.scaleZoom = 8; break; case 4: GraphicGlobals.scaleZoom = 6; break; case 3: GraphicGlobals.scaleZoom = 4; break; case 2: GraphicGlobals.scaleZoom = 2; break; case 1: GraphicGlobals.scaleZoom = 1.2; break; case 0: GraphicGlobals.scaleZoom = 1; break; case -1: GraphicGlobals.scaleZoom = 0.8; break; case -2: GraphicGlobals.scaleZoom = 0.5; break; case -3: GraphicGlobals.scaleZoom = 0.4; break; case -4: GraphicGlobals.scaleZoom = 0.2; break; case -5: GraphicGlobals.scaleZoom = 0.1; break; } this.sizeWindow = this.sizeSpace / GraphicGlobals.scaleZoom; GraphicGlobals.scalePixel = this.sizeWindow.X / this.ViewWidth; GraphicGlobals.scaleSymbols = this.sizeWindow.Y * this.scaleSymbolsFactor; }
static void Update() { if (Client != null) { Client.ReadMessages(Messages); for (int i = 0; i < 10; i++) { if (Messages.Count != 0) { Message.Handle(Messages[0]); Messages.RemoveAt(0); } else { break; } } } Game.UpdateClient(); menu.Connecting.Update(); if (KeyboardManager.IsPressed(Key.Escape)) { escapemenu.Hidden = !escapemenu.Hidden; } if (KeyboardManager.IsPressed(Key.Tilde)) { DevelopmentMenu.Hidden = !DevelopmentMenu.Hidden; } bool LockMouse = Game.LockMouse; if (escapemenu.Hidden && DevelopmentMenu.Hidden) { LockMouse = true; } else { LockMouse = false; } if (LockMouse != Game.LockMouse) { if (LockMouse) { OldPos = MouseManager.GetMousePositionWindows(); Game.CenterMouse(); } else { MouseManager.SetMousePositionWindows((int)OldPos.X, (int)OldPos.Y); } } Game.LockMouse = LockMouse; //Toggle Full Screen if (KeyboardManager.IsPressed(Key.F11)) { if (GraphicsManager.windowstate != OpenTK.WindowState.Fullscreen) { GraphicsManager.SetWindowState(OpenTK.WindowState.Fullscreen); } else { GraphicsManager.SetWindowState(OpenTK.WindowState.Normal); } } }
private void centerOnPoint(double[] centerPoint) { OpenTK.Vector2d newCenter = new OpenTK.Vector2d(centerPoint[0], centerPoint[1]); this.pointMinWindow = newCenter - this.sizeWindow / 2; this.pointMaxWindow = newCenter + this.sizeWindow / 2; this.shiftWindow = this.pointMinWindow - this.pointMinSpace; this.shiftMap = (1 - GraphicGlobals.scaleZoom) * (this.pointMinSpace / GraphicGlobals.scaleZoom) - this.shiftWindow; }
private void centerOnPoint() { this.pointMinWindow = this.pointCenter - this.sizeWindow / 2; this.pointMaxWindow = this.pointCenter + this.sizeWindow / 2; this.shiftWindow = this.pointMinWindow - this.pointMinSpace; this.shiftMap = (1 - GraphicGlobals.scaleZoom) * (this.pointMinSpace / GraphicGlobals.scaleZoom) - this.shiftWindow; }
// Methods public void updateWindow(int glcWidth, int glcHeight) { this.sizeSpace.X = (this.sizeSpace.X * glcWidth / this.sizeView.X); this.sizeSpace.Y = (this.sizeSpace.Y * glcHeight / this.sizeView.Y); this.pointMaxSpace = this.pointMinSpace + this.sizeSpace; this.sizeView = new OpenTK.Vector2d(glcWidth, glcHeight); this.ratioView = this.sizeView.Y / this.sizeView.X; this.sizeWindow = this.sizeSpace / GraphicGlobals.scaleZoom; this.pointMaxWindow = this.pointMinWindow + this.sizeWindow;; GraphicGlobals.scalePixel = this.sizeWindow.X / this.ViewWidth; GraphicGlobals.scaleSymbols = this.sizeWindow.Y * this.scaleSymbolsFactor; setCenterPoint(); }
public void setCenterPoint() { this.pointCenter = this.pointMinWindow + this.sizeWindow / 2; }
public void moveByDrag(OpenTK.Vector2d iPos) { this.pointDragCoordinates = iPos; }
public void moveTo(double[] newCenter) { OpenTK.Vector2d newPoint = new OpenTK.Vector2d(newCenter[0] / GraphicGlobals.scaleDataBase, newCenter[1] / GraphicGlobals.scaleDataBase); centerOnPoint(newPoint); }
public OpenTK.Vector2d pointToCartesian(int x, int y) { OpenTK.Vector2d tPoint = new OpenTK.Vector2d(x, y); tPoint = tPoint * GraphicGlobals.scalePixel + this.pointMinWindow; return tPoint; }