Code Search for Developers
 
 
  

testCalibration.cs from MASE: Agile Software Engineering at Krugle


Show testCalibration.cs syntax highlighted

using System;
using System.Drawing;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Tao.Platform.Windows;
using TrackerDllLib;
using Tao.OpenGl;

namespace New_Study_Project
{
	public class testCalibration : System.Windows.Forms.Form
	{
		/* Definitions of the Program */

		private Tao.Platform.Windows.SimpleOpenGlControl testOpenglWorkSpace;
		private int GLListMousePoint;
		private int GLListCamPoint;

		private Tracker3d irTracker;
		private double irX, irY, irZ;

		private PointF pointTopLeft, pointTopRight, pointBottomRight, pointBottomLeft;
		private Point pixelTopLeft, pixelTopRight, pixelBottomRight, pixelBottomLeft;

		private Point posMouse;
		private Point posCam;

		/* End of Definitions of the Program */
	
		public testCalibration()
		{
			InitializeComponent();
			this.testOpenglWorkSpace.InitializeContexts();

			this.posMouse = new Point((int) (this.testOpenglWorkSpace.Width/2), (int) (this.testOpenglWorkSpace.Height/2));
			this.posCam = new Point((int) (this.testOpenglWorkSpace.Width/2), (int) (this.testOpenglWorkSpace.Height/2));

			this.createMousePointList();
			this.createCamPointList();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				this.irTracker.Stop();
				this.irTracker = null;
				this.testOpenglWorkSpace.DestroyContexts();
			}
			base.Dispose( disposing );
		}

	
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(testCalibration));
			this.testOpenglWorkSpace = new Tao.Platform.Windows.SimpleOpenGlControl();
			this.SuspendLayout();
			// 
			// testOpenglWorkSpace
			// 
			this.testOpenglWorkSpace.AccumBits = ((System.Byte)(0));
			this.testOpenglWorkSpace.AutoCheckErrors = false;
			this.testOpenglWorkSpace.AutoFinish = false;
			this.testOpenglWorkSpace.AutoMakeCurrent = true;
			this.testOpenglWorkSpace.AutoSwapBuffers = true;
			this.testOpenglWorkSpace.BackColor = System.Drawing.Color.Black;
			this.testOpenglWorkSpace.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("testOpenglWorkSpace.BackgroundImage")));
			this.testOpenglWorkSpace.ColorBits = ((System.Byte)(32));
			this.testOpenglWorkSpace.DepthBits = ((System.Byte)(16));
			this.testOpenglWorkSpace.Location = new System.Drawing.Point(0, 0);
			this.testOpenglWorkSpace.Name = "testOpenglWorkSpace";
			this.testOpenglWorkSpace.Size = new System.Drawing.Size(768, 488);
			this.testOpenglWorkSpace.StencilBits = ((System.Byte)(0));
			this.testOpenglWorkSpace.TabIndex = 0;
			this.testOpenglWorkSpace.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.testOpenglWorkSpace_KeyPress);
			this.testOpenglWorkSpace.MouseUp += new System.Windows.Forms.MouseEventHandler(this.testOpenglWorkSpace_MouseUp);
			this.testOpenglWorkSpace.Paint += new System.Windows.Forms.PaintEventHandler(this.testOpenglWorkSpace_Paint);
			this.testOpenglWorkSpace.MouseMove += new System.Windows.Forms.MouseEventHandler(this.testOpenglWorkSpace_MouseMove);
			this.testOpenglWorkSpace.MouseDown += new System.Windows.Forms.MouseEventHandler(this.testOpenglWorkSpace_MouseDown);
			// 
			// testCalibration
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(768, 486);
			this.Controls.Add(this.testOpenglWorkSpace);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Name = "testCalibration";
			this.ShowInTaskbar = false;
			this.Text = "Test the Calibration";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Resize += new System.EventHandler(this.testCalibration_Resize);
			this.Load += new System.EventHandler(this.testCalibration_Load);
			this.ResumeLayout(false);

		}
		
	
		private void testCalibration_Resize(object sender, System.EventArgs e)
		{
			/* Initialize the OpenGLWorkSpace */
			this.testOpenglWorkSpace.Width = this.ClientSize.Width;
			this.testOpenglWorkSpace.Height = this.ClientSize.Height;
			
			this.posMouse = new Point((int) (this.testOpenglWorkSpace.Width/2), (int) (this.testOpenglWorkSpace.Height/2));
			this.posCam = new Point((int) (this.testOpenglWorkSpace.Width/2), (int) (this.testOpenglWorkSpace.Height/2));

			Gl.glViewport(0, 0, this.testOpenglWorkSpace.Width, this.testOpenglWorkSpace.Height);
			Gl.glMatrixMode(Gl.GL_PROJECTION);
			Gl.glLoadIdentity();
			Glu.gluOrtho2D(0.0, (double) this.testOpenglWorkSpace.Width, this.testOpenglWorkSpace.Height, 0.0);

		}

		
		private void testOpenglWorkSpace_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if(e.KeyChar == 27)
			{			
				this.testOpenglWorkSpace.Dispose();
				this.Dispose();
				this.Close();
			}
		}

		private void testOpenglWorkSpace_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
		{
			Gl.glEnable(Gl.GL_BLEND);
			Gl.glEnable(Gl.GL_LINE_SMOOTH);
			Gl.glDisable(Gl.GL_DEPTH_TEST);
			Gl.glShadeModel(Gl.GL_SMOOTH);		// Enables Smooth Color Shading
			Gl.glHint(Gl.GL_LINE_SMOOTH_HINT, Gl.GL_DONT_CARE);
			Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);
			Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
			
			Gl.glClearColor(0.4f, 0.4f, 0.4f, 1.0f);
			Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer

			Gl.glMatrixMode(Gl.GL_MODELVIEW);
			Gl.glLoadIdentity();

			Gl.glPushMatrix();
			Gl.glTranslatef(this.posMouse.X, this.posMouse.Y, 0.0f);
			Gl.glCallList(this.GLListMousePoint);
			Gl.glPopMatrix();

			Gl.glPushMatrix();
			Gl.glTranslatef(this.posCam.X, this.posCam.Y, 0.0f);
			Gl.glCallList(this.GLListCamPoint);
			Gl.glPopMatrix();

		}


		private void createMousePointList()
		{
			this.GLListMousePoint = Gl.glGenLists(1);
			Gl.glNewList(this.GLListMousePoint, Gl.GL_COMPILE);
			
			Gl.glScalef(9.0f, 9.0f, 1.0f);
			
			Gl.glBegin(Gl.GL_TRIANGLE_FAN);
			Gl.glColor4f(0.2f, 1.0f, 0.6f, 1.0f);
			Gl.glVertex2d(0.0, 0.0);
			for(float run=0.0f; run<=2*Math.PI; run+=0.06282f)
			{
				Gl.glColor4f(0.0f, 0.0f, 1.0f, 0.0f);
				Gl.glVertex2d(Math.Sin(run), Math.Cos(run));
			}
			Gl.glEnd(); 
			Gl.glEndList();
		}

		private void createCamPointList()
		{
			this.GLListCamPoint = Gl.glGenLists(1);
			Gl.glNewList(this.GLListCamPoint, Gl.GL_COMPILE);
			
			Gl.glScalef(9.0f, 9.0f, 1.0f);
			
			Gl.glBegin(Gl.GL_TRIANGLE_FAN);
			Gl.glColor4f(1.0f, 0.6f, 0.2f, 1.0f);
			Gl.glVertex2d(0.0, 0.0);
			for(float run=0.0f; run<=2*Math.PI; run+=0.06282f)
			{
				Gl.glColor4f(0.0f, 0.0f, 1.0f, 0.0f);
				Gl.glVertex2d(Math.Sin(run), Math.Cos(run));
			}
			Gl.glEnd(); 
			Gl.glEndList();
		}


		private void testOpenglWorkSpace_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			this.posMouse = new Point(e.X, e.Y);

			// Get current location of IR enhanced pen
			irTracker.GetLocation(0,out irX,out irY,out irZ);
			//this.posCam = new Point(e.X+40, e.Y-40);

			this.testOpenglWorkSpace.Refresh();
		}

		private void testOpenglWorkSpace_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			int deltaPixel_X, deltaPixel_Y;
			double deltaPoint_X, deltaPoint_Y;
			int posCalcX, posCalcY;

			this.posMouse = new Point(e.X, e.Y);

			// Get current location of IR enhanced pen
			irTracker.GetLocation(0,out irY,out irX,out irZ);

			deltaPixel_X = this.pixelBottomRight.X-this.pixelBottomLeft.X;
			deltaPixel_Y = this.pixelBottomRight.Y-this.pixelTopRight.Y;

			deltaPoint_X = this.pointBottomRight.X-this.pointBottomLeft.X;
			deltaPoint_Y = this.pointBottomRight.Y-this.pointTopRight.Y;

			posCalcX = (int) ((deltaPixel_X*(irX-this.pointBottomLeft.X))/deltaPoint_X + this.pixelBottomLeft.X);
			posCalcY = (int) ((deltaPixel_Y*(irY-this.pointTopRight.Y))/deltaPoint_Y + this.pixelTopRight.Y);

			this.posCam = new Point(posCalcX, posCalcY);

			this.testOpenglWorkSpace.Refresh();
		}

		private void testOpenglWorkSpace_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			this.posMouse = new Point(e.X, e.Y);

			// Get current location of IR enhanced pen
			irTracker.GetLocation(0,out irX,out irY,out irZ);
			//this.posCam = new Point(e.X+40, e.Y-40);

			this.testOpenglWorkSpace.Refresh();
		}


		private void testCalibration_Load(object sender, System.EventArgs e)
		{
			double[] arrayDouble;
			int[] arrayInt;
			StreamReader fileReader;
			bool f;

			// Initialize IR Tracker on tracking machine - make sure the IP address is correct.
			TrackerDllLib.RemoteTracker3D remoteTracker = new TrackerDllLib.RemoteTracker3D();
			irTracker = remoteTracker.GetRemoteTracker("192.168.20.140");
			irTracker.Start();
			irTracker.SetCallBack(this);

			fileReader = new StreamReader(System.Environment.CurrentDirectory+"//testCalibration.pcb");
			fileReader.ReadLine();
			fileReader.ReadLine();
			fileReader.ReadLine();
			fileReader.ReadLine();

			arrayDouble = new double[3];
			arrayInt = new int[2];
					
			do
			{
				f = ReadCoords(fileReader, arrayInt, arrayDouble);
				if(f)
				{
					this.pixelTopLeft = new Point(arrayInt[0], arrayInt[1]);
					this.pointTopLeft = new PointF((float) arrayDouble[1], (float) arrayDouble[0]);
				}
				f = ReadCoords(fileReader, arrayInt, arrayDouble);
				if(f) 
				{
					this.pixelTopRight = new Point(arrayInt[0], arrayInt[1]);
					this.pointTopRight = new PointF((float) arrayDouble[1], (float) arrayDouble[0]);
				}
				f = ReadCoords(fileReader, arrayInt, arrayDouble);
				if(f) 
				{
					this.pixelBottomRight = new Point(arrayInt[0], arrayInt[1]);
					this.pointBottomRight = new PointF((float) arrayDouble[1], (float) arrayDouble[0]);
				}
				f = ReadCoords(fileReader, arrayInt, arrayDouble);
				if(f) 
				{
					this.pixelBottomLeft = new Point(arrayInt[0], arrayInt[1]);
					this.pointBottomLeft = new PointF((float) arrayDouble[1], (float) arrayDouble[0]);
				}
			
			}
			while(f);
			fileReader.Close();

		}

		bool ReadCoords(StreamReader r, int[] pixel, double[] array)
		{
			string s = r.ReadLine();
			if((null ==s) || (s == string.Empty))
			{
				return false;
			}
			string[] sa = s.Split('|');
			if(sa.Length < 5)
			{
				return false;
			}
			for(int i = 0; i < 2; i++)
			{
				try
				{
					pixel[i] = int.Parse(sa[i].Trim());
				}
				catch(FormatException e)
				{
					Console.WriteLine(e.Message);
					return false;
				}
			}

			for(int i = 0; i < 3; i++)
			{
				try
				{
					array[i] = double.Parse(sa[i+2].Trim());
				}
				catch(FormatException e)
				{
					Console.WriteLine(e.Message);
					return false;
				}
			}
			return true;
		}

	}
}




See more files for this project here

MASE: Agile Software Engineering

The MASE project investigates methods to support the coordination and executable acceptance testing of software projects. Keywords: Agile methods, distributed teams, Extreme Programming. See http://ebe.cpsc.ucalgary.ca/ebe for more information.

Project homepage: http://sourceforge.net/projects/mase
Programming language(s): Java,XML
License: other

  ControlPoint.cs
  CustomTreeNode.cs
  CustomTreeView.cs
  Dashboard.cs
  Dashboard.resx
  EStoryForm.cs
  EStoryForm.resx
  IOSelectObject.cs
  InterfaceGrid.cs
  InterfaceObject.cs
  List.cs
  ListNode.cs
  LogFile.cs
  MenuForm.cs
  MenuForm.resx
  MoveAbleSpline.cs
  NonMoveAbleSpline.cs
  ObjectButton.cs
  Old_MoveAbleSpline.cs
  PenCalibration.cs
  PenCalibration.resx
  RNTObject.cs
  Spline.cs
  StartupScreen.cs
  StartupScreen.resx
  StorageButton.cs
  Study_Project.cs
  Study_Project.resx
  TabletUI.cs
  TabletUI.resx
  Workspace.cs
  Workspace.resx
  testCalibration.cs
  testCalibration.resx