WorldWind系列五: 插件加载过程全解析

上传人:pu****.1 文档编号:458526164 上传时间:2024-01-25 格式:DOCX 页数:14 大小:30.71KB
返回 下载 相关 举报
WorldWind系列五: 插件加载过程全解析_第1页
第1页 / 共14页
WorldWind系列五: 插件加载过程全解析_第2页
第2页 / 共14页
WorldWind系列五: 插件加载过程全解析_第3页
第3页 / 共14页
WorldWind系列五: 插件加载过程全解析_第4页
第4页 / 共14页
WorldWind系列五: 插件加载过程全解析_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《WorldWind系列五: 插件加载过程全解析》由会员分享,可在线阅读,更多相关《WorldWind系列五: 插件加载过程全解析(14页珍藏版)》请在金锄头文库上搜索。

1、WorldWind 系列五:插件加载过程全解析来源:博客园 作者:无痕客不得不承认World Wind的代码真的很庞大,没有太多帮助文档的前提下,一头钻进代码 里肯定令你头疼的,甚至研究代码间关联仿佛是在走迷宫。我最近一直想弄明白如何在 MenuBar 中加载那些插件的, WorldWind 学习系列四中研究的只是特殊的三个功能加载的, 那三个没有继承Plugin类,不算是插件功能加载。所以WorldWind学习系列四加载的三个是 特殊情况,不是一般的插件加载。今天下午终于柳暗花明,如果你真正关注World Wind分析, 那么就好好看看下面的插件加载过程全解析。我们先看看 Plugin 类的

2、继承图,看看到底都有些什么插件,然后在分析一般性的插件加载 全过程。NASA Wo rid Wind 1,4.1 API documenta tian (3923)Plugin ClassNamespaces ” VcrldWind.PluginEngine - Plugin-Pluginp-Te rr ainManagerp-DynamicCloudsp-PlaceFinderLaade r h-WavingFlags p-LayerManager h-NRLWeathe rLa ader:-ErnngLaad已r p-Tim 已(Zcntrcill己r L-Scale EarLeg 已 n

3、d p-Ccmpass3D h-GpTrackerPlkigin Sha p 已 Fi IsInfoTocI l-ShapeFileLcader :C v 已 rvie wFo rm Loader p-MovieR.eccrde r h-GlobeCu rso rPlugin p-Mea&ureToal L-StarE3D -Ma&ureToalNG p-V;hirebcardPlugin p-GecR.SSLcader p-AnaglyphStereo L-Joystick p -KM LImporter h-Atmo sphere -FloodLevelFlugin h-Escternal

4、LayerManagerLoader :-Ligh tdntroll 已p-CompassFlickrPluoin哦,原来这么多插件,我们要基于WW开发自己的应用,只需继承Plugin类写出自己的插 件功能即可的。我们现在分析插件加载过程,请确保你看过WorldWind学习系列二:擒贼先擒王篇2中 的(5.加载上次使用的配置信息)。加载的插件入口就是WorldWind.cs的Main()中调用的 LoadSetti ngs()静态方法。1.读取WorldWind的配置中插件信息 曰加载WorldWind配置private static void LoadSettings()try/先读取上次使

5、用时保存的使用插件配置文件”,如果存在,则从文件中读取配置实 例化 WorldWindSettingsSettings = (WorldWindSettings) SettingsBase.Load(Sett ings, SettingsBase.LocationType.User);if(!File.Exists(Settings.FileName)/我们假定是配置文件不存在,这就是一个个地加载插件,保存到ArrayList 中Settings.PluginsLoadedOnStartup.Add(ShapeFileInfoTool);/Settings.PluginsLoadedOnSta

6、rtup.Add(OverviewFormLoader);)/Settings.PluginsLoadedOnStartup.Add(Atmosphere丿;);Settings.PluginsLoadedOnStartup.Add(SkyGradientSettings.PluginsLoadedOnStartu p.Add( BmngLoader);/Settings.PluginsLoadedOnStartup.Add(Compass); /Settings.PluginsLoadedOnStartup.Add(ExternalLayerManagerLoader););Settings

7、.PluginsLoadedOnStartup.Add(MeasureTool/Settings.PluginsLoadedOnStartup.Add(MovieRecorder);Settings.PluginsLoadedOnStartup.Add(NRLWeatherLoader);Settings.PluginsLoadedOnStartup.Add(ShapeFileLoader);Settings.PluginsLoadedOnStartup.Add(Stars3D);Settings.PluginsLoadedOnStartup.Add(GlobalClouds)Settings

8、.PluginsLoadedOnStartup.Add(PlaceFinderLoader);Settings.PluginsLoadedOnStartup.Add(LightController);Settings.PluginsLoadedOnStartup.Add(Earthquake_2.0.2.1)Settings.PluginsLoadedOnStartup.Add(Historical_E arthquake_2.0.2.2);Settings.PluginsLoadedOnStartup.Add(KMLImporter )/Settings.PluginsLoadedOnSta

9、rtup.Add(doublezoom)/Settings.PluginsLoadedOnStartup.Add(PlanetaryRings);Settings.PluginsLoadedOnStartup.Add(TimeController);/Settings.PluginsLoadedOnStartup.Add(WavingFlags)Settings.PluginsLoadedOnStartup.Add(ScaleBarLegend);Settings.PluginsLoadedOnStartup.Add(Compass3D);Settings.PluginsLoadedOnSta

10、rtup.Add(AnaglyphStereo);Settings.PluginsLoadedOnStartup.Add(GlobeIcon);/ decrypt encoded user credentialsDataProtector dp = new DataProtector(DataProtector.Store.USE USER STORE);if (Settings.ProxyUsername.Length 0) Settings.ProxyU sername = dp.TransparentDecrypt(Settings.ProxyUsername);if(Settings.

11、ProxyPassword.Length 0) Settings.ProxyP assword = dp.TransparentDecrypt(Settings.ProxyPassword);catch(Exception caught)Log.Write(caught);2.Main()中后面调用 MainApplication()方法,该 MainApplication()调用OpenStartupWorld(),用来初始化启动World对象。OpenStartupWorld()方法首先确定加 载的是 Earth/Moon 等,然后开始加载一个星球。曰加载一个星球代码/ / Loads a

12、 new planet/ private void OpenWorld(string worldXmlFile)if(this.worldWindow.CurrentWorld != null)trythis.worldWindow.ResetToolbar();catchtryforeach (PluginInfo p in piler.Plugins)tryif(p.Plugin.IsLoaded) p.Plugin.Unload();catchcatchtrythis.worldWindow.CurrentWorld.Dispose();catch if(this.gotoDialog

13、!= null)this.gotoDialog.Dispose();this.gotoDialog = null;if(this.rapidFireModisManager != null)this.rapidFireModisManager.Dispose();this.rapidFireModisManager = null;if(this.animatedEarthMananger != null)this.animatedEarthMananger.Dispose();this.animatedEarthMananger = null;if(this.wmsBrowser != nul

14、l)this.wmsBrowser.Dispose();this.wmsBrowser = null;worldWindow.CurrentWorld = WorldWind.ConfigurationLoader.Load(worldXmlFile, worldWindow.Cache);this.splashScreen.SetText(Initializing menus.);/ InitializePluginCompiler()是我们要关注的初始化插件编辑器Plu ginCompiler (真正管理加载插件的类)InitializePluginCompiler();/Renderab

15、leObject系统很复杂,我们稍后准备专门分析一下foreach(RenderableObject worldRootObject in this.worldWin dow.CurrentWorld.RenderableObjects.ChildObjects)this.AddLayerMenuButtons(this.worldWindow, worldRootO bject);/加载 Earth 专有的 MenuButton( AnimatedEarthManager 和 RapidF ireModisManager)的配置,/这里主要不关注this.AddInternalPluginMenuButtons();this

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 机械/制造/汽车 > 综合/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号