Leal 发表于 2005-3-2 17:11:00

问获取当前视口(Viewport)坐标值的函数

rt<br>
<br>
3x a lot!<br>

Leal 发表于 2005-3-3 10:36:00

在ObjectARX Developer's
Guide 里找到了<br>

<div class="HeadingDiv">



<div class="TopHead" title="Example 3: Obtaining the Window Coordinates ">Example
3: Obtaining the Window Coordinates </div>

<br>
</div>

<p class="body">This example shows the use of AcGiViewportDraw::polylineDc() and AcGiViewport::getViewportDcCorners() to obtain the display
coordinates of the <font style="background-color: rgb(10, 36, 106);" color="#ffffff">viewport</font>. This function is convenient when you are drawing
graphics that depend on the physical layout of the <font style="background-color: rgb(10, 36, 106);" color="#ffffff">viewport</font>, such as icons
and markers that vary with the size or borders of the <font style="background-color: rgb(10, 36, 106);" color="#ffffff">viewport</font>. The graphics
drawn will change with panning and zooming.





<p class="body">The example draws a box in the upper-right corner of the <font style="background-color: rgb(10, 36, 106);" color="#ffffff">viewport</font>. The box's width
and height are always one-tenth of the viewport's shortest dimension, and the
box is centered one-tenth of the viewport's shortest dimension down and to the
left of the upper-right-hand corner of the <font style="background-color: rgb(10, 36, 106);" color="#ffffff">viewport</font>:




<pre class="prog_in_0">void</pre>
<pre class="prog_in_0">AsdkIconSamp::viewportDraw(AcGiViewportDraw* pV)</pre>
































<pre class="prog_in_end_0">{<br>    // Get the current viewport's display coordinates.<br>    //<br>    AcGePoint2d lower_left, upper_right;<br>    pV-&gt;<font style="background-color: rgb(10, 36, 106);" color="#ffffff">viewport</font>().getViewportDcCorners(lower_left, upper_right);<br>           double xsize = upper_right.x - lower_left.x;<br>           double ysize = upper_right.y - lower_left.y;<br>           xsize /= 10.0;<br>           ysize /= 10.0;<br>           double xcenter = upper_right.x - xsize;<br>           double ycenter = upper_right.y - ysize;<br>           double half_xsize = xsize / 2.0;<br>           double half_ysize = ysize / 2.0;<br>           // Create a unit square.<br>           //<br>           const int num_verts = 5;<br>           AcGePoint3d verts;<br>           for (int i = 0; i &lt; num_verts; i++) {<br>               verts.x = xcenter;<br>               verts.y = ycenter;<br>               verts.z = 0.0;<br>    }<br>    verts.x -= half_xsize;<br>    verts.y += half_ysize;<br>    verts.x += half_xsize;<br>    verts.y += half_ysize;<br>    verts.x += half_xsize;<br>    verts.y -= half_ysize;<br>    verts.x -= half_xsize;<br>    verts.y -= half_ysize;<br>    verts = verts;<br>    pV-&gt;subEntityTraits().setColor(kRed);<br>    pV-&gt;geometry().polylineDc(num_verts, verts);<br>}</pre>
页: [1]
查看完整版本: 问获取当前视口(Viewport)坐标值的函数