Ejemplo n.º 1
0
		/// <summary>
		/// Creates a pick path with the given Camera and pickbounds and adds this node.
		/// </summary>
		/// <param name="aCamera">The camera to use when creating the pick path.</param>
		/// <param name="pickBounds">The pick bounds to use when creating the pick path.</param>
		/// <returns>
		/// A pick path with the given camera and pickbounds that contains this node
		/// </returns>
		public virtual PPickPath ToPickPath(PCamera aCamera, RectangleF pickBounds) {
			PPickPath pickPath = new PPickPath(aCamera, pickBounds);
			pickPath.PushNode(this);
			return pickPath;
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Overridden.  Only picks this node's children if the pick bounds intersects the
		/// clip.
		/// </summary>
		/// <param name="pickPath">The pick path to add the node to if its picked.</param>
		/// <returns>
		/// True if this node or one of its descendents was picked; else false.
		/// </returns>
		public override bool FullPick(PPickPath pickPath) {
			if (Pickable && FullIntersects(pickPath.PickBounds)) {
				pickPath.PushNode(this);
				pickPath.PushMatrix(MatrixReference);
			
				if (Pick(pickPath)) {
					return true;
				}

				if (ChildrenPickable && PUtil.PathIntersectsRect(PathReference, pickPath.PickBounds)) { 		
					int count = ChildrenCount;
					for (int i = count - 1; i >= 0; i--) {
						PNode each = this.GetChild(i);
						if (each.FullPick(pickPath))
							return true;
					}				
				}

				if (PickAfterChildren(pickPath)) {
					return true;
				}

				pickPath.PopMatrix(MatrixReference);
				pickPath.PopNode(this);
			}

			return false;
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Try to pick this node and all of its descendents.
		/// </summary>
		/// <param name="pickPath">The pick path to add the node to if its picked.</param>
		/// <returns>True if this node or one of its descendents was picked; else false.</returns>
		/// <remarks>
		/// <b>Notes to Inheritors:</b>  Most subclasses should not need to override this
		/// method. Instead they should override <c>Pick</c> or <c>PickAfterChildren</c>.
		///	</remarks>
		public virtual bool FullPick(PPickPath pickPath) {
			if ((Pickable || ChildrenPickable) && FullIntersects(pickPath.PickBounds)) {
				pickPath.PushNode(this);
				pickPath.PushMatrix(matrix);
			
				bool thisPickable = Pickable && pickPath.AcceptsNode(this);

				if (thisPickable && Pick(pickPath)) {
					return true;
				}

				if (ChildrenPickable) {
					int count = ChildrenCount;
					for (int i = count - 1; i >= 0; i--) {
						if (children[i].FullPick(pickPath)) {
							return true;
						}
					}				
				}

				if (thisPickable && PickAfterChildren(pickPath)) {
					return true;
				}

				pickPath.PopMatrix(matrix);
				pickPath.PopNode(this);
			}

			return false;
		}
Ejemplo n.º 4
0
		//****************************************************************
		// Picking - Methods for picking the camera and it's view.
		//****************************************************************

		/// <summary>
		/// Generate and return a PPickPath for the point x,y specified in the local
		/// coordinate system of this camera.
		/// </summary>
		/// <param name="x">The x coordinate of the pick point.</param>
		/// <param name="y">The y coordinate of the pick point.</param>
		/// <param name="halo">
		/// The value to use for the width and height of the rectangle used for picking.
		/// </param>
		/// <returns>A PPickPath for the given point.</returns>
		/// <remarks>
		/// Picking is done with a rectangle, halo specifies how large that rectangle
		/// will be.
		/// </remarks>
		public virtual PPickPath Pick(float x, float y, float halo) {
			RectangleF b = PUtil.InflatedRectangle(new PointF(x, y), halo, halo);
			PPickPath result = new PPickPath(this, b);

			FullPick(result);
			
			// make sure this camera is pushed.
			if (result.NodeStackReference.Count == 0) {
				result.PushNode(this);
				result.PushMatrix(MatrixReference);
			}

			return result;
		}