示例#1
0
void wxPlFrame::OnKey( wxKeyEvent &event )
{
    //This only works on Windows, unfortunately on wxGTK, wxFrames cannot catch key presses
    if ( m_locateMode )
    {
        PLNamedMutexLocker locker( &m_mutex );
        MemoryMapHeader    *header = (MemoryMapHeader *) m_memoryMap.getBuffer();

        wxSize             clientSize = GetClientSize();

        header->graphicsIn.pX = m_cursorPosition.x;
        header->graphicsIn.pY = m_cursorPosition.y;
        header->graphicsIn.dX = PLFLT( m_cursorPosition.x + 0.5 ) / PLFLT( clientSize.GetWidth() );
        header->graphicsIn.dY = 1.0 - PLFLT( m_cursorPosition.y + 0.5 ) / PLFLT( clientSize.GetHeight() );
        // gin->state = keyEvent->state;

        int keycode = event.GetKeyCode();
        header->graphicsIn.string[0] = (char) keycode;
        header->graphicsIn.string[1] = '\0';

        // ESCAPE, RETURN, etc. are already in ASCII equivalent
        header->graphicsIn.keysym = keycode;

        header->locateModeFlag = 0;
        m_locateMode           = false;
    }
}
示例#2
0
void wxPlFrame::OnMouse( wxMouseEvent &event )
{
    //save the mouse position for use in key presses
    m_cursorPosition = event.GetPosition();

    //If the mouse button was clicked then
    if ( m_locateMode && event.ButtonDown() )
    {
        PLNamedMutexLocker locker( &m_mutex );
        MemoryMapHeader    *header    = (MemoryMapHeader *) m_memoryMap.getBuffer();
        wxSize             clientSize = GetClientSize();
        //PLGraphicsIn &     graphicsIn = header->graphicsIn;
        header->graphicsIn.pX = m_cursorPosition.x;
        header->graphicsIn.pY = m_cursorPosition.y;
        header->graphicsIn.dX = PLFLT( m_cursorPosition.x + 0.5 ) / PLFLT( clientSize.GetWidth() );
        header->graphicsIn.dY = 1.0 - PLFLT( m_cursorPosition.y + 0.5 ) / PLFLT( clientSize.GetHeight() );

        if ( event.LeftDown() )
        {
            header->graphicsIn.button = 1;      // X11/X.h: #define Button1	1
            header->graphicsIn.state  = 1 << 8; // X11/X.h: #define Button1Mask	(1<<8)
        }
        else if ( event.MiddleDown() )
        {
            header->graphicsIn.button = 2;      // X11/X.h: #define Button2	2
            header->graphicsIn.state  = 1 << 9; // X11/X.h: #define Button2Mask	(1<<9)
        }
        else if ( event.RightDown() )
        {
            header->graphicsIn.button = 3;       // X11/X.h: #define Button3	3
            header->graphicsIn.state  = 1 << 10; // X11/X.h: #define Button3Mask	(1<<10)
        }

        header->graphicsIn.keysym = 0x20;                // keysym for button event from xwin.c

        header->locateModeFlag = 0;
        m_locateMode           = false;
    }
}
示例#3
0
/**
 * Write data onto the screen as some graph
 * @return Returns the number of bytes written
 * @param  buf Pointer to the buffer to write out.
 */
size_t PlpotSink::write(Buffer *buf)
{
   if (pls == NULL || settings == NULL) { return 0; }

   float* src = (float*) buf->getData();
   float  ppeak = -1e9, npeak = 1e9;
   size_t len = settings->fft_ssb_points; // len = buf->getLength() / (sizeof(float));

   float xscale;
   std::string xlabel("FFT point");
   std::string ylabel("Logarithmic Spectral Power");

   xscale = 1e-6 * settings->samplingfreq / float(settings->fft_points);
   xlabel = std::string("Video BW in MHz");

   for (size_t i=0; i<len; i++) {
      xdata[i] = xscale*PLFLT(i);
      // ydata[i] = log10(abs(*(src+0))); // Re, skip Im if data is {Re,Im}
      // src += 2;
      if (*src == 0.0f) {
          ydata[i] = 1;
      } else {
          ydata[i] = log10(abs(*(src+0)));
      } 
      src++;
      if (i > 16) {
         if (ydata[i] > ppeak) ppeak = ydata[i];
         if (ydata[i] < npeak) npeak = ydata[i];
      }
   }
   #if 0
   std::cerr << "len=" << len
             << " npeak=" << npeak
             << " ppeak=" << ppeak
             << std::endl << std::flush;
   #endif

   pls->col0(2);
   pls->schr(0,0.5);
   pls->vpor(0.1, 0.9, 0.1, 0.9);
   pls->wind(xdata[0], xdata[len-1], npeak, ppeak);
   pls->clear();
   pls->box("bcnst", 0.0, 0, "bnstv", 0.0, 0);
   pls->line(len, xdata, ydata);
   pls->lab(xlabel.c_str(), ylabel.c_str(), this->title.c_str());
   return buf->getLength();
}