コード例 #1
0
ファイル: Envelope.cpp プロジェクト: ruthmagnus/audacity
void Envelope::Draw(wxDC & dc, wxRect & r, double h, double pps, bool dB)
{
   h -= mOffset;

   double tright = h + (r.width / pps);

   dc.SetPen(AColor::envelopePen);
   dc.SetBrush(*wxWHITE_BRUSH);

   int ctr, height;
   if (mMirror) {
      height = r.height / 2;
      ctr = r.y + height;
   }
   else {
      height = r.height;
      ctr = r.y + height;
   }

   int len = mEnv.Count();
   for (int i = 0; i < len; i++) {
      if (mEnv[i]->t >= h && mEnv[i]->t <= tright) {
         if (i == mDragPoint) {
            dc.SetPen(AColor::envelopePen);
            dc.SetBrush(AColor::envelopeBrush);
         }

         double v = mEnv[i]->val;
         int x = int ((mEnv[i]->t - h) * pps);
         int y;

         if (dB)
            y = int (toDB(v) * height);
         else
         y = int (v * height);

         wxRect circle(r.x + x - 1, ctr - y, 4, 4);
         dc.DrawEllipse(circle);
         if (mMirror) {
            circle.y = ctr + y - 2;
            dc.DrawEllipse(circle);
         }

         if (i == mDragPoint) {
            dc.SetPen(AColor::envelopePen);
            dc.SetBrush(*wxWHITE_BRUSH);
         }
      }
   }
}
コード例 #2
0
ファイル: Envelope.cpp プロジェクト: ruthmagnus/audacity
void DrawPoint(wxDC & dc, wxRect & r, int x, int y, bool top, bool contour)
{
   if (y >= 0 && y <= r.height) {
      if(contour){
         wxRect circle(r.x + x - 2, r.y + y - 2,
                       4, 4);
         dc.DrawEllipse(circle);
      }else{
         wxRect circle(r.x + x - 2, r.y + (top? y-1: y-4),
                       4, 4);
         dc.DrawEllipse(circle);
      }
   }
}
コード例 #3
0
ファイル: Envelope.cpp プロジェクト: dannyflax/audacity
/// TODO: This should probably move to track artist.
static void DrawPoint(wxDC & dc, const wxRect & r, int x, int y, bool top)
{
   if (y >= 0 && y <= r.height) {
      wxRect circle(r.x + x, r.y + (top ? y - 1: y - 2), 4, 4);
      dc.DrawEllipse(circle);
   }
}
コード例 #4
0
ファイル: graphics.cpp プロジェクト: CodeTickler/wxWidgets
    void BenchmarkEllipses(const wxString& msg, wxDC& dc)
    {
        if ( !opts.testEllipses )
            return;

        if ( opts.mapMode != 0 )
            dc.SetMapMode((wxMappingMode)opts.mapMode);
        if ( opts.penWidth != 0 )
            dc.SetPen(wxPen(*wxWHITE, opts.penWidth));

        dc.SetBrush( *wxBLUE_BRUSH );

        wxPrintf("Benchmarking %s: ", msg);
        fflush(stdout);

        wxStopWatch sw;
        for ( long n = 0; n < opts.numIters; n++ )
        {
            int x = rand() % opts.width,
                y = rand() % opts.height;

            dc.DrawEllipse(x, y, 48, 32);
        }

        const long t = sw.Time();

        wxPrintf("%ld ellipses done in %ldms = %gus/ellipse\n",
                 opts.numIters, t, (1000. * t)/opts.numIters);
    }
コード例 #5
0
ファイル: sashtest.cpp プロジェクト: euler0/Helium
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
    dc.SetFont(*wxSWISS_FONT);
    dc.SetPen(*wxGREEN_PEN);
    dc.DrawLine(0, 0, 200, 200);
    dc.DrawLine(200, 0, 0, 200);

    dc.SetBrush(*wxCYAN_BRUSH);
    dc.SetPen(*wxRED_PEN);
    dc.DrawRectangle(100, 100, 100, 50);
    dc.DrawRoundedRectangle(150, 150, 100, 50, 20);

    dc.DrawEllipse(250, 250, 100, 50);
#if wxUSE_SPLINES
    dc.DrawSpline(50, 200, 50, 100, 200, 10);
#endif // wxUSE_SPLINES
    dc.DrawLine(50, 230, 200, 230);
    dc.DrawText(wxT("This is a test string"), 50, 230);

    wxPoint points[3];
    points[0].x = 200; points[0].y = 300;
    points[1].x = 100; points[1].y = 400;
    points[2].x = 300; points[2].y = 400;

    dc.DrawPolygon(3, points);
}
コード例 #6
0
ファイル: m_list.cpp プロジェクト: erwincoumans/wxWidgets
void wxHtmlListmarkCell::Draw(wxDC& dc, int x, int y,
                              int WXUNUSED(view_y1), int WXUNUSED(view_y2),
                              wxHtmlRenderingInfo& WXUNUSED(info))
{
    dc.SetBrush(m_Brush);
    dc.DrawEllipse(x + m_PosX + m_Width / 3, y + m_PosY + m_Height / 3,
                   (m_Width / 3), (m_Width / 3));
}
コード例 #7
0
ファイル: draw.cpp プロジェクト: colindr/calchart
void DrawPath(wxDC& dc, const CalChartConfiguration& config, const std::vector<CC_DrawCommand>& draw_commands, const CC_coord& end)
{
    dc.SetBrush(*wxTRANSPARENT_BRUSH);
    auto brushAndPen = config.Get_CalChartBrushAndPen(COLOR_PATHS);
    dc.SetPen(brushAndPen.second);
    DrawCC_DrawCommandList(dc, draw_commands);
    dc.SetBrush(brushAndPen.first);
    float circ_r = Float2Coord(config.Get_DotRatio());
    dc.DrawEllipse(end.x - circ_r/2, end.y - circ_r/2, circ_r, circ_r);
}
コード例 #8
0
/*
 * Here we do the actual rendering. I put it in a separate
 * method so that it can work no matter what type of DC
 * (e.g. wxPaintDC or wxClientDC) is used.
 */
void 
pcl::visualization::ImageWidgetWX::ImagePanel::render (wxDC&  dc)
{
  //cout << __PRETTY_FUNCTION__<<" called.\n";
  if (image==NULL) return;
  
  int newWidth, newHeight;
  dc.GetSize (&newWidth, &newHeight);
  
  if (newWidth != scaledWidth || newHeight != scaledHeight) 
  {
    resizeImage (newWidth, newHeight);
  }
  dc.DrawBitmap (resized_, 0, 0, false);
  
  int circleSize = 4;
  for (unsigned int i = 0; i < markedPoints.size (); ++i) 
  {
    const ImagePoint& point = markedPoints.at (i);
    dc.SetPen (*point.color);
    dc.SetBrush (*point.background);
    dc.DrawEllipse (pcl_lrint ((point.x+0.5f)*scaledWidth / image->GetWidth ())-0.5f*circleSize,
                    pcl_lrint ((point.y+0.5f)*scaledHeight / image->GetHeight ())-0.5f*circleSize, circleSize, circleSize);
  }
  
  for (unsigned int i = 0; i < lines.size (); ++i) 
  {
    const ImageLine& line = lines.at (i);
    wxPoint points_array[2];
    points_array[0].x = pcl_lrint ((line.x1+0.5f)*scaledWidth / image->GetWidth ());
    points_array[0].y = pcl_lrint ((line.y1+0.5f)*scaledHeight / image->GetHeight ());
    points_array[1].x = pcl_lrint((line.x2+0.5f)*scaledWidth / image->GetWidth ());
    points_array[1].y = pcl_lrint((line.y2+0.5f)*scaledHeight / image->GetHeight ());
    wxPen pen(*line.color);
    pen.SetWidth(3);
    dc.SetPen(pen);
    dc.DrawLines (2, points_array);
  }
  
  if (getParentImageWidget()->visualize_selected_point)
  {
    int selected_x = getParentImageWidget()->last_clicked_point_x,
        selected_y = getParentImageWidget()->last_clicked_point_y;
    if (selected_x >= 0 && selected_y >= 0)
    {
      wxPen pen(*wxGREEN, 2);	 
      dc.SetPen (pen);
      dc.CrossHair (pcl_lrint((selected_x+0.5f)*scaledWidth / image->GetWidth ()),
                    pcl_lrint((selected_y+0.5f)*scaledHeight / image->GetHeight ()));
    }
  }
}
コード例 #9
0
// do something that the default renderer doesn't here just to show that it is
// possible to alter the appearance of the cell beyond what the attributes
// allow
void MyGridCellRenderer::Draw(wxGrid& grid,
                              wxGridCellAttr& attr,
                              wxDC& dc,
                              const wxRect& rect,
                              int row, int col,
                              bool isSelected)
{
    wxGridCellStringRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);

    dc.SetPen(*wxGREEN_PEN);
    dc.SetBrush(*wxTRANSPARENT_BRUSH);
    dc.DrawEllipse(rect);
}
コード例 #10
0
ファイル: shapes.cpp プロジェクト: d0k/malprogramm
void Guy::draw(wxDC& dc) const {
	dc.SetPen(*wxBLACK_PEN);
	dc.SetBrush(wxBrush(color));
	const int midx = left + width/2;
	const int midy = top + height/2;
	const int legs = height/4; // offset of arms & legs
	const int head = width/4;
	dc.DrawLine(midx, midy-legs, midx, midy+legs); // body
	dc.DrawLine(midx, midy-legs, left, midy); // left arm
	dc.DrawLine(midx, midy-legs, width+left, midy); // right arm
	dc.DrawLine(midx, midy+legs, left, top+height); // left leg
	dc.DrawLine(midx, midy+legs, left+width, top+height); // right leg
	dc.DrawEllipse(midx-head/2, top, head, legs); // head
}
コード例 #11
0
ファイル: basic2.cpp プロジェクト: kleopatra999/pgadmin3
void wxEllipseShape::OnDraw(wxDC &dc)
{
	if (m_shadowMode != SHADOW_NONE)
	{
		if (m_shadowBrush)
			dc.SetBrush(* m_shadowBrush);
		dc.SetPen(* g_oglTransparentPen);
		dc.DrawEllipse((long) ((m_xpos - GetWidth() / 2) + m_shadowOffsetX),
		               (long) ((m_ypos - GetHeight() / 2) + m_shadowOffsetY),
		               (long) GetWidth(), (long) GetHeight());
	}

	if (m_pen)
	{
		if (m_pen->GetWidth() == 0)
			dc.SetPen(* g_oglTransparentPen);
		else
			dc.SetPen(* m_pen);
	}
	if (m_brush)
		dc.SetBrush(* m_brush);
	dc.DrawEllipse((long) (m_xpos - GetWidth() / 2), (long) (m_ypos - GetHeight() / 2), (long) GetWidth(), (long) GetHeight());
}
コード例 #12
0
ファイル: Lyrics.cpp プロジェクト: ShockingIce/audacity
void Lyrics::HandlePaint_BouncingBall(wxDC &dc)
{
   int ctr = mWidth / 2;
   int x;
   double y;
   GetKaraokePosition(mT, &x, &y);

   dc.SetTextForeground(wxColour(238, 0, 102));
   bool changedColor = false;

   SetDrawnFont(&dc);
   unsigned int i;
   wxCoord yTextTop = mKaraokeHeight - mTextHeight - 4;
   for(i=0; i<mSyllables.GetCount(); i++) {
      if (mSyllables[i].x + mSyllables[i].width < (x - ctr))
         continue;
      if (mSyllables[i].x > x + ctr)
         continue;

      if (!changedColor && mSyllables[i].x >= x) {
         dc.SetTextForeground(*wxBLACK);
         changedColor = true;
      }

      wxString text = mSyllables[i].text;
      if (text.Length() > 0 && text.Right(1) == wxT("_")) {
         text = text.Left(text.Length() - 1);
      }

      dc.DrawText(text,
                  mSyllables[i].leftX + ctr - x,
                  yTextTop);
   }

   int ballRadius = (int)(mTextHeight / 8.0);
   int bounceTop = ballRadius * 2;
   int bounceHeight = yTextTop - bounceTop;
   int yi = (int)(yTextTop - 4 - (y * bounceHeight));

   if (mT >= 0.0) {
      wxRect ball(ctr - ballRadius, yi - ballRadius, 2 * ballRadius, 2 * ballRadius);
      dc.SetBrush(wxBrush(wxColour(238, 0, 102), wxSOLID));
      dc.DrawEllipse(ball);
   }
}
コード例 #13
0
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
    // vars to use ...
#if wxUSE_STATUSBAR
    wxString s;
#endif // wxUSE_STATUSBAR
    wxPen wP;
    wxBrush wB;
    wxPoint points[6];
    wxColour wC;
    wxFont wF;

    dc.SetFont(*wxSWISS_FONT);
    dc.SetPen(*wxGREEN_PEN);

    switch (m_index)
    {
        default:
        case 0:
            // draw lines to make a cross
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            // draw point colored line and spline
            wP = *wxCYAN_PEN;
            wP.SetWidth(3);
            dc.SetPen(wP);

            dc.DrawPoint (25,15);
            dc.DrawLine(50, 30, 200, 30);
            dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
            s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
            break;

        case 1:
            // draw standard shapes
            dc.SetBrush(*wxCYAN_BRUSH);
            dc.SetPen(*wxRED_PEN);
            dc.DrawRectangle(10, 10, 100, 70);
            wB = wxBrush (wxT("DARK ORCHID"), wxBRUSHSTYLE_TRANSPARENT);
            dc.SetBrush (wB);
            dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
            dc.SetBrush (wxBrush(wxT("GOLDENROD")) );
            dc.DrawEllipse(100, 100, 100, 50);

            points[0].x = 100; points[0].y = 200;
            points[1].x = 70; points[1].y = 260;
            points[2].x = 160; points[2].y = 230;
            points[3].x = 40; points[3].y = 230;
            points[4].x = 130; points[4].y = 260;
            points[5].x = 100; points[5].y = 200;

            dc.DrawPolygon(5, points);
            dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
            s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
            break;

        case 2:
            // draw text in Arial or similar font
            dc.DrawLine(50,25,50,35);
            dc.DrawLine(45,30,55,30);
            dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
            wC = dc.GetTextForeground();
            dc.SetTextForeground (wxT("FIREBRICK"));

            // no effect in msw ??
            dc.SetTextBackground (wxT("WHEAT"));
            dc.DrawText(wxT("This is a Red string"), 50, 200);
            dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
            dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.SetTextForeground (wC);
            dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
            break;

        case 3 :
            // four arcs start and end points, center
            dc.SetBrush(*wxGREEN_BRUSH);
            dc.DrawArc ( 200,300, 370,230, 300,300 );
            dc.SetBrush(*wxBLUE_BRUSH);
            dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
            dc.SetDeviceOrigin(-10,-10);
            dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
            dc.SetDeviceOrigin(0,0);

            wP.SetColour (wxT("CADET BLUE"));
            dc.SetPen(wP);
            dc.DrawArc ( 75,125, 110, 40, 75, 75 );

            wP.SetColour (wxT("SALMON"));
            dc.SetPen(wP);
            dc.SetBrush(*wxRED_BRUSH);
            //top left corner, width and height, start and end angle
                                 // 315 same center and x-radius as last pie-arc, half Y radius
            dc.DrawEllipticArc(25,50,100,50,180.0,45.0);

            wP = *wxCYAN_PEN;
            wP.SetWidth(3);
            dc.SetPen(wP);
                                 //wxTRANSPARENT));
            dc.SetBrush (wxBrush (wxT("SALMON")));
            dc.DrawEllipticArc(300,  0,200,100, 0.0,145.0);
                                 //same end point
            dc.DrawEllipticArc(300, 50,200,100,90.0,145.0);
            dc.DrawEllipticArc(300,100,200,100,90.0,345.0);

#if wxUSE_STATUSBAR
            s = wxT("This is an arc test page");
#endif // wxUSE_STATUSBAR
            break;

        case 4:
            dc.DrawCheckMark ( 30,30,25,25);
            dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);
#if wxUSE_STATUSBAR
            s = wxT("Two check marks");
#endif // wxUSE_STATUSBAR
            break;

        case 5:
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string"), 50, 60);

            // rescale and draw in blue
            wP = *wxCYAN_PEN;
            dc.SetPen(wP);
            dc.SetUserScale (2.0,0.5);
            dc.SetDeviceOrigin(200,0);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string 2 x 0.5 UserScaled"), 50, 60);
            dc.SetUserScale (2.0,2.0);
            dc.SetDeviceOrigin(200,200);
            dc.DrawText(wxT("This is an 18pt string 2 x 2 UserScaled"), 50, 60);

            wP = *wxRED_PEN;
            dc.SetPen(wP);
            dc.SetUserScale (1.0,1.0);
            dc.SetDeviceOrigin(0,10);
            dc.SetMapMode (wxMM_METRIC); //svg ignores this
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Scaling test page");
#endif // wxUSE_STATUSBAR
            break;

        case 6:
            dc.DrawIcon( wxICON(sample), 10, 10 );
            dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
#if wxUSE_STATUSBAR
            s = wxT("Icon and Bitmap ");
#endif // wxUSE_STATUSBAR
            break;

        case 7:
            dc.SetTextForeground(wxT("RED"));
            dc.DrawText(wxT("Red = Clipping Off"), 30, 5);
            dc.SetTextForeground(wxT("GREEN"));
            dc.DrawText(wxT("Green = Clipping On"), 30, 25);

            dc.SetTextForeground(wxT("BLACK"));

            dc.SetPen(*wxRED_PEN);
            dc.SetBrush (wxBrush (wxT("SALMON"),wxBRUSHSTYLE_TRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);

            dc.SetPen(*wxGREEN_PEN);

            // Clipped checkmarks
            dc.DrawRectangle(180,50,75,75);
            dc.SetClippingRegion(180,50,75,75);                   // x,y,width,height version
            dc.DrawCheckMark ( 180,50,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect(80,150,75,75));
            dc.SetClippingRegion(wxPoint(80,150),wxSize(75,75));  // pt,size version
            dc.DrawCheckMark ( 80,150,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect(180,150,75,75));
            dc.SetClippingRegion(wxRect(180,150,75,75));          // rect version
            dc.DrawCheckMark ( 180,150,75,75);
            dc.DestroyClippingRegion();

            dc.DrawRectangle(wxRect( 80,250,50,65));
            dc.DrawRectangle(wxRect(105,260,50,65));
            dc.SetClippingRegion(wxRect( 80,250,50,65));  // second call to SetClippingRegion
            dc.SetClippingRegion(wxRect(105,260,50,65));  // forms intersection with previous
            dc.DrawCheckMark(80,250,75,75);
            dc.DestroyClippingRegion();                   // only one call to destroy (there's no stack)

            /*
            ** Clipping by wxRegion not implemented for SVG.   Should be
            ** possible, but need to access points that define the wxRegion
            ** from inside DoSetDeviceClippingRegion() and wxRegion does not
            ** implement anything like getPoints().
            points[0].x = 180; points[0].y = 250;
            points[1].x = 255; points[1].y = 250;
            points[2].x = 180; points[2].y = 325;
            points[3].x = 255; points[3].y = 325;
            points[4].x = 180; points[4].y = 250;

            dc.DrawLines (5, points);
            wxRegion reg = wxRegion(5,points);

            dc.SetClippingRegion(reg);
            dc.DrawCheckMark ( 180,250,75,75);
            dc.DestroyClippingRegion();
            */

#if wxUSE_STATUSBAR
            s = wxT("Clipping region");
#endif // wxUSE_STATUSBAR
            break;

        case 8:
            wxString txtStr;
            wxCoord txtX, txtY, txtW, txtH, txtDescent, txtEL;
            wxCoord txtPad = 0;

            wP = *wxRED_PEN;
            dc.SetPen(wP);
            //dc.SetBackgroundMode(wxBRUSHSTYLE_SOLID);
            //dc.SetTextBackground(*wxBLUE);

            // Horizontal text
            txtStr = wxT("Horizontal string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            txtX = 50;
            txtY = 300;
            dc.DrawRectangle(txtX, txtY, txtW + 2*txtPad, txtH + 2*txtPad);
            dc.DrawText(txtStr, txtX + txtPad, txtY + txtPad);

            // Vertical text
            txtStr = wxT("Vertical string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            txtX = 50;
            txtY = 250;
            dc.DrawRectangle(txtX, txtY - (txtW + 2*txtPad), txtH + 2*txtPad, txtW + 2*txtPad);
            dc.DrawRotatedText(txtStr, txtX + txtPad, txtY - txtPad, 90);

            // 45 degree text
            txtStr = wxT("45 deg string");
            dc.GetTextExtent(txtStr, &txtW, &txtH, &txtDescent, &txtEL);
            double lenW = (double)(txtW + 2*txtPad) / sqrt(2.0);
            double lenH = (double)(txtH + 2*txtPad) / sqrt(2.0);
            double padding = (double)txtPad / sqrt(2.0);
            txtX = 150;
            txtY = 200;
            dc.DrawLine(txtX - padding, txtY, txtX + lenW, txtY - lenW); // top
            dc.DrawLine(txtX + lenW, txtY - lenW, txtX - padding + lenH + lenW, txtY + (lenH - lenW));
            dc.DrawLine(txtX - padding, txtY, txtX - padding + lenH, txtY + lenH);
            dc.DrawLine(txtX - padding + lenH, txtY + lenH, txtX - padding + lenH + lenW, txtY + (lenH - lenW)); // bottom
            dc.DrawRotatedText(txtStr, txtX, txtY, 45);
#if wxUSE_STATUSBAR
            s = wxT("Text position test page");
#endif // wxUSE_STATUSBAR
            break;
    }
#if wxUSE_STATUSBAR
    m_child->SetStatusText(s);
#endif // wxUSE_STATUSBAR
}
コード例 #14
0
void MyApp::Draw(wxDC&dc)
{
    // This routine just draws a bunch of random stuff on the screen so that we
    // can check that different types of object are being drawn consistently
    // between the screen image, the print preview image (at various zoom
    // levels), and the printed page.
    dc.SetBackground(*wxWHITE_BRUSH);
    // dc.Clear();
    dc.SetFont(m_testFont);

    // dc.SetBackgroundMode(wxTRANSPARENT);

    dc.SetPen(*wxBLACK_PEN);
    dc.SetBrush(*wxLIGHT_GREY_BRUSH);

    dc.DrawRectangle(0, 0, 230, 350);
    dc.DrawLine(0, 0, 229, 349);
    dc.DrawLine(229, 0, 0, 349);
    dc.SetBrush(*wxTRANSPARENT_BRUSH);

    dc.SetBrush(*wxCYAN_BRUSH);
    dc.SetPen(*wxRED_PEN);

    dc.DrawRoundedRectangle(0, 20, 200, 80, 20);

    dc.DrawText( wxT("Rectangle 200 by 80"), 40, 40);

    dc.SetPen( wxPen(*wxBLACK, 0, wxPENSTYLE_DOT_DASH) );
    dc.DrawEllipse(50, 140, 100, 50);
    dc.SetPen(*wxRED_PEN);

    dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);

#if wxUSE_UNICODE
    const char *test = "Hebrew    שלום -- Japanese (日本語)";
    wxString tmp = wxConvUTF8.cMB2WC( test );
    dc.DrawText( tmp, 10, 200 );
#endif

    wxPoint points[5];
    points[0].x = 0;
    points[0].y = 0;
    points[1].x = 20;
    points[1].y = 0;
    points[2].x = 20;
    points[2].y = 20;
    points[3].x = 10;
    points[3].y = 20;
    points[4].x = 10;
    points[4].y = -20;
    dc.DrawPolygon( 5, points, 20, 250, wxODDEVEN_RULE );
    dc.DrawPolygon( 5, points, 50, 250, wxWINDING_RULE );

    dc.DrawEllipticArc( 80, 250, 60, 30, 0.0, 270.0 );

    points[0].x = 150;
    points[0].y = 250;
    points[1].x = 180;
    points[1].y = 250;
    points[2].x = 180;
    points[2].y = 220;
    points[3].x = 200;
    points[3].y = 220;
    dc.DrawSpline( 4, points );

    dc.DrawArc( 20,10, 10,10, 25,40 );

    wxString str;
    int i = 0;
    str.Printf( wxT("---- Text at angle %d ----"), i );
    dc.DrawRotatedText( str, 100, 300, i );

    i = m_angle;
    str.Printf( wxT("---- Text at angle %d ----"), i );
    dc.DrawRotatedText( str, 100, 300, i );

    wxIcon my_icon = wxICON(sample);

    dc.DrawIcon( my_icon, 100, 100);

    if (m_bitmap.IsOk())
        dc.DrawBitmap( m_bitmap, 10, 10 );

#if wxUSE_GRAPHICS_CONTEXT
    wxGraphicsContext *gc = NULL;

    wxPrinterDC *printer_dc = wxDynamicCast( &dc, wxPrinterDC );
    if (printer_dc)
        gc = wxGraphicsContext::Create( *printer_dc );

    wxWindowDC *window_dc = wxDynamicCast( &dc, wxWindowDC );
    if (window_dc)
        gc = wxGraphicsContext::Create( *window_dc );

#ifdef __WXMSW__
    wxEnhMetaFileDC *emf_dc = wxDynamicCast( &dc, wxEnhMetaFileDC );
    if (emf_dc)
        gc = wxGraphicsContext::Create( *emf_dc );
#endif

    if (gc)
    {
        // make a path that contains a circle and some lines, centered at 100,100
        gc->SetPen( *wxRED_PEN );

        wxGraphicsPath path = gc->CreatePath();
        path.AddCircle( 50.0, 50.0, 50.0 );
        path.MoveToPoint(0.0, 50.0);
        path.AddLineToPoint(100.0, 50.0);
        path.MoveToPoint(50.0, 0.0);
        path.AddLineToPoint(50.0, 100.0 );
        path.CloseSubpath();
        path.AddRectangle(25.0, 25.0, 50.0, 50.0);

        gc->StrokePath(path);

        // draw some text
        wxString text("Text by wxGraphicsContext");
        gc->SetFont( m_testFont, *wxBLACK );
        gc->DrawText(text, 25.0, 60.0);

        // draw rectangle around the text
        double w, h, d, el;
        gc->GetTextExtent(text, &w, &h, &d, &el);
        gc->SetPen( *wxBLACK_PEN );
        gc->DrawRectangle(25.0, 60.0, w, h);

        delete gc;
    }
#endif
}
コード例 #15
0
ファイル: draw.cpp プロジェクト: colindr/calchart
// draw the continuity starting at a specific offset
void DrawCont(wxDC& dc, const CC_textline_list& print_continuity, const wxRect& bounding, bool landscape)
{
    SaveAndRestore_DeviceOrigin orig_dev(dc);
    SaveAndRestore_UserScale orig_scale(dc);
    SaveAndRestore_TextForeground orig_text(dc);
    SaveAndRestore_Font orig_font(dc);
#if DEBUG
    dc.DrawRectangle(bounding);
#endif

    dc.SetTextForeground(*wxBLACK);

    int pageMiddle = (bounding.GetWidth()/2);

    size_t numLines = 0;
    for (auto text = print_continuity.begin(); text != print_continuity.end(); ++text)
    {
        if (text->GetOnSheet())
        {
            ++numLines;
        }
    }

    int font_size = ((bounding.GetBottom() - bounding.GetTop()) - (numLines - 1)*2)/(numLines ? numLines : 1);
    //font size, we scale to be no more than 256 pixels.
    font_size = std::min(font_size, 10);

    wxFont *contPlainFont = wxTheFontList->FindOrCreateFont(font_size, wxMODERN, wxNORMAL, wxNORMAL);
    wxFont *contBoldFont = wxTheFontList->FindOrCreateFont(font_size, wxMODERN, wxNORMAL, wxBOLD);
    wxFont *contItalFont = wxTheFontList->FindOrCreateFont(font_size, wxMODERN, wxITALIC, wxNORMAL);
    wxFont *contBoldItalFont = wxTheFontList->FindOrCreateFont(font_size, wxMODERN, wxITALIC, wxBOLD);

    dc.SetFont(*contPlainFont);
    const wxCoord maxtexth = contPlainFont->GetPointSize()+2;

    float y = bounding.GetTop();
    const wxCoord charWidth = dc.GetCharWidth();
    for (auto& cont : print_continuity)
    {
        float x = bounding.GetLeft();
        // Determine how to center the text
        if (cont.GetCenter())
        {
            x += pageMiddle;
            auto chunks = cont.GetChunks();
            for (auto& c : chunks)
            {
                bool do_tab = false;
                switch (c.font)
                {
                case PSFONT_SYMBOL:
                {
                    wxCoord textw, texth;
                    dc.GetTextExtent(wxT("O"), &textw, &texth);
                    x += textw * c.text.length();
                }
                break;
                case PSFONT_NORM:
                    dc.SetFont(*contPlainFont);
                    break;
                case PSFONT_BOLD:
                    dc.SetFont(*contBoldFont);
                    break;
                case PSFONT_ITAL:
                    dc.SetFont(*contItalFont);
                    break;
                case PSFONT_BOLDITAL:
                    dc.SetFont(*contBoldItalFont);
                    break;
                case PSFONT_TAB:
                    do_tab = true;
                    break;
                }
                if (!do_tab && (c.font != PSFONT_SYMBOL))
                {
                    wxCoord textw, texth;
                    dc.GetTextExtent(c.text, &textw, &texth);
                    x -= textw/2;
                }
            }
        }
        // now draw the text
        unsigned tabnum = 0;
        auto chunks = cont.GetChunks();
        for (auto& c : chunks)
        {
            bool do_tab = false;
            switch (c.font)
            {
            case PSFONT_NORM:
            case PSFONT_SYMBOL:
                dc.SetFont(*contPlainFont);
                break;
            case PSFONT_BOLD:
                dc.SetFont(*contBoldFont);
                break;
            case PSFONT_ITAL:
                dc.SetFont(*contItalFont);
                break;
            case PSFONT_BOLDITAL:
                dc.SetFont(*contBoldItalFont);
                break;
            case PSFONT_TAB:
            {
                tabnum++;
                wxCoord textw = bounding.GetLeft() + charWidth * TabStops(tabnum, landscape);
                if (textw >= x) x = textw;
                else x += charWidth;
                do_tab = true;
            }
            break;
            default:
                break;
            }
            if (c.font == PSFONT_SYMBOL)
            {
                wxCoord textw, texth, textd;
                dc.GetTextExtent(wxT("O"), &textw, &texth, &textd);
                const float d = textw;
                const float top_y = y + texth - textd - textw;

                for (std::string::const_iterator s = c.text.begin(); s != c.text.end(); s++)
                {
                    {
                        dc.SetPen(*wxBLACK_PEN);
                        SYMBOL_TYPE sym = (SYMBOL_TYPE)(*s - 'A');
                        switch (sym)
                        {
                        case SYMBOL_SOL:
                        case SYMBOL_SOLBKSL:
                        case SYMBOL_SOLSL:
                        case SYMBOL_SOLX:
                            dc.SetBrush(*wxBLACK_BRUSH);
                            break;
                        default:
                            dc.SetBrush(*wxTRANSPARENT_BRUSH);
                        }
                        dc.DrawEllipse(x, top_y, d, d);
                        switch (sym)
                        {
                        case SYMBOL_SL:
                        case SYMBOL_X:
                        case SYMBOL_SOLSL:
                        case SYMBOL_SOLX:
                            dc.DrawLine(x-1, top_y + d+1, x + d+1, top_y-1);
                            break;
                        default:
                            break;
                        }
                        switch (sym)
                        {
                        case SYMBOL_BKSL:
                        case SYMBOL_X:
                        case SYMBOL_SOLBKSL:
                        case SYMBOL_SOLX:
                            dc.DrawLine(x-1, top_y-1, x + d+1, top_y + d+1);
                            break;
                        default:
                            break;
                        }
                    }
                    x += d;
                }
            }
            else
            {
                if (!do_tab)
                {
                    wxCoord textw, texth;
                    dc.GetTextExtent(c.text, &textw, &texth);
                    dc.DrawText(c.text, x, y);
                    x += textw;
                }
            }
        }
        y += maxtexth;
    }
#if DEBUG
    char buffer[100];
    snprintf(buffer, sizeof(buffer), "TopLeft %d, %d", bounding.GetTopLeft().x, bounding.GetTopLeft().y);
    dc.DrawText(buffer, bounding.GetTopLeft());
    snprintf(buffer, sizeof(buffer), "BottomRight %d, %d", bounding.GetBottomRight().x, bounding.GetBottomRight().y);
    dc.DrawText(buffer, bounding.GetBottomRight());
#endif
}
コード例 #16
0
void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
    PenColour(fore);
    BrushColour(back);
    hdc->DrawEllipse(wxRectFromPRectangle(rc));
}
コード例 #17
0
ファイル: draw.cpp プロジェクト: colindr/calchart
void
DrawPointHelper(wxDC& dc, const CalChartConfiguration& config, const CC_coord& pos, const CC_point& point, const wxString& label)
{
    SaveAndRestore_Brush restore(dc);
    const float circ_r = Float2Coord(config.Get_DotRatio());
    const float offset = circ_r / 2;
    const float plineoff = offset * config.Get_PLineRatio();
    const float slineoff = offset * config.Get_SLineRatio();
    float textoff = offset * 1.25;

    long x = pos.x;
    long y = pos.y;
    switch (point.GetSymbol())
    {
    case SYMBOL_SOL:
    case SYMBOL_SOLBKSL:
    case SYMBOL_SOLSL:
    case SYMBOL_SOLX:
        break;
    default:
        dc.SetBrush(*wxTRANSPARENT_BRUSH);
    }
    dc.DrawEllipse(x - offset, y - offset, circ_r, circ_r);
    switch (point.GetSymbol())
    {
    case SYMBOL_SL:
    case SYMBOL_X:
        dc.DrawLine(x - plineoff, y + plineoff,
                    x + plineoff, y - plineoff);
        break;
    case SYMBOL_SOLSL:
    case SYMBOL_SOLX:
        dc.DrawLine(x - slineoff, y + slineoff,
                    x + slineoff, y - slineoff);
        break;
    default:
        break;
    }
    switch (point.GetSymbol())
    {
    case SYMBOL_BKSL:
    case SYMBOL_X:
        dc.DrawLine(x - plineoff, y - plineoff,
                    x + plineoff, y + plineoff);
        break;
    case SYMBOL_SOLBKSL:
    case SYMBOL_SOLX:
        dc.DrawLine(x - slineoff, y - slineoff,
                    x + slineoff, y + slineoff);
        break;
    default:
        break;
    }
    if (point.LabelIsVisible()) {
        wxCoord textw, texth, textd;
        dc.GetTextExtent(label, &textw, &texth, &textd);
        dc.DrawText(label,
                    point.GetFlip() ? x : (x - textw),
                    y - textoff - texth + textd);
    }
}
コード例 #18
0
void MyFrame::Draw(wxDC& dc)
{
    // This routine just draws a bunch of random stuff on the screen so that we
    // can check that different types of object are being drawn consistently
    // between the screen image, the print preview image (at various zoom
    // levels), and the printed page.
    dc.SetBackground(*wxWHITE_BRUSH);
    dc.Clear();
    dc.SetFont(wxGetApp().m_testFont);

    dc.SetBackgroundMode(wxTRANSPARENT);

    dc.SetPen(*wxBLACK_PEN);
    dc.SetBrush(*wxLIGHT_GREY_BRUSH);
//    dc.SetBackground(*wxWHITE_BRUSH);
    dc.DrawRectangle(0, 0, 230, 350);
    dc.DrawLine(0, 0, 229, 349);
    dc.DrawLine(229, 0, 0, 349);
    dc.SetBrush(*wxTRANSPARENT_BRUSH);

    dc.SetBrush(*wxCYAN_BRUSH);
    dc.SetPen(*wxRED_PEN);

    dc.DrawRoundedRectangle(0, 20, 200, 80, 20);

    dc.DrawText( wxT("Rectangle 200 by 80"), 40, 40);

    dc.SetPen( wxPen(*wxBLACK,0,wxDOT_DASH) );
    dc.DrawEllipse(50, 140, 100, 50);
    dc.SetPen(*wxRED_PEN);

    dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
    
#if wxUSE_UNICODE
    //char *test = "Hebrew    שלום -- Japanese (日本語)";
    //wxString tmp = wxConvUTF8.cMB2WC( test );
    //dc.DrawText( tmp, 10, 200 );
#endif

    wxPoint points[5];
    points[0].x = 0;
    points[0].y = 0;
    points[1].x = 20;
    points[1].y = 0;
    points[2].x = 20;
    points[2].y = 20;
    points[3].x = 10;
    points[3].y = 20;
    points[4].x = 10;
    points[4].y = -20;
    dc.DrawPolygon( 5, points, 20, 250, wxODDEVEN_RULE );
    dc.DrawPolygon( 5, points, 50, 250, wxWINDING_RULE );

    dc.DrawEllipticArc( 80, 250, 60, 30, 0.0, 270.0 );

    points[0].x = 150;
    points[0].y = 250;
    points[1].x = 180;
    points[1].y = 250;
    points[2].x = 180;
    points[2].y = 220;
    points[3].x = 200;
    points[3].y = 220;
    dc.DrawSpline( 4, points );

    dc.DrawArc( 20,10, 10,10, 25,40 );
        
    wxString str;
    int i = 0;
    str.Printf( wxT("---- Text at angle %d ----"), i );
    dc.DrawRotatedText( str, 100, 300, i );

    i = m_angle;
    str.Printf( wxT("---- Text at angle %d ----"), i );
    dc.DrawRotatedText( str, 100, 300, i );

    wxIcon my_icon = wxICON(mondrian) ;

    dc.DrawIcon( my_icon, 100, 100);

    if (m_bitmap.Ok())
    {
      dc.DrawBitmap(m_bitmap, 10, 25);
    }
    if (m_imgUp.Ok())
    {
      dc.DrawBitmap(m_imgUp, 300, 200);
      dc.DrawBitmap(m_imgUp, 300, 250, true);
    }
}
コード例 #19
0
ファイル: shapes.cpp プロジェクト: d0k/malprogramm
void Circle::draw(wxDC& dc) const {
	dc.SetPen(*wxBLACK_PEN);
	dc.SetBrush(wxBrush(color));
	dc.DrawEllipse(left, top, width, height);
}
コード例 #20
0
ファイル: svgtest.cpp プロジェクト: EdgarTx/wx
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
    // vars to use ...
#if wxUSE_STATUSBAR
    wxString s ;
#endif // wxUSE_STATUSBAR
    wxPen wP ;
    wxBrush wB ;
    wxPoint points[6];
    wxColour wC;
    wxFont wF ;

    dc.SetFont(*wxSWISS_FONT);
    dc.SetPen(*wxGREEN_PEN);


    switch (m_index)
    {
        default:
        case 0:
            // draw lines to make a cross
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            // draw point colored line and spline
            wP = *wxCYAN_PEN ;
            wP.SetWidth(3);
            dc.SetPen(wP);

            dc.DrawPoint (25,15) ;
            dc.DrawLine(50, 30, 200, 30);
            dc.DrawSpline(50, 200, 50, 100, 200, 10);
#if wxUSE_STATUSBAR
            s = wxT("Green Cross, Cyan Line and spline");
#endif // wxUSE_STATUSBAR
            break ;

        case 1:
            // draw standard shapes
            dc.SetBrush(*wxCYAN_BRUSH);
            dc.SetPen(*wxRED_PEN);
            dc.DrawRectangle(10, 10, 100, 70);
            wB = wxBrush (_T("DARK ORCHID"), wxTRANSPARENT);
            dc.SetBrush (wB);
            dc.DrawRoundedRectangle(50, 50, 100, 70, 20);
            dc.SetBrush (wxBrush(_T("GOLDENROD"), wxSOLID) );
            dc.DrawEllipse(100, 100, 100, 50);

            points[0].x = 100; points[0].y = 200;
            points[1].x = 70; points[1].y = 260;
            points[2].x = 160; points[2].y = 230;
            points[3].x = 40; points[3].y = 230;
            points[4].x = 130; points[4].y = 260;
            points[5].x = 100; points[5].y = 200;

            dc.DrawPolygon(5, points);
            dc.DrawLines (6, points, 160);
#if wxUSE_STATUSBAR
            s = wxT("Blue rectangle, red edge, clear rounded rectangle, gold ellipse, gold and clear stars");
#endif // wxUSE_STATUSBAR
            break ;

        case 2:
            // draw text in Arial or similar font
            dc.DrawLine(50,25,50,35);
            dc.DrawLine(45,30,55,30);
            dc.DrawText(wxT("This is a Swiss-style string"), 50, 30);
            wC = dc.GetTextForeground() ;
            dc.SetTextForeground (_T("FIREBRICK"));

            // no effect in msw ??
            dc.SetTextBackground (_T("WHEAT"));
            dc.DrawText(wxT("This is a Red string"), 50, 200);
            dc.DrawRotatedText(wxT("This is a 45 deg string"), 50, 200, 45);
            dc.DrawRotatedText(wxT("This is a 90 deg string"), 50, 200, 90);
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.SetTextForeground (wC) ;
            dc.DrawText(wxT("This is a Times-style string"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Swiss, Times text; red text, rotated and colored orange");
#endif // wxUSE_STATUSBAR
            break ;

        case 3 :
            // four arcs start and end points, center
            dc.SetBrush(*wxGREEN_BRUSH);
            dc.DrawArc ( 200,300, 370,230, 300,300 );
            dc.SetBrush(*wxBLUE_BRUSH);
            dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
            dc.SetDeviceOrigin(-10,-10);
            dc.DrawArc ( 270-50, 270-86, 270-86, 270-50, 270,270 );
            dc.SetDeviceOrigin(0,0);

            wP.SetColour (_T("CADET BLUE"));
            dc.SetPen(wP);
            dc.DrawArc ( 75,125, 110, 40, 75, 75 );

            wP.SetColour (_T("SALMON"));
            dc.SetPen(wP);
            dc.SetBrush(*wxRED_BRUSH);
            //top left corner, width and height, start and end angle
                                 // 315 same center and x-radius as last pie-arc, half Y radius
            dc.DrawEllipticArc(25,50,100,50,180.0,45.0) ;

            wP = *wxCYAN_PEN ;
            wP.SetWidth(3);
            dc.SetPen(wP);
                                 //wxTRANSPARENT));
            dc.SetBrush (wxBrush (_T("SALMON"),wxSOLID)) ;
            dc.DrawEllipticArc(300,  0,200,100, 0.0,145.0) ;
                                 //same end point
            dc.DrawEllipticArc(300, 50,200,100,90.0,145.0) ;
            dc.DrawEllipticArc(300,100,200,100,90.0,345.0) ;

#if wxUSE_STATUSBAR
            s = wxT("This is an arc test page");
#endif // wxUSE_STATUSBAR
            break ;

        case 4:
            dc.DrawCheckMark ( 30,30,25,25);
            dc.SetBrush (wxBrush (_T("SALMON"),wxTRANSPARENT));
            dc.DrawCheckMark ( 80,50,75,75);
            dc.DrawRectangle ( 80,50,75,75);
#if wxUSE_STATUSBAR
            s = wxT("Two check marks");
#endif // wxUSE_STATUSBAR
            break ;

        case 5:
            wF = wxFont ( 18, wxROMAN, wxITALIC, wxBOLD, false, wxT("Times New Roman"));
            dc.SetFont(wF);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string"), 50, 60);

            // rescale and draw in blue
            wP = *wxCYAN_PEN ;
            dc.SetPen(wP);
            dc.SetUserScale (2.0,0.5);
            dc.SetDeviceOrigin(200,0);
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string 2 x 0.5 UserScaled"), 50, 60);
            dc.SetUserScale (2.0,2.0);
            dc.SetDeviceOrigin(200,200);
            dc.DrawText(wxT("This is an 18pt string 2 x 2 UserScaled"), 50, 60);

            wP = *wxRED_PEN ;
            dc.SetPen(wP);
            dc.SetUserScale (1.0,1.0);
            dc.SetDeviceOrigin(0,10);
            dc.SetMapMode (wxMM_METRIC) ; //svg ignores this
            dc.DrawLine(0, 0, 200, 200);
            dc.DrawLine(200, 0, 0, 200);
            dc.DrawText(wxT("This is an 18pt string in MapMode"), 50, 60);
#if wxUSE_STATUSBAR
            s = wxT("Scaling test page");
#endif // wxUSE_STATUSBAR
            break ;

        case 6:
            dc.DrawIcon( wxIcon(mondrian_xpm), 10, 10 );
            dc.DrawBitmap ( wxBitmap(svgbitmap_xpm), 50,15);
#if wxUSE_STATUSBAR
            s = wxT("Icon and Bitmap ");
#endif // wxUSE_STATUSBAR
            break ;

    }
#if wxUSE_STATUSBAR
    m_child->SetStatusText(s);
#endif // wxUSE_STATUSBAR
}
コード例 #21
0
//void simple_vector_layer::Draw(wxDC &dc, wxCoord x, wxCoord y, bool transparent, double zoomFactor, double translationX, double translationY, double resolution) const
void simple_vector_layer::draw(wxDC &dc, wxCoord x, wxCoord y, bool transparent) const
{
    wxPen pen;
    wxBrush brush;

    // 2D
    pen.SetWidth(m_polygon_border_width);
    pen.SetColour(m_polygon_border_color);
    pen.SetStyle(m_polygon_border_style);
    brush.SetColour(m_polygon_inner_color);
    brush.SetStyle(m_polygon_inner_style);
    dc.SetPen(pen);
    dc.SetBrush(brush);
    for (unsigned int i = 0; i < m_circles.size(); i++)
    {
        wxPoint p = transform().from_local_int(m_circles[i]);
        wxCoord r = static_cast<wxCoord>(m_circles[i].radius / transform().zoom_factor());
        dc.DrawCircle(p, r);
    }
    // Ellipses alignees
    for (unsigned int i=0;i<m_ellipses.size();++i)
    {
        wxPoint p = transform().from_local_int(m_ellipses[i]);
        wxSize  s(
                static_cast<wxCoord>(2*m_ellipses[i].a/transform().zoom_factor()),
                static_cast<wxCoord>(2*m_ellipses[i].b/transform().zoom_factor())
                );
        dc.DrawEllipse(p,s);
        //dc.DrawEllipticArc(p,s,0.,90.);
        //dc.DrawEllipticArcRot(p,s,0.,90.);
    }
    // Ellipses non alignees
    for (unsigned int i=0;i<m_rotatedellipses.size();++i)
    {
        std::vector<wxPoint> points;
        points.reserve( m_rotatedellipses[i].controlPoints.size() );
        for (unsigned int j=0;j<m_rotatedellipses[i].controlPoints.size();++j)
            points.push_back(transform().from_local_int(m_rotatedellipses[i].controlPoints[j]));
        dc.DrawSpline(static_cast<int>(points.size()),&points.front());
    }
    for (unsigned int i=0;i<m_polygons.size();++i)
    {
        std::vector<wxPoint> points;
        points.reserve( m_polygons[i].size() );
        for (unsigned int j=0;j<m_polygons[i].size();++j)
            points.push_back(transform().from_local_int(m_polygons[i][j]));
        dc.DrawPolygon( static_cast<int>(points.size()) , &(points.front()) );
    }

    // 1D
    pen.SetColour(m_line_color);
    pen.SetWidth(m_line_width);
    pen.SetStyle(m_line_style);
    dc.SetPen(pen);
    for (unsigned int i = 0; i < m_arcs.size(); i++)
    {
        const arc_type &local_tab = m_arcs[i];
        for (unsigned int j = 0; j < local_tab.arc_points.size() - 1; ++j)
        {
            wxPoint p = transform().from_local_int(local_tab.arc_points[j  ]);
            wxPoint q = transform().from_local_int(local_tab.arc_points[j+1]);
            dc.DrawLine(p,q);
        }
    }
    // Splines
    for (unsigned int i=0;i<m_splines.size();++i)
    {
        const spline_type& spline = m_splines[i];
        std::vector<wxPoint> points;
        unsigned int n = static_cast<int>(spline.size());
        for (unsigned int j=0;j<n;++j)
        {
            wxPoint p = transform().from_local_int(spline[j]);
            points.push_back(p);
        }
        dc.DrawSpline(n,&points.front());
    }

    // 0D
    pen.SetColour(m_point_color);
    pen.SetWidth(m_point_width);
    dc.SetPen(pen);
    for (unsigned int i = 0; i < m_points.size(); i++)
    {
        wxPoint p = transform().from_local_int(m_points[i]);
        //dc.DrawLine(p);
        dc.DrawPoint(p);
    }

    // Text
    if(text_visibility())
    {
        pen.SetColour(m_text_color);
        dc.SetPen(pen);
        for (unsigned int i = 0; i < m_texts.size(); i++)
        {
            wxPoint p = transform().from_local_int(m_texts[i].first);
            //dc.DrawLine(p);
            dc.DrawText(wxString(m_texts[i].second.c_str(),*wxConvCurrent),p);
        }
    }
}
コード例 #22
0
void GraphPane::FullRefresh(wxDC& dc)
{
    // Erase Background
    wxCoord width, height;
    this->GetSize(&width, &height);

    dc.SetPen((BlackBG ? *wxBLACK_PEN : *wxWHITE_PEN));
    dc.SetBrush(BlackBG ? *wxBLACK_BRUSH : *wxWHITE_BRUSH);
    dc.DrawRectangle(0, 0, width, height);

    // Set the origin at the centre
    dc.SetDeviceOrigin(wxCoord(width/2), wxCoord(height/2));


    wxPen pen((BlackBG ? *wxWHITE : *wxBLACK), 1);
    wxBrush brush((BlackBG ? *wxBLACK_BRUSH : *wxWHITE_BRUSH));
    dc.SetPen(pen);

    if (GraphInfoVector != NULL && !(GraphInfoVector->empty())) {

        // Declare iterators for each set of coordinates --> Loop through all trails/sets of coordinates
        std::vector<GraphInfo*>::const_iterator CoordSetIt;

        // Declare iterators for each trail
        std::deque<double>::const_iterator XCoordIt;
        std::deque<double>::const_iterator YCoordIt;

        //Begin iterating
        CoordSetIt = GraphInfoVector->begin();

        while (CoordSetIt != GraphInfoVector->end()) {
            // Set Colour
            if ((*CoordSetIt)->TrailColour == *wxBLACK && BlackBG) {
                    pen = wxPen(*wxWHITE, 1);
            } else {
                    pen = wxPen((*CoordSetIt)->TrailColour, 1);
            }
            dc.SetPen(pen);

            // Iterate through all coordinates
            if ((*CoordSetIt)->XCoordinate.size() > unsigned(NewPoints)) {
                XCoordIt = (*CoordSetIt)->XCoordinate.begin() + NewPoints - 1;
                YCoordIt = (*CoordSetIt)->YCoordinate.begin() + NewPoints - 1;
            }
            else {
                XCoordIt = (*CoordSetIt)->XCoordinate.begin();
                YCoordIt = (*CoordSetIt)->YCoordinate.begin();
            }


            while (XCoordIt != (*CoordSetIt)->XCoordinate.end()) {
                dc.DrawPoint(wxCoord((*XCoordIt) * ScalingFactor), wxCoord((*YCoordIt) * ScalingFactor* (-1)));
                XCoordIt++;
                YCoordIt++;
            }


            // If terminator size > 0, draw circle terminator at last coordinate.
            if ((*CoordSetIt)->TermSize > 0) {
                XCoordIt--;
                YCoordIt--;

                if ((*CoordSetIt)->TrailColour == *wxBLACK && BlackBG) {
                    brush.SetColour(*wxWHITE);
                } else {
                    brush.SetColour((*CoordSetIt)->TrailColour);
                }
                dc.SetBrush(brush);
                dc.DrawEllipse(wxCoord((*XCoordIt) * ScalingFactor - (*CoordSetIt)->TermSize),
                               wxCoord((*YCoordIt) * ScalingFactor* (-1) - (*CoordSetIt)->TermSize),
                               (*CoordSetIt)->TermSize * 2, (*CoordSetIt)->TermSize * 2);
            }

            ++CoordSetIt;
        }
    }
}
コード例 #23
0
ファイル: plot.cpp プロジェクト: darckense/fityk
void FPlot::draw_data_by_activity(wxDC& dc, wxPoint2DDouble *pp,
                                  const vector<bool>& aa, bool state)
{
    int len = aa.size();
    int count_state = count(aa.begin(), aa.end(), state);
    if (count_state == 0)
        return;
    wxGCDC* gdc = wxDynamicCast(&dc, wxGCDC);
    wxGraphicsContext *gc = gdc ? gdc->GetGraphicsContext() : NULL;
    if (line_between_points) {
        int start = (aa[0] == state ? 0 : -1);
        for (int i = 1; i != len; ++i) {
            if (aa[i] == state && start == -1)
                start = i;
            else if (aa[i] != state && start != -1) {
                wxPoint2DDouble start_bak = pp[start];
                wxPoint2DDouble i_bak = pp[i];
                if (start > 0) {
                    // draw half of the line between points start-1 and start
                    --start;
                    start_bak = pp[start];
                    pp[start] = (pp[start] + pp[start+1]) / 2;
                }
                // draw half of the line between points i-1 and i
                pp[i] = (pp[i-1] + pp[i]) / 2;
                stroke_lines(dc, gc, i - start + 1, pp + start);
                pp[i] = i_bak;
                pp[start] = start_bak;
                start = -1;
            }
        }
        if (start != -1) {
            wxPoint2DDouble start_bak = pp[start];
            if (start > 0) {
                // draw half of the line between points start-1 and start
                --start;
                start_bak = pp[start];
                pp[start] = (pp[start] + pp[start+1]) / 2;
            }
            stroke_lines(dc, gc, len - start, pp + start);
            pp[start] = start_bak;
        }
    }

    if (point_radius > 1) {
        int r = (point_radius - 1) * pen_width;
        if (gc) {
            for (int i = 0; i != len; ++i)
                if (aa[i] == state)
                    gc->DrawEllipse(pp[i].m_x - r/2., pp[i].m_y - r/2., r, r);
        }
        else
            for (int i = 0; i != len; ++i)
                if (aa[i] == state)
                    dc.DrawEllipse(pp[i].m_x - r/2, pp[i].m_y - r/2, r, r);
    }
    else if (!line_between_points) { // if we are here, point_radius == 1
        if (gc) {
            wxGraphicsPath path = gc->CreatePath();
            for (int i = 0; i != len; ++i)
                if (aa[i] == state) {
                    double rx = iround(pp[i].m_x);
                    double ry = iround(pp[i].m_y);
                    path.MoveToPoint(rx, ry - 0.1);
                    path.AddLineToPoint(rx, ry + 0.1);
                }
            gc->SetAntialiasMode(wxANTIALIAS_NONE);
            gc->StrokePath(path);
            gc->SetAntialiasMode(wxANTIALIAS_DEFAULT);
        }
        else
            for (int i = 0; i != len; ++i)
                if (aa[i] == state)
                    dc.DrawPoint(iround(pp[i].m_x), iround(pp[i].m_y));
    }
}
コード例 #24
0
ファイル: GLCanvas.cpp プロジェクト: JochenKempfle/MoCap
void GLCanvas::drawUserInterface(wxDC &dc) const
{
    wxSize size = GetSize();
    wxPoint pos(0, 0);
    pos.x = size.x - _buttonSize;

    wxSize buttonSize(_buttonSize, _buttonSize);

    wxPen whitePen(wxColour(255, 255, 255));
    whitePen.SetWidth(1);
    wxPen blackPen(wxColour(0, 0, 0));
    blackPen.SetWidth(1);
    wxPen greenPen(wxColour(0, 255, 0));
    wxBrush brush;

	dc.SetPen(blackPen);

    brush.SetColour(wxColour(0, 0, 0));
	dc.SetBrush(brush);

	// draw black background behind all buttons
	dc.DrawRectangle(pos.x - 1, pos.y, _buttonSize + 1, _numButtons * _buttonSize + 1);

	// draw grit
	if (_style & DRAW_GRID)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

	dc.DrawRectangle(pos.x + 1, pos.y + 1, _buttonSize - 2, _buttonSize - 2);

	dc.DrawLine(pos.x + _buttonSizeHalf, pos.y + 1, pos.x + _buttonSizeHalf, pos.y + _buttonSize - 1);
	dc.DrawLine(pos.x + 1, pos.y + _buttonSizeHalf, size.x - 1, pos.y + _buttonSizeHalf);

	pos.y += _buttonSize;

	// draw a cube for showing AABB
	if (_style & DRAW_AABB)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

	dc.DrawRectangle(pos.x + _buttonSizeHalf - 3, pos.y + 3, _buttonSizeHalf, _buttonSizeHalf);
	dc.DrawRectangle(pos.x + 2, pos.y + _buttonSizeHalf - 2, _buttonSizeHalf, _buttonSizeHalf);

	dc.DrawLine(pos.x + 2, pos.y + _buttonSizeHalf - 2, pos.x + _buttonSizeHalf - 3, pos.y + 3);
	dc.DrawLine(pos.x + 2 + _buttonSizeHalf, pos.y + _buttonSizeHalf - 2, pos.x + _buttonSize - 3, pos.y + 3);
	dc.DrawLine(pos.x + 2 + _buttonSizeHalf, pos.y + _buttonSize - 3, pos.x + _buttonSize - 3, pos.y + _buttonSizeHalf + 2);

	pos.y += _buttonSize;

	// draw coordinate system
	if (_style & DRAW_LOCAL_COORDINATE_SYSTEM)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

	dc.DrawLine(pos.x + 2, pos.y + 3, pos.x + 2, pos.y + _buttonSize - 2);
	dc.DrawLine(pos.x + 2, pos.y + _buttonSize - 2, size.x - 3, pos.y + _buttonSize - 2);

	dc.DrawLine(pos.x + 2, pos.y + _buttonSize - 2, pos.x + _buttonSize - 6, pos.y + _buttonSizeHalf + 2);

	pos.y += _buttonSize;

	// draw joint constraints
	if (_style & DRAW_JOINT_CONSTRAINTS)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }
	//dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 3);
    //dc.DrawArc(pos.x + 4, pos.y + 5, pos.x + 4, pos.y + _buttonSize - 5, pos.x + _buttonSizeHalf + 2, pos.y + _buttonSizeHalf);
	//dc.DrawCircle(pos.x + 6, pos.y + _buttonSizeHalf, 3);
	dc.DrawEllipse(pos.x + 4, pos.y + 3, _buttonSizeHalf - 5, _buttonSizeHalf + 4);
	dc.DrawLine(pos.x + 8, pos.y + 3, pos.x + _buttonSizeHalf + 5, pos.y + _buttonSizeHalf);
	dc.DrawLine(pos.x + 8, pos.y + _buttonSizeHalf + 7, pos.x + _buttonSizeHalf + 5, pos.y + _buttonSizeHalf);

	pos.y += _buttonSize;

	// draw rotation axis
	if (_style & DRAW_ROTATION_AXIS)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

    dc.DrawArc(pos.x + _buttonSizeHalf + 2, pos.y + _buttonSize - 2, pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf + 1, pos.x + 2, pos.y + _buttonSize - 2);
    //dc.DrawEllipse(pos.x + 6, pos.y + 5, _buttonSize - 12, _buttonSize - 10);
    //dc.DrawCircle(pos.x + _buttonSizeHalf + 2, pos.y + _buttonSizeHalf - 2, 3);
	dc.DrawLine(pos.x + 2, pos.y + _buttonSize - 2, pos.x + _buttonSize - 2, pos.y + 2);
	dc.DrawLine(pos.x + 2, pos.y + _buttonSize - 2, pos.x + _buttonSize - 2, pos.y + _buttonSize - 2);

	pos.y += _buttonSize;

	// draw label
	if (_style & DRAW_LABEL)
    {
        dc.SetPen(greenPen);
    }
    else
    {
        dc.SetPen(whitePen);
    }

	dc.DrawRoundedRectangle(pos.x + 4, pos.y + 3, _buttonSize - 5, _buttonSizeHalf, 3.0);
	dc.DrawSpline(pos.x + 4, pos.y + _buttonSizeHalf - 3, pos.x + 1, pos.y + _buttonSizeHalf + 4, pos.x + _buttonSizeHalf + 4, pos.y + _buttonSizeHalf + 6);

	pos.y += _buttonSize;

	// draw locate skeleton button
    dc.SetPen(whitePen);

	dc.DrawLine(pos.x + _buttonSizeHalf, pos.y + 2, pos.x + _buttonSizeHalf, pos.y + _buttonSize - 1);
	dc.DrawLine(pos.x + 2, pos.y + _buttonSizeHalf, size.x - 1, pos.y + _buttonSizeHalf);

	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 4);
	brush.SetColour(wxColour(255, 255, 255));
	dc.SetBrush(brush);
	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 8);


	pos.y += _buttonSize;

	// draw settings button
	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 3);

	dc.SetPen(blackPen);

	brush.SetColour(wxColour(0, 0, 0));
	dc.SetBrush(brush);

	dc.DrawCircle(pos.x + _buttonSizeHalf + 6, pos.y + _buttonSizeHalf, 2);
	dc.DrawCircle(pos.x + _buttonSizeHalf - 6, pos.y + _buttonSizeHalf, 2);

	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf + 6, 2);
	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf - 6, 2);

	dc.SetPen(whitePen);

	dc.DrawCircle(pos.x + _buttonSizeHalf, pos.y + _buttonSizeHalf, _buttonSizeHalf - 7);
}