Exemple #1
0
		public void AddConnection(Connection c)
		{
			connections.Add(c);
		}
Exemple #2
0
		protected void DrawSynapse(Pen pen, Graphics gr, Point start, Point end, Connection.CMode mode)
		{
			double t = Math.Atan2(end.Y - start.Y, end.X - start.X);
			double endt = Math.Atan2(start.Y - end.Y, start.X - end.X);

			// start at the circumference of the circle.
			Size offset = new Size((int)(5 * Math.Cos(t)), (int)(5 * Math.Sin(t)));

			// end at the circumference of the target neuron circle.
			Point endOffset = new Point((int)(15 * Math.Cos(endt)), (int)(15 * Math.Sin(endt)));
			end.Offset(endOffset);
			gr.DrawLine(pen, start + offset, end);

			// the synapse is a triangle whose base is opposite and perpendicular to the endpoint.
			double v1angle = t - 0.785398163;
			double v2angle = t + 0.785398163;

			Point v1 = new Point((int)(10 * Math.Cos(v1angle)), (int)((10 * Math.Sin(v1angle))));
			v1.Offset(end);

			Point v2 = new Point((int)(10 * Math.Cos(v2angle)), (int)((10 * Math.Sin(v2angle))));
			v2.Offset(end);

			switch (mode)
			{
				case Connection.CMode.Excitatory:
					// A white triangle.
					gr.DrawLine(pen, end, v1);
					gr.DrawLine(pen, end, v2);
					gr.DrawLine(pen, v1, v2);
					break;

				case Connection.CMode.Inhibitory:
					// A black triangle.
					gr.FillPolygon(brushBlack, new Point[] { end, v1, v2 }, System.Drawing.Drawing2D.FillMode.Winding);
					break;
			}
		}