/// <summary> /// Serializes the object and writes it to the output. /// </summary> /// <param name="output">Savable Output</param> public virtual void Write(ISavableWriter output) { output.Write("Name", _name); output.WriteSavable <Transform>("LocalTransform", _localTransform); output.WriteSavable <SceneHints>("SceneHints", _sceneHints); output.WriteSavable <LightCollection>("LocalLights", _localLights); List <ISavable> savableControllers = new List <ISavable>(); for (int i = 0; i < _controllers.Count; i++) { ISpatialController controller = _controllers[i]; if (controller is ISavable) { savableControllers.Add(controller as ISavable); } } if (savableControllers.Count > 0) { output.Write("HasControllers", true); output.WriteSavable <ISavable>("Controllers", savableControllers.ToArray()); } else { output.Write("HasControllers", false); } }
/// <summary> /// Deserializes the object and populates it from the input. /// </summary> /// <param name="input">Savable input</param> public virtual void Read(ISavableReader input) { _name = input.ReadString(); _localTransform = input.ReadSavable <Transform>(); _sceneHints = input.ReadSavable <SceneHints>(); _sceneHints.HintableSource = this; _localLights = input.ReadSavable <LightCollection>(); _localLights._spatial = this; bool hasControllers = input.ReadBoolean(); _controllers = new TeslaList <ISpatialController>(1); if (hasControllers) { ISavable[] savableControllers = input.ReadSavableArray <ISavable>(); for (int i = 0; i < savableControllers.Length; i++) { ISpatialController controller = savableControllers[i] as ISpatialController; if (controller != null) { _controllers.Add(controller); } } } _worldTransform = new Transform(_localTransform); _frustumIntersect = ContainmentType.Intersects; _parent = null; _dirtyMark = DirtyMark.Bounding | DirtyMark.Transform | DirtyMark.Lighting; }
/// <summary> /// Updates the controllers attached to this node. /// </summary> /// <param name="time">Interpolation</param> public void UpdateControllers(GameTime time) { for (int i = 0; i < _controllers.Count; i++) { ISpatialController c = _controllers[i]; if (c.IsEnabled) { c.Update(time, this); } } }
/// <summary> /// Creates a <c>SpatialController</c> with a map model that's suitable /// for use at design time. /// </summary> public SpatialController() { s_Controller = this; m_Data = new DesignTimeMapModel(); m_Selection = new SpatialSelection(); m_Displays = new List<ISpatialDisplay>(); // Initialize map model in case any of the prelim stuff needs it (the // running application needs to replace it with something more appropriate). SetMapModel(m_Data, null); }
/// <summary> /// Creates a <c>SpatialController</c> with a map model that's suitable /// for use at design time. /// </summary> public SpatialController() { s_Controller = this; m_Data = new DesignTimeMapModel(); m_Selection = new SpatialSelection(); m_Displays = new List <ISpatialDisplay>(); // Initialize map model in case any of the prelim stuff needs it (the // running application needs to replace it with something more appropriate). SetMapModel(m_Data, null); }
/// <summary> /// Removes a controller from the specified index in this Spatial's collection. If the index /// is out of range, then false will be returned. /// </summary> /// <param name="index">Index to remove controller at</param> /// <returns>True if operation was successful</returns> public bool RemoveControllerAt(int index) { if (index >= _controllers.Count || index < 0) { return(false); } ISpatialController c = _controllers[index]; if (c != null) { _controllers.RemoveAt(index); return(true); } return(false); }
/// <summary> /// Removes a controller from this Spatial's collection. /// </summary> /// <param name="controller">Controller to remove</param> /// <returns>True if operation was successful</returns> public bool RemoveController(ISpatialController controller) { return(_controllers.Remove(controller)); }
/// <summary> /// Add a controller to this Spatial's collection. /// </summary> /// <param name="controller">Controller to add</param> public void AddController(ISpatialController controller) { _controllers.Add(controller); }
/// <summary> /// Draws from the map model and refreshes the display /// </summary> /// <param name="addToHistory">Should the map panel extent be added to the view history?</param> internal void Draw(bool addToHistory) { Rectangle rect = new Rectangle(0, 0, mapPanel.Width, mapPanel.Height); Brush b = new SolidBrush(mapPanel.BackColor); //m_Display.Graphics.FillRectangle(Brushes.AntiqueWhite, rect); m_Display.Graphics.FillRectangle(b, rect); ISpatialController controller = SpatialController.Current; ISpatialModel mapModel = controller.MapModel; if (mapModel == null) { return; } SetScrollBars(); //Rectangle rect = new Rectangle(0, 0, mapPanel.Width, mapPanel.Height); //m_Display.Graphics.FillRectangle(Brushes.White, rect); // TEST: Try drawing an image (in Selkirk) try { IWindow w = this.Extent; IWindow testw = new Window(651000.0, 5555000.0, 652000.0, 5556000.0); if (w.IsOverlap(testw)) { float fx = EastingToDisplay(651000.0); float fy = NorthingToDisplay(5556000.0); float fsz = LengthToDisplay(1000.0); Rectangle r = new Rectangle((int)fx, (int)fy, (int)fsz, (int)fsz); Image i = Bitmap.FromFile(@"C:\Users\sstanton\Data\6515555.tif"); m_Display.Graphics.DrawImage(i, r); } } catch { } // end test mapModel.Render(this, controller.DrawStyle); // Paint the map panel using (Graphics g = mapPanel.CreateGraphics()) { m_Display.Render(g); // Save the display without any highlighting m_Display.Render(m_SavedDisplay.Graphics); //CopyMapPanelToSavedDisplay(); // Any selection needs to be drawn too, but after the above ISpatialSelection ss = controller.SpatialSelection; if (ss.Count > 0) { IDrawStyle style = controller.HighlightStyle; foreach (ISpatialObject item in ss.Items) { item.Render(this, style); } m_Display.Render(g); } } if (addToHistory) { AddExtent(); } }