Ejemplo n.º 1
0
BOOL DrawItem(WPARAM wParam, LPARAM lParam)
{
    LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
    UINT state = lpdi->itemState;
    RECT rect = lpdi->rcItem;
    HDC hdc = lpdi->hDC;

    switch (wParam)
    {
	// Scale

    case SCALE_ID:
	DrawScale(hdc, rect, state);
	break;

	// Display

    case DISPLAY_ID:
	DrawDisplay(hdc, rect, state);
	break;

	// Knob

    case KNOB_ID:
	DrawKnob(hdc, rect, state);
	break;
    }
}
Ejemplo n.º 2
0
void DrawPlot(QLabel* plot, QVector<int> values)
{
    QPixmap pm(350, 510);
    QPoint Center(10, pm.height() - 20);
    QPainter painter(&pm);

    pm.fill(Qt::white);
    DrawScale(painter, Center, pm.height() - 20, pm.width() - 20);
    DrawFigure(painter, Center, values);
    painter.end();
    plot->setGeometry(200, 40, pm.width(), pm.height());
    plot->setPixmap(pm);
    plot->show();
}
Ejemplo n.º 3
0
/* {{{ proto bool GmagickDraw::scale(float x, float y)
	Adjusts the scaling factor to apply in the horizontal and vertical directions to the current coordinate space.
*/
PHP_METHOD(gmagickdraw, scale)
{
	php_gmagickdraw_object *internd;
	double x, y;

	/* Parse parameters given to function */
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd", &x, &y) == FAILURE) {
		return;
	}

	internd = (php_gmagickdraw_object *) zend_object_store_get_object(getThis() TSRMLS_CC);

	DrawScale(internd->drawing_wand, x, y);
	GMAGICK_CHAIN_METHOD;
}
Ejemplo n.º 4
0
static void momToSpaceCB(Widget w, SpaceWindow *window,caddr_t call_data)
{
     int sliderValue;
     char line[40];
     XmString s1;
     float curval;
     
    if (window->filename == NULL) return;
     
    XtVaGetValues(w, XmNvalue, &sliderValue, 0);
    curval = 
         sliderValue * (window->maxMomToSpace)/SLIDER_MAX;
    if (curval == window->currentMomToSpace)  return;
    window->currentMomToSpace = curval;
    sprintf(line,"P to Dist = %12.5e",curval);
    s1=XmStringCreateSimple(line);
    XtVaSetValues(window->momToSpaceSliderValue, XmNlabelString, s1, 0);
    XmStringFree(s1);
    DrawEvent((StdHepWindow *) window, False);
    DrawScale((StdHepWindow *) window);
}
Ejemplo n.º 5
0
BOOL DrawItem(WPARAM wParam, LPARAM lParam)
{
    LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
    UINT state = lpdi->itemState;
    RECT rect = lpdi->rcItem;
    HDC hdc = lpdi->hDC;

    SetGraphicsMode(hdc, GM_ADVANCED);

    switch (wParam)
    {
	// Scale

    case SCALE_ID:
	return DrawScale(hdc, rect);
	break;

	// Spectrum

    case SPECTRUM_ID:
	return DrawSpectrum(hdc, rect);
	break;

	// Display

    case DISPLAY_ID:
	return DrawDisplay(hdc, rect);
	break;

	// Meter

    case METER_ID:
	return DrawMeter(hdc, rect);
	break;
    }
}
Ejemplo n.º 6
0
static void resizeCB(Widget w, SpaceWindow *window, caddr_t call_data)
{
    DrawScale((StdHepWindow *) window);
}
Ejemplo n.º 7
0
static void scaleDownCB(Widget w, SpaceWindow *window, caddr_t call_data)
{
    SpinSetScale(window->spin, SpinGetScale(window->spin) * (4./5.));
    DrawScale((StdHepWindow *) window);
}
Ejemplo n.º 8
0
static MagickBooleanType ScribbleImage (MagickWand *canvas)
{
  DrawingWand
    *picasso;

  PixelWand
    *color;

  picasso=NewDrawingWand();
  color=NewPixelWand();
  (void) PushDrawingWand(picasso);
  {
    DrawSetViewbox(picasso,0,0,(ssize_t) MagickGetImageWidth(canvas),
      (ssize_t) MagickGetImageHeight(canvas));
    DrawScale(picasso,1.101,1.08);
    DrawTranslate(picasso,-23.69,-22.97);
    DrawRotate(picasso,0);
    (void) PixelSetColor(color,"#ffffff");
    DrawSetFillColor(picasso,color);
    DrawRectangle(picasso,23.69,22.97,564.6,802.2);
    DrawSetFillAlpha(picasso,1.0);
    (void) PixelSetColor(color,"none");
    DrawSetFillColor(picasso,color);
    DrawSetStrokeColor(picasso,color);
    DrawSetStrokeAntialias(picasso,MagickTrue);
    DrawSetStrokeLineCap(picasso,RoundCap);
    DrawSetStrokeLineJoin(picasso,RoundJoin);
    DrawPushDefs(picasso);
    {
      DrawPushClipPath(picasso,"clip_1");
      {
        (void) PushDrawingWand(picasso);
        {
          DrawRectangle(picasso,0,0,595.3,841.9);
        }
        (void) PopDrawingWand(picasso);
      }
      DrawPopClipPath(picasso);
    }
    DrawPopDefs(picasso);
    (void) PushDrawingWand(picasso);
    {
      (void) DrawSetClipPath(picasso, "url(#clip_1)");

      (void) PushDrawingWand(picasso);
      {
        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,4.032);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#ff0000");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#ff00ff");
        DrawSetFillColor(picasso,color);
        DrawRectangle(picasso,72,72,144,144);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,9);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#00ff00");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#0080ff");
        DrawSetFillColor(picasso,color);
        DrawRoundRectangle(picasso,72,216,360,432,9,9);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        const PointInfo points[37] =
        {
          { 378.1,81.72 }, { 381.1,79.56 }, { 384.3,78.12 }, { 387.6,77.33 },
          { 391.1,77.11 }, { 394.6,77.62 }, { 397.8,78.77 }, { 400.9,80.57 },
          { 403.6,83.02 }, { 523.9,216.8 }, { 526.2,219.7 }, { 527.6,223 },
          { 528.4,226.4 }, { 528.6,229.8 }, { 528,233.3 },   { 526.9,236.5 },
          { 525.1,239.5 }, { 522.6,242.2 }, { 495.9,266.3 }, { 493,268.5 },
          { 489.7,269.9 }, { 486.4,270.8 }, { 482.9,270.9 }, { 479.5,270.4 },
          { 476.2,269.3 }, { 473.2,267.5 }, { 470.4,265 },   { 350,131.2 },
          { 347.8,128.3 }, { 346.4,125.1 }, { 345.6,121.7 }, {345.4,118.2 },
          { 346,114.8 },   { 347.1,111.5 }, { 348.9,108.5 }, { 351.4,105.8 },
          { 378.1,81.72 }
        };

        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,2.016);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#000080");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#c2c280");
        DrawSetFillColor(picasso,color);
        DrawPolygon(picasso,37,points);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,3.024);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#000080");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#000080");
        DrawSetFillColor(picasso,color);
        DrawEllipse(picasso,489.6,424.8,72,129.6,0,360);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        const PointInfo points[48] =
        {
          { 213.8,25.13},  { 216.7,24.48 }, {219.8,24.55 },  { 223.1,25.42 },
          { 226.7,27 },    { 230.3,29.3 },  { 234.1,32.26 }, { 237.9,35.86 },
          { 241.8,40.03 }, { 249.7,50.11 }, { 257.4,62.14 }, { 264.8,75.89 },
          { 271.6,91.15 }, { 277.3,106.8 }, { 281.6,121.8 }, { 284.4,135.9 },
          { 285.7,148.5 }, { 285.6,159.6 }, { 284.9,164.3 }, { 283.8,168.5 },
          { 282.5,172.1 }, { 280.7,175 },   { 278.5,177.3 }, { 275.9,178.7 },
          { 273,179.4 },   { 269.9,179.3 }, { 266.6,178.4 }, { 263.1,176.8 },
          { 259.5,174.5},  { 255.7,171.6 }, { 251.9,168 },   { 248,163.8 },
          { 244.1,159 },   { 240.1,153.7 }, { 232.3,141.7 }, { 225,127.9 },
          { 218.2,112.7 }, { 212.5,97.06 }, { 208.2,82.01 }, { 205.4,67.97 },
          { 204,55.3 },    { 204.3,44.35 }, { 204.9,39.6 },  { 205.9,35.42 },
          { 207.4,31.82 }, { 209.2,28.87 }, { 211.3,26.64},  { 213.8,25.13 }
        };

        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,3.024);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#ff8000");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#00ffff");
        DrawSetFillColor(picasso,color);
        DrawPolygon(picasso,48,points);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,12.02);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#4000c2");
        DrawSetStrokeColor(picasso,color);
        (void) PixelSetColor(color,"none");
        DrawSetFillColor(picasso,color);
        DrawArc(picasso,360,554.4,187.2,237.6,0,90);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,9);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#4000c2");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#4000c2");
        DrawSetFillColor(picasso,color);
        DrawEllipse(picasso,388.8,626.4,100.8,122.4,0,90);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        const PointInfo points[6] =
        {
          { 180,504 }, { 282.7,578.6 }, { 243.5,699.4 }, { 116.5,699.4 },
          { 77.26,578.6 }, { 180,504 }
        };

        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,9);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#4000c2");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#800000");
        DrawSetFillColor(picasso,color);
        DrawPolygon(picasso,6,points);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        const PointInfo points[11] =
        {
          { 180,504 },     { 211.8,568.3 }, { 282.7,578.6 }, { 231.3,628.7 },
          { 243.5,699.4 }, { 180,666 },     { 116.5,699.4 }, { 128.7,628.7 },
          { 77.26,578.6 }, { 148.2,568.3 }, { 180,504 }
        };

        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,9);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#4000c2");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#800000");
        DrawSetFillColor(picasso,color);
        DrawPolygon(picasso,11,points);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        const PointInfo points[15] =
        {
          { 540,288 },     { 561.6,216 },   { 547.2,43.2 },  { 280.8,36 },
          { 302.4,194.4 }, { 331.2,64.8 },  { 504,64.8 },    { 475.2,115.2 },
          { 525.6,93.6 },  { 496.8,158.4 }, { 532.8,136.8 }, { 518.4,180 },
          { 540,172.8 },   { 540,223.2 },   { 540,288 }
        };

        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,5.976);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#4000c2");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#ffff00");
        DrawSetFillColor(picasso,color);
        DrawPolygon(picasso,15,points);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        const PointInfo points[7] =
        {
          { 57.6,640.8 }, { 57.6,784.8 }, { 194.4,799.2 }, { 259.2,777.6 },
          { 151.2,756 }, { 86.4,748.8 }, { 57.6,640.8 }
        };

        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,5.976);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#4000c2");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#ffff00");
        DrawSetFillColor(picasso,color);
        DrawPolygon(picasso,7,points);
      }
      (void) PopDrawingWand(picasso);
      (void) PushDrawingWand(picasso);
      {
        const PointInfo points[193] =
        {
          { 27.86,565.3 }, { 29.66,550.8 }, { 31.97,538.1 }, { 34.85,527.1 },
          { 38.09,517.7 }, { 41.83,509.8 }, { 45.86,503.1 }, { 50.33,497.6 },
          { 55.08,493.2 }, { 60.19,489.8 }, { 65.45,487.3 }, { 70.92,485.4 },
          { 76.61,484.2 }, { 88.42,483 },   { 100.4,482.9 }, { 108.4,482.2 },
          { 119.8,480.3 }, { 150.8,474.1 }, { 189.4,466.6 }, { 210.3,463 },
          { 231.5,459.9 }, { 252.4,457.8 }, { 272.7,456.6 }, { 291.8,456.9 },
          { 300.7,457.7 }, { 309.1,458.9 }, { 316.9,460.6 }, { 324.1,462.8 },
          { 330.7,465.6 }, { 336.4,469 },   { 341.3,473 },   { 345.3,477.7 },
          { 348.4,483.1 }, { 350.4,489.2},  { 352.4,495.4 }, { 355.2,500.9 },
          { 358.8,505.8 }, { 363,510 },     { 367.8,513.6 }, { 373,516.8 },
          { 378.6,519.6 }, { 384.3,521.8 }, { 396.4,525.4 }, { 408.2,527.9 },
          { 428,531.2 },   { 434.6,532.9 }, { 436.7,533.8 }, { 437.8,534.9 },
          { 437.8,536.2 }, { 436.8,537.8 }, { 434.5,539.6 }, { 430.9,541.8 },
          { 419.3,547.6 }, { 401.3,555.2 }, { 342.4,577.9 }, {325.2,584.9 },
          { 311,591.3 },   { 300,597.3 },   { 291.6,602.8 }, { 285.8,607.8 },
          { 282.3,612.3 }, { 281.4,614.4 }, { 280.9,616.2 }, { 281.2,619.6 },
          { 282.1,621.2 }, { 283.3,622.6 }, { 286.8,624.9 }, { 291.5,626.6 },
          { 297.1,627.8 }, { 303.6,628.3 }, { 310.5,628.3 }, { 317.9,627.6 },
          { 325.2,626.3 }, { 332.6,624.3 }, { 339.5,621.7 }, { 345.9,618.4 },
          { 351.4,614.4 }, { 353.9,612.2 }, { 356,609.8 }, { 357.9,607.1 },
          { 359.4,604.3 }, { 360.6,601.3 }, { 361.4,598.2 }, { 361.7,594.9 },
          { 361.7,591.3 }, { 361.2,587.7 }, { 360.1,583.7 }, { 358.6,579.7 },
          { 356.4,575.4 }, { 353.7,570.9 }, { 350.4,566.2 }, { 346.4,561.3 },
          { 341.8,556.2 }, { 336.5,550.9 }, { 330.6,545.5 }, { 323.8,539.8 },
          { 316.2,533.9 }, { 298.7,521.5 }, { 277.8,508.2 }, { 256.1,495.5 },
          { 236,484.5 },   { 217.7,475.1 }, { 200.8,467.1 }, { 185.6,460.7 },
          { 171.9,455.5 }, { 159.6,451.6 }, { 148.6,448.8 }, { 139,447 },
          { 130.5,446.2 }, { 123.3,446.2 }, { 117.1,446.9 }, { 112,448.3 },
          { 107.9,450.2 }, { 104.8,452.5 }, { 102.5,455.2 }, { 101,458.1 },
          { 100.2,461.2 }, { 100.2,464.3 }, { 100.7,467.4 }, { 101.8,470.3 },
          { 103.4,473 },   { 105.4,475.3 }, { 107.8,477.1 }, { 110.5,478.4 },
          { 113.4,479.1 }, { 116.5,478.9 }, { 119.7,478 },   { 123,476.2 },
          { 126.4,473.3 }, { 129.6,469.2 }, { 132.7,463.9 }, { 135.2,458.4 },
          { 136.6,453.7 }, { 137,449.9 },   { 136.6,446.8 }, { 135.4,444.5 },
          { 133.3,442.9 }, { 130.8,441.9 }, { 127.5,441.4 }, { 123.9,441.6 },
          { 119.8,442.3 }, { 110.7,445.1 }, { 101.1,449.5 }, { 91.37,455.2 },
          { 82.37,461.9 }, { 74.66,469.2 }, { 71.57,473 },   { 68.98,476.8 },
          { 67.03,480.7 }, { 65.81,484.4 }, { 65.45,488.2 }, { 65.95,491.7 },
          { 67.46,495.1 }, { 69.98,498.3 }, { 73.66,501.3 }, { 78.55,503.9 },
          { 84.82,506.3 }, { 92.38,508.2 }, { 107.1,511.6 }, { 118.2,514.8 },
          { 125.9,517.8 }, { 130.7,520.4 }, { 132.1,521.7 }, { 132.8,522.9 },
          { 133,524.2 },   { 132.6,525.3 }, { 131.8,526.5 }, { 130.5,527.5 },
          { 126.6,529.6 }, { 121.5,531.7 }, { 115.3,533.7 }, { 101.4,537.6 },
          { 87.55,541.8 }, { 81.36,544 },   { 76.25,546.3 }, { 71.64,549.5 },
          { 66.89,554.1 }, { 62.14,559.8 }, { 57.38,566.1 }, { 48.17,579.6 },
          { 39.96,591.4 }, { 36.43,595.9 }, { 34.78,597.6 }, { 33.26,598.8 },
          { 31.9,599.6 },  { 30.67,599.9 }, { 29.59,599.7 }, { 28.66,598.8 },
          { 27.86,597.4 }, { 27.29,595.2 }, { 26.64,588.7 }, { 26.86,578.8 },
          { 27.86,565.3 }
        };

        DrawSetStrokeAntialias(picasso,MagickTrue);
        DrawSetStrokeWidth(picasso,5.904);
        DrawSetStrokeLineCap(picasso,RoundCap);
        DrawSetStrokeLineJoin(picasso,RoundJoin);
        (void) DrawSetStrokeDashArray(picasso,0,(const double *)NULL);
        (void) PixelSetColor(color,"#4000c2");
        DrawSetStrokeColor(picasso,color);
        DrawSetFillRule(picasso,EvenOddRule);
        (void) PixelSetColor(color,"#ffff00");
        DrawSetFillColor(picasso,color);
        DrawPolygon(picasso,193,points);
      }
      (void) PopDrawingWand(picasso);
    }
    (void) PopDrawingWand(picasso);
  }
  (void) PopDrawingWand(picasso);
  (void) MagickDrawImage(canvas,picasso);
  color=DestroyPixelWand(color);
  picasso=DestroyDrawingWand(picasso);
  return(MagickTrue);
}
Ejemplo n.º 9
0
MAGICK_NET_EXPORT void DrawingWand_Scaling(DrawingWand *instance, const double x, const double y, ExceptionInfo **exception)
{
  DrawScale(instance, x, y);
  MAGICK_NET_SET_DRAW_EXCEPTION;
}
Ejemplo n.º 10
0
/**************************************************************************
 MUIM_Draw
**************************************************************************/
IPTR Levelmeter__MUIM_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    struct Levelmeter_DATA *data = INST_DATA(cl, obj);
    struct RastPort *rp;
    WORD x1, y1, x2, y2;

    DoSuperMethodA(cl,obj,(Msg)msg);

    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE)))
        return FALSE;

    x1 = _mleft(obj);
    y1 = _mtop(obj);
    x2 = _mright(obj);
    y2 = _mbottom(obj);

    rp = _rp(obj);

    if (msg->flags & MADF_DRAWOBJECT)
    {
        /* Transparent edges */

        DoMethod(obj, MUIM_DrawParentBackground, x1, y1, 2, 1, x1, y1, 0);
        DoMethod(obj, MUIM_DrawParentBackground, x1, y1 + 1, 1, 1, x1, y1 + 1, 0);

        DoMethod(obj, MUIM_DrawParentBackground, x2 - 1, y1, 2, 1, x2 - 1, y1, 0);
        DoMethod(obj, MUIM_DrawParentBackground, x2, y1 + 1, 1, 1, x2, y1 + 1, 0);

        DoMethod(obj, MUIM_DrawParentBackground, x1, y2, 2, 1, x1, y2, 0);
        DoMethod(obj, MUIM_DrawParentBackground, x1, y2 - 1, 1, 1, x1, y2 - 1, 0);

        DoMethod(obj, MUIM_DrawParentBackground, x2 - 1, y2, 2, 1, x2 - 1, y2, 0);
        DoMethod(obj, MUIM_DrawParentBackground, x2, y2 - 1, 1, 1, x2, y2 - 1, 0);

        /* Outer frame */

        SetABPenDrMd(rp, _pens(obj)[MPEN_SHINE], 0, JAM1);
        Move(rp, x1 + 1, y2 - 1);
        Draw(rp, x1, y2 - 2);
        Draw(rp, x1, y1 + 2);
        Draw(rp, x1 + 2, y1);
        Draw(rp, x2 - 2, y1);
        Draw(rp, x2 - 1, y1 + 1);

        SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
        Move(rp, x2, y1 + 2);
        Draw(rp, x2, y2 - 2);
        Draw(rp, x2 - 2, y2);
        Draw(rp, x1 + 2, y2);

        SetAPen(rp, _pens(obj)[MPEN_HALFSHINE]);
        Move(rp, x1 + 1, y2 - 2);
        Draw(rp, x1 + 1, y1 + 2);
        Draw(rp, x1 + 2, y1 + 1);
        Draw(rp, x2 - 2, y1 + 1);

        SetAPen(rp, _pens(obj)[MPEN_HALFSHADOW]);
        Move(rp, x2 - 1, y1 + 2);
        Draw(rp, x2 - 1, y2 - 2);
        Draw(rp, x2 - 2, y2 - 1);
        Draw(rp, x1 + 2, y2 - 1);

        /* Border */

        x1 += OUTERFRAME_X;
        x2 -= OUTERFRAME_X;
        y1 += OUTERFRAME_X;
        y2 -= OUTERFRAME_Y;

        SetAPen(rp, _pens(obj)[MPEN_HALFSHINE]);
        RectFill(rp, x1, y1, x2, y1 + BORDERSIZE_Y - 1);
        RectFill(rp, x1, y1 + BORDERSIZE_Y, x1 + BORDERSIZE_X - 1, y2);
        RectFill(rp, x1 + BORDERSIZE_X - 1, y2 - BORDERSIZE_Y + 1, x2, y2);
        RectFill(rp, x2 - BORDERSIZE_X + 1, y1 + BORDERSIZE_Y, x2, y2 - BORDERSIZE_Y);

        /* Inner Frame */

        x1 += BORDERSIZE_X;
        x2 -= BORDERSIZE_X;
        y1 += BORDERSIZE_Y;
        y2 = y1 + LEVEL_HEIGHT + INNERFRAME_H - 1;

        Move(rp, x1, y1);
        Draw(rp, x1 + 2, y1);
        Draw(rp, x1, y1 + 2);
        Draw(rp, x1, y1 + 1);

        Move(rp, x2, y1);
        Draw(rp, x2 - 2, y1);
        Draw(rp, x2, y1 + 2);
        Draw(rp, x2, y1 + 1);

        Move(rp, x1, y2);
        Draw(rp, x1 + 2, y2);
        Draw(rp, x1, y2 - 2);
        Draw(rp, x1, y2 - 1);

        Move(rp, x2, y2);
        Draw(rp, x2 - 2, y2);
        Draw(rp, x2, y2 - 2);
        Draw(rp, x2, y2 - 1);

        SetAPen(rp, _pens(obj)[MPEN_HALFSHADOW]);
        Move(rp, x1 + 2, y2 - 1);
        Draw(rp, x1, y2 - 3);
        Draw(rp, x1, y1 + 3);
        Draw(rp, x1 + 3, y1);
        Draw(rp, x2 - 3, y1);
        Draw(rp, x2 - 1, y1 + 2);

        SetAPen(rp, _pens(obj)[MPEN_SHINE]);
        Move(rp, x2, y1 + 3);
        Draw(rp, x2, y2 - 3);
        Draw(rp, x2 - 3, y2);
        Draw(rp, x1 + 3, y2);

        SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
        Move(rp, x1 + 3, y1 + 1);
        Draw(rp, x2 - 3, y1 + 1);
        Move(rp, x1 + 1, y1 + 3);
        Draw(rp, x1 + 1, y2 - 3);
        Move(rp, x1 + 3, y2 - 1);
        Draw(rp, x2 - 3, y2 - 1);
        Move(rp, x2 - 1, y1 + 3),
             Draw(rp, x2 - 1, y2 - 3);

        /* Levelmeter bg */

        x1 += INNERFRAME_X;
        x2 -= INNERFRAME_X;
        y1 += INNERFRAME_Y;
        y2 -= INNERFRAME_Y;

        SetAPen(rp, data->levelbgpen);
        RectFill(rp, x1 + 1, y1, x2 - 1, y1);
        RectFill(rp, x1, y1 + 1, x2, y2 - 1);
        RectFill(rp, x1 + 1, y2, x2 - 1, y2);

        SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
        WritePixel(rp, x1, y1);
        WritePixel(rp, x2, y1);
        WritePixel(rp, x1, y2);
        WritePixel(rp, x2, y2);

        /* Levelmeter scale */

        DrawScale(rp, x1, y1, x2, y2, _pens(obj)[MPEN_SHINE]);

        /* Level-Label spacing */

        x1 -= INNERFRAME_X;
        x2 += INNERFRAME_X;
        y1 = y2 + INNERFRAME_Y + 1;

        SetAPen(rp, _pens(obj)[MPEN_HALFSHINE]);
        RectFill(rp, x1, y1, x2, y1 + LEVEL_LABEL_SPACING - 1);

        /* Label Frame */

        y1 += LEVEL_LABEL_SPACING;
        y2 = _mbottom(obj) - OUTERFRAME_Y - BORDERSIZE_Y;

        SetAPen(rp, _pens(obj)[MPEN_HALFSHINE]);
        Move(rp, x1, y1);
        Draw(rp, x1 + 1, y1);
        Draw(rp, x1, y1 + 1);
        Move(rp, x2, y1);
        Draw(rp, x2 - 1, y1);
        Draw(rp, x2, y1 + 1);
        Move(rp, x1, y2);
        Draw(rp, x1 + 1, y2);
        Draw(rp, x1, y2 - 1);
        Move(rp, x2, y2);
        Draw(rp, x2 - 1, y2);
        Draw(rp, x2, y2 - 1);

        SetAPen(rp, _pens(obj)[MPEN_HALFSHADOW]);
        Move(rp, x1 + 1, y2 - 1);
        Draw(rp, x1, y2 - 2);
        Draw(rp, x1, y1 + 2);
        Draw(rp, x1 + 2, y1);
        Draw(rp, x2 - 2, y1);
        Draw(rp, x2 - 1, y1 + 1);

        SetAPen(rp, _pens(obj)[MPEN_SHINE]);
        Move(rp, x2, y1 + 2);
        Draw(rp, x2, y2 - 2);
        Draw(rp, x2 - 2, y2);
        Draw(rp, x1 + 2, y2);

        SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
        RectFill(rp, x1 + 1, y1 + 2, x1 + 1, y2 - 2);
        RectFill(rp, x2 - 1, y1 + 2, x2 - 1, y2 - 2);
        RectFill(rp, x1 + 2, y1 + 1, x2 - 2, y1 + 1);
        RectFill(rp, x1 + 2, y2 - 1, x2 - 2, y2 - 1);

        /* Label Bg */

        RectFill(rp, x1 + 2, y1 +2, x2 - 2, y2 - 2);

    }

    x1 = _mleft(obj) + OUTERFRAME_X + BORDERSIZE_X + INNERFRAME_X;
    x2 = _mright(obj) - OUTERFRAME_X - BORDERSIZE_X - INNERFRAME_X;
    y1 = _mtop(obj) + OUTERFRAME_Y + BORDERSIZE_Y + INNERFRAME_Y;
    y2 = y1 + LEVEL_HEIGHT - 1;

    if (msg->flags & MADF_DRAWUPDATE)
    {
        DrawNeedle(rp, x1, y1, x2, y2, data->prevangle, data->levelbgpen);
    }

    data->prevangle = (double)DoMethod(obj, MUIM_Numeric_ValueToScale, 0, 180);

    DrawNeedle(rp, x1, y1, x2, y2, data->prevangle, _pens(obj)[MPEN_SHINE]);

    return TRUE;
}
Ejemplo n.º 11
0
void CAnalogMeter::ShowMeter(CDC * pDC, CRect rectBorder)
{
 // check for a new meter or a resize of the old one.
 // (if the rectangles have changed, then redraw from scratch).
 // If we are printing, always draw from scratch without bitmaps.
 if (m_rectOwner != rectBorder)
  m_boolForceRedraw = true;

 if (m_boolForceRedraw || (pDC->IsPrinting()))
 {
  m_boolForceRedraw = false;
  // first store the rectangle for the owner
  // and determine the rectangle to draw to
  m_rectOwner = rectBorder;
  if (pDC->IsPrinting())
  {
   m_boolUseBitmaps = false;
   m_rectDraw       = m_rectOwner;  // draw directly to the owner
  }
  else
  {
   m_boolUseBitmaps  = true;
   m_rectDraw.left   = 0;           // draw to a bitmap rectangle
   m_rectDraw.top    = 0;
   m_rectDraw.right  = rectBorder.Width();
   m_rectDraw.bottom = rectBorder.Height();
  }
  m_nRectWidth  = m_rectDraw.Width();
  m_nRectHeight = m_rectDraw.Height();

  // if we already have a memory dc, destroy it
  // (this occurs for a re-size of the meter)
  if (m_dcGrid.GetSafeHdc())
  {
   m_dcGrid.SelectObject(m_pbitmapOldGrid);
   m_dcGrid.DeleteDC();
   m_dcNeedle.SelectObject(m_pbitmapOldNeedle);
   m_dcNeedle.DeleteDC();
   m_bitmapGrid.DeleteObject();
   m_bitmapNeedle.DeleteObject();
  }
  if (m_boolUseBitmaps)
  {
   // create a memory based dc for drawing the grid
   m_dcGrid.CreateCompatibleDC(pDC);
   m_bitmapGrid.CreateCompatibleBitmap(pDC, m_nRectWidth, m_nRectHeight);
   m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid);
   // create a memory based dc for drawing the needle
   m_dcNeedle.CreateCompatibleDC(pDC);
   m_bitmapNeedle.CreateCompatibleBitmap(pDC, m_nRectWidth, m_nRectHeight);
   m_pbitmapOldNeedle = m_dcNeedle.SelectObject(&m_bitmapNeedle);
  }
  else  // no bitmaps, draw to the destination
  {
   // use the destination dc for the grid
   m_dcGrid.m_hDC = pDC->m_hDC;
   m_dcGrid.m_hAttribDC = pDC->m_hAttribDC;
   // use the destination dc for the grid
   m_dcNeedle.m_hDC = pDC->m_hDC;
   m_dcNeedle.m_hAttribDC = pDC->m_hAttribDC;
  }

  // draw the grid in to the "grid dc"
  DrawScale();
  // draw the needle in the "needle dc"
  DrawNeedle();
 }
 // display the new image, combining the needle with the grid
 if (m_boolUseBitmaps)
  ShowMeterImage(pDC);
}
Ejemplo n.º 12
0
void CScopeWindow::UpdateChart (void)
{
	UG_AREA Area;
	UG_WindowGetArea (&m_Window, &Area);
	Area.xs += MARGIN;
	Area.xe -= MARGIN;
	Area.ys += MARGIN+20+10;	// consider title height and margin below
	Area.ye -= MARGIN;

	UG_FillFrame (Area.xs, Area.ys, Area.xe, Area.ye, C_BLACK);

	if (m_pTimeLine == 0)
	{
		return;
	}

	// display headline

	double fZoomFactor = m_pTimeLine->GetZoomFactor ();
	CString Zoom;
	if (fZoomFactor >= 1.0)
	{
		Zoom.Format ("%.0f", fZoomFactor);
	}
	else
	{
		Zoom.Format ("1/%.0f", 1.0 / fZoomFactor);
	}

	double fSampleRate = m_pTimeLine->GetSampleRate ();
	CString SampleRate;
	if (fSampleRate < 1000000.0)
	{
		SampleRate.Format ("%.0fKHz", fSampleRate / 1000.0);
	}
	else
	{
		SampleRate.Format ("%.3fMHz", fSampleRate / 1000000.0);
	}

	CString String;
	String.Format ("SC: %.0fus     OF: %.1fus     TO: %.0fus     ZO: x%s     FQ: %s",
		       m_pTimeLine->GetScaleDivision () * 1000000.0,
		       m_pTimeLine->GetWindowLeft () * 1000000.0,
		       m_pTimeLine->GetRuntime () * 1000000.0,
		       (const char *) Zoom,
		       (const char *) SampleRate);

	UG_SetBackcolor (C_BLACK);
	UG_SetForecolor (C_WHITE);
	UG_FontSelect (&FONT_6X8);
	UG_PutString (Area.xs+5, Area.ys+1, (char *) (const char *) String);

	Area.ys += 12;
	UG_DrawLine (Area.xs, Area.ys, Area.xe, Area.ys, C_WHITE);

	// draw scale

	DrawScale (Area);

	// count active channels

	unsigned nChannelCount = 0;
	for (unsigned nChannel = 1; nChannel <= CHANS; nChannel++)
	{
		if (m_nChannelEnable & CH (nChannel))
		{
			nChannelCount++;
		}
	}

	if (nChannelCount == 0)
	{
		return;
	}

	if (nChannelCount == 1)
	{
		Area.ys += 100;
		Area.ye -= 100;
	}

	// draw channels

	UG_S16 sChannelHeight = (Area.ye-Area.ys+1) / nChannelCount;

	unsigned nChannelsDrawn = 0;
	for (unsigned nChannel = 1; nChannel <= CHANS; nChannel++)
	{
		if (m_nChannelEnable & CH (nChannel))
		{
			UG_AREA ChannelArea;
			ChannelArea.xs = Area.xs;
			ChannelArea.xe = Area.xe;
			ChannelArea.ys = Area.ys + sChannelHeight*nChannelsDrawn;
			ChannelArea.ye = ChannelArea.ys + sChannelHeight-1;

			DrawChannel (nChannel, ChannelArea);

			nChannelsDrawn++;
		}
	}
}
Ejemplo n.º 13
0
void StripChart::OnPaint(wxPaintEvent &event){

	wxPaintDC old_dc(this);
	
	int w,h ;
	GetClientSize(&w,&h);
	
	if (w != _currentWidth || h != _currentHeight){
		delete (_memBitmap);
		_currentWidth = w;
		_currentHeight = h;
		_memBitmap = new wxBitmap(_currentWidth, _currentHeight);
	}
	/////////////////
	// Create a memory DC
	wxMemoryDC dc;
	dc.SelectObject(*_memBitmap);

	wxColor backColor = GetBackgroundColour();
	dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.Clear();
	
	DrawGrid(dc);
	if (_showScale) DrawScale(dc);

	unsigned int dataBufferSize = _dataBuffer.size();
	
	
	float zoomFactor = (float)_zoomPercentage / 100;
	
	dc.SetPen(*wxThePenList->FindOrCreatePen(*wxLIGHT_GREY, 1, wxSHORT_DASH));
	
	int dataBufferUBound = _currentDataBufferUBound;
	
	float currentX = (float)w;
	for (int i = dataBufferUBound; i >= 0; i--){		
		if (_dataBuffer[i].IsMarked()){
			dc.DrawLine((int)currentX,0,(int)currentX,h);					
		}	
		currentX -= zoomFactor;
	}
	
	for (LogItemTypes::iterator it = _logItemTypes.begin(); it != _logItemTypes.end(); ++it){

		wxString key = it->first;
		
		LogItemType *itemType = it->second;
		
		ChartScale scale = _chartScales[itemType->scaleId];
		
		double minValue = scale.minValue;
		double maxValue = scale.maxValue;
		
		currentX = (float)w;
		
		dc.SetPen(*wxThePenList->FindOrCreatePen(itemType->lineColor, 1, wxSOLID));
		
		int lastX = (int)currentX;
		int lastY;
		
		if (dataBufferSize > 0){
			
			StripChartLogItem logItem = _dataBuffer[dataBufferUBound];
			double loggedValue = logItem[key];
			double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue);
			lastY = h - (int)(((double)h) * percentageOfMax);
			
			for (int i = dataBufferUBound; i >= 0; i--){
				StripChartLogItem logItem = _dataBuffer[i];
				double loggedValue = logItem[key];
				
				double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue);
				
				int y = h - (int)(((double)h) * percentageOfMax);
				
				dc.DrawLine(lastX, lastY, (int)currentX, y);
				lastX = (int)currentX;
				lastY = y;
				currentX -= zoomFactor;		
			}
		}
	}

	if (_showData) DrawCurrentValues(dc);
	//blit into the real DC
	old_dc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0);
	
}
Ejemplo n.º 14
0
//---------------------------------------------------------------------------
void __fastcall TMapDialog::UpdateMap(const double *sol, const double *ref,
	const double *vel, const int *stat, int psol, int psols, int psole,
	int nsol, AnsiString *solstr, int currentstat)
{
	TColor color[]={clWhite,clGreen,CLORANGE,clFuchsia,clBlue,clRed,clTeal};
	TCanvas *c=Plot->Canvas;
	AnsiString s;
	TPoint p0;
	double pos[3],posr[3],rr[3],enu[3],enuv[3],dr[3],dir,*pntpos;
	int gint[]={20,20,16,20,20,16,20,20,16,20,20,16,20,20,16,20,20,16,20};
	int ng[]={10,5,5,10,5,5,10,5,5,10,5,5,10,5,5,10,5,5,10};
	TColor colsol=color[stat[psol]];
	
	TRect r(0,0,Plot->Width,Plot->Height);
	c->Brush->Style=bsSolid;
	c->Brush->Color=clWhite;
	c->FillRect(r);
	
	for (int i=0;i<3;i++) {
		CurrentPos[i]=sol[i+psol*3];
	}
	if (norm(RefPos,3)<=0.0) {
		if (ref&&norm(ref+psol,3)>0.0) {
			RefName="Base Station";
			for (int i=0;i<3;i++) RefPos[i]=ref[i+psol*3];
			UpdatePntList();
		}
		else  {
			for (int i=0;i<3;i++) RefPos[i]=CurrentPos[i];
		}
	}
	ecef2pos(RefPos,posr);
	ecef2enu(posr,vel+psol*3,enuv);
	
	DrawGrid(PosToPoint(RefPos),gint[Scale],ng[Scale],CLLGRAY,clSilver);
	
	if (BtnPnt->Down) {
		for (int i=0;i<MainForm->NMapPnt+1;i++) {
			DrawPoint(i==0?RefPos:MainForm->PntPos[i-1],PntList->Items->Strings[i],
					  i==PntIndex?clGray:clSilver);
		}
	}
	if (BtnTrack->Down) {
		TPoint *p  =new TPoint[nsol];
		TColor *col=new TColor[nsol];
		int n=0;
		for (int i=psols;i!=psole;) {
			p[n]=PosToPoint(sol+i*3);
			col[n++]=color[stat[i]];
			if (++i>=nsol) i=0;
		}
		c->Pen->Color=CLLGRAY;
		c->Pen->Style=psSolid;
		c->Polyline(p,n-1);
		for (int i=0;i<n;i++) {
			DrawCircle(p[i],HISSIZE,col[i],col[i]);
		}
		delete [] p;
		delete [] col;
	}
	p0=PosToPoint(CurrentPos);
	c->Pen->Color=clBlack;
	c->MoveTo(p0.x-SOLSIZE/2-4,p0.y); c->LineTo(p0.x+SOLSIZE/2+4,p0.y);
	c->MoveTo(p0.x,p0.y-SOLSIZE/2-4); c->LineTo(p0.x,p0.y+SOLSIZE/2+4);
	DrawCircle(p0,SOLSIZE+4,clBlack,clWhite);
	DrawCircle(p0,SOLSIZE,clBlack,color[currentstat]);
	
	DrawVel(enuv);
	DrawScale();
	
	c->Brush->Style=bsSolid;
	c->Brush->Color=clWhite;
	DrawText(6,1,solstr[0],currentstat?colsol:clGray,0);
	TSize off=c->TextExtent(solstr[2]);
	DrawText(Plot->Width-off.cx-6,1,solstr[2],clGray,0);
	DrawText(50,1,solstr[1],clBlack,0);
	
	if (BtnPnt->Down) {
		pntpos=PntIndex>0?MainForm->PntPos[PntIndex-1]:RefPos;
		for (int i=0;i<3;i++) {
			rr[i]=pntpos[i]-CurrentPos[i];
		}
		ecef2pos(pntpos,pos);
		ecef2enu(posr,rr,enu);
		dir=norm(enu,2)<1E-9?0.0:atan2(enu[0],enu[1])*R2D;
		if (dir<0.0) dir+=360.0;
		s.sprintf("To %s: Distance %.3fm Direction %.1f%s",
			PntList->Items->Strings[PntIndex].c_str(),norm(enu,2),dir,CHARDEG);
		int y=Plot->Height-off.cy/2-2;
		if (BtnGraph->Down) y-=GRPHEIGHT+2;
		DrawText(Plot->Width/2,y,s,clGray,1);
	}
	if (BtnGraph->Down) {
		DrawVertGraph(sol,stat,psol,psols,psole, nsol,currentstat);
	}
	Disp->Invalidate();
}
Ejemplo n.º 15
0
/*virtual*/ void CWndTuner::OnPaint() {
  static int nLastNote = -1;
  static int nLastCents = -999;

  CRect rcClient(m_rcClient);
  rcClient.top += 74;
  // BIOS::LCD::Bar(rcClient, RGB565(FFFFFF));
  if (!m_bWave) {
    BIOS::LCD::Bar(m_rcClient, RGB565(FFFFFF));
    BIOS::LCD::Bar(m_rcClient.left, m_rcClient.bottom - 16, m_rcClient.right,
                   m_rcClient.bottom, RGB565(b0b0b0));
    CBitmap bmp;
    bmp.Load(bitmapTuner);
    bmp.Blit(70, 32);

    DrawPiano();
    DrawScale();

    CRect rcScale(200, 120, 340, 132);
    BIOS::LCD::Print(rcScale.CenterX() - 5 * 4, rcScale.bottom + 2,
                     RGB565(000000), RGBTRANS, "cents");
    BIOS::LCD::Print(240, BIOS::LCD::LcdHeight - 41, RGB565(ff0000), RGBTRANS,
                     "Spectrum");
  }

  float fBestFreq = GetFundamental();
  if (fBestFreq == 0) {
    BIOS::LCD::Bar(m_rcClient.left, m_rcClient.bottom - 16, m_rcClient.right,
                   m_rcClient.bottom, RGB565(b0b0b0));
    BIOS::LCD::Print(4, BIOS::LCD::LcdHeight - 16, RGB565(000000),
                     RGB565(b0b0b0), "No signal detected");

    if (nLastNote >= 0) {
      DrawKey(nLastNote, false);
      nLastNote = -1;
    }
    if (nLastCents != -999) {
      DrawCents(nLastCents, false);
      nLastCents = -999;
    }
    return;
  }

  float fNote =
      log(fBestFreq / 440.0f) / log(2.0f) * 12.0f + 9 + 12 * 4;  // 440Hz -> A4

  int nBaseNote = (int)floor(fNote + 0.5f);  // +50 cents
  int nOctave = nBaseNote / 12;
  int nNote = nBaseNote % 12;
  int nCents = (int)((fNote - nBaseNote) * 100.0f);

  if (nNote < 0) {
    BIOS::LCD::Bar(m_rcClient.left, m_rcClient.bottom - 16, m_rcClient.right,
                   m_rcClient.bottom, RGB565(b0b0b0));
    BIOS::LCD::Print(4, BIOS::LCD::LcdHeight - 16, RGB565(000000),
                     RGB565(b0b0b0), "Invalid signal");

    if (nLastNote >= 0) {
      DrawKey(nLastNote, false);
      nLastNote = -1;
    }
    if (nLastCents != -999) {
      DrawCents(nLastCents, false);
      nLastCents = -999;
    }
    return;
  }

  const char *notes[] = {"C-", "C#", "D-", "D#", "E-", "F-",
                         "F#", "G-", "G#", "A-", "A#", "B-"};
  BIOS::LCD::Printf(4, BIOS::LCD::LcdHeight - 16, RGB565(000000),
                    RGB565(b0b0b0), "%1f Hz -> Note: %s%d %c%d cents   ",
                    fBestFreq, notes[nNote], nOctave, nCents >= 0 ? '+' : '-',
                    ABS(nCents));

  if (nLastNote > -1) DrawKey(nLastNote, false);
  nLastNote = nNote;
  DrawKey(nNote, true);

  if (nLastCents != -999) DrawCents(nLastCents, false);
  nLastCents = nCents;
  DrawCents(nLastCents, true);
}
Ejemplo n.º 16
0
static bool HHVM_METHOD(ImagickDraw, scale,
    double x, double y) {
  auto wand = getDrawingWandResource(Object{this_});
  DrawScale(wand->getWand(), x, y);
  return true;
}
Ejemplo n.º 17
0
void LineChart::OnPaint(wxPaintEvent &event){

	wxPaintDC old_dc(this);

	float zoomFactor = (float)_zoomPercentage / 100;

	int w,h ;
	GetClientSize(&w,&h);

	if (w != _currentWidth || h != _currentHeight){
		delete (_memBitmap);
		_currentWidth = w;
		_currentHeight = h;
		_memBitmap = new wxBitmap(_currentWidth, _currentHeight);
	}
	/////////////////
	// Create a memory DC
	wxMemoryDC dc;
	dc.SelectObject(*_memBitmap);

	wxColor backColor = GetBackgroundColour();
	dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID));
	dc.Clear();
	DrawGrid(dc);

	if (m_showScale){
		m_leftEdge = DrawScale(dc);
	}
	else{
		m_leftEdge = 0;
	}

	size_t largestBufferSize = GetMaxSeriesBufferSize();
	double lastValue = 0;
	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		float currentX = (float)m_leftEdge;
		int lastX = (int)currentX;
		int lastY;

		Series *series = it->second;
		dc.SetPen(*wxThePenList->FindOrCreatePen(series->GetColor(), 1, wxSOLID));
		size_t bufSize = series->GetBufferSize();
		Range *range = m_rangeArray[series->GetRangeId()];
		if (bufSize > 0){

			double minValue = range->GetMin();
			double maxValue = range->GetMax();

			double loggedValue = series->GetValueAt(0);

			double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue);
			lastY = h - (int)(((double)h) * percentageOfMax);

			size_t i = (size_t)(((double)largestBufferSize) * m_viewOffsetFactor);

			while (i < bufSize && currentX < _currentWidth ){
				if (i == m_markerIndex){
					wxPen pen = dc.GetPen();
					dc.SetPen(*wxThePenList->FindOrCreatePen(*wxLIGHT_GREY, 1, wxSOLID));
					dc.DrawLine(currentX, 0, currentX, _currentHeight);
					DrawCurrentValues(dc, i, currentX, CURRENT_VALUES_TOP_OFFSET);
					dc.SetPen(pen);
				}

				loggedValue = series->GetValueAt(i);

				if (DatalogValue::NULL_VALUE == loggedValue){
					loggedValue = lastValue;
				}
				else{
					lastValue = loggedValue;
				}

				double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue);

				int y = h - (int)(((double)h) * percentageOfMax);

				dc.DrawLine(lastX, lastY, (int)currentX, y);
				lastX = (int)currentX;
				lastY = y;
				currentX += zoomFactor;
				i++;
			}
		}
	}
	if (m_showData) DrawMouseoverMarker(dc);
	//blit into the real DC
	old_dc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0);

}
Ejemplo n.º 18
0
/*
** DrawEvent
**
** Map an event to 3D segments for the spin widget.  From a 4-momentum vector,
** (i.e., the 3-momentum vector and the unique identifier from which a physical
** mass can be obtained), An array of 3-dimensional vector and track type is
** deduced).  The structure PhaseEvent is described in phase.h.  The setting
** of the displayMode toggle on the event display panel determines how the
** event is mapped onto the screen:
** 
** BY_MOMENTUM:		The length is proportional the  |P|, the norm of the 3-d
**		      	momentum vector. This is the simplest and default option.
**
** BY_PT:	 	The length of the vector is proportional to Pt, the 
**			transverse momentum. This trick greatly enhances 
**			the "high Pt" Physics in the event.
**
** BY_RAPIDITY: 	The length of the vector is propotional to the rapidity 
**			of the particle, as defined in the PDG bible.
**
** BY_PSEUDORAPIDITY:	The length of the vector is proportional to the pseudo
**			rapidity, i.e., the mass of the particle is 
**			neglected.
**
** BY_USER_ROUTINE :	The user function specified in the DisplayEvent call
**			is called to determine what the new vector ought to be... 
*/
void DrawEvent(StdHepWindow *window, int setScale)
{
    int i, maxIndex, nSegments, nns, npvis;
    int doPoints;
    double scale, innerScale, length, maxLength, outVec[3];
    SpinSegment *segment, *segments, *segdt, temp;
    SpinPoint *point, *points;
    PhaseParticle *p, *particles = window->event.particles;
    int nStable = 0, nParticles = window->event.nParticles;
    SpaceVertex *pinv, *v;
    char nameText[MAXCHAR_HEPNAM], statText[255];
    XmString cStatText;
    /* There is a very wierd Ultrix compiler problem concerning this statement:*/
    /*    PhaseEvent *event; */
    static char *unitText[6] = {"p", "Pt", "Eta", "Eta", "value", "Eta-Pt"};
    XmFontList fontList;
    PhaseWindow *winp;
    SpaceWindow *wins;
    ParaWindow *winpa;
    
    /* If a Space window, find out the number of vertices in this event, 
       so we can allocate more space to draw short segments to represent 
       a vertex.. */
       
    if (window->type == STDHEP_SPACE) {
       wins = (SpaceWindow *) window;
    /* allocate space for the maximum possible number of segments or points */
       nns = NUMPINSTETA * NUMPINSPHI * wins->numRealVertices + nParticles;
       nns += wins->nDetectorSegments;
       segments = (SpinSegment *)XtMalloc(sizeof(SpinSegment) * nns);
       doPoints = False;
     } else if (window->type == STDHEP_PARA) {
        winpa = (ParaWindow *) window;
	segments = (SpinSegment *)XtMalloc(sizeof(SpinSegment) * nParticles);
	doPoints = False;
     } else {
        winp =(PhaseWindow *) window;
        doPoints = (winp->vectorLength == 0.);
        if (doPoints)
	    points = (SpinPoint *)XtMalloc(sizeof(SpinPoint) * nParticles);
        else
	   segments = (SpinSegment *)XtMalloc(sizeof(SpinSegment) * nParticles);
     }
    
    /* Loop over all of the particles, translating them into 3-D line segments
       or points for the Spin widget.  Also find the particle of maximum value
       (for setting the scale and printing statistics), and the number of stable
       particles (for printing statistics later) */
    nSegments = 0;
    npvis = 0;
    maxLength = -1.;
    if (doPoints) {
	point = points;
	for (i=0, p=particles; i<nParticles; i++, p++) {
    	    if (p->stable)
    		nStable++;
    	    if (ParticleToSegment(winp, p, &temp, &length)) {
    	        point->x = temp.x1;
    	        point->y = temp.y1;
    	        point->z = temp.z1;
    	        point->pixel = temp.pixel;
    		point++;
    		nSegments++;
    		npvis++;
    		if (length > maxLength) {
    		    maxLength = length;
    		    maxIndex = i;
    		}
    	    }
	}
	/* Display the points */
	SpinSetPoints(window->spin, points, nSegments);
	XtFree((char *) points);
    } else {
      if (window->type == STDHEP_PHASE) {
	segment=segments;
	for (i=0, p=particles; i<nParticles; i++, p++) {
    	    if (p->stable)
    		nStable++;
    	    if (ParticleToSegment(winp, p, segment, &length)) {
    		segment++;
    		nSegments++;
    		npvis++;
    		if (length > maxLength) {
    		    maxLength = length;
    		    maxIndex = i;
    		}
    	    }
	}
       } else if (window->type == STDHEP_PARA) {
	 segment=segments;
	 for (i=0, p=particles; i<nParticles; i++, p++) {
    	    if (p->stable)
    		nStable++;
    	    if (ParticleToParaSegment(winpa, p, segment, &length)) {
    		segment++;
    		nSegments++;
    		npvis++;
    		if (length > maxLength) {
    		    maxLength = length;
    		    maxIndex = i;
    		}
    	    }
    	  }
       } else {            
	   segment=segments;
           maxLength = 0.;
	   for (i=0, p=particles, v=wins->vertices; 
	                     i<nParticles; i++, p++, v++) {
    	    if (p->stable)
    		nStable++;
    	    if (TrackToSegment(wins, p, v, segment, &length)) {
    		segment++;
    		nSegments++;
    		npvis++;
    		if (length > maxLength) {
    		    maxLength = length;
    		    maxIndex = i;
    		}
    	    }
	   }
	   if (wins->nDetectorSegments > 0) {
	    for (i=0, segdt = wins->detectorSegments;
	          i < wins->nDetectorSegments;
	           i++, segdt++, segment++, nSegments++)  
	          detectorToSegment(wins, segdt, segment);
	   } 
	   if (wins->showVertices) {
	   for (i=0, pinv=wins->realVertices;
	         i < wins->numRealVertices; i++, pinv++){
	          if (fabs((double) pinv->z) < wins->currentScale) {
	            VertexToSegment(wins, pinv, &segment);
	             nSegments += NUMPINSPHI *NUMPINSTETA;
	          } 
             }
           }
         }
	}    
	/* Display the line segments with the spin widget */
	SpinSetSegments(window->spin, segments, nSegments);
	XtFree((char *) segments);
	/* 
	* Currently, the spin widget Perspective resource is buggy, 
	* turn if off.. 
	*/
        SET_ONE_RSRC(window->spin, XmNperspectiveOn, FALSE);
    
    /* If requested, set the scale to show the data most effectively */
    if (setScale) {
    	SpinSetScale(window->spin, (maxLength > 0.) ? 1./maxLength : 1.);
    	DrawScale(window);
    }
    
    /* Fill in the statistics window */
    if (npvis == 0) {
    	sprintf(statText, "%d tracks, %d are stable.\nNo Tracks are visible",
    		nParticles, nStable);
    } else {
        if ((window->type == STDHEP_PHASE) || (window->type == STDHEP_PARA)) { 
	    GET_ONE_RSRC(window->statsLabel, XmNfontList, &fontList);
	    if (CharsetAvailable("greek", fontList)) {
    	        hepnmg_(&particles[maxIndex].id, nameText);
	    } else {
    	        hepnam_(&particles[maxIndex].id, nameText, MAXCHAR_HEPNAM);
	         *strchr(nameText, ' ') = '\0';
	    }
	    if (window->type == STDHEP_PHASE) {
	    sprintf(statText,
"%d tracks, %d are stable,\n%d are now displayed\nTrack of max. %s is a(n) %s",
    	        nParticles, nStable, nSegments,
    	        unitText[winp->displayMode], nameText);
    	    } else { 
	    sprintf(statText,
"%d tracks, %d are stable,\n%d are now displayed\nTrack of max. %s is a(n) %s",
    	        nParticles, nStable, nSegments,
    	        unitText[5], nameText);
    	    }
    	  } else {
    	    if (wins->showVertices)
    	      nns = nSegments
    	         - (NUMPINSPHI * NUMPINSTETA * wins->numRealVertices);
    	    else nns = nSegments; 
	    sprintf(statText,
"%d tracks, %d are stable,\n%d are now displayed\n %d distinct vertices found",
    	        nParticles, nStable, nns, wins->numRealVertices);
    	  }
    }
    cStatText = MultiFontString(statText);
    SET_ONE_RSRC(window->statsLabel, XmNlabelString, cStatText);
    XmStringFree(cStatText);
}
Ejemplo n.º 19
0
void CTimeBarScale::OnPaint( wxPaintEvent& /*event*/ )
{
    DrawScale();
}