Esempio n. 1
0
        private void ListViewIntegratorsSelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewIntegrators.SelectedItems.Count == 1)
            {
                MitsubaSettings.DefaultRenderSettingsPresetName = listViewIntegrators.SelectedItems[0].Text;

                var preset = LibraryPresets.GetPreset(MitsubaSettings.DefaultRenderSettingsPresetName);

                if (preset != null)
                {
                    var integrator           = LibraryIntegrators.GetIntegrator(preset.IntegratorName);
                    var sampler              = LibrarySamplers.GetSampler(preset.SamplerName);
                    var reconstructionFilter = LibraryReconstructionFilters.GetReconstructionFilter(preset.ReconstructionFilterName);

                    if (integrator != null)
                    {
                        MitsubaSettings.Integrator = integrator;
                    }

                    if (sampler != null)
                    {
                        MitsubaSettings.Sampler = sampler;
                    }

                    if (reconstructionFilter != null)
                    {
                        MitsubaSettings.ReconstructionFilter = reconstructionFilter;
                    }
                }
            }

            MitsubaSettings.SaveSettings();
        }
Esempio n. 2
0
        private void ComboBoxSamplerSelectedIndexChanged(object sender, EventArgs e)
        {
            tabControlProperties.SelectedIndex = 1;
            var samplerName = comboBoxSampler.SelectedItem.ToString();

            propertyGridSampler.SelectedObject = LibrarySamplers.GetSampler(samplerName);
        }
Esempio n. 3
0
        private void ButtonResetSamplerClick(object sender, EventArgs e)
        {
            var name = comboBoxSampler.SelectedItem.ToString();
            var path = Path.Combine(MitsubaSettings.FolderSamplersFolder, name) + LibrarySamplers.Extension;

            try {
                File.Delete(path);
            }
            catch {
                //TODO Localize me
                MessageBox.Show("A problem ocurred reseting the Sampler");
                return;
            }

            var obj = propertyGridSampler.SelectedObject;

            if (obj is SamplerHaltonQMC)
            {
                var sampler = new SamplerHaltonQMC();
                sampler.Save(name);
            }

            else if (obj is SamplerHammersleyQMC)
            {
                var sampler = new SamplerHammersleyQMC();
                sampler.Save(name);
            }
            else if (obj is SamplerIndependent)
            {
                var sampler = new SamplerIndependent();
                sampler.Save(name);
            }
            else if (obj is SamplerLowDiscrepancy)
            {
                var sampler = new SamplerLowDiscrepancy();
                sampler.Save(name);
            }

            else if (obj is SamplerSobolQMC)
            {
                var sampler = new SamplerSobolQMC();
                sampler.Save(name);
            }
            else if (obj is SamplerStraitfield)
            {
                var sampler = new SamplerStraitfield();
                sampler.Save(name);
            }

            var samplerName = comboBoxSampler.SelectedItem.ToString();

            propertyGridSampler.SelectedObject = LibrarySamplers.GetSampler(samplerName);
        }
Esempio n. 4
0
        private void ButtonDuplicateSamplerClick(object sender, EventArgs e)
        {
            var name      = comboBoxSampler.SelectedItem.ToString();
            var finalName = name;
            var sampler   = LibrarySamplers.GetSampler(name);
            var isaveObj  = sampler as ISave;

            var num  = 1;
            var path = Path.Combine(MitsubaSettings.FolderSamplersFolder, name) + LibrarySamplers.Extension;;

            while (File.Exists(path))
            {
                num++;
                finalName = name + " (" + num + ")";
                path      = Path.Combine(MitsubaSettings.FolderSamplersFolder, finalName);
                path     += LibrarySamplers.Extension;
            }

            if (isaveObj != null)
            {
                var input = new InputBoxDlg {
                    Titul     = "Mistuba Render Sampler",
                    TopicText = "Please Type a Name",
                    InputText = finalName
                };

                input.ShowDialog();

                if (input.DialogResult == DialogResult.OK)
                {
                    finalName = input.InputText;
                    path      = Path.Combine(MitsubaSettings.FolderSamplersFolder, finalName);

                    if (File.Exists(path))
                    {
                        //TODO Localize me
                        if (MessageBox.Show("This file already exist, do you want to overwrite it?",
                                            "Mistuba Render Sampler", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }
                    }

                    isaveObj.Save(finalName);
                    LibrarySamplers.Init();
                    comboBoxSampler.DataSource   = LibrarySamplers.Samplers.ToArray();
                    comboBoxSampler.SelectedItem = finalName;
                }
            }
        }
Esempio n. 5
0
        public static bool LoadSettings()
        {
            if (Tools.FileTools.CheckOrCreateFolder(FolderUserFolder) == -1)
            {
                return(false);
            }

            var configPath = Path.Combine(FolderUserFolder, FileConfigFileName);

            if (!File.Exists(configPath))
            {
                return(false);
            }

            try {
                var settings = File.ReadAllLines(configPath);

                if (!settings.Any())
                {
                    return(false);
                }

                foreach (var line in settings)
                {
                    var splited = line.Split(new[] { '=' });

                    if (splited.Length != 2)
                    {
                        continue;
                    }

                    var key        = splited[0];
                    var value      = splited[1];
                    var folderName = Path.GetDirectoryName(value);

                    switch (key)
                    {
                    case "FolderRenderSettingsPresetsFolder":
                        if (!String.IsNullOrEmpty(folderName))
                        {
                            FolderRenderSettingsPresetsFolder = value;
                            FolderRenderSettingsPresetsName   = folderName;
                        }

                        break;

                    case "FolderIntegratorsFolder":

                        if (!String.IsNullOrEmpty(folderName))
                        {
                            FolderIntegratorsFolder = value;
                            FolderIntegratorsName   = folderName;
                        }

                        break;

                    case "FolderSamplersFolder":
                        if (!String.IsNullOrEmpty(folderName))
                        {
                            FolderSamplersFolder = value;
                            FolderSamplersName   = folderName;
                        }

                        break;

                    case "FolderReconstructionFiltersFolder":
                        if (!String.IsNullOrEmpty(folderName))
                        {
                            FolderReconstructionFiltersFolder = value;
                            FolderReconstructionFiltersName   = folderName;
                        }

                        break;

                    case "DefaultRenderSettingsPreset": {
                        if (!String.IsNullOrEmpty(value))
                        {
                            DefaultRenderSettingsPresetName = value;
                            var preset = LibraryPresets.GetPreset(value);

                            if (preset != null)
                            {
                                var integrator           = LibraryIntegrators.GetIntegrator(preset.IntegratorName);
                                var sampler              = LibrarySamplers.GetSampler(preset.SamplerName);
                                var reconstructionFilter = LibraryReconstructionFilters.GetReconstructionFilter(preset.ReconstructionFilterName);

                                if (integrator != null)
                                {
                                    Integrator = integrator;
                                }

                                if (sampler != null)
                                {
                                    Sampler = sampler;
                                }

                                if (reconstructionFilter != null)
                                {
                                    ReconstructionFilter = reconstructionFilter;
                                }
                            }
                        }
                    }
                    break;
                    }
                }

                return(true);
            }
            catch {
                return(false);
            }
        }