画坐标,小弟初学,不会

nannan11 2004-07-14 08:53:55
从文本文件里读入一段X和Y值,怎么样能画出一条坐标轴?原点为0,最好给些代码
...全文
214 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
nineclock 2004-07-15
  • 打赏
  • 举报
回复
CStdioFile的ReadString()来逐行读取,然后放到二个数组里,一个X一个Y数组
在VIEW的ondraw画就行,大概就是这样的吧,m_intXArray[i]是X坐标,
X坐标
pDC->TextOut(x+pDoc->m_intXArray[i],y+5,Xtemp);
pDC->Rectangle(x+pDoc->m_intXArray[i],y,x+pDoc->m_intXArray[i]+5,y+5);
====》
Y坐标
。。。。。。。。
yeedward 2004-07-15
  • 打赏
  • 举报
回复
没见过英语这么牛的
名牌大灰狼 2004-07-15
  • 打赏
  • 举报
回复
Moves the upper-left corner of the element to the specified location for the movable behavior.

Syntax

movable.moveTo(iX, iY)
Parameters

iX Required. Horizontal scroll offset, in pixels.
iY Required. Vertical scroll offset, in pixels.

Return Value

No return value.

Remarks

The moveTo method is available only to objects participating in the movable behavior.

Applies To

movable
Platform Version
Win16: 5
Win32: 5
Unix: 5
Mac: 5
Version data is listed when the mouse hovers over a link, or the link has focus.
movable
Move the mouse pointer over an element in the Applies To list to display availability information for the listed platforms. Internet Explorer does not expose this member on platforms that are not listed.

CDC::LineTo
This method draws a line from the current position to, but not including, the point specified by x and y or point. The line is drawn with the selected pen. The current position is set to x,y or to point.

BOOL LineTo(
int x,
int y );

BOOL LineTo(
POINT point );
Parameters
x
The logical x-coordinate of the endpoint for the line.
y
The logical y-coordinate of the endpoint for the line.
point
The endpoint for the line. You can pass a POINT structure or a CPoint object for this parameter.
Return Value
Nonzero if the line is drawn; otherwise, it is zero.

Example
See the example for CRect::CenterPoint

Requirements
Windows CE versions: 1.0 and later
Header file: Declared in Afxwin.h
Platform: H/PC Pro, Palm-size PC, Pocket PC

See Also
CDC::MoveTo, CDC::GetCurrentPosition, CPoint, POINT

CDC
This class encapsulates the functionality of a Windows CE device context, which is a graphics device interface–managed structure containing information about the operating modes and current selections of a device, such as a display or printer.

Do all drawing through the methods of a CDC object. The class provides methods for device-context operations, working with drawing tools, type-safe graphics device interface (GDI) object selection, and working with colors and palettes. It also provides methods for getting and setting drawing attributes; mapping; working with the viewport; working with the window extent; converting coordinates; working with regions; clipping; drawing lines; and drawing simple shapes, ellipses, and polygons. Methods are also provided for drawing text, working with fonts, using printer escapes, scrolling, and playing metafiles.

To use a CDC object, construct it, and call the methods that parallel Windows functions that use device contexts.

For specific uses, the Microsoft Foundation Class Library for Windows CE provides several classes derived from CDC. CPaintDC encapsulates calls to BeginPaint and EndPaint. CClientDC manages a display context associated with the client area of a window. CWindowDC manages a display context associated with an entire window, including its frame and controls. CMetaFileDC associates a device context with a metafile.

CDC provides two methods, GetLayout and SetLayout, for reversing the layout of a device context, which does not inherit its layout from a window. Right-to-left orientation is necessary for applications written for languages such as Arabic or Hebrew, in which the character layout is right to left.

CDC contains two device contexts, m_hDC and m_hAttribDC, that refer to the same device on the creation of a CDC object. CDC directs all output GDI calls to m_hDC and most attribute GDI calls to m_hAttribDC. An example of an attribute call is GetTextColor; SetTextColor is an output call.

For example, the framework uses these two device contexts to implement a CMetaFileDC object that sends output to a metafile while reading attributes from a physical device. Print preview is implemented in the framework in a similar fashion. You can also use the two device contexts in the same way in your application-specific code.

There are times when you may need text-metric information from both the m_hDC and m_hAttribDC device contexts. The following pairs of functions provide this capability:

Uses m_hAttribDC Uses m_hDC
GetTextExtent GetOutputTextExtent
GetTabbedTextExtent GetOutputTabbedTextExtent
GetTextMetrics GetOutputTextMetrics
GetCharWidth GetOutputCharWidth


Remarks
MFC for Windows CE supports the following methods of the CDC class differently than standard MFC:

CDC::BitBlt CDC::GetMapMode
CDC::DrawEdge CDC::MaskBlt
CDC::DrawText CDC::Polygon
CDC::ExtTextOut CDC::PolyPolygon
CDC::GetDeviceCaps CDC::SelectStockObject
CDC::GetHalftoneBrush CDC::StretchBlt


The following methods do not do anything in Windows CE. They are included for compatibility with existing MFC code.

CDC::DPtoLP CDC::GetWindowExt
CDC::GetViewportExt CDC::GetWindowOrg
CDC::GetViewportOrg CDC::LPtoDP


MFC for Windows CE does not support the following methods of the CDC class:

AbortPath GetWindow
AddMetaFileComment GrayString
AngleArc HIMETRICtoDP
Arc HIMETRICtoLP
ArcTo InvertRgn
BeginPath LPtoHIMETRIC
Chord OffsetViewportOrg
CloseFigure OffsetWindowOrg
CreateDC PaintRgn
CreateIC Pie
DrawEscape PlayMetaFile
DrawState PlgBlt
DPtoHIMETRIC PolyBezier
EndPath PolyBezierTo
EnumObjects PolyDraw
Escape PtVisible
ExtFloodFill QueryAbort
FillPath ResetDC
FillRgn ScaleViewportExt
FlattenPath ScaleWindowExt
FloodFill SelectClipPath
FrameRgn SetArcDirection
GetArcDirection SetBoundsRect
GetAspectRatioFilter SetColorAdjustment
GetBoundsRect SetMapMode
GetCharABCWidths SetMapperFlags
GetCharWidth SetMiterLimit
GetColorAdjustment SetPixelV
GetCurrentPalette SetPolyFillMode
GetFontData SetStretchBltMode
GetGlyphOutline SetTextAlign
GetKerningPairs SetTextCharacterExtra
GetMiterLimit SetTextJustification
GetOutlineTextMetrics SetViewportOrg
GetOutputTabbedTextExtent SetViewportExt
GetOutputCharWidth SetWindowOrg
GetPath SetWindowExt
GetPolyFillMode StrokeAndFillPath
GetTabbedTextExtent StrokePath
GetTextAlign TabbedTextOut
GetTextCharacterExtra TextOut
GetROP2 UpdateColors
GetStretchBltMode WidenPath


Requirements
Windows CE versions: 1.0 and later
Header file: Declared in Afxwin.h
Platform: H/PC Pro, Palm-size PC, Pocket PC

See Also


kathywp 2004-07-14
  • 打赏
  • 举报
回复
你的需求也太不明确了
x,y的是值是坐标轴的单位?
还是坐标轴的最大范围
还是坐标上的点?
gunj 2004-07-14
  • 打赏
  • 举报
回复
你设一个初值为原点,然后取与x,y的相对值就好了啊,很简单的,自己想想吧!
nannan11 2004-07-14
  • 打赏
  • 举报
回复
从文本文件里读入一段X和Y值,X和Y有正有负,并在相应坐标轴上画出来X和Y的值?原点为0
快乐鹦鹉 2004-07-14
  • 打赏
  • 举报
回复
???为什么把我叫过来?你没写东西啊
gunj 2004-07-14
  • 打赏
  • 举报
回复
MoveTo(CPoint point1),point1为起始点坐标
LineTo(CPoint pointn) pointn为下一个坐标点,两者联系起来就是一条直线,画图时你可以把一个一个点连起来.
至于画坐标轴,取两个点,只要point1.x=point2.x,连起来就是x轴,同理可画y轴

至于文件读取
FILE *stream;
stream = fopen( "你的文件名", "r+t" );
fread( 缓存, 每一坐标字节数, 坐标点数, stream )
fclose( stream );
快乐鹦鹉 2004-07-14
  • 打赏
  • 举报
回复
用CDC画线啊。你的坐标轴有什么要求呢?

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧