Exemplo n.º 1
0
        /// <summary>
        /// Create animation info from string.
        /// </summary>
        private void CreateAnimationSteps(string animationDescription)
        {
            _animationSteps.Steps.Clear();
            string tempstr = animationDescription.Replace(System.Environment.NewLine, " ");

            string[]       entries   = tempstr.Split(' ');
            AnimationPoint currentAp = null;
            string         lastEntry = "";

            foreach (string str in entries)
            {
                switch (str.ToLower())
                {
                case "run":
                    if (currentAp != null)
                    {
                        _animationSteps.Steps.Add(currentAp);
                    }
                    currentAp = new AnimationPoint();
                    break;
                }
                switch (lastEntry.ToLower())
                {
                case "steps":
                    if (currentAp != null)
                    {
                        currentAp.Steps = int.Parse(str);
                    }
                    break;

                case "time":
                    if (currentAp != null)
                    {
                        currentAp.Time = int.Parse(str);
                    }
                    break;

                case "file":
                    if (currentAp != null)
                    {
                        currentAp.fileName = str;
                    }
                    break;
                }
                lastEntry = str;
            }
            if (currentAp != null)
            {
                _animationSteps.Steps.Add(currentAp);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Start rendering full Animation.
        /// </summary>
        private void btnStart_Click(object sender, EventArgs e)
        {
            _pictureSize     = ParameterDict.Current.GetDouble("Animation.Size");
            _animationSmooth = ParameterDict.Current.GetBool("Animation.Smooth");
            _inAnimation     = true;
            ParameterInput.MainParameterInput.SetButtonsToStart();
            CreateAnimationSteps(tbAnimationDescription.Text);
            if (_animationSteps.Steps.Count == 0)
            {
                return;
            }
            btnStart.Enabled          = false;
            btnStop.Enabled           = true;
            btnStop.Visible           = true;
            _animationAbort           = false;
            lblAnimationProgress.Text = "run ...";
            // Prepare AnimationHistory
            ParameterHistory animationHistory = new ParameterHistory();

            for (int i = 0; i < _animationSteps.Steps.Count; i++)
            {
                AnimationPoint ap = _animationSteps.Steps[i];
                _dataPerTime.Load(ap.Time);
                ParameterDict.Current.SetDouble("View.Size", _pictureSize);
                animationHistory.Save();
            }
            // Compute each Animation frame.
            for (int i = 1; i < _animationSteps.Steps.Count; i++)
            {
                AnimationPoint ap1 = _animationSteps.Steps[i - 1];
                AnimationPoint ap2 = _animationSteps.Steps[i];
                ComputeAnimationPart(ap1.Time, ap2.Time, ap2.Steps, animationHistory, i - 1);
                if (_animationAbort)
                {
                    break;
                }
            }
            if (_animationSteps.Steps.Count > 0)
            {
                ComputeAnimationPart(_animationSteps.Steps[_animationSteps.Steps.Count - 1].Time, _animationSteps.Steps[_animationSteps.Steps.Count - 1].Time, 1, animationHistory, _animationSteps.Steps.Count - 1);
            }
            btnStop.Visible           = false;
            btnStart.Enabled          = true;
            lblAnimationProgress.Text = "ready";
            _animationAbort           = false;
            _inAnimation = false;
            ParameterInput.MainParameterInput.SetButtonsToStop();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Rendering of one preview image is ready.
        /// </summary>

        void mPreview1_RenderingEnds()
        {
            if (_currentPreviewStep >= _animationSteps.Steps.Count)
            {
                _inRenderingPreview = false;
                _currentPreviewStep = 0;
                btnPreview.Enabled  = true;
                return;
            }
            if (!_inRenderingPreview)
            {
                return;
            }
            // Load data of currentPreviewStep:
            AnimationPoint   ap = _animationSteps.Steps[_currentPreviewStep];
            ParameterHistory animationHistory = new ParameterHistory();

            _dataPerTime.Load(ap.Time);
            animationHistory.Save();

            PreviewControl mPreview1 = new Fractrace.PreviewControl(0);

            mPreview1.Width    = _previewWidth;
            mPreview1.Height   = _previewHeight;
            mPreview1.Location = new System.Drawing.Point(_previewWidth * _currentPreviewStep, 0);
            pnlPreview.Controls.Add(mPreview1);
            mPreview1.ShowProgressBar = false;
            mPreview1.RenderOnClick   = false;

            AnimationStepPreview stepInfo = new AnimationStepPreview();

            stepInfo.Width    = _previewWidth;
            stepInfo.Height   = 30; // _previewHeight;
            stepInfo.Location = new System.Drawing.Point(_previewWidth * _currentPreviewStep, _previewHeight);
            pnlPreview.Controls.Add(stepInfo);
            int steps = 0;

            if (_animationSteps.Steps.Count > _currentPreviewStep + 1)
            {
                steps = _animationSteps.Steps[_currentPreviewStep + 1].Steps;
            }
            stepInfo.Init(ap.Time, steps);
            _stepPreviewControls[ap.Time] = stepInfo;
            _currentPreviewStep++;
            mPreview1.RenderingEnds += new PictureRenderingIsReady(mPreview1_RenderingEnds);
            mPreview1.Draw();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load Animation file.
        /// </summary>
        private void btnLoad_Click(object sender, EventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();

            od.Filter = "*.franim|*.franim";
            if (od.ShowDialog() == DialogResult.OK)
            {
                StreamReader sr         = new StreamReader(od.FileName, Encoding.GetEncoding("iso-8859-1"));
                String       animstring = sr.ReadToEnd();
                sr.Close();

                // Load scenes given in comment
                CreateAnimationSteps(animstring);
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < _animationSteps.Steps.Count; i++)
                {
                    AnimationPoint ap = _animationSteps.Steps[i];
                    // load file
                    if (ap.fileName != "")
                    {
                        string dir = ap.fileName.Substring(0, ap.fileName.IndexOf("pic"));
                        //picture filenename
                        string picFileName = System.IO.Path.Combine(System.IO.Path.Combine(FileSystem.Exemplar.ExportDir, dir), ap.fileName);
                        string fileName    = FileSystem.Exemplar.ExportDir + "/data/parameters/" + ap.fileName + ".gestalt";
                        if (!System.IO.File.Exists(fileName))
                        {
                            fileName = FileSystem.Exemplar.ExportDir + "/data/parameters/" + ap.fileName + ".tomo";
                        }
                        if (!System.IO.File.Exists(fileName))
                        {
                            fileName = fileName.Replace("Gestaltlupe", "Tomotrace");
                        }

                        ParameterDict.Current.Load(fileName);
                        ParameterInput.MainParameterInput.SaveHistory(picFileName);
                        // save in history
                        sb.AppendLine("Run Steps " + ap.Steps.ToString() + " Time " + ParameterInput.MainParameterInput.History.CurrentTime.ToString() + "      # File " + ap.fileName);
                    }
                }
                tbAnimationDescription.Text = sb.ToString();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Append Entry to Animation
        /// </summary>
        public void AddCurrentHistoryEntry()
        {
            AnimationPoint point = new AnimationPoint();

            point.Time  = _dataPerTime.CurrentTime;
            point.Steps = ParameterDict.Current.GetInt("Animation.Steps");
            string comment = "";

            try
            {
                string file = _dataPerTime.Get(point.Time)["Intern.FileName"];
                if (file != "")
                {
                    file    = System.IO.Path.GetFileNameWithoutExtension(file);
                    comment = "         # File " + file;
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            tbAnimationDescription.Text = tbAnimationDescription.Text + System.Environment.NewLine + "Run Steps " + point.Steps.ToString() + " Time " + point.Time.ToString() + comment;
        }