//*************************************************************** // Copyright 2008 Centre For Advanced Spatial Analysis, UCL // // Author: Joel Dearden, University College London // // Contact: j.dearden@ucl.ac.uk // // Joel Dearden, // Centre for Advanced Spatial Analysis, // University College London, // 1-19 Torrington Place, // London, // WC1E 7HB // // // This file is part of PedTrace. // // PedTrace is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // PedTrace is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with PedTrace. If not, see . // //*************************************************************** using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Collections; using System.Drawing; namespace pedTrace { public class PTPedestrian { private string fUUID; private ArrayList fMovementTrace; //private SolidBrush fActiveTraceBrush; //private SolidBrush fArchiveTraceBrush; private Pen fRandomTraceColourPen; private SolidBrush fRandomTraceColourBrush; public PTPedestrian(string UUID, PTTracePoint startPos, Color uniqueTraceColor) { fUUID = UUID; fMovementTrace = new ArrayList(); fMovementTrace.Add(startPos); //fActiveTraceBrush = new SolidBrush(Color.FromArgb(64, 0, 0, 255)); //fArchiveTraceBrush = new SolidBrush(Color.FromArgb(64, 0, 0, 0)); Random r = new Random(); fRandomTraceColourPen = new Pen(uniqueTraceColor, 1.0F); fRandomTraceColourBrush = new SolidBrush(uniqueTraceColor); } public bool UUIDMatch(string UUID) { return (UUID == fUUID); } public void addTracePoint(PTPoint p, double slTime) { fMovementTrace.Add(new PTTracePoint(p, slTime)); } //renders the parts of this pedestrian's movement trace that are visible on the specified floor public void renderTrace( ref System.Drawing.Graphics g, PT2DExtents modelExtents, int imageSize, ref PTFloor visibleFloor, bool active ) { if (fMovementTrace.Count > 1) { PTPoint projectedPrev; PTPoint projectedCurrent; //draw a line connecting each pair of points in the movement trace that are on the specified floor for (int i = 1; i < fMovementTrace.Count; i++) { if ((visibleFloor.onFloor(((PTTracePoint)fMovementTrace[i - 1]).getPos().fZ)) && (visibleFloor.onFloor(((PTTracePoint)fMovementTrace[i]).getPos().fZ)) ) { projectedPrev = PTModel.projectPointToImage(((PTTracePoint)fMovementTrace[i - 1]).getPos(), modelExtents, imageSize); projectedCurrent = PTModel.projectPointToImage(((PTTracePoint)fMovementTrace[i]).getPos(), modelExtents, imageSize); //g.FillRectangle(fArchiveTraceBrush, projected.fX, projected.fY, 1, 1); if (active) { g.DrawLine( fRandomTraceColourPen, projectedPrev.fX, projectedPrev.fY, projectedCurrent.fX, projectedCurrent.fY ); if (i == fMovementTrace.Count - 1) { g.FillEllipse(fRandomTraceColourBrush, projectedCurrent.fX - 10, projectedCurrent.fY - 10, 20, 20); } } else { g.DrawLine( fRandomTraceColourPen, projectedPrev.fX, projectedPrev.fY, projectedCurrent.fX, projectedCurrent.fY ); } } } } } } }