Ejemplo 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();
        }
Ejemplo n.º 2
0
        private void ComboBoxSamplerSelectedIndexChanged(object sender, EventArgs e)
        {
            tabControlProperties.SelectedIndex = 1;
            var samplerName = comboBoxSampler.SelectedItem.ToString();

            propertyGridSampler.SelectedObject = LibrarySamplers.GetSampler(samplerName);
        }
Ejemplo 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);
        }
Ejemplo 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;
                }
            }
        }
Ejemplo n.º 5
0
        private void ButtonDeleteSamplerClick(object sender, EventArgs e)
        {
            var name = comboBoxSampler.SelectedItem.ToString();
            //TODO Localize me
            {
                if (MessageBox.Show(String.Format("Are you sure to delete {0}?", name), "Mistuba Render Sampler",
                                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    var path = Path.Combine(MitsubaSettings.FolderSamplersFolder, name) + LibrarySamplers.Extension;

                    try {
                        File.Delete(path);
                        LibrarySamplers.Init();
                        comboBoxSampler.DataSource = LibrarySamplers.Samplers.ToArray();
                    }

                    catch {
                        MessageBox.Show("A problem ocurred deleting the file");
                    }
                }
            }
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
        private void IntegratorDialogLoad(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(_editingPreset))
            {
                //TODO Localize me
                Text = "New Mitsuba Render Settings";
            }
            else
            {
                Text = _editingPreset;
            }

            LibraryIntegrators.Init();
            LibrarySamplers.Init();
            LibraryReconstructionFilters.Init();

            if (LibraryIntegrators.Integrators == null || !LibraryIntegrators.Integrators.Any())
            {
                MitsubaSettings.GenerateDefaultIntegrators();
            }

            if (LibrarySamplers.Samplers == null || !LibrarySamplers.Samplers.Any())
            {
                MitsubaSettings.GenerateDefaultSamplers();
            }

            if (LibraryReconstructionFilters.ReconstructionFilters == null ||
                !LibraryReconstructionFilters.ReconstructionFilters.Any())
            {
                MitsubaSettings.GenerateDefaultReconstructionFilters();
            }


            if (LibraryIntegrators.Integrators != null)
            {
                comboBoxIntegrator.DataSource = LibraryIntegrators.Integrators.ToArray();
            }

            if (LibrarySamplers.Samplers != null)
            {
                comboBoxSampler.DataSource = LibrarySamplers.Samplers.ToArray();
            }

            if (LibraryReconstructionFilters.ReconstructionFilters != null)
            {
                comboBoxReconstruction.DataSource =
                    LibraryReconstructionFilters.ReconstructionFilters.ToArray();
            }


            if (!String.IsNullOrEmpty(_editingPreset))
            {
                var preset = LibraryPresets.GetPreset(_editingPreset);
                comboBoxReconstruction.SelectedItem = preset.ReconstructionFilterName;
                comboBoxSampler.SelectedItem        = preset.SamplerName;
                comboBoxIntegrator.SelectedItem     = preset.IntegratorName;
            }

            tabControlProperties.SelectedIndex = 0;

            SaveOriginals();
        }