Example #1
0
 public override void DrawContents(DataRecordRaw rec)
 {
     if (rec != null)
     {
         int reccount = 0;
         foreach (var data in rec.rawdata)
         {
             dispbuf.Push(data);
             offsetsamps += 1.0;
             reccount++;
         }
         interpolaterate = 0.999 * interpolaterate + 0.001 * reccount;
         if (offsetsamps > 0)
         {
             offsetsamps      = 0;
             interpolaterate *= 1.1;
         }
         if (offsetsamps < -50.0)
         {
             offsetsamps      = -50.0;
             interpolaterate *= 0.9;
         }
         //for (int i = 0; i < dispbuf.maxlen; i++)
         //    Console.Write(dispbuf[i]);
         //Console.WriteLine();
     }
     else
     {
         interpolaterate = 0.999 * interpolaterate + 0.001 * 0.0;
     }
     offsetsamps -= interpolaterate;
     RendererWrapper.DrawBaseline(boundingbox, boundingbox.Height / 2, baselinecol);
     RendererWrapper.DrawRawChannel(boundingbox, offsetsamps * samplelen, boundingbox.Height / 2, Globals.emgchannelcols[0], ref dispbuf);
 }
        public override void DrawContents(DataRecord rec)
        {
            if (rec != null)                //new record
            {
                if (rec.content[0] == 0x09) //check appuid
                {
                    state   = rec.content[8];
                    percent = AppUtils.ValueMapToDouble(rec.content[9], 0, 1);
                }
            }
            const double spacingy = 0.25, spacingx = 0.2;

            RendererWrapper.DrawPieMark(boundingbox, boundingbox.Width / 2 - spacingx * 1.5 * boundingbox.Width,
                                        boundingbox.Height / 2 + spacingy * boundingbox.Height,
                                        16, state == 0 ? percent : 0, state == 0 ? Globals.emgchannelcols[8] : coldisable, "0");

            RendererWrapper.DrawPieMark(boundingbox, boundingbox.Width / 2 - spacingx * 1.5 * boundingbox.Width,
                                        boundingbox.Height / 2 - spacingy * boundingbox.Height,
                                        16, state == 1 ? percent : 0, state == 1 ? Globals.emgchannelcols[8] : coldisable, "L");

            RendererWrapper.DrawPieMark(boundingbox, boundingbox.Width / 2 - spacingx * 0.5 * boundingbox.Width,
                                        boundingbox.Height / 2 - spacingy * boundingbox.Height,
                                        16, state == 2 ? percent : 0, state == 2 ? Globals.emgchannelcols[8] : coldisable, "R");

            RendererWrapper.DrawPieMark(boundingbox, boundingbox.Width / 2 + spacingx * 0.5 * boundingbox.Width,
                                        boundingbox.Height / 2 - spacingy * boundingbox.Height,
                                        16, state == 3 ? percent : 0, state == 3 ? Globals.emgchannelcols[8] : coldisable, "A");

            RendererWrapper.DrawPieMark(boundingbox, boundingbox.Width / 2 + spacingx * 1.5 * boundingbox.Width,
                                        boundingbox.Height / 2 - spacingy * boundingbox.Height,
                                        16, state == 4 ? percent : 0, state == 4 ? Globals.emgchannelcols[8] : coldisable, "D");
        }
Example #3
0
 //public bool animated = true;
 public void DrawBorder()
 {
     boundingbox.animateupdate(Globals.panelanimated);
     //RendererWrapper.SetBlendMode(RendererWrapper.BlendModes.Add);
     //RendererWrapper.DrawRectangle(boundingbox.ExpandTop(captionheight), bordercolor.Fade(0.5), glowradius, outer: true, glow: true);
     RendererWrapper.SetBlendMode(RendererWrapper.BlendModes.Normal);
     RendererWrapper.DrawRectangle(boundingbox, bordercolor, borderwidth, outer: true);
     RendererWrapper.DrawRectangle(boundingbox, bordercolor, -1);
     RendererWrapper.DrawRectangle(boundingbox, backgroundcolor, -1);
     RendererWrapper.DrawCaption(captionheight, boundingbox.left - borderwidth, boundingbox.top + borderwidth, caption, bordercolor);
 }
Example #4
0
 public void Draw(DataRecordRaw rec)
 {
     boundingbox.targetleft  = boundingbox.origleft * Globals.panelanimationratio;
     boundingbox.targetright = boundingbox.origright * Globals.panelanimationratio;
     DrawBorder();
     if (enablestencil)
     {
         RendererWrapper.SetStencil(boundingbox, true);
     }
     DrawContents(rec);
     RendererWrapper.SetStencil(boundingbox, false);
 }
Example #5
0
 public override void DrawContents(DataRecordRaw rec)
 {
     if (rec != null)
     {
         chplaterec[0] = rec.accelmeter[0, 0];
         chplaterec[1] = rec.accelmeter[0, 1];
         chplaterec[2] = rec.accelmeter[1, 0];
         chplaterec[3] = rec.accelmeter[1, 1];
         dispch1.Push(new PanelMotionData {
             accel = new short[3] {
                 rec.accelmeter[0, 0], rec.accelmeter[0, 1], rec.accelmeter[0, 2],
             },
             gyro = new short[3] {
                 rec.gyro[0, 0], rec.gyro[0, 1], rec.gyro[0, 2]
             }
         });
         dispch2.Push(new PanelMotionData {
             accel = new short[3] {
                 rec.accelmeter[1, 0], rec.accelmeter[1, 1], rec.accelmeter[1, 2],
             },
             gyro = new short[3] {
                 rec.gyro[1, 0], rec.gyro[1, 1], rec.gyro[1, 2]
             }
         });
     }
     for (int i = 0; i < 4; i++)
     {
         chplatedisp[i] = 0.9 * chplatedisp[i] + 0.1 * 0.2 * chplaterec[i];
     }
     RendererWrapper.Set3D(new RectangleBox(boundingbox.left, boundingbox.left + boundingbox.Width * 0.5, boundingbox.bottom + boundingbox.Height * 0.3, boundingbox.top));
     RendererWrapper.DrawPlate3D(0.0, 0, chplatedisp[0], 0, chplatedisp[1], Globals.emgchannelcols[0]);
     RendererWrapper.Set2D();
     RendererWrapper.Set3D(new RectangleBox(boundingbox.left + boundingbox.Width * 0.5, boundingbox.right, boundingbox.bottom + boundingbox.Height * 0.3, boundingbox.top));
     RendererWrapper.DrawPlate3D(0.0, 0, chplatedisp[2], 0, chplatedisp[3], Globals.emgchannelcols[0]);
     RendererWrapper.Set2D();
     RendererWrapper.DrawGyroChannel(new RectangleBox(
                                         boundingbox.left + 20, boundingbox.left + boundingbox.Width * 0.5 - 20,
                                         boundingbox.bottom, boundingbox.bottom + boundingbox.Height * 0.3
                                         )
                                     , 0, boundingbox.Height * 0.25, ref dispch1);
     RendererWrapper.DrawGyroChannel(new RectangleBox(
                                         boundingbox.left + boundingbox.Width * 0.5 + 20, boundingbox.right - 20,
                                         boundingbox.bottom, boundingbox.bottom + boundingbox.Height * 0.3
                                         )
                                     , 0, boundingbox.Height * 0.25, ref dispch2);
 }
Example #6
0
 public override void DrawContents(DataRecord rec)
 {
     if (rec != null)
     {
         if (rec.content[0] == 0x01)
         {
             xspp = (rec.content[1] - 128) / 10.0;
             yspp = (rec.content[2] - 128) / 10.0;
         }
     }
     xsp = 0.8 * xsp + 0.2 * xspp;
     ysp = 0.8 * ysp + 0.2 * yspp;
     RendererWrapper.DrawCoordinate(boundingbox, new RGBAColor(1, 1, 1, 0.3));
     RendererWrapper.DrawArrow(boundingbox, new Point2D(boundingbox.Width / 2, boundingbox.Height / 2),
                               new Point2D(boundingbox.Width / 2 + 7 * xsp, boundingbox.Height / 2 + 7 * ysp),
                               Globals.emgchannelcols[8], thickness: 2, headsize: 25);
 }
Example #7
0
        static void init_graphics()
        {
            //Gl.glEnable(Gl.GL_LIGHTING);
            //Gl.glEnable(Gl.GL_LIGHT0);
            //float[] light_pos = new float[3] { 1, 0.5F, 1 };
            //Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, light_pos);
            Gl.glEnable(Gl.GL_COLOR_MATERIAL);
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            //Gl.glEnable(Gl.GL_STENCIL_TEST);
            Gl.glEnable(Gl.GL_BLEND);
            RendererWrapper.SetBlendMode(RendererWrapper.BlendModes.Normal);
            Gl.glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
            Gl.glClearDepth(1.0);

            Wgl.wglSwapIntervalEXT(-1);

            Globals.thserial.Start();
            Globals.thapp.Start();
            Debug.Print(Wgl.wglGetSwapIntervalEXT().ToString());
        }
        public override void UpdateGraphics()
        {
            if (!inapp)
            {
                boundingbox.targetleft  = boundingbox.origleft * Globals.panelanimationratio;
                boundingbox.targetright = boundingbox.origright * Globals.panelanimationratio;
            }
            else
            {
                boundingbox.origleft = boundingbox.targetright - 1;
            }

            boundingbox.animateupdate(Globals.panelanimated);
            if (hover)
            {
                animationratio = 0.7 * animationratio + 0.3 * 0.2;
            }
            else
            {
                animationratio = 0.7 * animationratio + 0.3 * 0.0;
            }
            RectangleBox highlight = new RectangleBox(boundingbox.left, boundingbox.right, boundingbox.bottom,
                                                      animationratio * boundingbox.top + (1 - animationratio) * boundingbox.bottom);

            if (!border)
            {
                RendererWrapper.DrawRectangle(boundingbox, col, -1);
                RendererWrapper.DrawRectangle(highlight, col.Mix(col, new RGBAColor(1, 1, 1, 1), 0.5), -1);
            }
            else
            {
                RendererWrapper.DrawRectangle(boundingbox, new RGBAColor(0, 0, 0, 1), -1);
                RendererWrapper.DrawRectangle(highlight, col.Mix(col, new RGBAColor(1, 1, 1, 1), 0.5), -1);
                RendererWrapper.DrawRectangle(boundingbox, col, 2);
            }
            RendererWrapper.DrawString(boundingbox.left + 16, boundingbox.bottom + boundingbox.Height / 2 - 12.0 / 2, caption, new RGBAColor(1.0, 1.0, 1.0, 1.0));
        }
        public override void DrawContents(DataRecord rec)
        {
            if (rec != null)                    //new record
            {
                if (rec.content[0] == 0x09)     //check appuid
                {
                    if (rec.content[1] == 0x01) //mouse enabled
                    {
                        xspp = AppUtils.ValueMapToDouble(rec.content[2], -15, 15);
                        yspp = AppUtils.ValueMapToDouble(rec.content[3], -15, 15);
                    }
                    mxspp  = -AppUtils.ValueMapToDouble(rec.content[4], -15, 15);
                    myspp  = AppUtils.ValueMapToDouble(rec.content[5], -15, 15);
                    mxsoff = -AppUtils.ValueMapToDouble(rec.content[6], -15, 15);
                    mysoff = AppUtils.ValueMapToDouble(rec.content[7], -15, 15);
                }
            }
            xsp  = 0.8 * xsp + 0.2 * xspp;
            ysp  = 0.8 * ysp + 0.2 * yspp;
            mxsp = 0.8 * mxsp + 0.2 * mxspp;
            mysp = 0.8 * mysp + 0.2 * myspp;
            RendererWrapper.DrawCoordinate(boundingbox, new RGBAColor(1, 1, 1, 0.3));
            List <Point2D> mpts = new List <Point2D>();

            mpts.Add(new Point2D(boundingbox.Width / 2 + 7 * mxsoff, boundingbox.Height / 2));
            mpts.Add(new Point2D(boundingbox.Width / 2, boundingbox.Height / 2 + 7 * mysoff));
            RendererWrapper.DrawMarkers(boundingbox, mpts, Globals.emgchannelcols[7], 0, 10);
            RendererWrapper.DrawArrow(boundingbox, new Point2D(boundingbox.Width / 2, boundingbox.Height / 2),
                                      new Point2D(boundingbox.Width / 2 + 7 * mxsp - 7 * mxsoff, boundingbox.Height / 2),
                                      Globals.emgchannelcols[7], thickness: 2, headsize: 10);
            RendererWrapper.DrawArrow(boundingbox, new Point2D(boundingbox.Width / 2, boundingbox.Height / 2),
                                      new Point2D(boundingbox.Width / 2, boundingbox.Height / 2 + 7 * mysp - 7 * mysoff),
                                      Globals.emgchannelcols[7], thickness: 2, headsize: 10);
            RendererWrapper.DrawArrow(boundingbox, new Point2D(boundingbox.Width / 2, boundingbox.Height / 2),
                                      new Point2D(boundingbox.Width / 2 + 7 * xsp, boundingbox.Height / 2 + 7 * ysp),
                                      Globals.emgchannelcols[8], thickness: 2, headsize: 25);
        }
Example #10
0
 static void on_reshape(int w, int h)
 {
     RendererWrapper.Set2D(w, h);
 }
Example #11
0
        public override void DrawContents(DataRecordRaw rec)
        {
            if (rec != null)
            {
                dispbuf.Push(new PanelEMGData {
                    amp = rec.emgamplitude, freq = rec.emgfrequency
                });
                offsetsamps += 1.0;
                if (offsetsamps > 0)
                {
                    offsetsamps      = 0;
                    interpolaterate *= 1.1;
                }
                if (offsetsamps < -2.0)
                {
                    offsetsamps      = -2.0;
                    interpolaterate *= 0.99;
                }
                interpolaterate = 0.995 * interpolaterate + 0.005 * 1.0;
                //Console.WriteLine(interpolaterate);
                //Console.WriteLine(offsetsamps);
            }
            else
            {
                interpolaterate = 0.995 * interpolaterate + 0.005 * 0.0;
            }
            offsetsamps -= interpolaterate;
            for (int i = 1; i <= 8; i++)
            {
                RendererWrapper.DrawBaseline(boundingbox, boundingbox.Height - boundingbox.Height * i / 9.0, baselinecol);
                RendererWrapper.DrawEMGChannel(boundingbox, offsetsamps * samplelen, boundingbox.Height - boundingbox.Height * i / 9.0,
                                               Globals.emgchannelcols[i - 1], ref dispbuf, i - 1, i == 1);

                bool excited = dispbuf[dispbuf.maxlen - 1].amp[i - 1] > 0;
                RendererWrapper.DrawChannelLabel(boundingbox, 35, boundingbox.Height - boundingbox.Height * i / 9.0,
                                                 Globals.emgchannelcols[i - 1], "CH" + i.ToString(), excited);

                if (excited)
                {
                    effectstrengthslow[i - 1] = 0.9 * effectstrengthslow[i - 1] + 0.1 * 0.5;
                    if (0.2 * dispbuf[dispbuf.maxlen - 1].amp[i - 1] / 255.0 > effectstrengthfast[i - 1])
                    {
                        effectstrengthfast[i - 1] = 0.5 * effectstrengthfast[i - 1] + 0.5 * 0.3 * dispbuf[dispbuf.maxlen - 1].amp[i - 1] / 255.0;
                    }
                }
                else
                {
                    effectstrengthslow[i - 1] = 0.99 * effectstrengthslow[i - 1];
                }
                effectstrengthfast[i - 1] = 0.9 * effectstrengthfast[i - 1];
                RendererWrapper.DrawEffectExcitation(
                    new RectangleBox(
                        boundingbox.left,
                        boundingbox.right,
                        boundingbox.bottom + boundingbox.Height * (9 - i) / 9.0 - boundingbox.Height / 18.0,
                        boundingbox.bottom + boundingbox.Height * (10 - i) / 9.0 - boundingbox.Height / 18.0
                        ),
                    new RGBAColor(0, 122.0 / 255, 204.0 / 255, 0.7),
                    effectstrengthslow[i - 1]);
                RendererWrapper.DrawEffectExcitation(
                    new RectangleBox(
                        boundingbox.left,
                        boundingbox.right,
                        boundingbox.bottom + boundingbox.Height * (9 - i) / 9.0 - boundingbox.Height / 18.0,
                        boundingbox.bottom + boundingbox.Height * (10 - i) / 9.0 - boundingbox.Height / 18.0
                        ),
                    new RGBAColor(1, 1, 1, 0.9),
                    effectstrengthfast[i - 1]);
                //Console.Write(dispbuf[0].amp[i-1].ToString()+" ");
            }

            /*if (rec != null) {
             *  for (int i = 0; i < 256; i++)
             *      Console.Write(dispbuf[i].amp[0].ToString());
             *  Console.WriteLine();
             * }*/
            //Console.WriteLine();
        }
Example #12
0
        public override void DrawContents(DataRecord rec)
        {
            if (rec != null)
            {
                if (rec.content[0] == 0x01)
                {
                    xsp = (rec.content[1] - 128) / 50.0;
                    ysp = (rec.content[2] - 128) / 50.0;
                    if (rec.content[3] == 0x01)
                    {
                        particles.Add(new Particle(Particle.ParticleShapes.Cross, new RGBAColor(1.0, 0.5, 0.0, 1.0),
                                                   600, 7, 7, cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2,
                                                   lifefade_: 200
                                                   ));
                        particles.Add(new Particle(Particle.ParticleShapes.Diamond, new RGBAColor(1.0, 0.5, 0.0, 1.0),
                                                   30, 3, 3, cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2,
                                                   lifefade_: 30, xscalef_: 15, yscalef_: 15, bm_: RendererWrapper.BlendModes.Add, aseyecandy_: true
                                                   ));
                        //leftclicks.Add(new Point2D(cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2));
                    }
                    if (rec.content[4] == 0x01)
                    {
                        particles.Add(new Particle(Particle.ParticleShapes.Cross, new RGBAColor(0.0, 0.3, 1.0, 1.0),
                                                   600, 7, 7, cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2,
                                                   lifefade_: 200
                                                   ));
                        particles.Add(new Particle(Particle.ParticleShapes.Diamond, new RGBAColor(0.0, 0.3, 1.0, 1.0),
                                                   30, 3, 3, cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2,
                                                   lifefade_: 30, xscalef_: 15, yscalef_: 15, bm_: RendererWrapper.BlendModes.Add, aseyecandy_: true
                                                   ));
                        //rightclicks.Add(new Point2D(cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2));
                    }
                }
            }
            cursorpos.x += xsp;
            cursorpos.y += ysp;
            if (cursorpos.x > boundary)
            {
                cursorpos.x = boundary;
            }
            if (cursorpos.x < -boundary)
            {
                cursorpos.x = -boundary;
            }
            if (cursorpos.y > boundary)
            {
                cursorpos.y = boundary;
            }
            if (cursorpos.y < -boundary)
            {
                cursorpos.y = -boundary;
            }
            List <Point2D> curpos = new List <Point2D>();

            curpos.Add(new Point2D(cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2));
            RendererWrapper.DrawCoordinate(boundingbox, new RGBAColor(1, 1, 1, 0.3));
            //RendererWrapper.DrawMarkers(boundingbox, leftclicks, new RGBAColor(1.0, 0.5, 0.0, 1.0), 1, 8);
            //RendererWrapper.DrawMarkers(boundingbox, rightclicks, new RGBAColor(0.0, 0.3, 1.0, 1.0), 1, 8);
            RendererWrapper.DrawParticles(boundingbox, particles);
            RendererWrapper.DrawMarkers(boundingbox, curpos, new RGBAColor(Globals.emgchannelcols[8]), 0, 8);
        }