private void draw(Proxemics proxemics) { double scale = this.getScaleFactor(); DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext drawingContext = drawingVisual.RenderOpen()) { StreamGeometry sg0 = new StreamGeometry(); using (StreamGeometryContext sgc = sg0.Open()) { sgc.BeginFigure(this.toPoint(proxemics.ProxemicsPolygons[0].BoundaryPoints[0]), true, true); for (int i = 1; i < proxemics.ProxemicsPolygons[0].BoundaryPoints.Length; i++) { sgc.LineTo(this.toPoint(proxemics.ProxemicsPolygons[0].BoundaryPoints[i]), true, true); } } sg0.Freeze(); drawingContext.DrawGeometry(this.brushes[0], null, sg0); for (int n = 1; n < this.radiuses.Length; n++) { StreamGeometry sg = new StreamGeometry(); using (StreamGeometryContext sgc = sg.Open()) { sgc.BeginFigure(this.toPoint(proxemics.ProxemicsPolygons[n - 1].BoundaryPoints[0]), true, true); for (int i = 1; i < proxemics.ProxemicsPolygons[n - 1].BoundaryPoints.Length; i++) { sgc.LineTo(this.toPoint(proxemics.ProxemicsPolygons[n - 1].BoundaryPoints[i]), true, true); } sgc.BeginFigure(this.toPoint(proxemics.ProxemicsPolygons[n].BoundaryPoints[0]), true, true); for (int i = 1; i < proxemics.ProxemicsPolygons[n].BoundaryPoints.Length; i++) { sgc.LineTo(this.toPoint(proxemics.ProxemicsPolygons[n].BoundaryPoints[i]), true, true); } } sg.FillRule = FillRule.EvenOdd; sg.Freeze(); drawingContext.DrawGeometry(this.brushes[n], null, sg); } Point center = this.toPoint(proxemics.Center); var p1 = new Point(center.X - this.centerSize / (2 * scale), center.Y); var p2 = new Point(center.X + this.centerSize / (2 * scale), center.Y); drawingContext.DrawLine(new Pen(this.centerBrush, this.centerSize / scale), p1, p2); } drawingVisual.Drawing.Freeze(); this._children.Add(drawingVisual); }
private void mouseLeftButtonDown_GetProxemics(object sender, MouseButtonEventArgs e) { var point = this._host.InverseRenderTransform.Transform(Mouse.GetPosition(this._host.FloorScene)); UV p = new UV(point.X, point.Y); Cell cell = this._host.cellularFloor.FindCell(p); if (cell == null) { MessageBox.Show("Pick a point on the walkable field and try again!\n"); return; } switch (this._host.IsovistBarrierType) { case BarrierType.Visual: if (cell.VisualOverlapState != OverlapState.Outside) { MessageBox.Show("Pick a point outside visual barriers.\nTry again!"); return; } break; case BarrierType.Physical: if (cell.PhysicalOverlapState != OverlapState.Outside) { MessageBox.Show("Pick a point outside physical barriers.\nTry again!"); return; } break; case BarrierType.Field: if (cell.FieldOverlapState != OverlapState.Inside) { MessageBox.Show("Pick a point inside the walkable field.\nTry again!"); return; } break; case BarrierType.BarrierBuffer: if (cell.BarrierBufferOverlapState != OverlapState.Outside) { MessageBox.Show("Pick a point outside barrier buffers.\nTry again!"); return; } break; default: break; } try { BarrierPolygon[] barriers = new BarrierPolygon[this.radiuses.Length]; for (int i = 0; i < this.radiuses.Length; i++) { HashSet <UVLine> blocks = this._host.cellularFloor.PolygonalIsovistVisualObstacles(p, this.radiuses[i], this._host.IsovistBarrierType); barriers[i] = this._host.BIM_To_OSM.IsovistPolygon(p, this.radiuses[i], blocks); } Proxemics proxemics = new Proxemics(barriers, p); this.draw(proxemics); } catch (Exception error0) { MessageBox.Show(error0.Report()); } }