コード例 #1
0
        public virtual void Init(HashTableSettings settings, ICommonDeviceInterface cdi)
        {
            this.settings = settings;
            
            // load settings
            BackColor = (Color)settings["View3D.BgClr"];

            // filter profiles into supported
            // NOTE: Profiles should be done in CDI really
            List<GraphicsProfile> sProfiles = new List<GraphicsProfile>();
            foreach (GraphicsProfile profile in profiles)
            {
                if (GraphicsDeviceManager.CheckAdapterMeetsRequirements(((CommonDeviceInterface)cdi).Adapter,
                                                                        profile.MinReqs))
                {
                    sProfiles.Add(profile);
                    // decide which recommendation to use
                    profile.RecommendedVarInUse = -1;
                    for (int i = 0; i < profile.RecommendedVariations.Length; i++)
                    {
                        if (GraphicsDeviceManager.CheckAdapterMeetsRequirements(((CommonDeviceInterface)cdi).Adapter,
                                                                                profile.RecommendedVariations[i]))
                        {
                            profile.RecommendedVarInUse = i;
                            break;
                        }
                    }
                }
            }
            // TODO: This needs to feed back to UI?
            supportedProfiles = sProfiles.ToArray();
            if (supportedProfiles.Length == 0)
                throw new Exception("None of the available graphics profiles meet the graphics devices capabilities");
        }
コード例 #2
0
ファイル: MdiWindow.cs プロジェクト: xuchuansheng/GenXSource
        public void Init(HashTableSettings gSettings, Ribbon mainRibbon)
        {
            ribbon = mainRibbon;

            devSettings = (bool)gSettings["DeveloperMode"];

            appDir = Application.StartupPath + "\\";
            globalSettings = gSettings;

            // load recent files
            if (File.Exists(appDir + "recentFiles.xml"))
            {
                recentFiles = RecentFiles.LoadFromFile(appDir + "recentFiles.xml");
                recentFiles.ClearDeadEntires();
            }
            else
                recentFiles = new RecentFiles();

            RebuildRecentFilesMenu();

            baseDir = /*(string)gSettings["Base.Path"];*/Path.GetFullPath(ConfigurationManager.AppSettings[(devSettings ? "dev@" : "") + "Base.Path.Relative"].Replace("%STARTUP%", Application.StartupPath));
            if (!Directory.Exists(baseDir))
                throw new ApplicationException("Base directory does not exist! : " + baseDir);

            cdi = ICommonDeviceInterface.NewInterface((byte)globalSettings["CDI.Adapter"], baseDir);
            cdi.ResourceLoader.RegisterContentLoader(new LayerContentLoader());
            cdi.ResourceLoader.RegisterContentLoader(new BooScriptContentLoader());

            ShowHideGroups(false);
        }
コード例 #3
0
        public static HashTableSettings LoadFromXml(XmlDocument xml)
        {
            HashTableSettings settings = new HashTableSettings();

            XmlNodeList values = xml.SelectNodes("settings/values/valueType");

            foreach (XmlNode value in values)
            {
                string  token    = value.SelectSingleNode("@token").InnerText;
                XmlNode typeNode = value.SelectSingleNode("@type");
                //if (typeNode != null)
                //{
                string type = typeNode.InnerText;
                string data = value.SelectSingleNode("@data").InnerText;
                object obj  = null;

                if (type == "Int32")
                {
                    obj = Int32.Parse(data);
                }
                else if (type == "String")
                {
                    obj = data;
                }
                else if (type == "Float")
                {
                    obj = float.Parse(data);
                }
                else if (type == "Bool")
                {
                    obj = bool.Parse(data);
                }
                else if (type == "Color")
                {
                    obj = Color.FromArgb(Int32.Parse(data));
                }
                else if (type == "Byte")
                {
                    obj = byte.Parse(data);
                }

                if (obj != null)
                {
                    globalTable[token] = obj;
                }
                //}
                //else
                //{
                //    string asmName = value.SelectSingleNode("@assembly").InnerText;
                //    string typeName = value.SelectSingleNode("@typeName").InnerText;

                //    ObjectHandle handle = System.Activator.CreateInstance(asmName, typeName);
                //    settings[token] = handle.Unwrap();
                //}
            }
            return(settings);
        }
コード例 #4
0
 public static HashTableSettings LoadFromXml(string xmlText, bool isFilePath)
 {
     if (isFilePath)
     {
         StreamReader      reader   = new StreamReader(xmlText);
         HashTableSettings settings = LoadFromXml(reader);
         reader.Close();
         return(settings);
     }
     else
     {
         XmlDocument xml = new XmlDocument();
         xml.LoadXml(xmlText);
         return(LoadFromXml(xml));
     }
 }
コード例 #5
0
        public static HashTableSettings LoadFromXml(XmlDocument xml)
        {
            HashTableSettings settings = new HashTableSettings();

            XmlNodeList values = xml.SelectNodes("settings/values/valueType");

            foreach (XmlNode value in values)
            {
                string token = value.SelectSingleNode("@token").InnerText;
                XmlNode typeNode = value.SelectSingleNode("@type");
                //if (typeNode != null)
                //{
                    string type = typeNode.InnerText;
                    string data = value.SelectSingleNode("@data").InnerText;
                    object obj = null;

                    if (type == "Int32")
                        obj = Int32.Parse(data);
                    else if (type == "String")
                        obj = data;
                    else if (type == "Float")
                        obj = float.Parse(data);
                    else if (type == "Bool")
                        obj = bool.Parse(data);
                    else if (type == "Color")
                        obj = Color.FromArgb(Int32.Parse(data));
                    else if (type == "Byte")
                        obj = byte.Parse(data);

                    if (obj != null)
                        globalTable[token] = obj;
                //}
                //else
                //{
                //    string asmName = value.SelectSingleNode("@assembly").InnerText;
                //    string typeName = value.SelectSingleNode("@typeName").InnerText;

                //    ObjectHandle handle = System.Activator.CreateInstance(asmName, typeName);
                //    settings[token] = handle.Unwrap();
                //}
            }
            return settings;
        }
コード例 #6
0
ファイル: MainWindow.cs プロジェクト: xuchuansheng/GenXSource
        public MainWindow(HashTableSettings gSettings, bool devMode)
        {
            InitializeComponent();

            if (gSettings == null)
                throw new Exception("No global settings loaded");
                //gSettings = HashTableSettings.LoadFromXml(NuGenDEMVis.Properties.Resource1.DefaultGlobalSettings, false);

            gSettings["DeveloperMode"] = devMode;

            Init(gSettings, ribbon1);

            LoadFileTypes();
            LoadProfiles();

            Text += " [" + gSettings["Assembly.Version"] + "]";

            // TODO: proper measurements and cap size?
            //explorerBarContainerControl3.Height = 64 * 4;
        }
コード例 #7
0
 public DeviceInterface(Device device, CommonDeviceInterface cdi, HashTableSettings localSettings)
 {
     this.device = device;
     this.cdi = cdi;
     this.localSettings = localSettings;
     resourceSet = new ResourceSet(device);
     cdi.Resources.AddSet(resourceSet);
 }
コード例 #8
0
 public HashTableSettings()
 {
     instance       = this;
     overridesTable = new Dictionary <string, object>();
     globalOnly     = false;
 }
コード例 #9
0
 public HashTableSettings()
 {
     instance = this;
     overridesTable = new Dictionary<string, object>();
     globalOnly = false;
 }
コード例 #10
0
ファイル: MainWindow.cs プロジェクト: xuchuansheng/GenXSource
        private void NewVisualizationFromImg()
        {
            // open data sourcing dialog
            OpenFileDialog openDlg = new OpenFileDialog();
            openDlg.Title = "Open Image";
            openDlg.Filter = fileFilter;
            openDlg.InitialDirectory = baseDir;
            if (openDlg.ShowDialog(this) == DialogResult.OK)
            {
                NewVisDlg dlg = new NewVisDlg(openDlg.FileName, fileTypes, dataProfiles);
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    // create visualization
                    UI3DVisControl control = new UI3DVisControl();
                    VisViewTab tab = new VisViewTab(control);

                    control.Title = tab.Text = dlg.VisName;
                    tab.MdiParent = this;
                    tab.Show();

                    HashTableSettings localSettings = new HashTableSettings();
                    //localSettings["Base.Path"] = baseDir;
                    localSettings["GeometryVis.HeightShadingEnabled"] = false;
                    localSettings["GeometryVis.HeightShadingClr"] = Color.Red;
                    control.Init(localSettings, cdi);

                    OnTabChanged();

                    control.LoadVisualization(dlg.VisDataProfile, dlg.VisSubDataProfile, dlg.VisDataReader,
                                              dlg.VisDataSourceInfo);

                    OnTabChanged();

                    dlg.VisDataReader = null;

                    recentFiles.AddFile(openDlg.FileName, RecentFiles.RecentFileType.Molecule);
                    RebuildRecentFilesMenu();
                }
                dlg.Dispose();
            }
        }
コード例 #11
0
        public override void Init(HashTableSettings settings, ICommonDeviceInterface cdi)
        {
            base.Init(settings, cdi);

            renderContext = rContext = new VisRenderingContext3D(settings, this, (CommonDeviceInterface)cdi,
                                                                 profiles[0]);
            renderContext.BackColor = BackColor;
        }
コード例 #12
0
        public RenderingContext3D(Control targetRenderArea, GraphicsProfile profile, CommonDeviceInterface cdi,
                                  HashTableSettings localSettings)
        {
            isDeviceLost = false;
            isActive = false;
            hasFocus = false;

            this.targetRenderArea = targetRenderArea;
            outProfile = profile;
            log = cdi.GeneralLog;

            presentParams = new PresentParameters();
            outCaps = cdi.DeviceCaps;

            layers = new LayerStack();

            InitializeEnvironment(cdi, localSettings);

            view3D = new RenderingView3DPer(Matrix.Identity, Matrix.Identity);
            view3D.Near = 0.1f;
            view3D.Far = 25;

            int sceneSize = 60;
            sManager = new GenericSceneManager<SceneEntity>(gDevice, outSettings,
                                                            new Vector3(sceneSize / 2f, sceneSize / 2f, sceneSize / 2f), sceneSize);
        }
コード例 #13
0
        protected virtual void InitializeEnvironment(CommonDeviceInterface cdi, HashTableSettings localSettings)
        {
            // Get device settings
            if (outCaps == null)
                outCaps = GraphicsDeviceCaps.GetDefaultAdapterCaps(outProfile.RecommendedVariations[0]);
            // find first recommended settings with full match
            bool fullMatch = false;
            outSettings = GraphicsDeviceSettings.CreateFromRequirements(outProfile.RecommendedVariation,
                                                                        outCaps, outProfile.MinReqs,
                                                                        out fullMatch);

            // Set up the presentation parameters
            presentParams.Windowed = outProfile.RecommendedVariations[0].Windowed;
            presentParams.SwapEffect = SwapEffect.Discard;
            presentParams.AutoDepthStencilFormat = outSettings.DepthFormat;
            presentParams.EnableAutoDepthStencil = (outSettings.DepthFormat != DepthFormat.Unknown);
            presentParams.MultiSample = outSettings.MultiSample;

            CreateDevice();

            devIf = new DeviceInterface(gDevice, cdi, localSettings);

            gPipeline = new GraphicsPipeline(gDevice);
        }