📄 metmacs.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1997 - 1999 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* metmacs.c 1.9 */
/* */
/* COMPONENT */
/* */
/* All */
/* */
/* DESCRIPTION */
/* */
/* Various functions to perform the assembly language macros. */
/* */
/* AUTHOR */
/* */
/* Robert G. Burrill, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* None */
/* */
/* FUNCTIONS */
/* */
/* None */
/* */
/* DEPENDENCIES */
/* */
/* None */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* BobB 11/10/99 Removed unused functions */
/* */
/*************************************************************************/
#include "meta_wnd.h"
#include "metconst.h" /* MetaWINDOW Constant & Stucture Definitions */
#include "metports.h" /* MetaWINDOW Port & Bitmap Definitions */
#include "grafdata.h"
#include "metmacs3.h"
#include "xpol_4.h"
/* U2GP User To Global point */
/* UserX,UserY = point in user coordinates */
/* RtnX,RtnY = pointer to return global coordinates */
/* frame = 1 if frames, 0 if not */
void U2GP(int UserX, int UserY, short *RtnX, short *RtnY, short frame)
{
int TempX;
int TempY;
if (grafPort.portFlags & pfVirtual)
{
TempX = UserX;
TempY = UserY;
grafPort.portU2GP(&TempX, &TempY);
*RtnX = TempX;
*RtnY = TempY;
}
else
{
*RtnX = (short) (UserX + localXconst); /* add offset */
*RtnY = (short) ((UserY ^ localYinvert) + localYconst); /* conditionally mirror Y */
}
/* BobB 5/8/98 - modified the following line for the PPC compiler
if (frame && !(grafPort.portFlags & pfUpper)) *RtnY--; adjust up for frames */
if (frame && !(grafPort.portFlags & pfUpper))
{ /* adjust up for frames */
*RtnY = *RtnY - 1;
}
return;
}
/* G2UP Global to User point */
/* GloblX,GloblY = point in global coordinates */
/* RtnX,RtnY = pointer to return user coordinates */
void G2UP(int GloblX, int GloblY, short *RtnX, short *RtnY)
{
int TempX;
int TempY;
if (grafPort.portFlags & pfVirtual)
{
TempX = GloblX;
TempY = GloblY;
grafPort.portG2UP(&TempX, &TempY);
*RtnX = TempX;
*RtnY = TempY;
}
else
{
*RtnX = GloblX + grafPort.portRect.Xmin - grafPort.portOrgn.X;
if (grafPort.portFlags & pfUpper)
{
*RtnY = GloblY + grafPort.portRect.Ymin - grafPort.portOrgn.Y;
}
else
{
*RtnY = -GloblY + grafPort.portRect.Ymin + grafPort.portOrgn.Y - 1;
}
}
return;
}
/* U2GR User To Global rectangle */
/* UserRect = rectangle in user coordinates */
/* RtnRect = pointer to return global rectangle */
/* frame = 1 if frames, 0 if not */
void U2GR(rect UserRect, rect *RtnRect, short frame)
{
rect TempRect;
if (grafPort.portFlags & pfVirtual)
{
TempRect = UserRect;
grafPort.portU2GR(&TempRect);
*RtnRect = TempRect;
}
else
{
RtnRect->Xmin = (short) (UserRect.Xmin + localXconst); /* add offset */
RtnRect->Xmax = (short) (UserRect.Xmax + localXconst);
if (grafPort.portFlags & pfUpper)
{ /* conditionally mirror Y */
RtnRect->Ymin = (short) ((UserRect.Ymin ^ localYinvert) + localYconst);
RtnRect->Ymax = (short) ((UserRect.Ymax ^ localYinvert) + localYconst);
}
else /* swap Ymin with Ymax */
{ /* conditionally mirror Y */
RtnRect->Ymax = (short) ((UserRect.Ymin ^ localYinvert) + localYconst);
RtnRect->Ymin = (short) ((UserRect.Ymax ^ localYinvert) + localYconst);
}
}
if (frame && !(grafPort.portFlags & pfUpper)) /* adjust up for frames */
{
RtnRect->Ymin--;
RtnRect->Ymax--;
}
return;
}
/* G2UR Global To User rectangle */
/* UserRect = rectangle in user coordinates */
/* RtnRect = pointer to return global rectangle */
void G2UR(rect UserRect, rect *RtnRect)
{
rect TempRect;
if (grafPort.portFlags & pfVirtual)
{
TempRect = UserRect;
grafPort.portG2UR(&TempRect);
*RtnRect = TempRect;
}
else
{
RtnRect->Xmin = UserRect.Xmin + grafPort.portRect.Xmin -
grafPort.portOrgn.X;
RtnRect->Xmax = UserRect.Xmax + grafPort.portRect.Xmin -
grafPort.portOrgn.X;
if (grafPort.portFlags & pfUpper)
{
RtnRect->Ymin = UserRect.Ymin + grafPort.portRect.Ymin -
grafPort.portOrgn.Y;
RtnRect->Ymax = UserRect.Ymax + grafPort.portRect.Ymin -
grafPort.portOrgn.Y;
}
else
{
RtnRect->Ymin = -UserRect.Ymin + grafPort.portRect.Ymax +
grafPort.portOrgn.Y;
RtnRect->Ymax = -UserRect.Ymax + grafPort.portRect.Ymax +
grafPort.portOrgn.Y;
}
}
return;
}
/* V2GSIZE Virtual To Global size */
/* UserX,UserY = magnitudes in user coordinates */
/* RtnX,RtnY = pointer to return magnitudes */
/* frame = 1 if frames, 0 if not */
void V2GSIZE(int UserX, int UserY, short *RtnX, short *RtnY)
{
int TempX;
int TempY;
TempX = UserX + grafPort.portVirt.Xmin; /* make relative to virtual rect min */
TempY = UserY + grafPort.portVirt.Ymin;
grafPort.portU2GP(&TempX, &TempY);
*RtnX = TempX - grafPort.portOrgn.X; /* make realtive to 0 in port */
*RtnY = TempY - grafPort.portOrgn.Y;
if (!(grafPort.portFlags & pfUpper)) /* adjust up for frames */
{ /* find magnitude from bottom of port to Y */
*RtnY = grafPort.portRect.Ymax - grafPort.portRect.Ymin - *RtnY;
}
return;
}
/* AddToGETYXSorted - add to global edge table */
/* edgePtr = pointer to new edge to add */
/* GETPtr = pointer to the global edge table */
void AddToGETYXSorted(qarcState *newEdge)
{
qarcState **GETPtrPtr;
qarcState *tempPtr;
GETPtrPtr = &GETPtr; /* address of edge pointer */
while(1)
{
tempPtr = *GETPtrPtr; /* get edge pointer */
if (tempPtr == 0) break; /* any more in list? */
if (tempPtr->StartY > newEdge->StartY) break; /* does current edge have
higher Y than new edge? */
if ((tempPtr->StartY == newEdge->StartY) &&
(tempPtr->CurrentX >= newEdge->CurrentX)) break; /* higher or equal X? */
GETPtrPtr = &tempPtr->NextEdge; /* point to next edge field for next */
}
*GETPtrPtr = newEdge; /* point current edge to new edge */
newEdge->NextEdge = tempPtr; /* point new edge to next edge */
return;
}
/* BobB 11/10/99 - removed the following two unused functions */
#if(0)
/* TXW_PSH saves all location and does hide Pen */
void TXW_PSH(short savLocX, short savLocY, short savPenX, short savPenY)
{
savLocX = LocX;
savLocY = LocY;
savPenX = grafPort.pnLoc.X;
savPenY = grafPort.pnLoc.Y;
grafPort.pnLevel -= grafPort.pnLevel ; /* Hide Pen */
}
/* TXW_POP restores all location and does show Pen */
int TXW_POP(short savLocX, short savLocY, short savPenX, short savPenY)
{
short TemLocX;
grafPort.pnLevel += grafPort.pnLevel ; /* Show Pen */
#ifdef rtnLcl
TemLocX = grafPort.pnLoc.X ;
#else
TemLocX = LocX;
#endif
LocX = savLocX;
LocY = savLocY;
grafPort.pnLoc.X = savPenX;
thePort->pnLoc.X = savPenX;
grafPort.pnLoc.Y = savPenY;
thePort->pnLoc.Y = savPenY;
#ifdef rtnLcl
return(TemLocX - grafPort.pnLoc.X) ;
#else
return(TemLocX - LocX);
#endif
}
#endif
/* BobB 11/10/99 - end of removed functions */
/* ChkAngle insures that 0 <= angle < 3600 */
int ChkAngle(int angle)
{
while (angle < 0) angle += 3600;
return(angle % 3600);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -