Ejemplo n.º 1
0
        protected void Rescale(Size size)
        {
            Size3D hullSize = m_Hull.GetSize();

            // Scale all the points to fit in the canvas
            double scale1 = size.Width / hullSize.X;
            double scale2 = size.Height / hullSize.Y;

            double new_scale = 0.9 * Math.Min(scale1, scale2);

            Debug.WriteLine("HullDsiplay.Rescale: ({0}) {1} {2} {3} ({4})", size, m_scale, new_scale, m_scale * new_scale, hullSize);
            m_scale *= new_scale;

            m_Hull.Scale(new_scale, new_scale, new_scale);

            if (m_handles != null)
            {
                List <Rect> newHandles = new List <Rect>();
                foreach (Rect rect in m_handles)
                {
                    Point p = new Point();
                    p.X = rect.Location.X * new_scale;
                    p.Y = rect.Location.Y * new_scale;

                    newHandles.Add(new Rect(p, rect.Size));
                }

                m_handles = newHandles;
            }
        }
Ejemplo n.º 2
0
        private void ResizeClick(object sender, RoutedEventArgs e)
        {
            Size3D originalSize = myHull.GetSize();

            originalSize.X *= 2;    // compensate because this is a half-hull

            ResizeWindow resize = new ResizeWindow(myHull);

            resize.ShowDialog();

            if (resize.OK)
            {
                ResizeWindowData resizeData = (ResizeWindowData)resize.FindResource("ResizeData");
                double           scale_x    = 1.0;
                double           scale_y    = 1.0;
                double           scale_z    = 1.0;

                if (resizeData != null)
                {
                    scale_x = resizeData.Width / originalSize.X;
                    scale_y = resizeData.Height / originalSize.Y;
                    scale_z = resizeData.Length / originalSize.Z;

                    myHull.Scale(scale_x, scale_y, scale_z);
                    UpdateDisplays();
                }
            }
        }