本文整理汇总了C++中ON_Viewport::GetScreenPort方法的典型用法代码示例。如果您正苦于以下问题:C++ ON_Viewport::GetScreenPort方法的具体用法?C++ ON_Viewport::GetScreenPort怎么用?C++ ON_Viewport::GetScreenPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ON_Viewport
的用法示例。
在下文中一共展示了ON_Viewport::GetScreenPort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myDrawAxesSprite
static void myDrawAxesSprite( const ON_Viewport& viewport, HDC hdc )
{
// Use simple Windows calls to draw world axes sprite in lower left corner.
// Note that Windows has screen (0,0) in the upper left corner; i.e,
// screen "y" increases downwards.
if ( !hdc )
return;
const int axes_size = 30;
int port_left, port_right, port_top, port_bottom;
if ( !viewport.GetScreenPort( &port_left, &port_right, &port_bottom, &port_top, NULL, NULL ) )
return;
const int scr_width = port_right - port_left; // no "+1" here
const int scr_height = port_bottom - port_top; // no "+1" here
if (4*axes_size >= scr_width )
return;
if (4*axes_size >= scr_height )
return;
int x0 = 3*axes_size/2;
int y0 = port_bottom - 3*axes_size/2;
int indx[3] = {0,1,2};
double scr_coord[3][2];
viewport.GetCoordinateSprite( axes_size, x0, y0, indx, scr_coord );
#define LXSIZE 3
#define LYSIZE 3
#define LOFF 3
// draw 3 axes from back to front
HPEN axis_pen[3];
axis_pen[0] = CreatePen( PS_SOLID, 2, RGB(255,0,0) );
axis_pen[1] = CreatePen( PS_SOLID, 2, RGB(0,255,0) );
axis_pen[2] = CreatePen( PS_SOLID, 2, RGB(0,0,255) );
HGDIOBJ saved_pen = SelectObject( hdc, axis_pen[0] );
int i, k, x, y, lx, ly;
for (i=0;i<3;i++) {
k = indx[i];
x = (int)scr_coord[k][0];
y = (int)scr_coord[k][1];
// use direction of screen vector to determine letter placement
lx = x-x0; ly = y-y0;
if (abs(lx) > abs(ly)) {
// center letter to right/left of axis end
lx = (x >= x0) ? x + LXSIZE+LOFF : x - LXSIZE-LOFF;
ly = y;
}
else if (abs(ly) > abs(lx)) {
// center letter above/below axis end
lx = x;
ly = (y >= y0) ? y + LYSIZE+LOFF : y - LYSIZE-LOFF;
}
else if (lx) {
// diagonal axis - center letter on axis
lx = (x >= x0) ? x + LXSIZE+LOFF : x - LXSIZE-LOFF;
ly = (y >= y0) ? y + LYSIZE+LOFF : y - LYSIZE-LOFF;
}
else {
// axis is perp to screen - center letter at axis end
lx = x;
ly = y;
}
SelectObject( hdc, axis_pen[k] );
// draw axis
MoveToEx( hdc, x0, y0, NULL );
LineTo( hdc, x, y );
// draw axis label
switch (k) {
case 0: // X
MoveToEx( hdc, lx-LXSIZE, ly-LYSIZE, NULL );
LineTo( hdc, lx+LXSIZE, ly+LYSIZE );
MoveToEx( hdc, lx-LXSIZE, ly+LYSIZE, NULL );
LineTo( hdc, lx+LXSIZE, ly-LYSIZE );
break;
case 1: // Y
MoveToEx( hdc, lx-LXSIZE, ly-LYSIZE, NULL );
LineTo( hdc, lx, ly );
LineTo( hdc, lx+LXSIZE, ly-LYSIZE );
MoveToEx( hdc, lx, ly, NULL );
LineTo( hdc, lx, ly+LYSIZE );
break;
case 2: // Z
MoveToEx( hdc, lx-LXSIZE, ly-LYSIZE, NULL );
LineTo( hdc, lx+LXSIZE, ly-LYSIZE );
LineTo( hdc, lx-LXSIZE, ly+LYSIZE );
LineTo( hdc, lx+LXSIZE, ly+LYSIZE );
break;
}
}
SelectObject( hdc, saved_pen );
DeleteObject( axis_pen[0] );
DeleteObject( axis_pen[1] );
DeleteObject( axis_pen[2] );
#undef LXSIZE
//.........这里部分代码省略.........
示例2: SetGLProjectionMatrix
void SetGLProjectionMatrix( ON_Viewport& viewport )
{
int pl, pr, pb, pt;
viewport.GetScreenPort( &pl, &pr, &pb, &pt, NULL, NULL );
ON_GL( viewport, pl, pr, pb, pt ); // updates GL projection matrix
}