Beispiel #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();
        }
Beispiel #2
0
        private void ComboBoxIntegratorSelectedIndexChanged(object sender, EventArgs e)
        {
            tabControlProperties.SelectedIndex = 0;

            var integratorName = comboBoxIntegrator.SelectedItem.ToString();

            propertyGridIntegrator.SelectedObject = LibraryIntegrators.GetIntegrator(integratorName);
        }
Beispiel #3
0
        private void ButtonDuplicateIntegratorClick(object sender, EventArgs e)
        {
            var name       = comboBoxIntegrator.SelectedItem.ToString();
            var finalName  = name;
            var integrator = LibraryIntegrators.GetIntegrator(name);
            var isaveObj   = integrator as ISave;

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

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

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

                input.ShowDialog();

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

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

                    isaveObj.Save(finalName);
                    LibraryIntegrators.Init();
                    comboBoxIntegrator.DataSource   = LibraryIntegrators.Integrators.ToArray();
                    comboBoxIntegrator.SelectedItem = finalName;
                }
            }
        }
Beispiel #4
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);
            }
        }
Beispiel #5
0
        private void ButtonResetIntegratorClick(object sender, EventArgs e)
        {
            var name = comboBoxIntegrator.SelectedItem.ToString();
            var path = Path.Combine(MitsubaSettings.FolderIntegratorsFolder, name) + LibraryIntegrators.Extension;

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

            var obj = propertyGridIntegrator.SelectedObject;

            if (obj is IntegratorAdaptativeIntegrator)
            {
                var integrator = new IntegratorAdaptativeIntegrator();
                integrator.Save(name);
            }

            else if (obj is IntegratorAdjointParticleTracer)
            {
                var integrator = new IntegratorAdjointParticleTracer();
                integrator.Save(name);
            }
            else if (obj is IntegratorAmbientOclusion)
            {
                var integrator = new IntegratorAmbientOclusion();
                integrator.Save(name);
            }
            else if (obj is IntegratorBidirectionalPathTracer)
            {
                var integrator = new IntegratorBidirectionalPathTracer();
                integrator.Save(name);
            }
            else if (obj is IntegratorDirectIlumination)
            {
                var integrator = new IntegratorDirectIlumination();
                integrator.Save(name);
            }
            else if (obj is IntegratorEnergyRedisributionPathTracing)
            {
                var integrator = new IntegratorEnergyRedisributionPathTracing();
                integrator.Save(name);
            }
            else if (obj is IntegratorIrradianceCaching)
            {
                var integrator = new IntegratorIrradianceCaching();
                integrator.Save(name);
            }
            else if (obj is IntegratorPathTracer)
            {
                var integrator = new IntegratorPathTracer();
                integrator.Save(name);
            }
            else if (obj is IntegratorPhotonMapper)
            {
                var integrator = new IntegratorPhotonMapper();
                integrator.Save(name);
            }
            else if (obj is IntegratorPrimarySampleSpaceMLT)
            {
                var integrator = new IntegratorPrimarySampleSpaceMLT();
                integrator.Save(name);
            }
            else if (obj is IntegratorProgressivePhotonMapper)
            {
                var integrator = new IntegratorProgressivePhotonMapper();
                integrator.Save(name);
            }
            else if (obj is IntegratorSampleSpaceMLT)
            {
                var integrator = new IntegratorSampleSpaceMLT();
                integrator.Save(name);
            }
            else if (obj is IntegratorStochasticProgressivePhotonMapper)
            {
                var integrator = new IntegratorStochasticProgressivePhotonMapper();
                integrator.Save(name);
            }
            else if (obj is IntegratorVirtualPointLightRenderer)
            {
                var integrator = new IntegratorVirtualPointLightRenderer();
                integrator.Save(name);
            }
            else if (obj is IntegratorVolumetricPathTracerExtended)
            {
                var integrator = new IntegratorVolumetricPathTracerExtended();
                integrator.Save(name);
            }
            else if (obj is IntegratorVolumetricPathTracerSimple)
            {
                var integrator = new IntegratorVolumetricPathTracerSimple();
                integrator.Save(name);
            }

            var integratorName = comboBoxIntegrator.SelectedItem.ToString();

            propertyGridIntegrator.SelectedObject = LibraryIntegrators.GetIntegrator(integratorName);
        }