Moving the Origin

部署运行你感兴趣的模型镜像
 

Moving the Origin

By default, a device context's origin is in the upper left corner of the display surface. Even if you change the mapping mode, the origin remains in the upper left corner. But just as you can change the mapping mode, you can also move the origin. MFC's CDC class provides two functions for moving the origin. CDC::SetWindowOrg moves the window origin, and CDC::SetViewportOrg moves the viewport origin. You'll normally use one but not both. Using both can be very confusing.

Suppose you'd like to move the origin to the center of the window so that you can center what you draw by centering your output around the point (0,0). Assuming that dc is a device context object, here's one way to do it:

CRect rect;
GetClientRect (&rect);
dc.SetViewportOrg (rect.Width () / 2, rect.Height () / 2);

Here's another way to accomplish the same thing, assuming that you're working in the MM_LOENGLISH mapping mode:

CRect rect;
GetClientRect (&rect);
CPoint point (rect.Width () / 2, rect.Height () / 2);
dc.SetMapMode (MM_LOENGLISH);
dc.DPtoLP (&point);
dc.SetWindowOrg (-point.x, -point.y);

It's easy to get SetViewportOrg and SetWindowOrg confused, but the distinction between them is actually quite clear. Changing the viewport origin to (x,y) with SetViewportOrg tells Windows to map the logical point (0,0) to the device point (x,y). Changing the window origin to (x,y) with SetWindowOrg does essentially the reverse, telling Windows to map the logical point (x,y) to the device point (0,0)—the upper left corner of the display surface. In the MM_TEXT mapping mode, the only real difference between the two functions is the signs of x and y. In other mapping modes, there's more to it than that because SetViewportOrg deals in device coordinates and SetWindowOrg deals in logical coordinates. You'll see examples of how both functions are used later in this chapter.

As a final example, suppose you're drawing in the MM_HIMETRIC mapping mode, where 1 unit equals 1/100 of a millimeter, positive x points to the right, and positive y points upward, and you'd like to move the origin to the lower left corner of the window. Here's an easy way to do it:

CRect rect;
GetClientRect (&rect);
dc.SetViewportOrg (0, rect.Height ());

Now you can draw with positive x and y values using coordinates relative to the window's lower left corner.

A Final Word on Coordinate Systems

When you talk about mapping modes, window origins, viewport origins, and other idioms related to the GDI's handling of coordinates, it's easy to get tangled up in the terminology. Understanding the difference between the device coordinate system and the logical coordinate system might help clear some of the cobwebs.

In the device coordinate system, distances are measured in pixels. The device point (0,0) is always in the upper left corner of the display surface, and the positive x and y axes always point right and downward. The logical coordinate system is altogether different. The origin can be placed anywhere, and both the orientation of the x and y axes and the scaling factor (the number of pixels that correspond to 1 logical unit) vary with the mapping mode. To be precise, they vary with the window extents and the viewport extents. You can change these extents in the MM_ISOTROPIC and MM_ANISOTROPIC mapping modes but not in the other mapping modes.

You'll sometimes hear Windows programmers talk about "client coordinates" and "screen coordinates." Client coordinates are simply device coordinates relative to the upper left corner of a window's client area. Screen coordinates are device coordinates relative to the upper left corner of the screen. You can convert from client coordinates to screen coordinates and vice versa using the CWnd::ClientToScreen and CWnd::ScreenToClient functions. Why these functions are useful will become apparent to you the first time you call a Windows function that returns screen coordinates and you pass them to a function that requires client coordinates, or vice versa.

Getting Information About a Device

Sometimes it's helpful to get information about a device before you send output to it. The CDC::GetDeviceCaps function lets you retrieve all kinds of information about a device, from the number of colors it supports to the number of pixels it can display horizontally and vertically. The following code initializes cx and cy to the width and height of the screen, in pixels:

CClientDC dc (this);
int cx = dc.GetDeviceCaps (HORZRES);
int cy = dc.GetDeviceCaps (VERTRES);

If the screen resolution is 1,024 by 768, cx and cy will be set to 1,024 and 768, respectively.

The table below lists some of the parameters you can pass to GetDeviceCaps to acquire information about the physical output device associated with a device context. How you interpret the results depends somewhat on the device type. For example, calling GetDeviceCaps with a HORZRES parameter for a screen DC returns the screen width in pixels. Make the same call to a printer DC and you get back the width of the printable page, once more in pixels. As a rule, values that imply any kind of scaling (for example, LOGPIXELSX and LOGPIXELSY) return physically correct values for printers and other hardcopy devices but not for screens. For a 600 dpi laser printer, both LOGPIXELSX and LOGPIXELSY return 600. For a screen, both will probably return 96, regardless of the physical screen size or resolution.

Interpreting the color information returned by the NUMCOLORS, BITSPIXEL, and PLANES parameters of GetDeviceCaps is a bit tricky. For a printer or a plotter, you can usually find out how many colors the device is capable of displaying from the NUMCOLORS parameter. For a monochrome printer, NUMCOLORS returns 2.

Useful GetDeviceCaps Parameters

Parameter Returns
HORZRES Width of the display surface in pixels
VERTRESHeight of the display surface in pixels
HORZSIZEWidth of the display surface in millimeters
VERTSIZEHeight of the display surface in millimeters
LOGPIXELSX Number of pixels per logical inch horizontally
LOGPIXELSY Number of pixels per logical inch vertically
NUMCOLORS For a display device, the number of static colors; for a printer or plotter, the number of colors supported
BITSPIXEL Number of bits per pixel
PLANES Number of bit planes
RASTERCAPS Bit flags detailing certain characteristics of the device, such as whether it is palettized and whether it can display bitmapped images
TECHNOLOGYBit flags identifying the device type—screen, printer, plotter, and so on

However, the color resolution of the screen (the number of colors that can be displayed onscreen simultaneously) is computed by multiplying BITSPIXEL and PLANES and raising 2 to the power of the result, as demonstrated here:

CClientDC dc (this);
int nPlanes = dc.GetDeviceCaps (PLANES);
int nBPP = dc.GetDeviceCaps (BITSPIXEL);
int nColors = 1 << (nPlanes * nBPP);

If this code is executed on a PC equipped with a 256-color video adapter, nColors equals 256. Calling GetDeviceCaps with a NUMCOLORS parameter, meanwhile, returns not 256 but 20—the number of "static colors" that Windows programs into the video adapter's color palette. I'll have more to say about the color characteristics of screens and video adapters and also about static colors in Chapter 15.

I'll use GetDeviceCaps several times in this book to adapt the sample programs' output to the physical attributes of the output device. The first use will come later in this chapter, when the screen's LOGPIXELSX and LOGPIXELSY parameters are used to draw rectangles 1 logical inch long and 1/4 logical inch tall in the MM_TEXT mapping mode.

您可能感兴趣的与本文相关的镜像

AutoGPT

AutoGPT

AI应用

AutoGPT于2023年3月30日由游戏公司Significant Gravitas Ltd.的创始人Toran Bruce Richards发布,AutoGPT是一个AI agent(智能体),也是开源的应用程序,结合了GPT-4和GPT-3.5技术,给定自然语言的目标,它将尝试通过将其分解成子任务,并在自动循环中使用互联网和其他工具来实现这一目标

wall attribute command Syntax wall attribute <facet> <vertex> keyword ... <range> Primary keywords: centrotation | conveyor | cutoffang | displacement | euler | fragment | position | spin | velocity | xcentrotation | xconveyor | xdisplacement | xeuler | xposition | xspin | xvelocity | ycentrotation | yconveyor | ydisplacement | yeuler | yposition | yspin | yvelocity | zcentrotation | zconveyor | zdisplacement | zeuler | zposition | zspin | zvelocity Set the value of wall attributes. This command is a synonym for the wall initialize command. Individual attributes can be listed with the wall list command and all attributes can be visualized. The optional vertex kewyord can be used to with the velocity, xvelocity, yvelocity, or zvelocity keywords to set the vertex velocities for vertices in the specified range. The optional facet keyword can be used with the conveyor, xconveyor, yconveyor, or zconveyor keywords to set the facet conveyor velocities for facets in the specified range. centrotation vcen Set the center of rotation for walls in the range. This is the position about which rotations occur when an angular velocity is supplied to a wall. The center of rotation translates with the wall if a translational velocity is supplied. The default center of rotation is the origin. conveyor vconcvel Set the facet conveyor velocity vector. If given with the facet keyword, then the range applies to facets. Otherwise the conveyor velocity is set for all facets in each wall in the specified range. The conveyor velocity is a fictitious velocity that is added to the wall velocity when calculating the relative velocity between a facet and another piece. A conveyor velocity cannot be active when vertex velocities are active. Setting a nonzero conveyor velocity allows one to simulate conveyance of balls or clumps along facets without moving the facets. cutoffang fang Set the cutoff angle (an angle in degrees) for walls. By default, the cutoff angle is 0. This angle controls contact state information propagation. displacement vdisp Accumulated wall displacement vector as a result of cycling. euler veuler (3D ONLY) Current orientation of Euler angles following the X,Y,Z convention (e.g., rotation about the x-axis followed by rotation about the y'-axis followed by rotation about the z''-axis) in degrees. The orientation is updated only when orientation tracking has been enabled (see set orientation command). When active, the current clump orientation can be visualized. fragment i Fragment ID (see "Fragment"). position vpos Wall location vector. This corresponds to the average position of all vertices. The center of rotation is not modified. spin fspin fspiny fspinz (y- and z- components are 3D ONLY) The wall angular velocity in radians per second. Walls rotate around their center of rotation. velocity vel Wall translational velocity vector. If given with the vertex keyword, then this corresponds to the vertex velocity and the range applies to vertices. xcentrotation fcenx Set the x-component of the center of rotation for walls in the range. This is the position about which rotations occur when an angular velocity is supplied to a wall. The center of rotation translates with the wall if a translational velocity is supplied. The default center of rotation is the origin. xconveyor fconcvelx Set the x-component of the facet conveyor velocity. If given with the facet keyword, then the range applies to facets. Otherwise the conveyor velocity is set for all facets in each wall in the specified range. The conveyor velocity is a fictitious velocity that is added to the wall velocity when calculating the relative velocity between a facet and another piece. A conveyor velocity cannot be active when vertex velocities are active. Setting a nonzero conveyor velocity allows one to simulate conveyance of balls or clumps along facets without moving the facets. xdisplacement fdispx The x-component of the accumulated wall displacement as a result of cycling. xeuler feulerx (3D ONLY) The x-euler angle (in degrees) of the current wall orientation. See the euler keyword for further details. xposition fposx The x-component of the wall location. This corresponds to the average position of all vertices. The center of rotation is not modified. xspin fspinx (3D ONLY) The x-component of the wall angular velocity in radians per second. Walls rotate around their center of rotation. xvelocity fvelx The x-component of the wall translational velocity. If given with the vertex keyword, then this corresponds to the x-component of the vertex velocity and the range applies to vertices. ycentrotation fceny Set the y-component of the center of rotation for walls in the range. This is the position about which rotations occur when an angular velocity is supplied to a wall. The center of rotation translates with the wall if a translational velocity is supplied. The default center of rotation is the origin. yconveyor fconcvely Set the y-component of the facet conveyor velocity. If given with the facet keyword, then the range applies to facets. Otherwise the conveyor velocity is set for all facets in each wall in the specified range. The conveyor velocity is a fictitious velocity that is added to the wall velocity when calculating the relative velocity between a facet and another piece. A conveyor velocity cannot be active when vertex velocities are active. Setting a nonzero conveyor velocity allows one to simulate conveyance of balls or clumps along facets without moving the facets. ydisplacement fdispy The y-component of the accumulated wall displacement as a result of cycling. yeuler feulery (3D ONLY) The y-euler angle (in degrees) of the current wall orientation. See the euler keyword for further details. yposition fposy The y-component of the wall location. This corresponds to the average position of all vertices. The center of rotation is not modified. yspin fspiny (3D ONLY) The y-component of the wall angular velocity in radians per second. Walls rotate around their center of rotation. yvelocity fvely The y-component of the wall translational velocity. If given with the vertex keyword, then this corresponds to the y-component of the vertex velocity and the range applies to vertices. zcentrotation fcenz (3D ONLY) Set the z-component of the center of rotation for walls in the range. This is the position about which rotations occur when an angular velocity is supplied to a wall. The center of rotation translates with the wall if a translational velocity is supplied. The default center of rotation is the origin. zconveyor fconcvelz (3D ONLY) Set the z-component of the facet conveyor velocity. If given with the facet keyword, then the range applies to facets. Otherwise the conveyor velocity is set for all facets in each wall in the specified range. The conveyor velocity is a fictitious velocity that is added to the wall velocity when calculating the relative velocity between a facet and another piece. A conveyor velocity cannot be active when vertex velocities are active. Setting a nonzero conveyor velocity allows one to simulate conveyance of balls or clumps along facets without moving the facets. zdisplacement fdispz (3D ONLY) The z-component of the accumulated wall displacement as a result of cycling. zeuler feulerz (3D ONLY) The z-euler angle (in degrees) of the current wall orientation. See the euler keyword for further details. zposition fposz (3D ONLY) The z-component of the wall location. This corresponds to the average position of all vertices. The center of rotation is not modified. zspin fspinz (3D ONLY) The z-component of the wall angular velocity in radians per second. Walls rotate around their center of rotation. zvelocity fvelz (3D ONLY) The z-component of the wall translational velocity. If given with the vertex keyword, then this corresponds to the z-component of the vertex velocity and the range applies to vertices. Usage Example Be aware of the distinction between attributes and properties! The tutorial example "Attributes and Properties" discusses this issue in detail. © Copyright 2015, Itasca Consulting Group Inc. Last updated on Jun 24, 2016. 学习这些资料研磨球形wall坐标为[grind_x = 0.2e-5][grind_y = 0.2e-5][grind_z = 12e-7],写出球形wall绕着z轴以一角速度旋转的PFC命令流,
07-08
Exercise 3.16 In terms of the ˆxs, ˆys, ˆzs coordinates of a fixed space frame {s}, frame {a} has its ˆxa-axis pointing in the direction (0, 0, 1) and its ˆya-axis pointing in the direction (1, 0, 0), and frame {b} has its ˆxb-axis pointing in the direction (1, 0, 0) and its ˆyb-axis pointing in the direction (0, 0, 1). The origin of {a} is at (3, 0, 0) in {s} and the origin of {b} is at (0, 2, 0) in {s}. (a) Draw by hand a diagram showing {a} and {b} relative to {s}. (b) Write down the rotation matrices Rsa and Rsb and the transformation matrices Tsa and Tsb. (c) Given Tsb, how do you calculate T 1 sb without using a matrix inverse? Write T 1 sb and verify its correctness using your drawing. (d) Given Tsa and Tsb, how do you calculate Tab (again without using matrix inverses)? Compute the answer and verify its correctness using your drawing. (e) Let T = Tsb be considered as a transformation operator consisting of a rotation about ˆx by 90 and a translation along ˆy by 2 units. Calculate T1 = TsaT. Does T1 correspond to a rotation and translation about ˆxs and ˆys, respectively (a world-fixed transformation of Tsa), or a rotation and translation about ˆxa and ˆya, respectively (a body-fixed transformation of Tsa)? Now calculate T2 = T Tsa. Does T2 correspond to a body-fixed or world-fixed transformation of Tsa? (f) Use Tsb to change the representation of the point pb = (1, 2, 3) in {b} coordinates to {s} coordinates. (g) Choose a point p represented by ps = (1, 2, 3) in {s} coordinates. Calculate p0 = Tsbps and p00 = T 1 sb ps. For each operation, should the result be interpreted as changing coordinates (from the {s} frame to {b}) without moving the point p, or as moving the location of the point without changing the reference frame of the representation? (h) A twist V is represented in {s} as Vs = (3, 2, 1, 1, 2, 3). What is its representation Va in frame {a}? (i) By hand, calculate the matrix logarithm [S]✓ of Tsa. (You may verify your answer with software.) Extract the normalized screw axis S and rotation amount ✓. Find a {q, s, h ˆ } representation of the screw axis. Redraw the fixed frame {s} and in it draw S.
10-15
[user@localhost buildroot]$ git reflog 3fe0afff0 (HEAD -> master_BUG1170320) HEAD@{0}: commit (amend): 【修复bug】【CLI】Bug 1169037 - Telnet keeps the connection after changing the port. Telnet更改端口后不断开连接 138be4ce3 HEAD@{1}: reset: moving to 138be4ce3ac685cf9991e7596f128f21e8b369c7 6269e5cc7 HEAD@{2}: reset: moving to HEAD 6269e5cc7 HEAD@{3}: commit (amend): 【修复bug】【CLI】Bug 1171754 - Stacked devices in controller adoption mode log in to the device on the serial port but lack the show startup-config command, making it impossible to view the next startup configuration. controller收养模式下的堆叠设备在串口上登录设备,缺少show startup-config指令,无法查看下一次启动配置 c58999f17 HEAD@{4}: reset: moving to HEAD c58999f17 HEAD@{5}: commit: 【修复bug】【CLI】Bug 1171754 - Stacked devices in controller adoption mode log in to the device on the serial port but lack the show startup-config command, making it impossible to view the next startup configuration. controller收养模式下的堆叠设备在串口上登录设备,缺少show startup-config指令,无法查看下一次启动配置 138be4ce3 HEAD@{6}: commit (amend): 【修复bug】【CLI】Bug 1169037 - Telnet keeps the connection after changing the port. Telnet更改端口后不断开连接 06ed64fd6 HEAD@{7}: commit: 【修复bug】【CLI】Bug 1169037 - Telnet keeps the connection after changing the port. Telnet更改端口后不断开连接 ea869b9c7 (origin/master, origin/HEAD) HEAD@{8}: reset: moving to HEAD~1 7587b3434 HEAD@{9}: commit: 【修复bug】【cli】Bug 1169037 - Telnet keeps the connection after changing the port. Telnet更改端口后不断开连接 ea869b9c7 (origin/master, origin/HEAD) HEAD@{10}: pull --rebase (finish): returning to refs/heads/master_BUG1170320 ea869b9c7 (origin/master, origin/HEAD) HEAD@{11}: pull --rebase (start): checkout ea869b9c76beefac240cc4eec85a9dd1725eb65d 24569b5fb HEAD@{12}: reset: moving to HEAD 24569b5fb HEAD@{13}: commit (amend): 【修复bug】【sysManage】Bug 1170320 - Three stacks, set reboot schedule at xx, execute show reboot schedule command to display in xx minutes without changing with system time. 三台堆叠,设置reboot schedule at xx,执行show reboot-schedule命令回显in xx minutes不随系统时间改变而更改 599c45596 HEAD@{14}: commit (amend): 【修复bug】【sysManage】Bug 1170320 - Three stacks, set reboot schedule at xx, execute show reboot schedule command to display in xx minutes without changing with system time. 三台堆叠,设置reboot schedule at xx,执行show reboot-schedule命令回显in xx minutes不随系统时间改变而更改 19e6c175e HEAD@{15}: commit (amend): 【修复bug】【sysManage】Bug 1170320 - Three stacks, set reboot schedule at xx, execute show reboot schedule command to display in xx minutes without changing with system time. 三台堆叠,设置reboot schedule at xx,执行show reboot-schedule命令回显in xx minutes不随系统时间改变而更改 4c48fc2d9 HEAD@{16}: commit: 【修复bug】【sysManage】Bug 1170320 - Three stacks, set reboot schedule at xx, execute show reboot schedule command to display in xx minutes without changing with system time. 三台堆叠,设置reboot schedule at xx,执行show reboot-schedule命令回显in xx minutes不随系统时间改变而更改 4856737d4 HEAD@{17}: pull: Fast-forward 2c23e99b0 HEAD@{18}: reset: moving to 2c23e99b0714d61331db2b21485408dbfb7d4255 2c23e99b0 HEAD@{19}: reset: moving to 2c23e99b0714d61331db2b21485408dbfb7d4255 d0ea56e97 HEAD@{20}: checkout: moving from master to master_BUG1170320 我想回到 6269e5cc7 HEAD@{3}: commit (amend): 【修复bug】【CLI】Bug 1171754 - Stacked devices in controller adoption mode log in to the device on the serial port but lack the show startup-config command, making it impossible to view the next startup configuration. controller收养模式下的堆叠设备在串口上登录设备,缺少show startup-config指令,无法查看下一次启动配置
最新发布
12-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值