コード例 #1
0
///////////////////////////////////////////////////////////////////////////////////////////////
// paint routine
void PixRasterBaseCtrl::Paint(Draw &d)
{
	// clears background
	d.DrawRect(GetSize(), SColorFace());

	// if no associated PixRaster, does nothing
	if(!pixRasterCtrl->GetPixBase())
		return;

	// paints image inside cache, if needed
	PaintCache();
	
	// paints image cache inside control
	if(imageCache.GetWidth() >= GetSize().cx)
		imageCache.Paint(d, Point(0, 0));
	else
		imageCache.Paint(d, Point((GetSize().cx - imageCache.GetWidth()) / 2, 0));
	
	// paints markers inside control
	PaintMarkers(d);
	
	// if dragging, paints rubber banded polygon
	if(selectedMarker && dragPolygon.GetCount())
	{
		d.DrawPolygon(dragPolygon, dragPolygon.GetCount(),
		selectedMarker->GetFillColor(),
		selectedMarker->GetBorderThickness(),
		selectedMarker->GetBorderColor(),
		PEN_DOT,
		White);
	}

} // END LeptonicaBaseCtrl::Paint()
コード例 #2
0
ファイル: main.cpp プロジェクト: AbdelghaniDr/mirror
	virtual void Paint(Draw& w) {
		w.DrawRect(GetSize(), White());

		w.DrawRect(10, 10, 60, 80, Green());

		w.DrawLine(100, 10, 160, 80, 0, Black());
		w.DrawLine(160, 10, 100, 80, 4, Red());
		w.DrawLine(160, 40, 100, 50, PEN_DOT, Red());

		w.DrawEllipse(210, 20, 80, 60, Blue());

		w.DrawEllipse(310, 20, 80, 60, LtBlue(), 5, Red());

		w.DrawArc(RectC(410, 20, 80, 60), Point(10, 10), Point(450, 80), 3, Cyan);

		Vector<Point> p;
		p << Point(30, 110) << Point(60, 180) << Point(10, 150) << Point(70, 150);
		w.DrawPolyline(p, 4, Black);

		p.Clear();
		p << Point(130, 110) << Point(160, 180) << Point(110, 150) << Point(170, 120)
		  << Point(130, 110);
		w.DrawPolygon(p, Blue);

		p.Clear();
		p << Point(230, 110) << Point(260, 180) << Point(210, 150) << Point(270, 120)
		  << Point(230, 110);
		w.DrawPolygon(p, Cyan, 5, Magenta);

		p.Clear();
		p << Point(330, 110) << Point(360, 180) << Point(310, 150) << Point(370, 120)
		  << Point(330, 110);
		w.DrawPolygon(p, Cyan, 5, Magenta, I64(0xaa55aa55aa55aa55));

		w.DrawImage(40, 240, CtrlImg::save());
		w.DrawImage(110, 210, 80, 80, CtrlImg::save());
		w.DrawImage(240, 240, CtrlImg::save(), Blue);
		w.DrawImage(310, 210, 80, 80, CtrlImg::save(), Blue);

		w.DrawText(20, 330, "Hello world!");
		w.DrawText(120, 330, "Hello world!", Arial(15).Bold());
		w.DrawText(220, 330, "Hello world!", Roman(15).Italic(), Red);
		w.DrawText(320, 380, 400, "Hello world!", Courier(15).Underline());
	}
コード例 #3
0
ファイル: PieDraw.cpp プロジェクト: ultimatepp/mirror
static void DrawPie(Draw& w, double c_x, double c_y, double r, int start, int alpha, int width = 0, 
					Color fill = Null, Color outline = Black, uint64 pattern = 0, Color background = White) {
	const int dalpha = 1;
	int n = alpha/dalpha;
	
	Vector <Point> vP;
	Point centre = Point(int(c_x), int(c_y));
	vP << centre;
	int ix;
	int iy;	
	for (int i = 0; i <= n; i++) {
		double x = c_x + r*cos((start+i*dalpha)*M_PI/1800);
		ix = fround(x);		
		double y = c_y + r*sin((start+i*dalpha)*M_PI/1800);
		iy = fround(y);
		double dxy = (x-ix)*(x-ix) + (y-iy)*(y-iy);
		if(dxy < 0.1 || i == 0 || i == n) 
			vP << Point(ix,iy);
		if(w.IsGui()) 
			w.DrawRect(ix, iy, 1, 1, Blend(fill, background, 150));			
	}
	vP << centre;	
	w.DrawPolygon(vP, fill, width, outline, pattern, Null);
}
コード例 #4
0
///////////////////////////////////////////////////////////////////////////////////////////////
// repaint polygon markers over the images
void PixRasterBaseCtrl::PaintMarkers(Draw &d)
{
	// if no associated PixRaster object, do nothing
	if(!pixRasterCtrl || !pixRasterCtrl->GetPixBase())
		return;
	
	// gets associated PixRaster object
	PixBase *pixBase = pixRasterCtrl->GetPixBase();
	
	// calculate view position inside the full tiff image
	int left, top;
	if(hScrollBar.IsVisible())
		left = hScrollBar.Get();
	else
		left = 0;
	if(vScrollBar.IsVisible())
		top = vScrollBar.Get();
	else
		top = 0;

	// loop for all pages, to see which of them fits the view
	int currentTop = 0;
	int currentPage = pixBase->GetActivePage();
	for(int i = 0 ; i < pixBase->GetPageCount() ; i++)
	{
		// sets the active page
		pixBase->SeekPage(i);
		
		// translates current top of page in view coordinates
		int viewCurrentTop = ScaleToView(currentTop);
		
		// gets current page size and translates it in view coordinates
		Rect viewPageRect(
			-left,
			-top + viewCurrentTop,
			ScaleToView(pixBase->GetSize().cx) - left,
			ScaleToView(pixBase->GetSize().cy) - top + viewCurrentTop
		);
		
		// this is when page view is smaller than ctrl view
		int hGap;
		int pw = viewPageRect.right - viewPageRect.left;
		if(pw >= GetSize().cx)
			hGap = 0;
		else
			hGap = (GetSize().cx - pw) / 2;

		// checks wether the page fits the view..
		viewPageRect.Intersect(GetView());
		if(!viewPageRect.IsEmpty())
		{
		
			// this page is inside view, let's take its markers
			Markers &markers = *pixBase->GetMarkers();
			for(int iMarker = 0; iMarker < markers.GetCount(); iMarker++)
			{
				Marker &marker = markers[iMarker];
				
				// don't paint marker being dragged... it will be done by
				// drag routine itself
				if(&marker == selectedMarker)
					continue;
				
				switch(marker.GetKind())
				{
					case Marker::EmptyMarker:
						continue;
						
					default:
						Vector<Point> pts = marker.GetPoints();
						Point points[pts.GetCount()];
						for(int i = 0; i < pts.GetCount(); i++)
						{
							points[i].x = ScaleToView(pts[i].x) - left + hGap;
							points[i].y = ScaleToView(pts[i].y) - top + viewCurrentTop;
						}
						if(&marker != highlightMarker)
							d.DrawPolygon(points, pts.GetCount(),
							marker.GetFillColor(),
							marker.GetBorderThickness(),
							marker.GetBorderColor(),
							marker.GetBorderLineType(),
							White);
						else
							d.DrawPolygon(points, pts.GetCount(),
							marker.GetSelFillColor(),
							marker.GetSelBorderThickness(),
							marker.GetSelBorderColor(),
							marker.GetSelBorderLineType(),
							White);
						break;
				}
			}
		}
		currentTop += pixBase->GetHeight() + ScaleToPage(10);
	}

	// restore PixRaster's active page
	pixBase->SeekPage(currentPage);
	
} // END PixRasterBaseCtrl::PaintMarkers()