Exemplo n.º 1
0
 public ResampleCmd(ref Sketch.Sketch sketch, ref LabelerPanel lp, ref Substroke original, int numPts)
 {
     _sketch = sketch;
     _lp     = lp;
     _ss     = original;
     _pts    = numPts;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="fStrokeToCorners">FeatureStrokes to fragment points</param>
        /// <param name="labelerPanel">LabelerPanel</param>
        public CommitHandFragmentCmd(Dictionary <Sketch.Stroke, List <int> > fragStrokeToCorners, LabelerPanel labelerPanel)
        {
            this.labelerPanel        = labelerPanel;
            this.fragStrokeToCorners = new Dictionary <Sketch.Stroke, List <int> >(fragStrokeToCorners);
            this.oldStrokeToCorners  = new Dictionary <Sketch.Stroke, List <int> >();

            foreach (KeyValuePair <Sketch.Stroke, List <int> > entry in this.fragStrokeToCorners)
            {
                try
                {
                    this.oldStrokeToCorners[entry.Key] =
                        this.labelerPanel.LTool.StrokeToCorners[entry.Key];
                }

                catch (KeyNotFoundException e)
                {
                    continue;
                }
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="labelerPanel">LabelerPanel holding the Strokes to fragment</param>
        public AutoFragmentCmd(LabelerPanel labelerPanel)
        {
            this.labelerPanel = labelerPanel;
            Sketch.Stroke[] strokes = this.labelerPanel.Sketch.Strokes;

            this.oldStrokeToCorners = new Dictionary <Sketch.Stroke, List <int> >(strokes.Length);
            foreach (Sketch.Stroke stroke in strokes)
            {
                List <int> corners;
                if (this.labelerPanel.LTool.StrokeToCorners.TryGetValue(stroke, out corners))
                {
                    this.oldStrokeToCorners.Add(stroke, corners);
                }
            }

            this.strokeToCorners = new Dictionary <Sketch.Stroke, List <int> >();

            // Initialize the FeatureStrokes
            FeatureStroke[] featureStrokes = new FeatureStroke[strokes.Length];
            for (int i = 0; i < featureStrokes.Length; i++)
            {
                featureStrokes[i] = new FeatureStroke(strokes[i]);
            }

            for (int i = 0; i < featureStrokes.Length; i++)
            {
                List <int> currCorners = new List <int>();

                int[] corners = new Corners(featureStrokes[i]).FindCorners();

                if (corners.Length > 0)
                {
                    this.strokeToCorners.Add(strokes[i], new List <int>(corners));
                }
                else
                {
                    this.strokeToCorners.Add(strokes[i], new List <int>());
                }
            }
        }