public FormControls() { InitializeComponent(); InitializeArrays(); scale = AutoCADManager.ReadPrefScale(); if (scale != 1) { RearrangeControls(scale); } }
void RearrangeControls(float scale) { int width, height; width = (int)(Properties.Resources.background.Width * scale); height = (int)(Properties.Resources.background.Height * scale); this.Width = width; this.Height = height; for (int i = 0; i < Buttons.Length; i++) { //Position update Buttons[i].Left = (int)(Buttons[i].Left * scale); Buttons[i].Top = (int)(Buttons[i].Top * scale); //Picture update Buttons[i].DefaultImage = AutoCADManager.ResizeBitmap(scale, ButtonsDefault[i]); Buttons[i].PressedImage = AutoCADManager.ResizeBitmap(scale, ButtonsPressed[i]); //Size update Buttons[i].Width = Buttons[i].DefaultImage.Width; Buttons[i].Height = Buttons[i].DefaultImage.Height; } }
private void pbEmpty_Click(object sender, EventArgs e) { if (pbEmpty.isPressed) // Start the capture { acadManager = new AutoCADManager(); acadManager.SelectObjects(); cameraDetector = new FormWebCamEmgu(); //cameraDetector.ResetCapturing(); cameraDetector.Show(); //cameraDetector.DrawViewPoint += cameraDetector_DrawViewPoint; cameraDetector.SendOrientationParameters += cameraDetector_SendOrientationParameters; cameraDetector.DrawPolylines += cameraDetector_DrawPolylines; //acadManager.vizDataText = cameraDetector.vizDataText; //cameraDetector.calibrateModule.DrawTestEvent += cameraDetector_DrawTest; } else // Stop the capture { if (GlobalProperties.UseTimers) { cameraDetector.TimerDispatchPars.Enabled = false; } cameraDetector.ResetCapturing(); //cameraDetector.DrawViewPoint -= cameraDetector_DrawViewPoint; cameraDetector.SendOrientationParameters -= cameraDetector_SendOrientationParameters; cameraDetector.DrawPolylines -= cameraDetector_DrawPolylines; //cameraDetector.calibrateModule.DrawTestEvent -= cameraDetector_DrawTest; cameraDetector.Close(); cameraDetector.Dispose(); cameraDetector = null; acadManager = null; Close(); } }
public void TestViewDir(ScreenAxisRotation axis) { Document doc = AcadApp.DocumentManager.MdiActiveDocument; ViewTableRecord vtr = doc.Editor.GetCurrentView(); Vector3d dirVectorInitial = vtr.ViewDirection; Vector3d sideVectorAxis = dirVectorInitial.GetPerpendicularVector(); // If there is existing ViewTwist angle // rotate the side vector with that angle // so it will coincide with the side vector if (vtr.ViewTwist > 1e-6) { sideVectorAxis = sideVectorAxis.RotateBy(-vtr.ViewTwist, dirVectorInitial); } Vector3d upVectorAxis = dirVectorInitial.CrossProduct(sideVectorAxis).GetNormal(); Vector3d axisRotation = new Vector3d(); switch (axis) { case ScreenAxisRotation.SideAxis: axisRotation = sideVectorAxis; break; case ScreenAxisRotation.UpAxis: axisRotation = upVectorAxis; break; case ScreenAxisRotation.Twist: break; default: break; } double angle5deg = 0.0872664626; for (int i = 0; i < 72; i++) { Thread.Sleep(50); // By X axis vtr.ViewDirection = vtr.ViewDirection.RotateBy(angle5deg, sideVectorAxis); upVectorAxis = upVectorAxis.RotateBy(angle5deg, sideVectorAxis); vtr.ViewTwist = AutoCADManager.CalcViewTwist(doc, vtr); doc.Editor.SetCurrentView(vtr); // By Y axis vtr.ViewDirection = vtr.ViewDirection.RotateBy(angle5deg, upVectorAxis); sideVectorAxis = sideVectorAxis.RotateBy(angle5deg, upVectorAxis); vtr.ViewTwist = AutoCADManager.CalcViewTwist(doc, vtr); doc.Editor.SetCurrentView(vtr); doc.Editor.Regen(); } angle5deg *= -1; for (int i = 72; i > 0; i--) { Thread.Sleep(50); // By Y axis vtr.ViewDirection = vtr.ViewDirection.RotateBy(angle5deg, upVectorAxis); sideVectorAxis = sideVectorAxis.RotateBy(angle5deg, upVectorAxis); vtr.ViewTwist = AutoCADManager.CalcViewTwist(doc, vtr); doc.Editor.SetCurrentView(vtr); // By X axis vtr.ViewDirection = vtr.ViewDirection.RotateBy(angle5deg, sideVectorAxis); upVectorAxis = upVectorAxis.RotateBy(angle5deg, sideVectorAxis); vtr.ViewTwist = AutoCADManager.CalcViewTwist(doc, vtr); doc.Editor.SetCurrentView(vtr); doc.Editor.Regen(); } }