Пример #1
0
 void AddGfx()
 {
     _frameGfx = _controller.TemporaryGraphics.DrawFrame(
         _controller.PointerOffsetTransform,
         .1,
         2);
 }
Пример #2
0
        public void DrawZone(RsMechanicalUnit mechanicalUnit)
        {
            // Draw a part that cointaions a body (sphere)
            Part part   = new Part();
            Body sphere = Body.CreateSolidSphere(new Vector3(), Decimal.ToDouble(_dimensions.Radius / 1000));

            sphere.Color = System.Drawing.Color.Purple;
            part.Bodies.Add(sphere);

            // Drawing a temporary graphic requires it to be present in the station, therefore the part is added prior to it being drawn as a temorary graphic
            // then immedietely removed from the station
            Matrix4 spherePosition = new Matrix4(new Vector3(_dimensions.x, _dimensions.y, _dimensions.z));

            Station.ActiveStation.GraphicComponents.Add(part);
            TemporaryGraphic tg = Station.ActiveStation.TemporaryGraphics.DrawPart(spherePosition, part, 0.3);

            Station.ActiveStation.GraphicComponents.Remove(part);

            if (_sphereGraphic != null)
            {
                Station.ActiveStation.TemporaryGraphics.Remove(_sphereGraphic);
                _sphereGraphic.Delete();
            }

            _sphereGraphic = tg;
        }
Пример #3
0
        public void DrawZone(RsMechanicalUnit mechanicalUnit)
        {
            // Draw a part that cointaions a body (cylinder)
            Part part     = new Part();
            Body cylinder = Body.CreateSolidCylinder(new Matrix4(new Vector3()), Decimal.ToDouble(_dimensions.Radius / 1000), Decimal.ToDouble(_dimensions.Height / 1000));

            cylinder.Color = System.Drawing.Color.Purple;
            part.Bodies.Add(cylinder);

            // Get the base frame and modify only the translation part, this way the cylinder orientation is the same as the robots orientation
            Matrix4 cylinderMatrix = mechanicalUnit.BaseFrame.GlobalMatrix;

            cylinderMatrix.Translation = new Vector3(_dimensions.x, _dimensions.y, _dimensions.z);

            // Drawing a temporary graphic requires it to be present in the station, therefore the part is added prior to it being drawn as a temorary graphic
            // then immedietely removed from the station
            Station.ActiveStation.GraphicComponents.Add(part);
            TemporaryGraphic tg = Station.ActiveStation.TemporaryGraphics.DrawPart(cylinderMatrix, part, 0.3d);

            Station.ActiveStation.GraphicComponents.Remove(part);

            if (_CylinderGraphic != null)
            {
                Station.ActiveStation.TemporaryGraphics.Remove(_CylinderGraphic);
                _CylinderGraphic.Delete();
            }

            _CylinderGraphic = tg;
        }
Пример #4
0
        void CreateBrushPlanePreview(Vector3 point, Matrix4 wobjMat)
        {
            var axis = ComputeBrushAxis();

            Vector3 v1, v2;

            switch (axis)
            {
            case Axis.X: v1 = wobjMat.GetAxisVector(Axis.Y); v2 = wobjMat.GetAxisVector(Axis.Z); break;

            case Axis.Y: v1 = wobjMat.GetAxisVector(Axis.Z); v2 = wobjMat.GetAxisVector(Axis.X); break;

            case Axis.Z: v1 = wobjMat.GetAxisVector(Axis.X); v2 = wobjMat.GetAxisVector(Axis.Y); break;

            default: throw new Exception();
            }

            double size = 0.05;

            v1    = v1 * size; v2 = v2 * size;
            point = point - v1 * 0.5 - v2 * 0.5;

            var corners = new Vector3[] { point, point + v1, point + v1 + v2, point + v2, point };

            _brushTempGfx = Station.ActiveStation.TemporaryGraphics.DrawLineStrip(corners, 1, System.Drawing.Color.FromArgb(100, 255, 255, 100));
        }
Пример #5
0
        void AddGfxPointer()
        {
            double tipLength = 0.01;
            double width     = 2;
            Color  color     = Color.Red;

            Matrix4 Roty = Matrix4.Identity; //Want to rotate 180 degrees around y-axis

            Roty.x = Roty.x * -1;
            Roty.z = Roty.z * -1;
            Matrix4 Rotz = Matrix4.Identity; //Want to rotate 90 degrees around z-axis

            Rotz.x = new Vector4(0, 1, 0, 0);
            Rotz.y = new Vector4(-1, 0, 0, 0);
            Rotz.z = new Vector4(0, 0, 1, 0);



            int    robPos = RecData.GetCurrentValue();
            double xa     = Graph.chart.Series[0].Points[robPos].XValue;

            double[] xy = Graph.chart.Series[0].Points[robPos].YValues;


            Matrix4 rcontrollerpos = _rcontroller.PointerOffsetTransform;
            Vector3 vorigin        = rcontrollerpos.Translation;
            Vector3 voriginmove    = new Vector3(RecData.GetCurrentValue() * RecData.ToolValuesList.Count() * 0.00000025 + .0415, 0.015, -0.02);
            Vector3 vstart         = vorigin + voriginmove;
            Vector3 move           = new Vector3(0, 0, 0.05);
            Vector3 vend           = vstart + move;

            _GraphPointer = _rcontroller.TemporaryGraphics.DrawArrow(vstart, vend, tipLength, width, color);
        }
Пример #6
0
        void AddGfx()
        {
            Matrix4 Roty = Matrix4.Identity; //Want to rotate 180 degrees around y-axis

            Roty.x = Roty.x * -1;
            Roty.z = Roty.z * -1;



            Matrix4 Rotz = Matrix4.Identity; //Want to rotate 90 degrees around z-axis

            Rotz.x = new Vector4(0, 1, 0, 0);
            Rotz.y = new Vector4(-1, 0, 0, 0);
            Rotz.z = new Vector4(0, 0, 1, 0);



            //_attachOffset = VrEnvironment.Session.RightController.PointerOffsetTransform * paintToolOffset * tooldata.Frame.Matrix.InverseRigid();
            Bitmap bmp = new Bitmap(@"C:\Users\Kinect\source\repos\chart1\chart1\bin\Debug\mychart.bmp");

            _frameGfx = _controller.TemporaryGraphics.DrawTexturedRectangle(_controller.PointerOffsetTransform * Rotz * Roty, .4, .2, bmp); // Fin størrelse. Må få bedre graf

            //_frameGfx = _controller.TemporaryGraphics.DrawFrame(_controller.PointerOffsetTransform,.1,2);
            //  _frameGfx = _controller.TemporaryGraphics.DrawLineStrip
        }
Пример #7
0
        public override void Update(VrUpdateArgs args)
        {
            var session = args.Session;

            if (session.SemanticInput().IsSelectPressed)
            {
                var transform = session.RightController.Transform;
                transform.CleanRigid(); //:TODO: Should not be needed. Review
                transform = transform * _attachOffset * Station.ActiveStation.ActiveTask.ActiveTool.Frame.Matrix;

                if (_pathBuilder == null)
                {
                    _pathBuilder  = new PathBuilder(Station.ActiveStation);
                    _previewTrace = Station.ActiveStation.TemporaryGraphics.DrawTrace(transform.Translation, 1, 100);
                }
                else
                {
                    _previewTrace.ContinueTrace(transform.Translation, System.Drawing.Color.LightYellow, false);
                }

                session.RightController.HapticFeedback(1);
                _pathBuilder.AddTransform(transform);
            }
            else
            {
                if (_pathBuilder != null)
                {
                    _pathBuilder.Finish();
                    _pathBuilder = null;

                    _previewTrace.Delete();
                    _previewTrace = null;
                }
            }
        }
Пример #8
0
 public static void DeleteTemporaryGraphic(TemporaryGraphic temporaryGraphic)
 {
     if (temporaryGraphic == null)
     {
         return;
     }
     Station.ActiveStation.TemporaryGraphics.Remove(temporaryGraphic);
 }
Пример #9
0
 void DeleteBrushTempGfx()
 {
     if (_brushTempGfx != null)
     {
         _brushTempGfx.Delete();
         _brushTempGfx = null;
     }
 }
Пример #10
0
        private void UpdatePreview(VrSession session)
        {
            if (_paintCone != null)
            {
                _paintCone.Delete();
            }
            var mesh = _painter.CreatePreviewGraphics();
            var pm   = session.RightController.PointerOffsetTransform;

            _paintCone = session.RightController.TemporaryGraphics.DrawMesh(pm, mesh);
        }
Пример #11
0
        void AddGfxAtStick()
        {
            if (RecData.colorList.Count == 0)
            {
                RecData.lineStyle(GetCurrentSignal());
            }
            double l = RecData.signalList[currentSignal].Count();

            for (int i = 0; i < l - 1; i++)
            {
                _PathAtStick = _rcontroller.TemporaryGraphics.DrawLine(RecData.transposList[i], RecData.transposList[i + 1], RecData.lineWidthList[i], RecData.colorList[i]);
                StickgraphList.Add(_PathAtStick);
            }
        }
Пример #12
0
        public override void Deactivate(VrSession session)
        {
            if (_painter != null)
            {
                _painter.Dispose();
                _painter = null;
            }

            if (_paintCone != null)
            {
                _paintCone.Delete();
                _paintCone = null;
            }

            _part = null;
        }
Пример #13
0
        void AddGfxAtTrack()
        {
            Station station = Project.ActiveProject as Station;

            if (TrackgraphList.Count <= 1)
            {
                RecData.lineStyle(GetCurrentSignal());
            }
            double l = RecData.signalList[GetCurrentSignal()].Count();

            for (int i = 0; i < l - 1; i++)
            {
                _PathAtTrack = station.TemporaryGraphics.DrawLine(RecData.transposList[i], RecData.transposList[i + 1], RecData.lineWidthList[i], RecData.colorList[i]);
                TrackgraphList.Add(_PathAtTrack);
            }
        }
Пример #14
0
        public void DrawZone(RsMechanicalUnit mechanicalUnit)
        {
            // Find the orientation of the robot base frame
            Vector3 orientationVector = mechanicalUnit.BaseFrame.GlobalMatrix.EulerZYX;

            // Create a Matrix4 with the same orientation as the robot base frame and the translation of the first corner of the box
            Vector3 boxTranslation = new Vector3(_dimensions.x, _dimensions.y, _dimensions.z);
            Matrix4 boxPosition    = new Matrix4(boxTranslation, orientationVector);

            // Create a Vector3 that contains the dimensions
            Vector3 dimensionVector = new Vector3()
            {
                x = Decimal.ToDouble(_dimensions.Length) / 1000,
                y = Decimal.ToDouble(_dimensions.Width) / 1000,
                z = Decimal.ToDouble(_dimensions.Height) / 1000
            };

            // Draw a part that contains a box (body)
            Part part = new Part();
            Body box  = Body.CreateSolidBox(new Matrix4(new Vector3()), dimensionVector);

            box.Color = Color.Purple;
            part.Bodies.Add(box);

            // Drawing a temporary graphic requires it to be present in the station, therefore the part is added prior to it being drawn as a temorary graphic
            // then immedietely removed from the station
            Station.ActiveStation.GraphicComponents.Add(part);
            TemporaryGraphic tg = Station.ActiveStation.TemporaryGraphics.DrawPart(boxPosition, part, 0.3);

            Station.ActiveStation.GraphicComponents.Remove(part);

            if (_boxGraphic != null)
            {
                Station.ActiveStation.TemporaryGraphics.Remove(_boxGraphic);
                _boxGraphic.Delete();
            }

            _boxGraphic = tg;
        }
Пример #15
0
        void AddGfxGraph()
        {
            new Graph().CreateChart();
            Matrix4 Roty = Matrix4.Identity; //Want to rotate 180 degrees around y-axis

            Roty.x = Roty.x * -1;
            Roty.z = Roty.z * -1;
            Matrix4 Rotz = Matrix4.Identity; //Want to rotate 90 degrees around z-axis

            Rotz.x = new Vector4(0, 1, 0, 0);
            Rotz.y = new Vector4(-1, 0, 0, 0);
            Rotz.z = new Vector4(0, 0, 1, 0);
            //Matrix4 Rotx = Matrix4.Identity;
            //Rotx.x = new Vector4()


            Bitmap bmp = new Bitmap(@"mychart.bmp");

            _GraphGfx         = _rcontroller.TemporaryGraphics.DrawTexturedRectangle(_rcontroller.PointerOffsetTransform * Rotz * Roty, .4 + RecData.signalList[0].Count() / 1000, .2, bmp);
            _GraphGfx.Topmost = true;
            //_GraphGfx = _rcontroller.TemporaryGraphics.DrawFrame(_rcontroller.PointerOffsetTransform, .1,2);
        }
Пример #16
0
        public override void Update(VrUpdateArgs args)
        {
            var     session = args.Session;
            Vector3 xorigin = _controller.PointerOffsetTransform.Translation;


            Vector3 btrans = _controller.PointerOffsetTransform.Translation;

            var rwand = VrEnvironment.Session.RightController as VrViveWandController;

            if (rwand.InputState.IsTouchPadTouched)
            {
                double u     = rwand.InputState.TouchPadPosition.u;
                double uPrev = rwand.PreviousInputState.TouchPadPosition.u;
                if ((u - uPrev) < 0 && Math.Abs(u - uPrev) >= 0.1 && btrans.x > xorigin.x)
                {
                    btrans.x = btrans.x - 10;
                    _pospointer.Delete();
                }

                else if ((u - uPrev) >= 0 && Math.Abs(u - uPrev) >= 0.1)
                {
                    btrans.x = btrans.x + 10;
                    _pospointer.Delete();
                }
            }



            Matrix4 boxpos = _controller.PointerOffsetTransform;

            boxpos.Translation = new Vector3(btrans.x, btrans.y, btrans.z);
            Vector3 box = new Vector3(.01, .01, .01);

            _pospointer = _controller.TemporaryGraphics.DrawBox(boxpos, box, Color.DarkBlue);
        }