Esempio n. 1
0
        /// <summary>
        /// Merges Velocity,Elogation, mass and walls of additional and loaded settings
        /// </summary>
        /// <returns>The Merged settings</returns>
        public WaveSettings GetMergedMaps()
        {
            WaveSettings exportSettings = new WaveSettings(_simulationSize);
            WaveSettings currentSetings = _waveEngineRef.Settings;

            exportSettings.VelocityMap = currentSetings.VelocityMap;
            exportSettings.ElongationMap = currentSetings.ElongationMap;

            for (int x = 0; x < _simulationSize.Width; x++)
            {
                for (int y = 0; y < _simulationSize.Height; y++)
                {
                    //Elongation
                    if (Math.Abs(_additionalSettings.ElongationMap[x, y] - 0.0) > 0.00000001)
                        exportSettings.ElongationMap[x, y] = _additionalSettings.ElongationMap[x, y];

                    //Mass
                    if (Math.Abs(_additionalSettings.MassMap[x, y] - 0.0) > 0.00000001)
                        exportSettings.MassMap[x, y] = _additionalSettings.MassMap[x, y];
                    else
                        exportSettings.MassMap[x, y] = _loadedSettings.MassMap[x, y];

                    //Walls
                    if (_additionalSettings.WallMap[x, y])
                        exportSettings.WallMap[x, y] = _additionalSettings.WallMap[x, y];
                    else
                        exportSettings.WallMap[x, y] = _loadedSettings.WallMap[x, y];
                }
            }
            return exportSettings;
        }
Esempio n. 2
0
 private void ImportWaveSettings(WaveSettings set)
 {
     _positionMap = (double[, ])set.ElongationMap.Clone();
     _massMap     = (double[, ])set.MassMap.Clone();
     _clearPoints = (bool[, ])set.WallMap.Clone();
     _velocityMap = (double[, ])set.ElongationMap.Clone();
     _waveSources = set.WaveSources;
     _settings    = set;
 }
Esempio n. 3
0
        public bool LoadFromFile(string filename)
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      fstr = null;

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

            try
            {
                fstr = new FileStream(filename, FileMode.Open);
                WaveSettings set = (WaveSettings)bf.Deserialize(fstr);
                fstr.Close();

                this.DeltaT                 = set.DeltaT;
                this.DesiredFPS             = set.DesiredFPS;
                this.ElongationMap          = set.ElongationMap;
                this.Energieerhaltung       = set.Energieerhaltung;
                this.FederkonstanteKopplung = set.FederkonstanteKopplung;
                this.FederkonstanteTeilchen = set.FederkonstanteTeilchen;
                this.Height                 = set.Height;
                this.MassMap                = set.MassMap;
                this.TeilchenDistanz        = set.TeilchenDistanz;
                this.Teilchenmasse          = set.Teilchenmasse;
                this.VelocityMap            = set.VelocityMap;
                this.WallMap                = set.WallMap;
                this.Width       = set.Width;
                this.WaveSources = set.WaveSources;
            }
            catch (Exception)
            {
                if (fstr != null)
                {
                    fstr.Close();
                }
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
 private void UpdateSimParams(bool read=false)
 {
     if (read)
     {
         WaveSettings sr = _waveTableEngine.GetSimulationData(false);
         txt_deltaT.Text = sr.DeltaT.ToString();
         txt_distanz.Text = sr.TeilchenDistanz.ToString();
         txt_dkopplung.Text = sr.FederkonstanteKopplung.ToString();
         txt_energie.Text = sr.Energieerhaltung.ToString();
         txt_dteilchen.Text = sr.FederkonstanteTeilchen.ToString();
         txt_fps.Text = sr.DesiredFPS.ToString();
         txt_stdmasse.Text = sr.Teilchenmasse.ToString();
     }
     else
     {
         WaveSettings set = new WaveSettings(new System.Drawing.Size(1, 1)); //Right size will be set by waveTableEngine
         try
         {
             set.DeltaT = Convert.ToDouble(txt_deltaT.Text);
             set.DesiredFPS = Convert.ToInt32(txt_fps.Text);
             set.Energieerhaltung = Convert.ToDouble(txt_energie.Text);
             set.FederkonstanteKopplung = Convert.ToDouble(txt_dkopplung.Text);
             set.FederkonstanteTeilchen = Convert.ToDouble(txt_dteilchen.Text);
             set.TeilchenDistanz = Convert.ToDouble(txt_distanz.Text);
             set.Teilchenmasse = Convert.ToDouble(txt_stdmasse.Text);
             _waveTableEngine.UpdateSimParams(set);
         }
         catch (Exception e)
         {
             MessageBox.Show("Fehler bei der Datenkonvertierung. Änderungen wurden nicht übernommen.", "Fehler");
         }
     }
 }
Esempio n. 5
0
        private void b_load_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "WaveSim-Dateien|*.was|Alle Dateien|*.*";

            if (ofd.ShowDialog() == true)
            {
                WaveSettings load = new WaveSettings();
                bool res = load.LoadFromFile(ofd.FileName);
                if (!res)
                {
                    MessageBox.Show("Fehler beim Laden der Datei.", "Laden");
                    return;
                }

                //Check sizes
                int simWidth = _waveTableEngine.SimulationSize.Width / _waveTableEngine.SimulationDivisor;
                int simHeight = _waveTableEngine.SimulationSize.Height / _waveTableEngine.SimulationDivisor;

                if ((load.Width != simWidth) || (load.Height != simHeight))
                {
                    MessageBox.Show("Fehler beim Laden der Datei.\n \nDie Simulationsgrößen stimmen nicht überein.");
                    return;
                }

                _waveTableEngine.LoadSimulation(load, (bool)cb_loadElongation.IsChecked, (bool)cb_LoadMass.IsChecked, (bool)cb_loadWalls.IsChecked, (bool)cb_loadWaveSources.IsChecked, (bool)cb_loadSimParams.IsChecked);

                if ((bool)cb_loadSimParams.IsChecked)
                    UpdateSimParams(true);
            }
        }
Esempio n. 6
0
        public void Start(Size simulationSize)
        {
            _simulationSize = simulationSize;

                _loadedSettings = new WaveSettings(simulationSize);
                _additionalSettings = new WaveSettings(simulationSize);

            _waveEngineRef.Settings = _loadedSettings;
        }
Esempio n. 7
0
        public bool LoadSettings(WaveSettings loaded, bool elong, bool sources, bool wall, bool mass, bool parameters)
        {
            _waveEngineRef.Stop();

            _loadedSettings = _waveEngineRef.Settings; //some times, we dont want to load all values - reuse current values that arent loaded

            if ((loaded.Width != _loadedSettings.Width)||(loaded.Height != _loadedSettings.Height))
            {
                _waveEngineRef.Start();
                return false;
            }

            if (elong)
                _loadedSettings.ElongationMap = loaded.ElongationMap;
            if (wall)
                _loadedSettings.WallMap = loaded.WallMap;
            if (mass)
                _loadedSettings.MassMap = loaded.MassMap;
            if (sources)
            {
                _loadedSettings.WaveSources.Clear();
                    _loadedSettings.WaveSources = loaded.WaveSources;
            }
            if (parameters)
            {
                _loadedSettings.DeltaT = loaded.DeltaT;
                _loadedSettings.DesiredFPS = loaded.DesiredFPS;
                _loadedSettings.Energieerhaltung = loaded.Energieerhaltung;
                _loadedSettings.FederkonstanteKopplung = loaded.FederkonstanteKopplung;
                _loadedSettings.FederkonstanteTeilchen = loaded.FederkonstanteTeilchen;
                _loadedSettings.TeilchenDistanz = loaded.TeilchenDistanz;
                _loadedSettings.Teilchenmasse = loaded.Teilchenmasse;
            }

            _waveEngineRef.Settings = _loadedSettings;

            _waveEngineRef.Start();
            return true;
        }
Esempio n. 8
0
 public WaveEngine()
 {
     Settings = new WaveSettings();
 }
Esempio n. 9
0
 private void ImportWaveSettings(WaveSettings set)
 {
     _positionMap = (double[,])set.ElongationMap.Clone();
     _massMap = (double[,])set.MassMap.Clone();
     _clearPoints = (bool[,])set.WallMap.Clone();
     _velocityMap = (double[,])set.ElongationMap.Clone();
     _waveSources = set.WaveSources;
     _settings = set;
 }
Esempio n. 10
0
 private void b_cancel_Click(object sender, EventArgs e)
 {
     Settings = null;
     this.Close();
 }
Esempio n. 11
0
        public void UpdateSimParams(WaveSettings paramsOnly)
        {
            //adjust to right size, otherwise the map manager wont load it
            paramsOnly.Width = _realSimulationSize.Width;
            paramsOnly.Height = _realSimulationSize.Height;

            _waveEngine.Settings.FederkonstanteKopplung = paramsOnly.FederkonstanteKopplung;
            _waveEngine.Settings.TeilchenDistanz = paramsOnly.TeilchenDistanz;
            _waveEngine.Settings.Teilchenmasse = paramsOnly.Teilchenmasse;
            _waveEngine.Settings.DeltaT = paramsOnly.DeltaT;
            _waveEngine.Settings.DesiredFPS = paramsOnly.DesiredFPS;
            _waveEngine.Settings.Energieerhaltung = paramsOnly.Energieerhaltung;
            _waveEngine.Settings.FederkonstanteTeilchen = paramsOnly.FederkonstanteTeilchen;
        }
Esempio n. 12
0
 public bool LoadSimulation(WaveSettings load, bool Elongation, bool Mass, bool Walls, bool Sources, bool Parameters)
 {
     return _mapManager.LoadSettings(load, Elongation, Sources, Walls, Mass, Parameters);
 }
Esempio n. 13
0
        public void UpdateSimParams(WaveSettings paramsOnly)
        {
            //adjust to right size, otherwise the map manager wont load it
            paramsOnly.Width = _realSimulationSize.Width;
            paramsOnly.Height = _realSimulationSize.Height;

            _mapManager.LoadSettings(paramsOnly, false, false, false, false, true);
        }
Esempio n. 14
0
 public WaveEngine()
 {
     Settings = new WaveSettings();
 }