Esempio n. 1
0
        public void copyWaveform(Waveform copyMe)
        {
            if (copyMe.combiners!=null)
                this.combiners = new List<InterpolationType.CombinationOperators>(copyMe.combiners);
            else
                this.combiners = null;

            this.dataFileName = copyMe.dataFileName;
            this.dataFromFile = copyMe.dataFromFile;
            this.equationString = copyMe.equationString;

            if (copyMe.extraParameters != null)
                this.extraParameters = new List<DimensionedParameter>(copyMe.extraParameters);
            else
                this.extraParameters = null;

            this.myInterpolationType = copyMe.myInterpolationType;

            if (copyMe.referencedWaveforms != null)
                this.referencedWaveforms = new List<Waveform>(copyMe.referencedWaveforms);
            else
                this.referencedWaveforms = null;

            this.waveformDuration = new DimensionedParameter(copyMe.waveformDuration);

            this.waveformName = copyMe.waveformName;

            if (copyMe.xValues != null)
                this.xValues = new List<DimensionedParameter>(copyMe.xValues);
            else
                this.xValues = null;

            this.YUnits = copyMe.YUnits;

            if (copyMe.yValues != null)
                this.yValues = new List<DimensionedParameter>(copyMe.yValues);
            else
                this.yValues = null;

        }
        //REO 10/2008
        private void fileLoadButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (StreamReader sr = new StreamReader(filePathTextBox.Text))
                {
                    //to hold temporary X and Y values
                    Waveform tempwaveform = new Waveform();
                    //to parse each line in the file at either space or comma seperator
                    //trimming each line of white space at the beginning and end
                    DataStructures.UtilityClasses.WaveformParser p = new  DataStructures.UtilityClasses.WaveformParser(sr, @"[,\s]\s*", delegate(string s) { return s.Trim(); });

                    double[] values;
                    while ((values = p.ReadFloats()) != null)
                    {
                        //there should be two values, otherwise the file is formated wrong
                        if (values.Length != 2)
                            throw new System.ApplicationException("File should have two comma or tab separated numbers per line");

                        tempwaveform.XValues.Add(new DimensionedParameter(Units.s, values[0]));
                        tempwaveform.YValues.Add(new DimensionedParameter(new Units(currentWaveform.YUnits, Units.Multiplier.unity), values[1]));
                    }

                    currentWaveform.XValues = tempwaveform.XValues;
                    currentWaveform.YValues = tempwaveform.YValues;
                    currentWaveform.DataFileName = filePathTextBox.Text;
                    currentWaveform.WaveformDuration = (currentWaveform.XValues.Count > 0)
                        ? currentWaveform.XValues[currentWaveform.XValues.Count-1] : currentWaveform.WaveformDuration;
                    layoutNewWaveform();

                    updateGraph(this, null);
                }
            }
            catch (Exception ex)
            {
                // Let the user know what went wrong.
                MessageBox.Show("The file could not be read:\n" + ex.Message);
            }
        }
 private void copyToCommonWaveformsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Waveform copy = new Waveform(currentWaveform);
     Storage.sequenceData.CommonWaveforms.Add(copy);
     WordGenerator.mainClientForm.instance.commonWaveformEditor1.setCommonWaveforms(Storage.sequenceData.CommonWaveforms);
 }
 public void setWaveform(Waveform waveform)
 {
     this.currentWaveform = waveform;
     layoutNewWaveform();
 }
 public void setWaveform(Waveform waveform)
 {
     this.waveform = waveform;
     this.updateGraph(this, null);
 }
 public WaveformGraph(Waveform waveform, WaveformEditor waveformEditor, bool waveformEditable)
     : this()
 {
     // TODO: Write this function.
     setWaveform(waveform);
     setWaveformEditor(waveformEditor);
     this.editable = waveformEditable;
 }