Ejemplo n.º 1
0
        public override void Render(DrawArgs drawArgs)
        {
            try
            {
                if (this.isInitialized)
                {
                    lock (this._currentPolygons.SyncRoot)
                    {
                        foreach (string key in this._currentPolygons.Keys)
                        {
                            PolygonLayer curPoly = (PolygonLayer)this._currentPolygons[key];
                            curPoly.Render(drawArgs);
                        }
                    }

                    lock (this._currentBoundaries.SyncRoot)
                    {
                        foreach (string key in this._currentBoundaries.Keys)
                        {
                            BoundaryLayer curBoundary = (BoundaryLayer)this._currentBoundaries[key];
                            curBoundary.Render(drawArgs);
                        }
                    }
                }
            }
            catch (Exception caught)
            {
                Log.Write(caught);
            }
        }
Ejemplo n.º 2
0
        public override void Update(DrawArgs drawArgs)
        {
            try
            {
                if (drawArgs.WorldCamera.Altitude <= this._maxDisplayAltitude &&
                    drawArgs.WorldCamera.Altitude >= this._minDisplayAltitude)
                {
                    if (!this.isInitialized)
                    {
                        this.Initialize(drawArgs);
                    }

                    foreach (ShapeRecord curShapeRecord in this._shapeIndex.ShapeRecords)
                    {
                        BoundingBox bb = new BoundingBox(
                            (float)curShapeRecord.South, (float)curShapeRecord.North,
                            (float)curShapeRecord.West, (float)curShapeRecord.East,
                            (float)(this._parentWorld.EquatorialRadius + this._Altitude + 0),
                            (float)(this._parentWorld.EquatorialRadius + this._Altitude + 10000f));

                        if (drawArgs.WorldCamera.ViewFrustum.Intersects(bb))
                        {
                            if (this._showFilledPolygons && curShapeRecord.PolygonFile != String.Empty)
                            {
                                if (!this._currentPolygons.Contains(curShapeRecord.ID))
                                {
                                    double dv;

                                    double curScalar = (double)curShapeRecord.ScalarData[this._scalarKey];

                                    double r = 1.0;
                                    double g = 1.0;
                                    double b = 1.0;

                                    if (curScalar < this._scalarMin)
                                    {
                                        curScalar = this._scalarMin;
                                    }
                                    if (curScalar > this._scalarMax)
                                    {
                                        curScalar = this._scalarMax;
                                    }
                                    dv = this._scalarMax - this._scalarMin;

                                    if (curScalar < (this._scalarMin + 0.25 * dv))
                                    {
                                        r = 0;
                                        g = 4 * (curScalar - this._scalarMin) / dv;
                                    }
                                    else if (curScalar < (this._scalarMin + 0.5 * dv))
                                    {
                                        r = 0;
                                        b = 1 + 4 * (this._scalarMin + 0.25 * dv - curScalar) / dv;
                                    }
                                    else if (curScalar < (this._scalarMin + 0.75 * dv))
                                    {
                                        r = 4 * (curScalar - this._scalarMin - 0.5 * dv) / dv;
                                        b = 0;
                                    }
                                    else
                                    {
                                        g = 1 + 4 * (this._scalarMin + 0.75 * dv - curScalar) / dv;
                                        b = 0;
                                    }

                                    //float colorPercent = 1.0f;
                                    //if(this._scalarKey != null)
                                    //{
                                    //	double curScalar = (double)curShapeRecord.ScalarData[this._scalarKey];
                                    //	colorPercent = (float)((float)curScalar - (float)this._scalarMin) / ((float)this._scalarMax - (float)this._scalarMin);
                                    //}
                                    PolygonLayer newPoly = new PolygonLayer(
                                        curShapeRecord.ID,
                                        this._parentWorld,
                                        this._minDisplayAltitude,
                                        this._maxDisplayAltitude,
                                        this._Altitude,
                                        curShapeRecord.PolygonFile,
                                        System.Drawing.Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b))
                                        //System.Drawing.Color.FromArgb((int)(this._color.R * colorPercent), (int)(this._color.G * colorPercent), (int)(this._color.B * colorPercent))
                                        );
                                    newPoly.Initialize(drawArgs);
                                    newPoly.Update(drawArgs);
                                    lock (this._currentPolygons.SyncRoot)
                                    {
                                        this._currentPolygons.Add(curShapeRecord.ID, newPoly);
                                    }
                                }
                                else
                                {
                                    PolygonLayer curPoly = (PolygonLayer)this._currentPolygons[curShapeRecord.ID];
                                    curPoly.Update(drawArgs);
                                }
                            }

                            if (this._showBoundaries && curShapeRecord.BoundaryFile != String.Empty)
                            {
                                if (!this._currentBoundaries.Contains(curShapeRecord.ID))
                                {
                                    BoundaryLayer newBoundary = new BoundaryLayer(
                                        curShapeRecord.ID,
                                        this._parentWorld,
                                        this._Altitude,
                                        this._minDisplayAltitude,
                                        this._maxDisplayAltitude,
                                        curShapeRecord.BoundaryFile,
                                        this._color);
                                    newBoundary.Initialize(drawArgs);
                                    newBoundary.Update(drawArgs);
                                    lock (this._currentBoundaries.SyncRoot)
                                    {
                                        this._currentBoundaries.Add(curShapeRecord.ID, newBoundary);
                                    }
                                }
                                else
                                {
                                    BoundaryLayer curBoundary = (BoundaryLayer)this._currentBoundaries[curShapeRecord.ID];
                                    curBoundary.Update(drawArgs);
                                }
                            }
                        }
                        else
                        {
                            if (this._showFilledPolygons && curShapeRecord.PolygonFile != String.Empty)
                            {
                                if (this._currentPolygons.Contains(curShapeRecord.ID))
                                {
                                    lock (this._currentPolygons.SyncRoot)
                                    {
                                        using (PolygonLayer oldPoly = (PolygonLayer)this._currentPolygons[curShapeRecord.ID])
                                            this._currentPolygons.Remove(curShapeRecord.ID);
                                    }
                                }
                            }

                            if (this._showBoundaries && curShapeRecord.BoundaryFile != String.Empty)
                            {
                                if (this._currentBoundaries.Contains(curShapeRecord.ID))
                                {
                                    lock (this._currentBoundaries.SyncRoot)
                                    {
                                        using (BoundaryLayer oldBoundary = (BoundaryLayer)this._currentBoundaries[curShapeRecord.ID])
                                            this._currentBoundaries.Remove(curShapeRecord.ID);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    //remove current rendering resources
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
            }
            catch (Exception caught)
            {
                Log.Write(caught);
            }
        }
Ejemplo n.º 3
0
		public override void Update(DrawArgs drawArgs)
		{
			try
			{
				if(drawArgs.WorldCamera.Altitude <= this._maxDisplayAltitude &&
					drawArgs.WorldCamera.Altitude >= this._minDisplayAltitude)
				{
					if(!this.isInitialized)
						this.Initialize(drawArgs);

					foreach(ShapeRecord curShapeRecord in this._shapeIndex.ShapeRecords)
					{
						BoundingBox bb = new BoundingBox( 
							(float)curShapeRecord.South, (float)curShapeRecord.North, 
							(float)curShapeRecord.West, (float)curShapeRecord.East, 
							(float)(this._parentWorld.EquatorialRadius + this._Altitude + 0),
							(float)(this._parentWorld.EquatorialRadius + this._Altitude + 10000f));

						if(drawArgs.WorldCamera.ViewFrustum.Intersects(bb))
						{
							if(this._showFilledPolygons && curShapeRecord.PolygonFile != String.Empty)
							{
								if(!this._currentPolygons.Contains(curShapeRecord.ID))
								{
									double dv;

									double curScalar = (double)curShapeRecord.ScalarData[this._scalarKey];

									double r = 1.0;
									double g = 1.0;
									double b = 1.0;
									
									if (curScalar < this._scalarMin)
										curScalar = this._scalarMin;
									if (curScalar > this._scalarMax)
										curScalar = this._scalarMax;
									dv = this._scalarMax - this._scalarMin;

									if (curScalar < (this._scalarMin + 0.25 * dv)) 
									{
										r = 0;
										g = 4 * (curScalar - this._scalarMin) / dv;
									} 
									else if (curScalar < (this._scalarMin + 0.5 * dv)) 
									{
										r = 0;
										b = 1 + 4 * (this._scalarMin + 0.25 * dv - curScalar) / dv;
									} 
									else if (curScalar < (this._scalarMin + 0.75 * dv)) 
									{
										r = 4 * (curScalar - this._scalarMin - 0.5 * dv) / dv;
										b = 0;
									} 
									else 
									{
										g = 1 + 4 * (this._scalarMin + 0.75 * dv - curScalar) / dv;
										b = 0;
									}

									//float colorPercent = 1.0f;
									//if(this._scalarKey != null)
									//{
									//	double curScalar = (double)curShapeRecord.ScalarData[this._scalarKey];
									//	colorPercent = (float)((float)curScalar - (float)this._scalarMin) / ((float)this._scalarMax - (float)this._scalarMin);
									//}
									PolygonLayer newPoly = new PolygonLayer(
										curShapeRecord.ID,
										this._parentWorld,
										this._minDisplayAltitude,
										this._maxDisplayAltitude,
										this._Altitude,
										curShapeRecord.PolygonFile, 
										System.Drawing.Color.FromArgb((int)(255*r), (int)(255*g), (int)(255*b))
										//System.Drawing.Color.FromArgb((int)(this._color.R * colorPercent), (int)(this._color.G * colorPercent), (int)(this._color.B * colorPercent))
										);
									newPoly.Initialize(drawArgs);
									newPoly.Update(drawArgs);
									lock(this._currentPolygons.SyncRoot)
									{
										this._currentPolygons.Add(curShapeRecord.ID, newPoly);
									}
								}
								else
								{
									PolygonLayer curPoly = (PolygonLayer)this._currentPolygons[curShapeRecord.ID];
									curPoly.Update(drawArgs);
								}
							}

							if(this._showBoundaries && curShapeRecord.BoundaryFile != String.Empty)
							{
								if(!this._currentBoundaries.Contains(curShapeRecord.ID))
								{
									BoundaryLayer newBoundary = new BoundaryLayer(
										curShapeRecord.ID,
										this._parentWorld,
										this._Altitude,
										this._minDisplayAltitude,
										this._maxDisplayAltitude,
										curShapeRecord.BoundaryFile,
                              this._color);
									newBoundary.Initialize(drawArgs);
									newBoundary.Update(drawArgs);
									lock(this._currentBoundaries.SyncRoot)
									{
										this._currentBoundaries.Add(curShapeRecord.ID, newBoundary);
									}
								}
								else
								{
									BoundaryLayer curBoundary = (BoundaryLayer)this._currentBoundaries[curShapeRecord.ID];
									curBoundary.Update(drawArgs);
								}
							}
						}
						else
						{
							if(this._showFilledPolygons && curShapeRecord.PolygonFile != String.Empty)
							{
								if(this._currentPolygons.Contains(curShapeRecord.ID))
								{
									lock(this._currentPolygons.SyncRoot)
									{
										using( PolygonLayer oldPoly = (PolygonLayer)this._currentPolygons[curShapeRecord.ID])
											this._currentPolygons.Remove(curShapeRecord.ID);
									}
								}
							}

							if(this._showBoundaries && curShapeRecord.BoundaryFile != String.Empty)
							{
								if(this._currentBoundaries.Contains(curShapeRecord.ID))
								{
									lock(this._currentBoundaries.SyncRoot)
									{
										using( BoundaryLayer oldBoundary = (BoundaryLayer)this._currentBoundaries[curShapeRecord.ID] )
											this._currentBoundaries.Remove(curShapeRecord.ID);
									}
								}
							}
						}
					}
				}
				else
				{
					//remove current rendering resources
				}
			}
			catch(System.Threading.ThreadAbortException)
			{
			}
			catch(Exception caught)
			{
				Log.Write( caught );
			}
		}