public void Initialize(DrawArgs drawArgs) { // Initialize fonts if (m_drawingFont == null) { System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold); m_drawingFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont); System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f); m_wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings); System.Drawing.Font worldwinddings = new System.Drawing.Font("World Wind dings", 12.0f); m_worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, worldwinddings); } // Initialize icon if any if (m_imageName.Trim() != string.Empty) { object key = null; // Icon image from file m_iconTexture = (JHU_IconTexture)m_textures[m_imageName]; if (m_iconTexture == null) { key = m_imageName; m_iconTexture = new JHU_IconTexture(drawArgs.device, JHU_Globals.getInstance().BasePath + @"\Data\Icons\Interface\" + m_imageName); } if (m_iconTexture != null) { m_iconTexture.ReferenceCount++; if (key != null) { // New texture, cache it m_textures.Add(key, m_iconTexture); } if (m_size.Width == 0) { m_size.Width = m_iconTexture.Width; } if (m_size.Height == 0) { m_size.Height = m_iconTexture.Height; } this.XScale = (float)m_size.Width / m_iconTexture.Width; this.YScale = (float)m_size.Height / m_iconTexture.Height; } if (m_sprite == null) { m_sprite = new Sprite(drawArgs.device); } } m_isInitialized = true; }
public bool PerformRMBAction(MouseEventArgs e) { int closestIconDistanceSquared = int.MaxValue; JHU_Icon closestIcon = null; DrawArgs drawArgs = JHU_Globals.getInstance().WorldWindow.DrawArgs; foreach (RenderableObject ro in m_children) { // If renderable object can handle the selection if (!ro.IsOn) { continue; } if (!ro.isSelectable) { continue; } JHU_Icon icon = ro as JHU_Icon; // if its a JHU_Icon check to see if we're on top if (icon != null) { // don't check if we aren't even in view if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(icon.Position)) { // check if inside current icon's selection rectangle Vector3 projectedPoint = drawArgs.WorldCamera.Project(icon.Position); int dx = e.X - (int)projectedPoint.X; int dy = e.Y - (int)projectedPoint.Y; if (icon.SelectionRectangle.Contains(dx, dy)) { // Mouse is over, check whether this icon is closest int distanceSquared = dx * dx + dy * dy; if (distanceSquared < closestIconDistanceSquared) { closestIconDistanceSquared = distanceSquared; closestIcon = icon; } } } } } // if no other object has handled the selection let the closest icon try if (closestIcon != null) { if (closestIcon.PerformRMBAction(e)) { return(true); } } return(false); }
/// <summary> /// Default Constructor /// </summary> public JHU_CompassWidget() { m_textures = JHU_Globals.getInstance().Textures; m_location.X = 5; m_location.Y = 100; m_size.Height = 79; m_size.Width = 79; m_isInitialized = false; }
/// <summary> /// Default constructor /// </summary> public JHU_ButtonWidget() { m_textures = JHU_Globals.getInstance().Textures; m_location.X = 90; m_location.Y = 100; m_size.Height = 32; m_size.Width = 32; m_isInitialized = false; }
public JHU_TreeNodeWidget() { m_textures = JHU_Globals.getInstance().Textures; m_location.X = 0; m_location.Y = 0; m_size.Height = NODE_HEIGHT; m_size.Width = 100; m_ConsumedSize = m_size; m_isInitialized = false; }
/// <summary> /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.Icon"/> class /// </summary> /// <param name="name">Name of the icon</param> /// <param name="latitude">Latitude in decimal degrees.</param> /// <param name="longitude">Longitude in decimal degrees.</param> public JHU_Icon(string name, double latitude, double longitude) : base(name) { m_latitude = (float)latitude; m_longitude = (float)longitude; m_globals = JHU_Globals.getInstance(); m_textures = m_globals.Textures; }
public static JHU_Globals getInstance() { lock (typeof(JHU_Globals)) { if (m_instance == null) { m_instance = new JHU_Globals(); } } return m_instance; }
/// <summary> /// Default constructor /// </summary> public JHU_ControlWidget() { m_textures = JHU_Globals.getInstance().Textures; m_location.X = 10; m_location.Y = 5; m_size.Height = 90; m_size.Width = 180; m_isInitialized = false; LeftClickAction = new MouseClickAction(this.PerformLMBAction); }
public static JHU_Globals getInstance() { lock (typeof(JHU_Globals)) { if (m_instance == null) { m_instance = new JHU_Globals(); } } return(m_instance); }
public static void PerformReset(System.Windows.Forms.MouseEventArgs e) { DrawArgs drawArgs = JHU_Globals.getInstance().WorldWindow.DrawArgs; double lat = drawArgs.WorldCamera.Latitude.Degrees; double lon = drawArgs.WorldCamera.Longitude.Degrees; double alt = drawArgs.WorldCamera.Altitude; double fov = drawArgs.WorldCamera.ViewRange.Degrees; JHU_Globals.getInstance().WorldWindow.GotoLatLon(lat, lon, 0, alt, fov, 0); JHU_Log.Write(1, "NAV", drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees, drawArgs.WorldCamera.Altitude, "", "Reset Button Pressed"); }
/// <summary> /// Clean up any resources being used. /// Maybe this is a dumb thing for a singleton? /// </summary> protected static void Dispose() { foreach (IconTexture iconTexture in m_textures.Values) { iconTexture.Texture.Dispose(); } m_textures.Clear(); m_textures = null; m_instance = null; m_initialized = false; }
public static void PerformZoomIn(System.Windows.Forms.MouseEventArgs e) { DrawArgs drawArgs = JHU_Globals.getInstance().WorldWindow.DrawArgs; double alt = System.Math.Round(drawArgs.WorldCamera.Altitude); alt = alt * 0.8; if (alt <= 0) { return; } drawArgs.WorldCamera.Altitude = alt; JHU_Log.Write(1, "NAV", drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees, alt, "", "Zoom In Button Pressed"); }
/// <summary> /// Initializes the button by loading the texture, creating the sprite and figure out the scaling. /// /// Called on the GUI thread. /// </summary> /// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param> public void Initialize(DrawArgs drawArgs) { object key = null; // Icon image from file m_iconTexture = (JHU_IconTexture)m_textures[m_imageName]; if (m_iconTexture == null) { key = m_imageName; m_iconTexture = new JHU_IconTexture(drawArgs.device, JHU_Globals.getInstance().BasePath + @"\Data\Icons\Interface\" + m_imageName); } if (m_iconTexture != null) { m_iconTexture.ReferenceCount++; if (key != null) { // New texture, cache it m_textures.Add(key, m_iconTexture); } if (m_size.Width == 0) { m_size.Width = m_iconTexture.Width; } if (m_size.Height == 0) { m_size.Height = m_iconTexture.Height; } this.XScale = (float)m_size.Width / m_iconTexture.Width; this.YScale = (float)m_size.Height / m_iconTexture.Height; } if (m_sprite == null) { m_sprite = new Sprite(drawArgs.device); } if (m_crossHairs == null) { m_crossHairs = new Line(drawArgs.device); } m_isInitialized = true; }
public override void Dispose() { if (isInitialized) { m_sprite.Dispose(); m_sprite = null; JHU_Globals.getInstance().WorldWindow.MouseUp -= new MouseEventHandler(OnMouseUp); isInitialized = false; m_needToInitChildren = true; m_childrenToInit.Clear(); } // base dispose calls dispose of all children base.Dispose(); }
/// <summary> /// Default implementation of left click. /// </summary> /// <param name="e">Mouse event parameters</param> public void PerformLMBAction(System.Windows.Forms.MouseEventArgs e) { double lon = (e.X - this.AbsoluteLocation.X) * 2 - 180; double lat = (e.Y - this.AbsoluteLocation.Y) * 2 - 90; if (lat > 0) { lat = -lat; } else { lat = System.Math.Abs(lat); } JHU_Globals.getInstance().WorldWindow.GotoLatLon(lat, lon); JHU_Log.Write(1, "NAV", lat, lon, 0, this.Name, "Control Widget Goto Point Called."); }
public override void Initialize(DrawArgs drawArgs) { if (!isOn) { return; } if (!isInitialized) { JHU_Globals.getInstance().WorldWindow.MouseUp += new MouseEventHandler(OnMouseUp); m_sprite = new Sprite(drawArgs.device); // force the init of all children m_needToInitChildren = true; m_childrenToInit.Clear(); } InitializeChildren(drawArgs); isInitialized = true; }
/// <summary> /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.Icon"/> class /// </summary> /// <param name="name">Name of the icon</param> /// <param name="latitude">Latitude in decimal degrees.</param> /// <param name="longitude">Longitude in decimal degrees.</param> public JHU_Icon(string name, double latitude, double longitude) : base( name ) { m_latitude = (float) latitude; m_longitude = (float) longitude; m_globals = JHU_Globals.getInstance(); m_textures = m_globals.Textures; }
public static void PerformBuildingZoom(System.Windows.Forms.MouseEventArgs e) { JHU_Globals.getInstance().WorldWindow.DrawArgs.WorldCamera.Altitude = 1000; JHU_Log.Write(1, "NAV", JHU_Globals.getInstance().WorldWindow.DrawArgs.WorldCamera.Latitude.Degrees, JHU_Globals.getInstance().WorldWindow.DrawArgs.WorldCamera.Longitude.Degrees, JHU_Globals.getInstance().WorldWindow.DrawArgs.WorldCamera.Altitude, "", "Building Zoom Button Pressed"); }
/// <summary> /// Creates the instance if it doesn't exist and initializes passed in data /// </summary> /// <param name="application"></param> public static void Initialize(WorldWindow worldWindow) { lock (typeof(JHU_Globals)) { if (m_instance == null) { m_instance = new JHU_Globals(); } m_worldWindow = worldWindow; if (m_rootWidget == null) { m_rootWidget = new JHU_RootWidget(m_worldWindow); m_rootWidget.Visible = true; m_rootWidget.Enabled = true; } if (m_infoForm == null) { m_infoForm = new JHU_FormWidget("Info"); m_infoForm.WidgetSize = new System.Drawing.Size(200, 250); m_infoForm.Location = new System.Drawing.Point(m_rootWidget.ClientSize.Width - 201, m_rootWidget.ClientSize.Height - 271); m_infoForm.Anchor = JHU_Enums.AnchorStyles.Right; m_infoTree = new JHU_SimpleTreeNodeWidget("Info"); m_infoTree.IsRadioButton = true; m_infoTree.Expanded = true; m_infoTree.EnableCheck = false; // general node m_generalInfoLabel = new JHU_LabelWidget(""); m_generalInfoLabel.ClearOnRender = true; m_generalInfoLabel.Format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak; m_generalInfoLabel.Location = new System.Drawing.Point(0, 0); m_generalInfoLabel.AutoSize = true; m_generalInfoLabel.UseParentWidth = false; m_generalInfoTreeNode = new JHU_SimpleTreeNodeWidget("General"); m_generalInfoTreeNode.IsRadioButton = true; m_generalInfoTreeNode.Expanded = true; m_generalInfoTreeNode.EnableCheck = false; m_generalInfoTreeNode.Add(m_generalInfoLabel); m_infoTree.Add(m_generalInfoTreeNode); // Detail node m_detailedInfoTreeNode = new JHU_SimpleTreeNodeWidget("Detailed"); m_detailedInfoTreeNode.IsRadioButton = true; m_detailedInfoTreeNode.Expanded = false; m_detailedInfoTreeNode.EnableCheck = false; m_detailedInfoLabel = new JHU_LabelWidget(""); m_detailedInfoLabel.ClearOnRender = true; m_detailedInfoLabel.Format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak; m_detailedInfoLabel.Location = new System.Drawing.Point(0, 0); m_detailedInfoLabel.AutoSize = true; m_detailedInfoLabel.UseParentWidth = false; m_detailedInfoTreeNode.Add(m_detailedInfoLabel); m_infoTree.Add(m_detailedInfoTreeNode); // Description node m_descriptionTreeNode = new JHU_SimpleTreeNodeWidget("Description"); m_descriptionTreeNode.IsRadioButton = true; m_descriptionTreeNode.Expanded = false; m_descriptionTreeNode.EnableCheck = false; m_descriptionLabel = new JHU_LabelWidget(""); m_descriptionLabel.ClearOnRender = true; m_descriptionLabel.Format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak; m_descriptionLabel.Location = new System.Drawing.Point(0, 0); m_descriptionLabel.AutoSize = true; m_descriptionLabel.UseParentWidth = true; m_descriptionTreeNode.Add(m_descriptionLabel); m_infoTree.Add(m_descriptionTreeNode); // Add the tree to the info form m_infoForm.Add(m_infoTree); //m_infoForm.Add(m_descriptionLabel); m_rootWidget.Add(m_infoForm); } if (m_controlForm == null) { m_controlForm = new JHU_FormWidget("Navigator"); m_controlForm.Location = new System.Drawing.Point(m_rootWidget.ClientSize.Width - 201, 0); m_controlForm.WidgetSize = new System.Drawing.Size(200, 242); m_controlForm.HorizontalScrollbarEnabled = false; m_controlForm.HorizontalResizeEnabled = false; m_controlForm.Anchor = JHU_Enums.AnchorStyles.Right; m_overviewWidget = new JHU_ControlWidget(); m_controlForm.Add(m_overviewWidget); m_compassWidget = new JHU_CompassWidget(); m_controlForm.Add(m_compassWidget); m_zoomInWidget = new JHU_ButtonWidget(); m_zoomInWidget.Location = new System.Drawing.Point(84, 100); m_zoomInWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformZoomIn); m_controlForm.Add(m_zoomInWidget); m_zoomOutWidget = new JHU_ButtonWidget(); m_zoomOutWidget.ImageName = "button_out.png"; m_zoomOutWidget.Location = new System.Drawing.Point(84, 137); m_zoomOutWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformZoomOut); m_controlForm.Add(m_zoomOutWidget); m_zoomWorldWidget = new JHU_ButtonWidget(); m_zoomWorldWidget.ImageName = "button_world.png"; m_zoomWorldWidget.Location = new System.Drawing.Point(10, 174); m_zoomWorldWidget.CountHeight = true; m_zoomWorldWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformWorldZoom); m_controlForm.Add(m_zoomWorldWidget); m_zoomCountryWidget = new JHU_ButtonWidget(); m_zoomCountryWidget.ImageName = "button_country.png"; m_zoomCountryWidget.Location = new System.Drawing.Point(47, 174); m_zoomCountryWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformCountryZoom); m_controlForm.Add(m_zoomCountryWidget); m_zoomStateWidget = new JHU_ButtonWidget(); m_zoomStateWidget.ImageName = "button_state.png"; m_zoomStateWidget.Location = new System.Drawing.Point(84, 174); m_zoomStateWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformStateZoom); m_controlForm.Add(m_zoomStateWidget); m_zoomCityWidget = new JHU_ButtonWidget(); m_zoomCityWidget.ImageName = "button_city.png"; m_zoomCityWidget.Location = new System.Drawing.Point(121, 174); m_zoomCityWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformCityZoom); m_controlForm.Add(m_zoomCityWidget); m_zoomBldgWidget = new JHU_ButtonWidget(); m_zoomBldgWidget.ImageName = "button_building.png"; m_zoomBldgWidget.Location = new System.Drawing.Point(158, 174); m_zoomBldgWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformBuildingZoom); m_controlForm.Add(m_zoomBldgWidget); m_resetWidget = new JHU_ButtonWidget(); m_resetWidget.ImageName = "button_reset.png"; m_resetWidget.Location = new System.Drawing.Point(158, 100); m_resetWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformReset); m_controlForm.Add(m_resetWidget); m_rootWidget.Add(m_controlForm); } m_initialized = true; } }
/// <summary> /// Clean up any resources being used. /// Maybe this is a dumb thing for a singleton? /// </summary> protected static void Dispose() { foreach(IconTexture iconTexture in m_textures.Values) iconTexture.Texture.Dispose(); m_textures.Clear(); m_textures = null; m_instance = null; m_initialized = false; }
/// <summary> /// Creates the instance if it doesn't exist and initializes passed in data /// </summary> /// <param name="application"></param> public static void Initialize(WorldWindow worldWindow) { lock (typeof(JHU_Globals)) { if (m_instance == null) { m_instance = new JHU_Globals(); } m_worldWindow = worldWindow; if (m_rootWidget == null) { m_rootWidget = new JHU_RootWidget(m_worldWindow); m_rootWidget.Visible = true; m_rootWidget.Enabled = true; } if (m_infoForm == null) { m_infoForm = new JHU_FormWidget("Info"); m_infoForm.WidgetSize = new System.Drawing.Size(200, 250); m_infoForm.Location = new System.Drawing.Point(m_rootWidget.ClientSize.Width - 201, m_rootWidget.ClientSize.Height - 271); m_infoForm.Anchor = JHU_Enums.AnchorStyles.Right; m_infoTree = new JHU_SimpleTreeNodeWidget("Info"); m_infoTree.IsRadioButton = true; m_infoTree.Expanded = true; m_infoTree.EnableCheck = false; // general node m_generalInfoLabel = new JHU_LabelWidget(""); m_generalInfoLabel.ClearOnRender = true; m_generalInfoLabel.Format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak ; m_generalInfoLabel.Location = new System.Drawing.Point(0, 0); m_generalInfoLabel.AutoSize = true; m_generalInfoLabel.UseParentWidth = false; m_generalInfoTreeNode = new JHU_SimpleTreeNodeWidget("General"); m_generalInfoTreeNode.IsRadioButton = true; m_generalInfoTreeNode.Expanded = true; m_generalInfoTreeNode.EnableCheck = false; m_generalInfoTreeNode.Add(m_generalInfoLabel); m_infoTree.Add(m_generalInfoTreeNode); // Detail node m_detailedInfoTreeNode = new JHU_SimpleTreeNodeWidget("Detailed"); m_detailedInfoTreeNode.IsRadioButton = true; m_detailedInfoTreeNode.Expanded = false; m_detailedInfoTreeNode.EnableCheck = false; m_detailedInfoLabel = new JHU_LabelWidget(""); m_detailedInfoLabel.ClearOnRender = true; m_detailedInfoLabel.Format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak ; m_detailedInfoLabel.Location = new System.Drawing.Point(0, 0); m_detailedInfoLabel.AutoSize = true; m_detailedInfoLabel.UseParentWidth = false; m_detailedInfoTreeNode.Add(m_detailedInfoLabel); m_infoTree.Add(m_detailedInfoTreeNode); // Description node m_descriptionTreeNode = new JHU_SimpleTreeNodeWidget("Description"); m_descriptionTreeNode.IsRadioButton = true; m_descriptionTreeNode.Expanded = false; m_descriptionTreeNode.EnableCheck = false; m_descriptionLabel = new JHU_LabelWidget(""); m_descriptionLabel.ClearOnRender = true; m_descriptionLabel.Format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak ; m_descriptionLabel.Location = new System.Drawing.Point(0, 0); m_descriptionLabel.AutoSize = true; m_descriptionLabel.UseParentWidth = true; m_descriptionTreeNode.Add(m_descriptionLabel); m_infoTree.Add(m_descriptionTreeNode); // Add the tree to the info form m_infoForm.Add(m_infoTree); //m_infoForm.Add(m_descriptionLabel); m_rootWidget.Add(m_infoForm); } if (m_controlForm == null) { m_controlForm = new JHU_FormWidget("Navigator"); m_controlForm.Location = new System.Drawing.Point(m_rootWidget.ClientSize.Width - 201, 0); m_controlForm.WidgetSize = new System.Drawing.Size(200, 242); m_controlForm.HorizontalScrollbarEnabled = false; m_controlForm.HorizontalResizeEnabled = false; m_controlForm.Anchor = JHU_Enums.AnchorStyles.Right; m_overviewWidget = new JHU_ControlWidget(); m_controlForm.Add(m_overviewWidget); m_compassWidget = new JHU_CompassWidget(); m_controlForm.Add(m_compassWidget); m_zoomInWidget = new JHU_ButtonWidget(); m_zoomInWidget.Location = new System.Drawing.Point(84,100); m_zoomInWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformZoomIn); m_controlForm.Add(m_zoomInWidget); m_zoomOutWidget = new JHU_ButtonWidget(); m_zoomOutWidget.ImageName = "button_out.png"; m_zoomOutWidget.Location = new System.Drawing.Point(84,137); m_zoomOutWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformZoomOut); m_controlForm.Add(m_zoomOutWidget); m_zoomWorldWidget = new JHU_ButtonWidget(); m_zoomWorldWidget.ImageName = "button_world.png"; m_zoomWorldWidget.Location = new System.Drawing.Point(10,174); m_zoomWorldWidget.CountHeight = true; m_zoomWorldWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformWorldZoom); m_controlForm.Add(m_zoomWorldWidget); m_zoomCountryWidget = new JHU_ButtonWidget(); m_zoomCountryWidget.ImageName = "button_country.png"; m_zoomCountryWidget.Location = new System.Drawing.Point(47,174); m_zoomCountryWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformCountryZoom); m_controlForm.Add(m_zoomCountryWidget); m_zoomStateWidget = new JHU_ButtonWidget(); m_zoomStateWidget.ImageName = "button_state.png"; m_zoomStateWidget.Location = new System.Drawing.Point(84,174); m_zoomStateWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformStateZoom); m_controlForm.Add(m_zoomStateWidget); m_zoomCityWidget = new JHU_ButtonWidget(); m_zoomCityWidget.ImageName = "button_city.png"; m_zoomCityWidget.Location = new System.Drawing.Point(121,174); m_zoomCityWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformCityZoom); m_controlForm.Add(m_zoomCityWidget); m_zoomBldgWidget = new JHU_ButtonWidget(); m_zoomBldgWidget.ImageName = "button_building.png"; m_zoomBldgWidget.Location = new System.Drawing.Point(158,174); m_zoomBldgWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformBuildingZoom); m_controlForm.Add(m_zoomBldgWidget); m_resetWidget = new JHU_ButtonWidget(); m_resetWidget.ImageName = "button_reset.png"; m_resetWidget.Location = new System.Drawing.Point(158,100); m_resetWidget.LeftClickAction = new MouseClickAction(JHU_Globals.PerformReset); m_controlForm.Add(m_resetWidget); m_rootWidget.Add(m_controlForm); } m_initialized = true; } }