Ejemplo n.º 1
0
void ASSISTANT::Text::Draw(CDC *pDC, float _zoomFactor, double dOffX, double dOffY)
{
   if (!visible) return;
   
   if (text.IsEmpty())
      return;

   Gdiplus::Graphics graphics(pDC->m_hDC);
   graphics.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAliasGridFit);

   // Move and Scale
   graphics.TranslateTransform((Gdiplus::REAL)dOffX, (Gdiplus::REAL)dOffY);
   
   Gdiplus::Font gdipFont(pDC->m_hDC, &m_logFont);
   Gdiplus::FontFamily fontFamily;
   gdipFont.GetFamily(&fontFamily);

   int fontStyle = GetValidFontStyle(fontFamily);
   Gdiplus::REAL ascent = fontFamily.GetCellAscent(fontStyle) * 
                          (gdipFont.GetSize() / fontFamily.GetEmHeight(fontStyle));

   Gdiplus::PointF drawPoint;
   drawPoint.X = (Gdiplus::REAL)m_dX;
   drawPoint.Y = (Gdiplus::REAL)(m_dY - ascent);

   // convert text string to WCHAR format
   int iStringLength = text.GetLength();
   WCHAR *wcString = (WCHAR *)malloc((iStringLength+1)*sizeof(WCHAR)); // +1 for null termination
#ifdef _UNICODE
   wcscpy(wcString, text);
#else
   MultiByteToWideChar(CP_ACP, 0, text, iStringLength+1, 
                       wcString, iStringLength+1);
#endif

   // compute real text width
   Gdiplus::StringFormat measureStringFormat(Gdiplus::StringFormatFlagsMeasureTrailingSpaces);
   Gdiplus::RectF bbox;
   
   graphics.MeasureString(wcString, iStringLength, &gdipFont, Gdiplus::PointF(0.0, 0.0), &measureStringFormat, &bbox);

   Gdiplus::CharacterRange charRange(0, iStringLength);
   measureStringFormat.SetMeasurableCharacterRanges(1, &charRange);
   Gdiplus::Region pRangeRegion[1];
   graphics.MeasureCharacterRanges(wcString, iStringLength,
                                   &gdipFont, bbox, &measureStringFormat, 1, pRangeRegion);
   // get bounding rectangle
   Gdiplus::RectF rect;
   pRangeRegion[0].GetBounds(&rect, &graphics);

   Gdiplus::REAL realTextWidth = rect.Width;
   if (iStringLength > 1 && m_dWidth != 0 && realTextWidth != m_dWidth)
   {
      Gdiplus::REAL scaleX = (Gdiplus::REAL)(m_dWidth / realTextWidth);
      graphics.ScaleTransform(scaleX, 1.0);
      drawPoint.X = (Gdiplus::REAL)(m_dX / scaleX); //(x_*scaleX - x_);
   }
   // the text should begin at x, y
   drawPoint.X -= rect.X;

   graphics.ScaleTransform(_zoomFactor, _zoomFactor);

   Gdiplus::Color clrText(m_argbLineColor);
   Gdiplus::SolidBrush solidBrush(clrText);
   graphics.DrawString(wcString, iStringLength, &gdipFont, drawPoint, &measureStringFormat, &solidBrush);
   
   if (wcString)
      delete wcString;
}
Ejemplo n.º 2
0
	throb::throb (int32_t rate, uint8_t mode, QwtPlot *scope) {
double		half_bw;
float		*fp;
int16_t		i;

	sampleRate	= rate;
	downRate	= sampleRate / 250;
	throbMode 	= mode;
	throbscope	= scope;
	throbIF		= THROB_IF;
	afcOn		= false;
	throbReverse 	= false;
//
	for (i = 0; i < 55; i ++)
	   rxtone [i]	= NULL;

	switch (throbMode) {
	case MODE_THROB1:
	   symlen	= (SYMLEN_1 * rate / 8000);
	   rxsymlen 	= symlen / downRate;
//
//	pulse for filter
	   fp = (float *)alloca (rxsymlen * sizeof (float));
	   mk_pulse (fp, rxsymlen, HALF);
	   
	   idlesym	= 0;
	   spacesym	= 44;
	   freqs	= ThrobToneFreqsNarrow;
	   half_bw	= 36.0;
	   break;

	case MODE_THROB2:
	   symlen	= (SYMLEN_2 * rate) / 8000;
	   rxsymlen 	= symlen / downRate;
	   fp = (float *)alloca (rxsymlen * sizeof (float));
	   mk_pulse (fp, rxsymlen, HALF);

	   idlesym 	= 0;
	   spacesym 	= 44;
	   freqs	= ThrobToneFreqsNarrow;
	   half_bw	= 36.0;
	   break;

	case MODE_THROB4:
	default:
	   symlen 	= (SYMLEN_4 * rate) / 8000;
	   rxsymlen 	= symlen / downRate;
	   fp = (float *)alloca (rxsymlen * sizeof (float));
	   mk_pulse (fp, rxsymlen, FULL);
	   idlesym	= 0;
	   spacesym	= 44;
	   freqs	= ThrobToneFreqsWid;
	   half_bw	= 72.0;
	   break;

        case MODE_THROBX1:
           symlen	= (SYMLEN_1 * rate) / 8000;
	   rxsymlen 	= symlen / downRate;
	   fp = (float *)alloca (rxsymlen * sizeof (float));
           mk_pulse (fp, rxsymlen, HALF);
	   idlesym	= 0;
	   spacesym	= 1;
	   freqs	= ThrobXToneFreqsNarrow;
           half_bw	= 47.0;
	   break;

        case MODE_THROBX2:
           symlen 	= (SYMLEN_2 * rate / 8000);
	   rxsymlen 	= symlen / downRate;
	   fp = (float *)alloca (rxsymlen * sizeof (float));
           mk_pulse (fp, rxsymlen, HALF);
	   idlesym	= 0;
	   spacesym	= 1;
	   freqs	= ThrobXToneFreqsNarrow;
           half_bw	= 47.0;
           break;
	}

	ourScope	= new fft_scope (throbscope,
	                                 64,
	                                 1,
	                                 50,
	                                 256,
	                                 rxsymlen,
	                                 4);
	ourScope	-> SelectView (WATERFALL_MODE);
	fft_filter = new fftFilter (2048, 255);
	fft_filter -> setLowPass (half_bw, sampleRate);

	syncFilter	= new Basic_FIR (symlen / downRate);
	syncFilter	-> setTaps (rxsymlen, fp, NULL);

	for (i = 0; i < tonesformode (throbMode); i++)
	   rxtone[i] = mk_rxtone (freqs[i], symlen, downRate);

	metrics		= 0.0;
	thresHold	= 0;
	symptr 		= 0;
	localOscillator	= new Oscillator (sampleRate);
	for (i = 0; i < 1000; i++)
	   syncbuf [i] =  0.0;
	rxcntr 		= rxsymlen;
	waitsync 	= 1;
	deccntr 	= 0;
	symptr 		= 0;
	shift 		= 0;
	lastchar 	= '\0';
	clrText	();
}