public void MouseMove(object sender, MouseEventArgs e)
		{
			if(!isOn)
				return;

			if(State!=MeasureState.Measuring)
				return;

			Angle lat;
			Angle lon;
			m_drawArgs.WorldCamera.PickingRayIntersection(
				e.X,
				e.Y,
				out lat,
				out lon);

			if(Angle.IsNaN(lat))
				return;

			EndLongitude = lon;
			EndLatitude = lat;

			// Calculate distance (meters) and heading between start and current mouse position
			Angle angularDistance = World.ApproxAngularDistance(StartLatitude, StartLongitude, EndLatitude, EndLongitude);
			Distance = angularDistance.Radians * m_world.EquatorialRadius;
			Azimuth = MathEngine.Azimuth(StartLatitude, StartLongitude, EndLatitude, EndLongitude);

			BuildMeasureLine(angularDistance);
			
			if(multiline.Count>0)
			this.multiline.deleteLine();
			MeasureLine line = new MeasureLine(multiline.Count);
			line.StartLatitude = this.StartLatitude;
			line.EndLatitude = this.EndLatitude;
			line.StartLongitude = this.StartLongitude;
			line.EndLongitude = this.EndLongitude;
			line.Calculate(this.m_world,false);
			this.multiline.addLine(line);
		}
Example #2
0
		public void MouseMove(object sender, MouseEventArgs e)
		{
			if(!isOn)
				return;

			if(State!=MeasureState.Measuring)
				return;

			Angle lat;
			Angle lon;
			m_drawArgs.WorldCamera.PickingRayIntersection(
				e.X,
				e.Y,
				out lat,
				out lon);

			if(Angle.IsNaN(lat))
				return;

			EndLongitude = lon;
			EndLatitude = lat;

			// Calculate distance (meters) and heading between start and current mouse position
			Angle angularDistance = World.ApproxAngularDistance(StartLatitude, StartLongitude, EndLatitude, EndLongitude);
			Distance = angularDistance.Radians * m_world.EquatorialRadius;
			Azimuth = MathEngine.Azimuth(StartLatitude, StartLongitude, EndLatitude, EndLongitude);

			BuildMeasureLine(angularDistance);
			
			if(multiline.Count>0)
			this.multiline.deleteLine();
			MeasureLine line = new MeasureLine(multiline.Count);
			line.StartLatitude = this.StartLatitude;
			line.EndLatitude = this.EndLatitude;
			line.StartLongitude = this.StartLongitude;
			line.EndLongitude = this.EndLongitude;
			line.Calculate(this.m_world,false);
			this.multiline.addLine(line);
		}
Example #3
0
		public void MouseUp(object sender, MouseEventArgs e )
		{
			if(!isOn)
				return;
			
			// Test if mouse was clicked and dragged
			if (mouseDragged())
				return;

			// Check if dialog box has been instantiated then get the measure mod
			// if not, automatically assign the mode to be single

			if (World.Settings.MeasureMode == MeasureMode.Multi && multiline == null)
				multiline = new MeasureMultiLine();

			// Cancel selection if right mouse button clicked
			if (e.Button == MouseButtons.Right)
			{
				if(State != MeasureState.Idle && World.Settings.MeasureMode == MeasureMode.Multi)
					MouseRightClick(sender,e);
				else
				{
					multiline.Clear();
					IsOn = false;
				}
				return;
			}

			// Do nothing for all other mouse buttons clicked
			if (e.Button != MouseButtons.Left)
				return;
			
			// Don't know if this is best way to do things...
			if (World.Settings.MeasureMode == MeasureMode.Single)
			{
				switch(State)
				{
					case MeasureState.Idle:
						State = MeasureState.Measuring;
						break;
					case MeasureState.Measuring:
						State = MeasureState.Complete;
						return;
					case MeasureState.Complete:
					{
						multiline.Clear();
						State = MeasureState.Idle;
						return;
					}
				}
			} 
			else if (World.Settings.MeasureMode == MeasureMode.Multi) 
			{
				switch(State)
				{
					case MeasureState.Idle:
						State = MeasureState.Measuring;
						break;
					case MeasureState.Measuring:
					{
						State = MeasureState.Measuring;
						if(multiline.Count>0)
							this.multiline.deleteLine();
						MeasureLine line = new MeasureLine(multiline.Count);
						line.StartLatitude = this.StartLatitude;
						line.EndLatitude = this.EndLatitude;
						line.StartLongitude = this.StartLongitude;
						line.EndLongitude = this.EndLongitude;
						line.Calculate(this.m_world,false);
						this.multiline.addLine(line);
						break;
					}
					case MeasureState.Complete:
					{
						State = MeasureState.Idle;
						return;
					}
				}
			}

			m_drawArgs.WorldCamera.PickingRayIntersection(
				e.X,
				e.Y,
				out StartLatitude,
				out StartLongitude);

			EndLatitude = StartLatitude;
			EndLongitude = StartLongitude;

			measureLine[0].X = (MathEngine.SphericalToCartesian(StartLatitude, 
				StartLongitude, m_drawArgs.WorldCamera.WorldRadius)).X;
			measureLine[0].Y = (MathEngine.SphericalToCartesian(StartLatitude, 
				StartLongitude, m_drawArgs.WorldCamera.WorldRadius)).Y;
			measureLine[0].Z = (MathEngine.SphericalToCartesian(StartLatitude, 
				StartLongitude, m_drawArgs.WorldCamera.WorldRadius)).Z;

			MeasureLine newline = new MeasureLine(multiline.Count);
			newline.StartLatitude = this.StartLatitude;
			newline.EndLatitude = this.EndLatitude;
			newline.StartLongitude = this.StartLongitude;
			newline.EndLongitude = this.EndLongitude;
			newline.Calculate(this.m_world,false);
			this.multiline.addLine(newline);
		}
		public void MouseUp(object sender, MouseEventArgs e )
		{
			if(!isOn)
				return;
			
			// Test if mouse was clicked and dragged
			if (mouseDragged())
				return;

			// Check if dialog box has been instantiated then get the measure mod
			// if not, automatically assign the mode to be single

			if (World.Settings.MeasureMode == MeasureMode.Multi && multiline == null)
				multiline = new MeasureMultiLine();

			// Cancel selection if right mouse button clicked
			if (e.Button == MouseButtons.Right)
			{
				if(State != MeasureState.Idle && World.Settings.MeasureMode == MeasureMode.Multi)
					MouseRightClick(sender,e);
				else
				{
					multiline.Clear();
					IsOn = false;
				}
				return;
			}

			// Do nothing for all other mouse buttons clicked
			if (e.Button != MouseButtons.Left)
				return;
			
			// Don't know if this is best way to do things...
			if (World.Settings.MeasureMode == MeasureMode.Single)
			{
				switch(State)
				{
					case MeasureState.Idle:
						State = MeasureState.Measuring;
						break;
					case MeasureState.Measuring:
						State = MeasureState.Complete;
						return;
					case MeasureState.Complete:
					{
						multiline.Clear();
						State = MeasureState.Idle;
						return;
					}
				}
			} 
			else if (World.Settings.MeasureMode == MeasureMode.Multi) 
			{
				switch(State)
				{
					case MeasureState.Idle:
						State = MeasureState.Measuring;
						break;
					case MeasureState.Measuring:
					{
						State = MeasureState.Measuring;
						if(multiline.Count>0)
							this.multiline.deleteLine();
						MeasureLine line = new MeasureLine(multiline.Count);
						line.StartLatitude = this.StartLatitude;
						line.EndLatitude = this.EndLatitude;
						line.StartLongitude = this.StartLongitude;
						line.EndLongitude = this.EndLongitude;
						line.Calculate(this.m_world,false);
						this.multiline.addLine(line);
						break;
					}
					case MeasureState.Complete:
					{
						State = MeasureState.Idle;
						return;
					}
				}
			}

			m_drawArgs.WorldCamera.PickingRayIntersection(
				e.X,
				e.Y,
				out StartLatitude,
				out StartLongitude);

			EndLatitude = StartLatitude;
			EndLongitude = StartLongitude;

			measureLine[0].X = (MathEngine.SphericalToCartesian(StartLatitude, 
				StartLongitude, m_drawArgs.WorldCamera.WorldRadius)).X;
			measureLine[0].Y = (MathEngine.SphericalToCartesian(StartLatitude, 
				StartLongitude, m_drawArgs.WorldCamera.WorldRadius)).Y;
			measureLine[0].Z = (MathEngine.SphericalToCartesian(StartLatitude, 
				StartLongitude, m_drawArgs.WorldCamera.WorldRadius)).Z;

			MeasureLine newline = new MeasureLine(multiline.Count);
			newline.StartLatitude = this.StartLatitude;
			newline.EndLatitude = this.EndLatitude;
			newline.StartLongitude = this.StartLongitude;
			newline.EndLongitude = this.EndLongitude;
			newline.Calculate(this.m_world,false);
			this.multiline.addLine(newline);
		}