Example #1
0
        /// <summary>
        /// Start Computing. Is called while rendering an animation.
        /// </summary>
        public void Run(int updateSteps)
        {
            _currentProgress = 0;
            _master.Progress(_currentProgress);
            System.Diagnostics.Debug.WriteLine("PaintJob.Run " + updateSteps.ToString());
            _parameters       = ParameterDict.Current.Clone();
            _updateSteps      = updateSteps;
            _currentProgressd = 100.0 / (double)(_updateSteps);
            for (int i = 0; i < _updateSteps; i++)
            {
                if (_abort)
                {
                    return;
                }
                _iterate = new Iterate(_parameters, this, false);
                if (_lastIterate != null)
                {
                    _iterate.SetOldData(_lastIterate.GraphicInfo, _lastIterate.PictureData, i);
                }
                if (_abort)
                {
                    return;
                }
                _iterate.StartAsync();
                _iterate.Wait();
                if (_abort)
                {
                    return;
                }
                _lastIterate      = _iterate;
                _currentProgress += _currentProgressd;
                _master.Progress(_currentProgress);
            }
            Renderer renderer = PictureArtFactory.Create(_iterate.PictureData, _iterate.LastUsedFormulas, ParameterDict.Current.Clone());

            renderer.Paint(_graphics);
            if (_abort)
            {
                return;
            }
            _master.Progress(0);
        }
Example #2
0
 /// <summary>
 /// Create PictureArt and use it to paint the current picture according to iter.
 /// </summary>
 void DrawPicture()
 {
     if (_inPaint)
     {
         lock (_firstPaintMutex)
         {
             if (_currentPicturArt != null)
             {
                 if (!IsSubStepRendering())
                 {
                     _currentPicturArt.StopAndWait();
                     _lastPicturArt    = _currentPicturArt;
                     _currentPicturArt = null;
                 }
                 else
                 {
                     return;
                 }
             }
         }
     }
     lock (_paintMutex)
     {
         _inPaint = true;
         try
         {
             if (_currentPicturArt != null)
             {
                 System.Diagnostics.Debug.WriteLine("Error in DrawPicture() currentPicturArt != null");
             }
             if (IsFirstSubStepRendering())
             {
                 FastRenderingFilter fastRenderingFilter = null;
                 if (Fractrace.Animation.AnimationControl.InAnimation)
                 {
                     _currentPicturArt = PictureArtFactory.Create(_iterateForPictureArt.PictureData, _iterateForPictureArt.LastUsedFormulas, ParameterDict.Current.Clone());
                 }
                 else
                 {
                     fastRenderingFilter = new FastRenderingFilter();
                     _currentPicturArt   = PictureArtFactory.Create(_iterateForPictureArt.PictureData, _iterateForPictureArt.LastUsedFormulas, fastRenderingFilter.Apply());
                 }
                 _currentPicturArt.Paint(_graphics);
                 if (_currentPicturArt.Valid)
                 {
                     _lastPicturArt    = _currentPicturArt;
                     _currentPicturArt = null;
                     CallDrawImage();
                 }
                 else
                 {
                     _currentPicturArt = null;
                 }
             }
             else if (!IsSubStepRendering())
             {
                 ImageCreationStarts();
                 _currentPicturArt = PictureArtFactory.Create(_iterateForPictureArt.PictureData, _iterateForPictureArt.LastUsedFormulas, ParameterDict.Current.Clone());
                 _currentPicturArt.Paint(_graphics);
                 if (_currentPicturArt.Valid)
                 {
                     _lastPicturArt    = _currentPicturArt;
                     _currentPicturArt = null;
                     CallDrawImage();
                 }
                 else
                 {
                     _currentPicturArt = null;
                     ImageCreationEnds();
                 }
             }
         }
         catch (System.Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.ToString());
         }
         _inPaint = false;
     }
     if (_needRepaintPictureArt)
     {
         _needRepaintPictureArt = false;
         DrawPicture();
     }
 }