📄 mainform.c
字号:
case formGadgetEraseCmd:
bHandled = false;
break;
}
return (bHandled);
}
/*============================================================================*/
/* Function: DrawPlotAreaGadget */
/* Description: This routine draws the Plot Area Gadget. */
/* */
/* Arguments: None */
/* Returns: None */
/* Globals affected: None */
/* Hardware affected: None */
/* */
/*============================================================================*/
/* Change History: */
/* */
/* ECO#: ? */
/* Change Date: dd-mmm-yyyy */
/* Changed By: ? */
/* Description of Change: ? */
/* */
/*============================================================================*/
void DrawPlotAreaGadget(void)
{
/*========================================================================*/
/* Declare all local variables. */
/*========================================================================*/
FormPtr pFrm;
RectangleType recBounds;
Coord xPosBegin;
Coord yPosBegin;
Coord xPosEnd;
Coord yPosEnd;
Coord PlotPixelX = 23;
Coord PlotPixelY;
UInt16 SmplIdx;
UInt8 BytValue;
Boolean PrevValue[8];
Boolean CurrValue[8];
UInt8 TopSpc;
UInt8 InterSpc;
UInt8 BottomSpc;
UInt8 TraceAmp;
float PixelsPerSmpl;
float SmplsPerPixel;
/*========================================================================*/
/* Get the pointer to the active form. */
/*========================================================================*/
pFrm = FrmGetActiveForm();
/*========================================================================*/
/* Calculate the Plot To/From coordinates. */
/*========================================================================*/
PlotData.PlotFromSmplIdx = 0;
PlotData.PlotToSmplIdx = 5 * TimebaseInNSec(AppPrefs.Timebase) /
SampleRateInNSec(AppPrefs.Timebase);
/*========================================================================*/
/* Draw the window rectangle around the plot window. */
/*========================================================================*/
recBounds.topLeft.x = 24;
recBounds.topLeft.y = 23;
recBounds.extent.x = 135;
recBounds.extent.y = 108;
WinDrawRectangleFrame (rectangleFrame, &recBounds);
/*========================================================================*/
/* Erase the plot window. */
/*========================================================================*/
WinEraseRectangle (&recBounds, 0);
/*========================================================================*/
/* Plot the grid lines in the plot window. */
/*========================================================================*/
xPosBegin = 24 + 27;
yPosBegin = 23;
xPosEnd = xPosBegin;
yPosEnd = 23 + 108;
WinDrawGrayLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
xPosBegin = xPosBegin + 27;
WinDrawGrayLine (xPosBegin, yPosBegin, xPosBegin, yPosEnd);
xPosBegin = xPosBegin + 27;
WinDrawGrayLine (xPosBegin, yPosBegin, xPosBegin, yPosEnd);
xPosBegin = xPosBegin + 27;
WinDrawGrayLine (xPosBegin, yPosBegin, xPosBegin, yPosEnd);
/*========================================================================*/
/* Get the spacing values and the trace amplitudes for the number of */
/* active channels. */
/*========================================================================*/
GetPlotSpacing (AppPrefs.ActiveChnlCnt, &TopSpc, &InterSpc, &BottomSpc,
&TraceAmp);
SmplsPerPixel = (float)TimebaseInNSec(AppPrefs.Timebase) /
((float)SampleRateInNSec(AppPrefs.Timebase) * 27.0);
PixelsPerSmpl = 1 / SmplsPerPixel;
/*========================================================================*/
/* Decode the individual channel values from the packed data byte for the */
/* value just previous to this sample. */
/*========================================================================*/
if (PlotData.PlotFromSmplIdx > 0)
BytValue = PlotData.SmplData[PlotData.PlotFromSmplIdx - 1];
else
BytValue = 0;
PrevValue[0] = ((BytValue & 0x01) != 0) ? true : false;
PrevValue[1] = ((BytValue & 0x02) != 0) ? true : false;
PrevValue[2] = ((BytValue & 0x04) != 0) ? true : false;
PrevValue[3] = ((BytValue & 0x08) != 0) ? true : false;
PrevValue[4] = ((BytValue & 0x10) != 0) ? true : false;
PrevValue[5] = ((BytValue & 0x20) != 0) ? true : false;
PrevValue[6] = ((BytValue & 0x40) != 0) ? true : false;
PrevValue[7] = ((BytValue & 0x80) != 0) ? true : false;
if (PixelsPerSmpl > 1.0)
{
/*====================================================================*/
/* Plot the data. */
/*====================================================================*/
for (SmplIdx = PlotData.PlotFromSmplIdx;
SmplIdx <= PlotData.PlotToSmplIdx; SmplIdx++)
{
PlotPixelY = 23 + TopSpc;
/*================================================================*/
/* Decode the individual channel values from the packed data byte.*/
/*================================================================*/
BytValue = PlotData.SmplData[SmplIdx];
CurrValue[0] = ((BytValue & 0x01) != 0) ? true : false;
CurrValue[1] = ((BytValue & 0x02) != 0) ? true : false;
CurrValue[2] = ((BytValue & 0x04) != 0) ? true : false;
CurrValue[3] = ((BytValue & 0x08) != 0) ? true : false;
CurrValue[4] = ((BytValue & 0x10) != 0) ? true : false;
CurrValue[5] = ((BytValue & 0x20) != 0) ? true : false;
CurrValue[6] = ((BytValue & 0x40) != 0) ? true : false;
CurrValue[7] = ((BytValue & 0x80) != 0) ? true : false;
/*================================================================*/
/* Do Channel 0 if it is active. */
/*================================================================*/
if (AppPrefs.bChnlOn[0] == true)
{
CtlHideControl(GetObjectPtr(frmMainCh0LabelButton));
FrmSetObjectPosition(pFrm,
FrmGetObjectIndex(pFrm, frmMainCh0LabelButton),
0, PlotPixelY);
CtlShowControl(GetObjectPtr(frmMainCh0LabelButton));
if (CurrValue[0] != PrevValue[0])
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY;
xPosEnd = PlotPixelX;
yPosEnd = PlotPixelY + TraceAmp;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
}
if (CurrValue[0] == true)
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY;
xPosEnd = PlotPixelX + (UInt8)PixelsPerSmpl;
yPosEnd = PlotPixelY;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
}
else
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY + TraceAmp;
xPosEnd = PlotPixelX + (UInt8)PixelsPerSmpl;
yPosEnd = PlotPixelY + TraceAmp;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
WinDrawLine (xPosBegin, (yPosBegin-1), xPosEnd, (yPosEnd-1));
}
PrevValue[0] = CurrValue[0];
PlotPixelY += (TraceAmp + InterSpc);
}
else
{
CtlHideControl(GetObjectPtr(frmMainCh0LabelButton));
}
/*================================================================*/
/* Do Channel 1 if it is active. */
/*================================================================*/
if (AppPrefs.bChnlOn[1] == true)
{
CtlHideControl(GetObjectPtr(frmMainCh1LabelButton));
FrmSetObjectPosition(pFrm,
FrmGetObjectIndex(pFrm, frmMainCh1LabelButton),
0, PlotPixelY);
CtlShowControl(GetObjectPtr(frmMainCh1LabelButton));
if (CurrValue[1] != PrevValue[1])
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY;
xPosEnd = PlotPixelX;
yPosEnd = PlotPixelY + TraceAmp;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
}
if (CurrValue[1] == true)
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY;
xPosEnd = PlotPixelX + (UInt8)PixelsPerSmpl;
yPosEnd = PlotPixelY;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
}
else
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY + TraceAmp;
xPosEnd = PlotPixelX + (UInt8)PixelsPerSmpl;
yPosEnd = PlotPixelY + TraceAmp;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
WinDrawLine (xPosBegin, (yPosBegin-1), xPosEnd, (yPosEnd-1));
}
PrevValue[1] = CurrValue[1];
PlotPixelY += (TraceAmp + InterSpc);
}
else
{
CtlHideControl(GetObjectPtr(frmMainCh1LabelButton));
}
/*================================================================*/
/* Do Channel 2 if it is active. */
/*================================================================*/
if (AppPrefs.bChnlOn[2] == true)
{
CtlHideControl(GetObjectPtr(frmMainCh2LabelButton));
FrmSetObjectPosition(pFrm,
FrmGetObjectIndex(pFrm, frmMainCh2LabelButton),
0, PlotPixelY);
CtlShowControl(GetObjectPtr(frmMainCh2LabelButton));
if (CurrValue[2] != PrevValue[2])
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY;
xPosEnd = PlotPixelX;
yPosEnd = PlotPixelY + TraceAmp;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
}
if (CurrValue[2] == true)
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY;
xPosEnd = PlotPixelX + (UInt8)PixelsPerSmpl;
yPosEnd = PlotPixelY;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
}
else
{
xPosBegin = PlotPixelX;
yPosBegin = PlotPixelY + TraceAmp;
xPosEnd = PlotPixelX + (UInt8)PixelsPerSmpl;
yPosEnd = PlotPixelY + TraceAmp;
WinDrawLine (xPosBegin, yPosBegin, xPosEnd, yPosEnd);
WinDrawLine (xPosBegin, (yPosBegin-1), xPosEnd, (yPosEnd-1));
}
PrevValue[2] = CurrValue[2];
PlotPixelY += (TraceAmp + InterSpc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -