Ejemplo n.º 1
0
        IEnumerator <Ctrl.IOperation> DragCompass(int x0, int y0)
        {
            Cursor.Current = Cursors.SizeAll;
            Geom.Point2i   pos0 = _pos;
            Ctrl.MouseMove drag = new Ctrl.MouseMove(_view.Events);
            while (true)
            {
                yield return(drag);

                if (drag.EventArgs.Button != MouseButtons.Left)
                {
                    yield break;
                }
                _pos.x = pos0.x + (drag.EventArgs.X - x0);
                _pos.y = pos0.y + (drag.EventArgs.Y - y0);
                this.FixPos();
                _view.Invalidate();
            }
        }
Ejemplo n.º 2
0
        void viewControl_MouseMove(object sender, MouseEventArgs e)
        {
            Geom.Point2i p = new Geom.Point2i(e.X, e.Y);
            if ((e.Button & MouseButtons.Left) != 0 && p != _prevPos)
            {
                Graphics.ICamera camera = viewControl.Camera;
                Geom.Vector3d    vec    = camera.ScreenToCamera(p - _prevPos);
                Geom.Vector3d    axis   = Geom.Vector3d.Ez * vec;
                double           depth  = 0.5 * camera.ViewingDepth;
                double           theta  = System.Math.Atan2(vec.Length, depth);
                Geom.Rotation3d  rot    =
                    new Geom.Rotation3d(axis.Normalize(), theta);

                Geom.HmCod3d  c = this.ActiveLight.Position;
                Geom.Vector3d d = new Geom.Vector3d(c.X, c.Y, c.Z);
                d = rot.Rotate(d);
                this.ActiveLight.Position = new Geom.HmCod3d(d.x, d.y, d.z, 0.0);
                viewControl.Invalidate();
                _docviews.Invalidate();
            }
            _prevPos = p;
        }
Ejemplo n.º 3
0
        void viewControl_MouseMove( object sender, MouseEventArgs e )
        {
            Geom.Point2i p = new Geom.Point2i( e.X, e.Y );
              if ( (e.Button & MouseButtons.Left) != 0 && p != _prevPos ) {
            Graphics.ICamera camera = viewControl.Camera;
            Geom.Vector3d vec = camera.ScreenToCamera( p - _prevPos );
            Geom.Vector3d axis = Geom.Vector3d.Ez * vec;
            double depth = 0.5 * camera.ViewingDepth;
            double theta = System.Math.Atan2( vec.Length, depth );
            Geom.Rotation3d rot =
              new Geom.Rotation3d( axis.Normalize(), theta );

            Geom.HmCod3d c = this.ActiveLight.Position;
            Geom.Vector3d d = new Geom.Vector3d( c.X, c.Y, c.Z );
            d = rot.Rotate( d );
            this.ActiveLight.Position = new Geom.HmCod3d( d.x, d.y, d.z, 0.0 );
            viewControl.Invalidate();
            _docviews.Invalidate();
              }
              _prevPos = p;
        }
Ejemplo n.º 4
0
 static Geom.Box2i MakeBox(Geom.Point2i center, int size)
 {
     Geom.Point2i lower = center - size * Geom.Vector2i.One;
     Geom.Point2i upper = center + size * Geom.Vector2i.One;
     return(new Geom.Box2i(lower, upper));
 }